Skip to content

Commit ef8d85f

Browse files
author
Trent Guillory
committed
Committing progress on airline example before pivoting.
1 parent 1219082 commit ef8d85f

File tree

4 files changed

+160
-0
lines changed

4 files changed

+160
-0
lines changed

ScrollViewReactiveHeaderDemoApp/ScrollViewReactiveHeaderDemoApp.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
8459FC1A26E25E0C00EB434F /* FlightHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8459FC1926E25E0C00EB434F /* FlightHeaderView.swift */; };
11+
8459FC1C26E25E5D00EB434F /* FlightViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8459FC1B26E25E5D00EB434F /* FlightViewModel.swift */; };
12+
8459FC1E26E2665D00EB434F /* FlightDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8459FC1D26E2665D00EB434F /* FlightDetailView.swift */; };
1013
848BCF8826DE4ED800F8D967 /* ScrollViewReactiveHeaderDemoAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848BCF8726DE4ED800F8D967 /* ScrollViewReactiveHeaderDemoAppApp.swift */; };
1114
848BCF8A26DE4ED800F8D967 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848BCF8926DE4ED800F8D967 /* ContentView.swift */; };
1215
848BCF8C26DE4EDA00F8D967 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 848BCF8B26DE4EDA00F8D967 /* Assets.xcassets */; };
@@ -15,6 +18,9 @@
1518
/* End PBXBuildFile section */
1619

1720
/* Begin PBXFileReference section */
21+
8459FC1926E25E0C00EB434F /* FlightHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlightHeaderView.swift; sourceTree = "<group>"; };
22+
8459FC1B26E25E5D00EB434F /* FlightViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlightViewModel.swift; sourceTree = "<group>"; };
23+
8459FC1D26E2665D00EB434F /* FlightDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlightDetailView.swift; sourceTree = "<group>"; };
1824
848BCF8426DE4ED800F8D967 /* ScrollViewReactiveHeaderDemoApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScrollViewReactiveHeaderDemoApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
1925
848BCF8726DE4ED800F8D967 /* ScrollViewReactiveHeaderDemoAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollViewReactiveHeaderDemoAppApp.swift; sourceTree = "<group>"; };
2026
848BCF8926DE4ED800F8D967 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -36,6 +42,15 @@
3642
/* End PBXFrameworksBuildPhase section */
3743

3844
/* Begin PBXGroup section */
45+
8459FC1826E25DEF00EB434F /* FlightView */ = {
46+
isa = PBXGroup;
47+
children = (
48+
8459FC1926E25E0C00EB434F /* FlightHeaderView.swift */,
49+
8459FC1D26E2665D00EB434F /* FlightDetailView.swift */,
50+
);
51+
path = FlightView;
52+
sourceTree = "<group>";
53+
};
3954
848BCF7B26DE4ED800F8D967 = {
4055
isa = PBXGroup;
4156
children = (
@@ -60,6 +75,8 @@
6075
848BCF9626DE4EFC00F8D967 /* Resource Files */,
6176
848BCF8726DE4ED800F8D967 /* ScrollViewReactiveHeaderDemoAppApp.swift */,
6277
848BCF8926DE4ED800F8D967 /* ContentView.swift */,
78+
8459FC1B26E25E5D00EB434F /* FlightViewModel.swift */,
79+
8459FC1826E25DEF00EB434F /* FlightView */,
6380
);
6481
path = Sources;
6582
sourceTree = "<group>";
@@ -161,7 +178,10 @@
161178
isa = PBXSourcesBuildPhase;
162179
buildActionMask = 2147483647;
163180
files = (
181+
8459FC1A26E25E0C00EB434F /* FlightHeaderView.swift in Sources */,
164182
848BCF8A26DE4ED800F8D967 /* ContentView.swift in Sources */,
183+
8459FC1C26E25E5D00EB434F /* FlightViewModel.swift in Sources */,
184+
8459FC1E26E2665D00EB434F /* FlightDetailView.swift in Sources */,
165185
848BCF8826DE4ED800F8D967 /* ScrollViewReactiveHeaderDemoAppApp.swift in Sources */,
166186
);
167187
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import SwiftUI
2+
import UIKit
3+
4+
// MARK: - FlightDetailView
5+
6+
struct FlightDetailView: View {
7+
8+
var body: some View {
9+
10+
VStack {
11+
12+
Text("Boarding Passes")
13+
.font(.system(size: 24, weight: .regular, design: .serif))
14+
HStack {}
15+
.frame(height: 200)
16+
17+
Text("Upgrades")
18+
19+
Text("Perks")
20+
}
21+
}
22+
}
23+
24+
// MARK: - FlightDetailView_Previews
25+
26+
struct FlightDetailView_Previews: PreviewProvider {
27+
static var previews: some View {
28+
FlightDetailView()
29+
}
30+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import SwiftUI
2+
3+
// MARK: - FlightHeaderView
4+
5+
struct FlightHeaderView: View {
6+
7+
let viewModel: FlightViewModel
8+
9+
let labelFont: Font = .system(size: 32, weight: .light, design: .rounded)
10+
11+
var body: some View {
12+
13+
VStack {
14+
15+
Spacer()
16+
17+
if let firstFlight = viewModel.flights.first,
18+
let lastFlight = viewModel.flights.last {
19+
20+
HStack {
21+
22+
Text(firstFlight.departingAirport.abbreviatedName)
23+
.font(labelFont)
24+
25+
Spacer()
26+
27+
Image(systemName: "airplane")
28+
29+
Spacer()
30+
31+
Text(lastFlight.arrivingAirport.abbreviatedName)
32+
.font(labelFont)
33+
}
34+
}
35+
}
36+
.preferredColorScheme(.dark)
37+
}
38+
39+
struct airportLabelStyle: ViewModifier {
40+
41+
func body(content: Content) -> some View {
42+
43+
return content.font(.system(size: 16, weight: .semibold, design: .rounded))
44+
}
45+
}
46+
}
47+
48+
// MARK: - FlightHeaderView_Previews
49+
50+
struct FlightHeaderView_Previews: PreviewProvider {
51+
static var previews: some View {
52+
53+
FlightHeaderView(viewModel: FlightViewModel.example)
54+
}
55+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// FlightViewModel.swift
3+
// FlightViewModel
4+
//
5+
// Created by Trent Guillory on 9/3/21.
6+
//
7+
8+
import Foundation
9+
10+
struct Airport {
11+
12+
let abbreviatedName: String
13+
let fullName: String
14+
let city: String
15+
let state: String
16+
17+
var cityDisplayString: String {
18+
19+
return "\(city), \(state)"
20+
}
21+
22+
static let newOrleans: Airport = .init(abbreviatedName: "MSY", fullName: "Louis Armstrong International", city: "New Orleans", state: "LA")
23+
static let houston: Airport = .init(abbreviatedName: "IAH", fullName: "George Bush Intercontinental", city: "Houston", state: "TX")
24+
static let losAngeles: Airport = .init(abbreviatedName: "LAX", fullName: "Los Angeles International", city: "Los Angeles", state: "CA")
25+
}
26+
27+
struct Flight {
28+
29+
let departingAirport: Airport
30+
let arrivingAirport: Airport
31+
32+
// IRL, these would be dates. But this demo is mostly a UI
33+
// example. There are plenty of date-to-string tutorials out there.
34+
// Plus, if you plan to support iOS 15+, now there are built in
35+
// date conversions!
36+
let departure: String
37+
let arrival: String
38+
39+
var flightTime: String
40+
}
41+
42+
struct FlightViewModel {
43+
44+
let flights: [Flight]
45+
46+
var backgroundImage: String {
47+
48+
flights.last!.arrivingAirport.abbreviatedName
49+
}
50+
51+
static let example: FlightViewModel = .init(flights: [
52+
.init(departingAirport: Airport.newOrleans, arrivingAirport: Airport.houston, departure: "Oct 1, 11:15 am", arrival: "1:30 pm", flightTime: "2h 15m"),
53+
.init(departingAirport: Airport.houston, arrivingAirport: Airport.losAngeles, departure: "2:30 pm", arrival: "6:00 pm", flightTime: "4h")
54+
])
55+
}

0 commit comments

Comments
 (0)