Admin 4 anni fa
parent
commit
430eeaad1e

Landmarks/HandlingUserInput.xcodeproj/.xcodesamplecode.plist → Landmarks/DrawingPathsAndShapes.xcodeproj/.xcodesamplecode.plist


+ 22 - 18
Landmarks/HandlingUserInput.xcodeproj/project.pbxproj

@@ -7,7 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		8473A7282530857400415A81 /* UserData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8473A7272530857400415A81 /* UserData.swift */; };
+		B7310DD1229F6839001079B9 /* HexagonParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7310DD0229F6839001079B9 /* HexagonParameters.swift */; };
 		B7394866229F194000C47603 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7394865229F194000C47603 /* AppDelegate.swift */; };
 		B7394868229F194000C47603 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7394867229F194000C47603 /* SceneDelegate.swift */; };
 		B739486A229F194000C47603 /* LandmarkDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7394869229F194000C47603 /* LandmarkDetail.swift */; };
@@ -33,12 +33,12 @@
 		B739489F229F2D9700C47603 /* LandmarkRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = B739489E229F2D9700C47603 /* LandmarkRow.swift */; };
 		B73948A1229F2E1F00C47603 /* LandmarkList.swift in Sources */ = {isa = PBXBuildFile; fileRef = B73948A0229F2E1F00C47603 /* LandmarkList.swift */; };
 		B73948A3229F3E2200C47603 /* charleyrivers.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B73948A2229F3E2200C47603 /* charleyrivers.jpg */; };
+		B7D2AAC5229F4D7C0061E5F5 /* UserData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7D2AAC4229F4D7C0061E5F5 /* UserData.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-		6AF17FBC250C47AD4B5BC2FB /* SampleCode.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = SampleCode.xcconfig; path = ../Configuration/SampleCode.xcconfig; sourceTree = "<group>"; };
-		8016A7122042026B58FF1299 /* LICENSE.txt */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
-		8473A7272530857400415A81 /* UserData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserData.swift; sourceTree = "<group>"; };
+		27FFE5444DA58085F4325C68 /* LICENSE.txt */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE.txt; sourceTree = "<group>"; };
+		B7310DD0229F6839001079B9 /* HexagonParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexagonParameters.swift; sourceTree = "<group>"; };
 		B7394862229F194000C47603 /* Landmarks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Landmarks.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		B7394865229F194000C47603 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
 		B7394867229F194000C47603 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -66,6 +66,8 @@
 		B739489E229F2D9700C47603 /* LandmarkRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LandmarkRow.swift; path = "Supporting Views/LandmarkRow.swift"; sourceTree = "<group>"; };
 		B73948A0229F2E1F00C47603 /* LandmarkList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandmarkList.swift; sourceTree = "<group>"; };
 		B73948A2229F3E2200C47603 /* charleyrivers.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = charleyrivers.jpg; sourceTree = "<group>"; };
+		B7D2AAC4229F4D7C0061E5F5 /* UserData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserData.swift; sourceTree = "<group>"; };
+		B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */ = {isa = PBXFileReference; name = SampleCode.xcconfig; path = ../Configuration/SampleCode.xcconfig; sourceTree = "<group>"; };
 		C4E4AAA0C4E4035000000001 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
@@ -80,10 +82,10 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
-		00ABA66E85532B385D477CBF /* Configuration */ = {
+		8BF134F5A54BCFC44BB3699D /* Configuration */ = {
 			isa = PBXGroup;
 			children = (
-				6AF17FBC250C47AD4B5BC2FB /* SampleCode.xcconfig */,
+				B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */,
 			);
 			name = Configuration;
 			sourceTree = "<group>";
@@ -94,8 +96,8 @@
 				C4E4AAA0C4E4035000000001 /* README.md */,
 				B7394864229F194000C47603 /* Landmarks */,
 				B7394863229F194000C47603 /* Products */,
-				00ABA66E85532B385D477CBF /* Configuration */,
-				E573155042573F7430EB4C1C /* LICENSE */,
+				8BF134F5A54BCFC44BB3699D /* Configuration */,
+				F0E92604CFEDA83BAF383A9E /* LICENSE */,
 			);
 			sourceTree = "<group>";
 		};
@@ -115,8 +117,8 @@
 				B7394867229F194000C47603 /* SceneDelegate.swift */,
 				B73948A0229F2E1F00C47603 /* LandmarkList.swift */,
 				B739489E229F2D9700C47603 /* LandmarkRow.swift */,
-				8473A7272530857400415A81 /* UserData.swift */,
 				B7394869229F194000C47603 /* LandmarkDetail.swift */,
+				B7310DD0229F6839001079B9 /* HexagonParameters.swift */,
 				B739487D229F1C0100C47603 /* Supporting Views */,
 				B7394883229F291A00C47603 /* Resources */,
 				B739486B229F194200C47603 /* Assets.xcassets */,
@@ -149,6 +151,7 @@
 			children = (
 				B7394880229F28B900C47603 /* Data.swift */,
 				B739487F229F28B900C47603 /* Landmark.swift */,
+				B7D2AAC4229F4D7C0061E5F5 /* UserData.swift */,
 			);
 			path = Models;
 			sourceTree = "<group>";
@@ -173,10 +176,10 @@
 			path = Resources;
 			sourceTree = "<group>";
 		};
-		E573155042573F7430EB4C1C /* LICENSE */ = {
+		F0E92604CFEDA83BAF383A9E /* LICENSE */ = {
 			isa = PBXGroup;
 			children = (
-				8016A7122042026B58FF1299 /* LICENSE.txt */,
+				27FFE5444DA58085F4325C68 /* LICENSE.txt */,
 			);
 			name = LICENSE;
 			path = ../LICENSE;
@@ -217,7 +220,7 @@
 					};
 				};
 			};
-			buildConfigurationList = B739485D229F194000C47603 /* Build configuration list for PBXProject "HandlingUserInput" */;
+			buildConfigurationList = B739485D229F194000C47603 /* Build configuration list for PBXProject "DrawingPathsAndShapes" */;
 			compatibilityVersion = "Xcode 9.3";
 			developmentRegion = en;
 			hasScannedForEncodings = 0;
@@ -270,11 +273,12 @@
 				B7394866229F194000C47603 /* AppDelegate.swift in Sources */,
 				B739487A229F1B3F00C47603 /* CircleImage.swift in Sources */,
 				B739487C229F1B6800C47603 /* MapView.swift in Sources */,
+				B7310DD1229F6839001079B9 /* HexagonParameters.swift in Sources */,
 				B73948A1229F2E1F00C47603 /* LandmarkList.swift in Sources */,
 				B7394868229F194000C47603 /* SceneDelegate.swift in Sources */,
 				B739486A229F194000C47603 /* LandmarkDetail.swift in Sources */,
 				B739489F229F2D9700C47603 /* LandmarkRow.swift in Sources */,
-				8473A7282530857400415A81 /* UserData.swift in Sources */,
+				B7D2AAC5229F4D7C0061E5F5 /* UserData.swift in Sources */,
 				B7394881229F28B900C47603 /* Landmark.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -295,7 +299,7 @@
 /* Begin XCBuildConfiguration section */
 		B7394874229F194200C47603 /* Debug */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 6AF17FBC250C47AD4B5BC2FB /* SampleCode.xcconfig */;
+			baseConfigurationReference = B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ANALYZER_NONNULL = YES;
@@ -357,7 +361,7 @@
 		};
 		B7394875229F194200C47603 /* Release */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 6AF17FBC250C47AD4B5BC2FB /* SampleCode.xcconfig */;
+			baseConfigurationReference = B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ANALYZER_NONNULL = YES;
@@ -413,7 +417,7 @@
 		};
 		B7394877229F194200C47603 /* Debug */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 6AF17FBC250C47AD4B5BC2FB /* SampleCode.xcconfig */;
+			baseConfigurationReference = B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_STYLE = Automatic;
@@ -435,7 +439,7 @@
 		};
 		B7394878229F194200C47603 /* Release */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 6AF17FBC250C47AD4B5BC2FB /* SampleCode.xcconfig */;
+			baseConfigurationReference = B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_STYLE = Automatic;
@@ -458,7 +462,7 @@
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
-		B739485D229F194000C47603 /* Build configuration list for PBXProject "HandlingUserInput" */ = {
+		B739485D229F194000C47603 /* Build configuration list for PBXProject "DrawingPathsAndShapes" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
 				B7394874229F194200C47603 /* Debug */,

Landmarks/HandlingUserInput.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings → Landmarks/DrawingPathsAndShapes.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings


+ 0 - 8
Landmarks/HandlingUserInput.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IDEDidComputeMac32BitWarning</key>
-	<true/>
-</dict>
-</plist>

+ 0 - 14
Landmarks/HandlingUserInput.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>SchemeUserState</key>
-	<dict>
-		<key>Landmarks.xcscheme_^#shared#^_</key>
-		<dict>
-			<key>orderHint</key>
-			<integer>0</integer>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 1 - 2
Landmarks/Landmarks/Assets.xcassets/AppIcon.appiconset/Contents.json

@@ -82,9 +82,8 @@
       "scale" : "2x"
     },
     {
-      "size" : "76x76",
       "idiom" : "ipad",
-      "filename" : "landmark_app_icon_76x76.png",
+      "size" : "76x76",
       "scale" : "1x"
     },
     {

BIN
Landmarks/Landmarks/Assets.xcassets/AppIcon.appiconset/landmark_app_icon_76x76.png


+ 57 - 0
Landmarks/Landmarks/HexagonParameters.swift

@@ -0,0 +1,57 @@
+/*
+See LICENSE folder for this sample’s licensing information.
+
+Abstract:
+Size, position, and other information used to draw a badge.
+*/
+
+import SwiftUI
+
+struct HexagonParameters {
+    struct Segment {
+        let useWidth: (CGFloat, CGFloat, CGFloat)
+        let xFactors: (CGFloat, CGFloat, CGFloat)
+        let useHeight: (CGFloat, CGFloat, CGFloat)
+        let yFactors: (CGFloat, CGFloat, CGFloat)
+    }
+    
+    static let adjustment: CGFloat = 0.085
+    static let points = [
+        Segment(
+            useWidth:  (1.00, 1.00, 1.00),
+            xFactors:  (0.60, 0.40, 0.50),
+            useHeight: (1.00, 1.00, 0.00),
+            yFactors:  (0.05, 0.05, 0.00)
+        ),
+        Segment(
+            useWidth:  (1.00, 1.00, 0.00),
+            xFactors:  (0.05, 0.00, 0.00),
+            useHeight: (1.00, 1.00, 1.00),
+            yFactors:  (0.20 + adjustment, 0.30 + adjustment, 0.25 + adjustment)
+        ),
+        Segment(
+            useWidth:  (1.00, 1.00, 0.00),
+            xFactors:  (0.00, 0.05, 0.00),
+            useHeight: (1.00, 1.00, 1.00),
+            yFactors:  (0.70 - adjustment, 0.80 - adjustment, 0.75 - adjustment)
+        ),
+        Segment(
+            useWidth:  (1.00, 1.00, 1.00),
+            xFactors:  (0.40, 0.60, 0.50),
+            useHeight: (1.00, 1.00, 1.00),
+            yFactors:  (0.95, 0.95, 1.00)
+        ),
+        Segment(
+            useWidth:  (1.00, 1.00, 1.00),
+            xFactors:  (0.95, 1.00, 1.00),
+            useHeight: (1.00, 1.00, 1.00),
+            yFactors:  (0.80 - adjustment, 0.70 - adjustment, 0.75 - adjustment)
+        ),
+        Segment(
+            useWidth:  (1.00, 1.00, 1.00),
+            xFactors:  (1.00, 0.95, 1.00),
+            useHeight: (1.00, 1.00, 1.00),
+            yFactors:  (0.30 + adjustment, 0.20 + adjustment, 0.25 + adjustment)
+        )
+    ]
+}

+ 14 - 11
Landmarks/Landmarks/LandmarkDetail.swift

@@ -10,30 +10,32 @@ import SwiftUI
 struct LandmarkDetail: View {
     @EnvironmentObject var userData: UserData
     var landmark: Landmark
-
+    
     var landmarkIndex: Int {
         userData.landmarks.firstIndex(where: { $0.id == landmark.id })!
     }
-
+    
     var body: some View {
         VStack {
             MapView(coordinate: landmark.locationCoordinate)
                 .edgesIgnoringSafeArea(.top)
                 .frame(height: 300)
-
+            
             CircleImage(image: landmark.image)
                 .offset(x: 0, y: -130)
                 .padding(.bottom, -130)
-
+            
             VStack(alignment: .leading) {
-                HStack{
+                HStack {
                     Text(landmark.name)
                         .font(.title)
                     
                     Button(action: {
-                        self.userData.landmarks[self.landmarkIndex].isFavorite.toggle()
+                        self.userData.landmarks[self.landmarkIndex]
+                            .isFavorite.toggle()
                     }) {
-                        if self.userData.landmarks[self.landmarkIndex].isFavorite {
+                        if self.userData.landmarks[self.landmarkIndex]
+                            .isFavorite {
                             Image(systemName: "star.fill")
                                 .foregroundColor(Color.yellow)
                         } else {
@@ -42,7 +44,7 @@ struct LandmarkDetail: View {
                         }
                     }
                 }
-
+                
                 HStack(alignment: .top) {
                     Text(landmark.park)
                         .font(.subheadline)
@@ -52,15 +54,16 @@ struct LandmarkDetail: View {
                 }
             }
             .padding()
-
+            
             Spacer()
         }
-        .navigationBarTitle(Text(landmark.name), displayMode: .inline)
     }
 }
 
 struct LandmarkDetail_Previews: PreviewProvider {
     static var previews: some View {
-        LandmarkDetail(landmark: landmarkData[0])
+        let userData = UserData()
+        return LandmarkDetail(landmark: userData.landmarks[0])
+            .environmentObject(userData)
     }
 }

+ 10 - 5
Landmarks/Landmarks/LandmarkList.swift

@@ -8,17 +8,21 @@ A view showing a list of landmarks.
 import SwiftUI
 
 struct LandmarkList: View {
-    @EnvironmentObject var userData: UserData
+    @EnvironmentObject private var userData: UserData
     
     var body: some View {
         NavigationView {
-            List{
+            List {
                 Toggle(isOn: $userData.showFavoritesOnly) {
-                    Text("Favorites Only")
+                    Text("Show Favorites Only")
                 }
+                
                 ForEach(userData.landmarks) { landmark in
                     if !self.userData.showFavoritesOnly || landmark.isFavorite {
-                            NavigationLink(destination: LandmarkDetail(landmark: landmark)) {
+                        NavigationLink(
+                            destination: LandmarkDetail(landmark: landmark)
+                                .environmentObject(self.userData)
+                        ) {
                             LandmarkRow(landmark: landmark)
                         }
                     }
@@ -29,12 +33,13 @@ struct LandmarkList: View {
     }
 }
 
-struct LandmarkList_Previews: PreviewProvider {
+struct LandmarksList_Previews: PreviewProvider {
     static var previews: some View {
         ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
             LandmarkList()
                 .previewDevice(PreviewDevice(rawValue: deviceName))
                 .previewDisplayName(deviceName)
         }
+        .environmentObject(UserData())
     }
 }

+ 14 - 0
Landmarks/Landmarks/Models/UserData.swift

@@ -0,0 +1,14 @@
+/*
+See LICENSE folder for this sample’s licensing information.
+
+Abstract:
+A model object that stores app data.
+*/
+
+import Combine
+import SwiftUI
+
+final class UserData: ObservableObject {
+    @Published var showFavoritesOnly = false
+    @Published var landmarks = landmarkData
+}

+ 1 - 4
Landmarks/Landmarks/SceneDelegate.swift

@@ -20,10 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
         // Use a UIHostingController as window root view controller
         if let windowScene = scene as? UIWindowScene {
             let window = UIWindow(windowScene: windowScene)
-            window.rootViewController = UIHostingController(
-                rootView: LandmarkList()
-                    .environmentObject(UserData())
-            )
+            window.rootViewController = UIHostingController(rootView: LandmarkList().environmentObject(UserData()))
             self.window = window
             window.makeKeyAndVisible()
         }

+ 3 - 3
Landmarks/Landmarks/Supporting Views/LandmarkRow.swift

@@ -17,10 +17,10 @@ struct LandmarkRow: View {
                 .frame(width: 50, height: 50)
             Text(landmark.name)
             Spacer()
-            
-            if landmark.isFavorite{
+
+            if landmark.isFavorite {
                 Image(systemName: "star.fill")
-                    .imageScale(/*@START_MENU_TOKEN@*/.medium/*@END_MENU_TOKEN@*/)
+                    .imageScale(.medium)
                     .foregroundColor(.yellow)
             }
         }

+ 0 - 15
Landmarks/Landmarks/UserData.swift

@@ -1,15 +0,0 @@
-//
-//  UserData.swift
-//  Landmarks
-//
-//  Created by Admin on 09.10.2020.
-//  Copyright © 2020 Apple. All rights reserved.
-//
-
-import SwiftUI
-import Combine
-
-final class UserData: ObservableObject{
-    @Published var showFavoritesOnly = false
-    @Published var landmarks = landmarkData
-}

+ 2 - 2
README.md

@@ -1,3 +1,3 @@
-# Handling User Input
+# Drawing Paths and Shapes
 
-Use this project to code along with the [Handling User Input](https://developer.apple.com/tutorials/swiftui/handling-user-input) tutorial.
+Use this project to code along with the [Drawing Paths and Shapes](https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes) tutorial.