Skip to content

Commit a16efce

Browse files
committed
Upgrade "SwiftUI Essentials"
1 parent c2f5fd6 commit a16efce

32 files changed

+93
-136
lines changed

App-Design-and-Layout/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// AppDelegate.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import UIKit

App-Design-and-Layout/CategoryRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// CategoryRow.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ContentView.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/HikeBadge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// HikeBadge.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/Home.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Home.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/Profile/ProfileEditor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ProfileEditor.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/Profile/ProfileHost.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ProfileHost.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/Profile/ProfileSummary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ProfileSummary.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

App-Design-and-Layout/SceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SceneDelegate.swift
33
// App-Design-and-Layout
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import UIKit

Drawing-and-Animation/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// AppDelegate.swift
33
// Drawing-and-Animation
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Drawing-and-Animation/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ContentView.swift
33
// SwiftUI-Tutorials
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Drawing-and-Animation/SceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SceneDelegate.swift
33
// Drawing-and-Animation
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Drawing-and-Animation/Supporting Views/Badge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Badge.swift
33
// Drawing-and-Animation
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Drawing-and-Animation/Supporting Views/BadgeBackground.swift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// BadgeBackground.swift.swift
33
// Drawing-and-Animation
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Drawing-and-Animation/Supporting Views/BadgeSymbol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// BadgeSymbol.swift
33
// Drawing-and-Animation
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Drawing-and-Animation/Supporting Views/RotatedBadgeSymbol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RotatedBadgeSymbol.swift
33
// Drawing-and-Animation
44
//
5-
// Created by 王炜 on 2019/6/8.
5+
// Created by Willie on 2019/6/8.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

Framework-Integration/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// AppDelegate.swift
33
// Framework-Integration
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import UIKit

Framework-Integration/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ContentView.swift
33
// Framework-Integration
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

Framework-Integration/PageControl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// PageControl.swift
33
// Framework-Integration
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

Framework-Integration/PageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// PageView.swift
33
// Framework-Integration
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

Framework-Integration/PageViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// PageViewController.swift
33
// Framework-Integration
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import SwiftUI

Framework-Integration/SceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SceneDelegate.swift
33
// Framework-Integration
44
//
5-
// Created by 王炜 on 2019/6/9.
5+
// Created by Willie on 2019/6/9.
66
//
77

88
import UIKit

SwiftUI-Essentials/AppDelegate.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,36 @@
22
// AppDelegate.swift
33
// SwiftUI-Tutorials
44
//
5-
// Created by 王炜 on 2019/6/6.
5+
// Created by Willie on 2019/6/6.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

99
import UIKit
1010

1111
@UIApplicationMain
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
13-
14-
15-
13+
1614
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1715
// Override point for customization after application launch.
1816
return true
1917
}
20-
18+
2119
func applicationWillTerminate(_ application: UIApplication) {
2220
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
2321
}
24-
22+
2523
// MARK: UISceneSession Lifecycle
26-
2724
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
2825
// Called when a new scene session is being created.
2926
// Use this method to select a configuration to create the new scene with.
3027
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
3128
}
32-
29+
3330
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
3431
// Called when the user discards a scene session.
3532
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
3633
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
3734
}
38-
39-
35+
4036
}
4137

SwiftUI-Essentials/LandmarkDetail.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// LandmarkDetail.swift
33
// SwiftUI-Essentials
44
//
5-
// Created by 王炜 on 2019/6/4.
5+
// Created by Willie on 2019/6/4.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

@@ -22,7 +22,7 @@ struct LandmarkDetail: View {
2222
.edgesIgnoringSafeArea(.top)
2323
.frame(height: 300)
2424

25-
CircleImage(image: landmark.image(forSize: 250))
25+
CircleImage(image: landmark.image)
2626
.offset(x: 0, y: -130)
2727
.padding(.bottom, -130)
2828

@@ -53,21 +53,18 @@ struct LandmarkDetail: View {
5353
Text(verbatim: landmark.state)
5454
.font(.subheadline)
5555
}
56-
}
57-
.padding()
56+
}
57+
.padding()
5858

5959
Spacer()
6060
}
6161
}
6262
}
6363

64-
#if DEBUG
6564
struct LandmarkDetail_Preview: PreviewProvider {
6665
static var previews: some View {
6766
let userData = UserData()
6867
return LandmarkDetail(landmark: userData.landmarks[0])
6968
.environmentObject(userData)
7069
}
7170
}
72-
#endif
73-

SwiftUI-Essentials/LandmarkList.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// LandmarkList.swift
33
// SwiftUI-Tutorials
44
//
5-
// Created by 王炜 on 2019/6/7.
5+
// Created by Willie on 2019/6/7.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

@@ -20,27 +20,27 @@ struct LandmarkList: View {
2020

2121
ForEach(userData.landmarks) { landmark in
2222
if !self.userData.showFavoritesOnly || landmark.isFavorite {
23-
NavigationButton(
24-
destination: LandmarkDetail(landmark: landmark)) {
23+
NavigationLink(
24+
destination: LandmarkDetail(landmark: landmark)
25+
.environmentObject(self.userData)
26+
) {
2527
LandmarkRow(landmark: landmark)
2628
}
2729
}
2830
}
29-
}
30-
.navigationBarTitle(Text("Landmarks"), displayMode: .large)
31+
}
32+
.navigationBarTitle(Text("Landmarks"))
3133
}
3234
}
3335
}
3436

35-
#if DEBUG
3637
struct LandmarksList_Previews: PreviewProvider {
3738
static var previews: some View {
38-
ForEach(["iPhone SE", "iPhone XS Max"].identified(by: \.self)) { deviceName in
39+
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
3940
LandmarkList()
4041
.previewDevice(PreviewDevice(rawValue: deviceName))
4142
.previewDisplayName(deviceName)
42-
}
43-
.environmentObject(UserData())
43+
}
44+
.environmentObject(UserData())
4445
}
4546
}
46-
#endif

SwiftUI-Essentials/LandmarkRow.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
// LandmarkRow.swift
33
// SwiftUI-Tutorials
44
//
5-
// Created by 王炜 on 2019/6/7.
5+
// Created by Willie on 2019/6/7.
66
// Copyright © 2019 Willie. All rights reserved.
77
//
88

99
import SwiftUI
1010

1111
struct LandmarkRow: View {
1212
var landmark: Landmark
13-
13+
1414
var body: some View {
1515
HStack {
16-
landmark.image(forSize: 50)
16+
landmark.image
17+
.resizable()
18+
.frame(width: 50, height: 50)
1719
Text(verbatim: landmark.name)
1820
Spacer()
19-
21+
2022
if landmark.isFavorite {
2123
Image(systemName: "star.fill")
2224
.imageScale(.medium)
@@ -26,14 +28,12 @@ struct LandmarkRow: View {
2628
}
2729
}
2830

29-
#if DEBUG
3031
struct LandmarkRow_Previews: PreviewProvider {
3132
static var previews: some View {
3233
Group {
3334
LandmarkRow(landmark: landmarkData[0])
3435
LandmarkRow(landmark: landmarkData[1])
35-
}
36-
.previewLayout(.fixed(width: 300, height: 70))
36+
}
37+
.previewLayout(.fixed(width: 300, height: 70))
3738
}
3839
}
39-
#endif

0 commit comments

Comments
 (0)