├── .gitignore ├── LumeCitySelectionRecreate.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── LumeCitySelectionRecreate ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── City.swift ├── CitySelectionView.swift ├── LumeCitySelectionRecreate.entitlements ├── LumeCitySelectionRecreateApp.swift ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json ├── WeatherBarListView.swift ├── WeatherItem+color.swift ├── WeatherItem+mocks.swift ├── WeatherItem.swift ├── WeatherServiceWrapper.swift ├── WeatherView.swift └── WeatherViewModel.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # User State 2 | *.xcuserstate 3 | *.xcuserdatad/ 4 | *.xcworkspace/xcuserdata/ 5 | *.xcodeproj/xcuserdata/ 6 | *.xcscmblueprint/xcuserdata/ 7 | *.xccheckout/xcuserdata/ 8 | *.xcworkspace/xcshareddata/ 9 | *.xcodeproj/xcshareddata/ 10 | *.xcscmblueprint/xcshareddata/ 11 | *.xccheckout/xcshareddata/ 12 | 13 | # Xcode 14 | # 15 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 16 | 17 | ## User settings 18 | xcuserdata/ 19 | 20 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 21 | *.xcscmblueprint 22 | *.xccheckout 23 | 24 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 25 | build/ 26 | DerivedData/ 27 | *.moved-aside 28 | *.pbxuser 29 | !default.pbxuser 30 | *.mode1v3 31 | !default.mode1v3 32 | *.mode2v3 33 | !default.mode2v3 34 | *.perspectivev3 35 | !default.perspectivev3 36 | 37 | ## Obj-C/Swift specific 38 | *.hmap 39 | 40 | ## App packaging 41 | *.ipa 42 | *.dSYM.zip 43 | *.dSYM 44 | 45 | ## Playgrounds 46 | timeline.xctimeline 47 | playground.xcworkspace 48 | 49 | # Swift Package Manager 50 | # 51 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 52 | # Packages/ 53 | # Package.pins 54 | # Package.resolved 55 | # *.xcodeproj 56 | # 57 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 58 | # hence it is not needed unless you have added a package configuration file to your project 59 | .swiftpm 60 | 61 | .build/ 62 | 63 | # CocoaPods 64 | # 65 | # We recommend against adding the Pods directory to your .gitignore. However 66 | # you should judge for yourself, the pros and cons are mentioned at: 67 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 68 | # 69 | # Pods/ 70 | # 71 | # Add this line if you want to avoid checking in source code from the Xcode workspace 72 | # *.xcworkspace 73 | 74 | # Carthage 75 | # 76 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 77 | # Carthage/Checkouts 78 | 79 | Carthage/Build/ 80 | 81 | # Accio dependency management 82 | Dependencies/ 83 | .accio/ 84 | 85 | # fastlane 86 | # 87 | # It is recommended to not store the screenshots in the git repo. 88 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 89 | # For more information about the recommended setup visit: 90 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 91 | 92 | fastlane/report.xml 93 | fastlane/Preview.html 94 | fastlane/screenshots/**/*.png 95 | fastlane/test_output 96 | 97 | # Code Injection 98 | # 99 | # After new code Injection tools there's a generated folder /iOSInjectionProject 100 | # https://github.com/johnno1962/injectionforxcode 101 | 102 | iOSInjectionProject/ 103 | 104 | # macOS 105 | .DS_Store 106 | .AppleDouble 107 | .LSOverride 108 | 109 | # Thumbnails 110 | ._* 111 | 112 | # Files that might appear in the root of a volume 113 | .DocumentRevisions-V100 114 | .fseventsd 115 | .Spotlight-V100 116 | .TemporaryItems 117 | .Trashes 118 | .VolumeIcon.icns 119 | .com.apple.timemachine.donotpresent 120 | 121 | # Directories potentially created on remote AFP share 122 | .AppleDB 123 | .AppleDesktop 124 | Network Trash Folder 125 | Temporary Items 126 | .apdisk -------------------------------------------------------------------------------- /LumeCitySelectionRecreate.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 77; 7 | objects = { 8 | 9 | /* Begin PBXFileReference section */ 10 | 1938ECF92DAFAFF9005C92F8 /* LumeCitySelectionRecreate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LumeCitySelectionRecreate.app; sourceTree = BUILT_PRODUCTS_DIR; }; 11 | /* End PBXFileReference section */ 12 | 13 | /* Begin PBXFileSystemSynchronizedRootGroup section */ 14 | 1938ECFB2DAFAFF9005C92F8 /* LumeCitySelectionRecreate */ = { 15 | isa = PBXFileSystemSynchronizedRootGroup; 16 | path = LumeCitySelectionRecreate; 17 | sourceTree = ""; 18 | }; 19 | /* End PBXFileSystemSynchronizedRootGroup section */ 20 | 21 | /* Begin PBXFrameworksBuildPhase section */ 22 | 1938ECF62DAFAFF9005C92F8 /* Frameworks */ = { 23 | isa = PBXFrameworksBuildPhase; 24 | buildActionMask = 2147483647; 25 | files = ( 26 | ); 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXFrameworksBuildPhase section */ 30 | 31 | /* Begin PBXGroup section */ 32 | 1938ECF02DAFAFF9005C92F8 = { 33 | isa = PBXGroup; 34 | children = ( 35 | 1938ECFB2DAFAFF9005C92F8 /* LumeCitySelectionRecreate */, 36 | 1938ECFA2DAFAFF9005C92F8 /* Products */, 37 | ); 38 | sourceTree = ""; 39 | }; 40 | 1938ECFA2DAFAFF9005C92F8 /* Products */ = { 41 | isa = PBXGroup; 42 | children = ( 43 | 1938ECF92DAFAFF9005C92F8 /* LumeCitySelectionRecreate.app */, 44 | ); 45 | name = Products; 46 | sourceTree = ""; 47 | }; 48 | /* End PBXGroup section */ 49 | 50 | /* Begin PBXNativeTarget section */ 51 | 1938ECF82DAFAFF9005C92F8 /* LumeCitySelectionRecreate */ = { 52 | isa = PBXNativeTarget; 53 | buildConfigurationList = 1938ED072DAFAFF9005C92F8 /* Build configuration list for PBXNativeTarget "LumeCitySelectionRecreate" */; 54 | buildPhases = ( 55 | 1938ECF52DAFAFF9005C92F8 /* Sources */, 56 | 1938ECF62DAFAFF9005C92F8 /* Frameworks */, 57 | 1938ECF72DAFAFF9005C92F8 /* Resources */, 58 | ); 59 | buildRules = ( 60 | ); 61 | dependencies = ( 62 | ); 63 | fileSystemSynchronizedGroups = ( 64 | 1938ECFB2DAFAFF9005C92F8 /* LumeCitySelectionRecreate */, 65 | ); 66 | name = LumeCitySelectionRecreate; 67 | packageProductDependencies = ( 68 | ); 69 | productName = LumeCitySelectionRecreate; 70 | productReference = 1938ECF92DAFAFF9005C92F8 /* LumeCitySelectionRecreate.app */; 71 | productType = "com.apple.product-type.application"; 72 | }; 73 | /* End PBXNativeTarget section */ 74 | 75 | /* Begin PBXProject section */ 76 | 1938ECF12DAFAFF9005C92F8 /* Project object */ = { 77 | isa = PBXProject; 78 | attributes = { 79 | BuildIndependentTargetsInParallel = 1; 80 | LastSwiftUpdateCheck = 1620; 81 | LastUpgradeCheck = 1620; 82 | TargetAttributes = { 83 | 1938ECF82DAFAFF9005C92F8 = { 84 | CreatedOnToolsVersion = 16.2; 85 | }; 86 | }; 87 | }; 88 | buildConfigurationList = 1938ECF42DAFAFF9005C92F8 /* Build configuration list for PBXProject "LumeCitySelectionRecreate" */; 89 | developmentRegion = en; 90 | hasScannedForEncodings = 0; 91 | knownRegions = ( 92 | en, 93 | Base, 94 | ); 95 | mainGroup = 1938ECF02DAFAFF9005C92F8; 96 | minimizedProjectReferenceProxies = 1; 97 | preferredProjectObjectVersion = 77; 98 | productRefGroup = 1938ECFA2DAFAFF9005C92F8 /* Products */; 99 | projectDirPath = ""; 100 | projectRoot = ""; 101 | targets = ( 102 | 1938ECF82DAFAFF9005C92F8 /* LumeCitySelectionRecreate */, 103 | ); 104 | }; 105 | /* End PBXProject section */ 106 | 107 | /* Begin PBXResourcesBuildPhase section */ 108 | 1938ECF72DAFAFF9005C92F8 /* Resources */ = { 109 | isa = PBXResourcesBuildPhase; 110 | buildActionMask = 2147483647; 111 | files = ( 112 | ); 113 | runOnlyForDeploymentPostprocessing = 0; 114 | }; 115 | /* End PBXResourcesBuildPhase section */ 116 | 117 | /* Begin PBXSourcesBuildPhase section */ 118 | 1938ECF52DAFAFF9005C92F8 /* Sources */ = { 119 | isa = PBXSourcesBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | ); 123 | runOnlyForDeploymentPostprocessing = 0; 124 | }; 125 | /* End PBXSourcesBuildPhase section */ 126 | 127 | /* Begin XCBuildConfiguration section */ 128 | 1938ED052DAFAFF9005C92F8 /* Debug */ = { 129 | isa = XCBuildConfiguration; 130 | buildSettings = { 131 | ALWAYS_SEARCH_USER_PATHS = NO; 132 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 133 | CLANG_ANALYZER_NONNULL = YES; 134 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 135 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 136 | CLANG_ENABLE_MODULES = YES; 137 | CLANG_ENABLE_OBJC_ARC = YES; 138 | CLANG_ENABLE_OBJC_WEAK = YES; 139 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 140 | CLANG_WARN_BOOL_CONVERSION = YES; 141 | CLANG_WARN_COMMA = YES; 142 | CLANG_WARN_CONSTANT_CONVERSION = YES; 143 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 145 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 146 | CLANG_WARN_EMPTY_BODY = YES; 147 | CLANG_WARN_ENUM_CONVERSION = YES; 148 | CLANG_WARN_INFINITE_RECURSION = YES; 149 | CLANG_WARN_INT_CONVERSION = YES; 150 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 151 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 152 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 153 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 154 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 155 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 156 | CLANG_WARN_STRICT_PROTOTYPES = YES; 157 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 158 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 159 | CLANG_WARN_UNREACHABLE_CODE = YES; 160 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 161 | COPY_PHASE_STRIP = NO; 162 | DEBUG_INFORMATION_FORMAT = dwarf; 163 | ENABLE_STRICT_OBJC_MSGSEND = YES; 164 | ENABLE_TESTABILITY = YES; 165 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 166 | GCC_C_LANGUAGE_STANDARD = gnu17; 167 | GCC_DYNAMIC_NO_PIC = NO; 168 | GCC_NO_COMMON_BLOCKS = YES; 169 | GCC_OPTIMIZATION_LEVEL = 0; 170 | GCC_PREPROCESSOR_DEFINITIONS = ( 171 | "DEBUG=1", 172 | "$(inherited)", 173 | ); 174 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 175 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 176 | GCC_WARN_UNDECLARED_SELECTOR = YES; 177 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 178 | GCC_WARN_UNUSED_FUNCTION = YES; 179 | GCC_WARN_UNUSED_VARIABLE = YES; 180 | IPHONEOS_DEPLOYMENT_TARGET = 18.2; 181 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 182 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 183 | MTL_FAST_MATH = YES; 184 | ONLY_ACTIVE_ARCH = YES; 185 | SDKROOT = iphoneos; 186 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; 187 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 188 | }; 189 | name = Debug; 190 | }; 191 | 1938ED062DAFAFF9005C92F8 /* Release */ = { 192 | isa = XCBuildConfiguration; 193 | buildSettings = { 194 | ALWAYS_SEARCH_USER_PATHS = NO; 195 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 196 | CLANG_ANALYZER_NONNULL = YES; 197 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 198 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 199 | CLANG_ENABLE_MODULES = YES; 200 | CLANG_ENABLE_OBJC_ARC = YES; 201 | CLANG_ENABLE_OBJC_WEAK = YES; 202 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 203 | CLANG_WARN_BOOL_CONVERSION = YES; 204 | CLANG_WARN_COMMA = YES; 205 | CLANG_WARN_CONSTANT_CONVERSION = YES; 206 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 207 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 208 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 209 | CLANG_WARN_EMPTY_BODY = YES; 210 | CLANG_WARN_ENUM_CONVERSION = YES; 211 | CLANG_WARN_INFINITE_RECURSION = YES; 212 | CLANG_WARN_INT_CONVERSION = YES; 213 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 214 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 215 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 216 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 217 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 218 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 219 | CLANG_WARN_STRICT_PROTOTYPES = YES; 220 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 221 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 222 | CLANG_WARN_UNREACHABLE_CODE = YES; 223 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 224 | COPY_PHASE_STRIP = NO; 225 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 226 | ENABLE_NS_ASSERTIONS = NO; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 229 | GCC_C_LANGUAGE_STANDARD = gnu17; 230 | GCC_NO_COMMON_BLOCKS = YES; 231 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 232 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 233 | GCC_WARN_UNDECLARED_SELECTOR = YES; 234 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 235 | GCC_WARN_UNUSED_FUNCTION = YES; 236 | GCC_WARN_UNUSED_VARIABLE = YES; 237 | IPHONEOS_DEPLOYMENT_TARGET = 18.2; 238 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 239 | MTL_ENABLE_DEBUG_INFO = NO; 240 | MTL_FAST_MATH = YES; 241 | SDKROOT = iphoneos; 242 | SWIFT_COMPILATION_MODE = wholemodule; 243 | VALIDATE_PRODUCT = YES; 244 | }; 245 | name = Release; 246 | }; 247 | 1938ED082DAFAFF9005C92F8 /* Debug */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 251 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 252 | CODE_SIGN_ENTITLEMENTS = LumeCitySelectionRecreate/LumeCitySelectionRecreate.entitlements; 253 | CODE_SIGN_STYLE = Automatic; 254 | CURRENT_PROJECT_VERSION = 1; 255 | DEVELOPMENT_ASSET_PATHS = "\"LumeCitySelectionRecreate/Preview Content\""; 256 | DEVELOPMENT_TEAM = D45XUJ5XY2; 257 | ENABLE_PREVIEWS = YES; 258 | GENERATE_INFOPLIST_FILE = YES; 259 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 260 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 261 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 262 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 263 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 264 | LD_RUNPATH_SEARCH_PATHS = ( 265 | "$(inherited)", 266 | "@executable_path/Frameworks", 267 | ); 268 | MARKETING_VERSION = 1.0; 269 | PRODUCT_BUNDLE_IDENTIFIER = io.appbeyond.tutorial.LumeCitySelectionRecreate; 270 | PRODUCT_NAME = "$(TARGET_NAME)"; 271 | SWIFT_EMIT_LOC_STRINGS = YES; 272 | SWIFT_VERSION = 5.0; 273 | TARGETED_DEVICE_FAMILY = "1,2"; 274 | }; 275 | name = Debug; 276 | }; 277 | 1938ED092DAFAFF9005C92F8 /* Release */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 281 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 282 | CODE_SIGN_ENTITLEMENTS = LumeCitySelectionRecreate/LumeCitySelectionRecreate.entitlements; 283 | CODE_SIGN_STYLE = Automatic; 284 | CURRENT_PROJECT_VERSION = 1; 285 | DEVELOPMENT_ASSET_PATHS = "\"LumeCitySelectionRecreate/Preview Content\""; 286 | DEVELOPMENT_TEAM = D45XUJ5XY2; 287 | ENABLE_PREVIEWS = YES; 288 | GENERATE_INFOPLIST_FILE = YES; 289 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 290 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 291 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 292 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 293 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 294 | LD_RUNPATH_SEARCH_PATHS = ( 295 | "$(inherited)", 296 | "@executable_path/Frameworks", 297 | ); 298 | MARKETING_VERSION = 1.0; 299 | PRODUCT_BUNDLE_IDENTIFIER = io.appbeyond.tutorial.LumeCitySelectionRecreate; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | SWIFT_EMIT_LOC_STRINGS = YES; 302 | SWIFT_VERSION = 5.0; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | }; 305 | name = Release; 306 | }; 307 | /* End XCBuildConfiguration section */ 308 | 309 | /* Begin XCConfigurationList section */ 310 | 1938ECF42DAFAFF9005C92F8 /* Build configuration list for PBXProject "LumeCitySelectionRecreate" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | 1938ED052DAFAFF9005C92F8 /* Debug */, 314 | 1938ED062DAFAFF9005C92F8 /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | defaultConfigurationName = Release; 318 | }; 319 | 1938ED072DAFAFF9005C92F8 /* Build configuration list for PBXNativeTarget "LumeCitySelectionRecreate" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | 1938ED082DAFAFF9005C92F8 /* Debug */, 323 | 1938ED092DAFAFF9005C92F8 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | /* End XCConfigurationList section */ 329 | }; 330 | rootObject = 1938ECF12DAFAFF9005C92F8 /* Project object */; 331 | } 332 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | }, 8 | { 9 | "appearances" : [ 10 | { 11 | "appearance" : "luminosity", 12 | "value" : "dark" 13 | } 14 | ], 15 | "idiom" : "universal", 16 | "platform" : "ios", 17 | "size" : "1024x1024" 18 | }, 19 | { 20 | "appearances" : [ 21 | { 22 | "appearance" : "luminosity", 23 | "value" : "tinted" 24 | } 25 | ], 26 | "idiom" : "universal", 27 | "platform" : "ios", 28 | "size" : "1024x1024" 29 | } 30 | ], 31 | "info" : { 32 | "author" : "xcode", 33 | "version" : 1 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/City.swift: -------------------------------------------------------------------------------- 1 | // 2 | // City.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/18/25. 6 | // 7 | 8 | import CoreLocation 9 | 10 | struct City: Hashable { 11 | let name: String 12 | let location: CLLocation 13 | 14 | static func == (lhs: City, rhs: City) -> Bool { 15 | lhs.name == rhs.name 16 | } 17 | 18 | func hash(into hasher: inout Hasher) { 19 | hasher.combine(name) 20 | } 21 | } 22 | 23 | extension City { 24 | static var all: [City] = [ 25 | City(name: "New York", location: CLLocation(latitude: 40.7128, longitude: -74.0060)), 26 | City(name: "Tokyo", location: CLLocation(latitude: 35.6762, longitude: 139.6503)), 27 | City(name: "Paris", location: CLLocation(latitude: 48.8566, longitude: 2.3522)), 28 | City(name: "Bangkok", location: CLLocation(latitude: 13.7563, longitude: 100.5018)), 29 | City(name: "Singapore", location: CLLocation(latitude: 1.3521, longitude: 103.8198)), 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/CitySelectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CitySelectionView.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/17/25. 6 | // 7 | 8 | import SwiftUI 9 | import CoreLocation 10 | 11 | struct CitySelectionView: View { 12 | 13 | init(cities: [City], selectedCity: Binding, selectedUnit: Binding) { 14 | self.cities = cities 15 | self._selectedCity = selectedCity 16 | self._selectedUnit = selectedUnit 17 | self.animatedSelectedCity = selectedCity.wrappedValue 18 | self.animatedSelectedUnit = selectedUnit.wrappedValue 19 | } 20 | 21 | let cities: [City] 22 | 23 | @Binding var selectedCity: City 24 | @Binding var selectedUnit: UnitTemperature 25 | 26 | @State private var animatedSelectedCity: City 27 | @State private var animatedSelectedUnit: UnitTemperature 28 | @Namespace private var namespace 29 | 30 | var body: some View { 31 | VStack(alignment: .leading) { 32 | HStack(spacing: 20) { 33 | Text(UnitTemperature.celsius.symbol) 34 | .opacity(animatedSelectedUnit == .celsius ? 1 : 0.5) 35 | .onTapGesture { 36 | selectedUnit = .celsius 37 | withAnimation(.snappy) { 38 | animatedSelectedUnit = .celsius 39 | } 40 | } 41 | 42 | Text(UnitTemperature.fahrenheit.symbol) 43 | .opacity(animatedSelectedUnit == .fahrenheit ? 1 : 0.5) 44 | .onTapGesture { 45 | selectedUnit = .fahrenheit 46 | withAnimation(.snappy) { 47 | animatedSelectedUnit = .fahrenheit 48 | } 49 | } 50 | } 51 | .font(.system(.title, weight: .semibold)) 52 | .foregroundStyle(.white) 53 | .padding(20) 54 | 55 | Spacer() 56 | 57 | ForEach(cities) { city in 58 | HStack { 59 | ZStack { 60 | if animatedSelectedCity == city { 61 | Rectangle() 62 | .frame(width: 40, height: 1) 63 | .foregroundStyle(.white) 64 | .matchedGeometryEffect(id: "line", in: namespace, properties: .position) 65 | } 66 | 67 | Rectangle() 68 | .frame(width: 40, height: 1) 69 | .opacity(0) 70 | } 71 | 72 | Text(city.name) 73 | .font(.system(.title, weight: .semibold)) 74 | .foregroundStyle(.white) 75 | .opacity(animatedSelectedCity == city ? 1 : 0.5) 76 | 77 | Spacer() 78 | } 79 | .onTapGesture { 80 | selectedCity = city 81 | withAnimation(.snappy) { 82 | animatedSelectedCity = city 83 | } 84 | } 85 | } 86 | 87 | Spacer() 88 | Spacer() 89 | } 90 | .frame(maxWidth: .infinity, maxHeight: .infinity) 91 | } 92 | } 93 | 94 | extension City: Identifiable { 95 | var id: String { name } 96 | } 97 | 98 | #Preview { 99 | @Previewable @State var selectedCity = City.all.first! 100 | @Previewable @State var selectedUnit: UnitTemperature = .celsius 101 | 102 | CitySelectionView( 103 | cities: City.all, 104 | selectedCity: $selectedCity, 105 | selectedUnit: $selectedUnit 106 | ) 107 | .background(.black, ignoresSafeAreaEdges: .all) 108 | } 109 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/LumeCitySelectionRecreate.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.weatherkit 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/LumeCitySelectionRecreateApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LumeCitySelectionRecreateApp.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/16/25. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct LumeCitySelectionRecreateApp: App { 12 | 13 | @State var viewModel = WeatherViewModel(service: WeatherServiceWrapper(), cities: City.all) 14 | 15 | var body: some Scene { 16 | WindowGroup { 17 | WeatherView(viewModel: viewModel) 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherBarListView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeatherBarListView.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/16/25. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct WeatherBarListView: View { 11 | 12 | init(items: [WeatherItem], selectedUnit: Binding) { 13 | self.items = items 14 | self.values = Array(repeating: 0, count: items.count) 15 | self.colors = items.map { $0.temperatureColor } 16 | self.symbolNames = items.map { $0.symbolName } 17 | self._selectedUnit = selectedUnit 18 | } 19 | 20 | @Binding var selectedUnit: UnitTemperature 21 | 22 | private let items: [WeatherItem] 23 | @State private var values: [Int] 24 | @State private var colors: [Color] 25 | @State private var symbolNames: [String] 26 | 27 | var body: some View { 28 | ScrollView { 29 | VStack(alignment: .leading, spacing: .zero) { 30 | ForEach(Array(values.enumerated()), id: \.offset) { index, value in 31 | HStack { 32 | Rectangle() 33 | .containerRelativeFrame(.vertical, count: 24, span: 1, spacing: 0) 34 | .containerRelativeFrame( 35 | .horizontal, 36 | count: 120, 37 | span: value, 38 | spacing: 0 39 | ) 40 | .foregroundStyle(colors[index]) 41 | .overlay { 42 | LinearGradient( 43 | colors: [.black.opacity(0.05), .clear], 44 | startPoint: .top, 45 | endPoint: .bottom 46 | ) 47 | } 48 | .brightness(-Double(index - 23) * 0.01) 49 | 50 | Image(systemName: symbolNames[index]) 51 | .symbolEffect(.bounce, value: symbolNames[index]) 52 | .foregroundStyle(colors[index].gradient) 53 | } 54 | .task { 55 | await animate(at: index) 56 | } 57 | } 58 | } 59 | .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) 60 | .background(.black, ignoresSafeAreaEdges: .all) 61 | .overlay { 62 | LinearGradient( 63 | colors: [.black.opacity(0.7), .clear], 64 | startPoint: .top, 65 | endPoint: .bottom 66 | ) 67 | } 68 | } 69 | .scrollDisabled(true) 70 | .ignoresSafeArea(.all) 71 | .onChange(of: items) { 72 | Task { @MainActor in 73 | await wave() 74 | } 75 | } 76 | .onChange(of: selectedUnit) { 77 | Task { @MainActor in 78 | await wave() 79 | } 80 | } 81 | } 82 | 83 | private func wave() async { 84 | let m = items.count / 2 85 | var l = m - 1 86 | var r = m 87 | 88 | while l >= 0 || r <= items.count - 1 { 89 | try? await Task.sleep(for: .seconds(abs(Double(r - m)) * 0.005)) 90 | withAnimation(.spring(.bouncy(duration: 0.4, extraBounce: 0.2))) { 91 | if l >= 0 { 92 | values[l] = Int(items[l].temperature.converted(to: selectedUnit).value) 93 | colors[l] = items[l].temperatureColor 94 | symbolNames[l] = items[l].symbolName 95 | } 96 | 97 | if r <= items.count - 1 { 98 | values[r] = Int(items[r].temperature.converted(to: selectedUnit).value) 99 | colors[r] = items[r].temperatureColor 100 | symbolNames[r] = items[r].symbolName 101 | } 102 | } 103 | 104 | l -= 1 105 | r += 1 106 | } 107 | } 108 | 109 | private func animate(at index: Int) async { 110 | try? await Task.sleep(for: .seconds(0.5 + Double(index) * 0.02)) 111 | withAnimation(.spring(.bouncy(duration: 0.4, extraBounce: 0.2))) { 112 | values[index] = Int(items[index].temperature.converted(to: selectedUnit).value) 113 | } 114 | } 115 | } 116 | 117 | #Preview { 118 | WeatherBarListView(items: WeatherItem.bangkok, selectedUnit: .constant(.celsius)) 119 | } 120 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherItem+color.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeatherItem+color.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/17/25. 6 | // 7 | 8 | import SwiftUI 9 | 10 | extension Color { 11 | static let coldBlue = Color(red: 64 / 255.0, green: 248 / 255.0, blue: 255 / 255.0) 12 | static let comfortMint = Color(red: 109 / 255.0, green: 225 / 255.0, blue: 210 / 255.0) 13 | static let comfortGreen = Color(red: 0 / 255.0, green: 255 / 255.0, blue: 156 / 255.0) 14 | static let warmYellow = Color(red: 255 / 255.0, green: 186 / 255.0, blue: 23 / 255.0) 15 | static let hotOrange = Color(red: 255 / 255.0, green: 145 / 255.0, blue: 73 / 255.0) 16 | static let hotOrange2 = Color(red: 234 / 255.0, green: 115 / 255.0, blue: 0 / 255.0) 17 | static let hellRed = Color(red: 247 / 255.0, green: 90 / 255.0, blue: 90 / 255.0) 18 | } 19 | 20 | extension WeatherItem { 21 | var temperatureColor: Color { 22 | let temp = temperature.converted(to: .celsius).value 23 | switch temp { 24 | case ..<15: return .coldBlue 25 | case 15..<20: return .comfortGreen 26 | case 20..<25: return .comfortGreen 27 | case 25..<30: return .warmYellow 28 | case 30..<35: return .hotOrange 29 | case 35..<40: return .hotOrange2 30 | default: return .hellRed 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherItem+mocks.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension WeatherItem { 4 | static var mocks: [WeatherItem] { 5 | [ 6 | WeatherItem( 7 | id: UUID(), 8 | cityName: "New York", 9 | date: Date(), 10 | symbolName: "sun.max.fill", 11 | description: "Sunny", 12 | temperature: Measurement(value: 25, unit: .celsius), 13 | apparentTemperature: Measurement(value: 26, unit: .celsius), 14 | windSpeed: Measurement(value: 10, unit: .kilometersPerHour), 15 | humidity: 0.65 16 | ), 17 | WeatherItem( 18 | id: UUID(), 19 | cityName: "Tokyo", 20 | date: Date(), 21 | symbolName: "cloud.rain.fill", 22 | description: "Rainy", 23 | temperature: Measurement(value: 18, unit: .celsius), 24 | apparentTemperature: Measurement(value: 17, unit: .celsius), 25 | windSpeed: Measurement(value: 15, unit: .kilometersPerHour), 26 | humidity: 0.85 27 | ), 28 | WeatherItem( 29 | id: UUID(), 30 | cityName: "Paris", 31 | date: Date(), 32 | symbolName: "cloud.fill", 33 | description: "Cloudy", 34 | temperature: Measurement(value: 20, unit: .celsius), 35 | apparentTemperature: Measurement(value: 19, unit: .celsius), 36 | windSpeed: Measurement(value: 12, unit: .kilometersPerHour), 37 | humidity: 0.75 38 | ), 39 | WeatherItem( 40 | id: UUID(), 41 | cityName: "Bangkok", 42 | date: Date(), 43 | symbolName: "cloud.sun.fill", 44 | description: "Partly Cloudy", 45 | temperature: Measurement(value: 32, unit: .celsius), 46 | apparentTemperature: Measurement(value: 35, unit: .celsius), 47 | windSpeed: Measurement(value: 8, unit: .kilometersPerHour), 48 | humidity: 0.70 49 | ) 50 | ] 51 | } 52 | } 53 | 54 | extension WeatherItem { 55 | static var bangkok: [WeatherItem] { 56 | [32.0, 33.0, 34.0, 33.0, 34.0, 35.0, 34.0, 33.0, 32.0, 31.0, 30.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 34.0, 33.0, 32.0, 31.0, 29.0, 31.0] 57 | .map { Measurement(value: $0, unit: .celsius) } 58 | .map { 59 | WeatherItem( 60 | id: UUID(), 61 | cityName: "Bangkok", 62 | date: Date(), 63 | symbolName: "cloud.sun.fill", 64 | description: "Partly Cloudy", 65 | temperature: $0, 66 | apparentTemperature: $0, 67 | windSpeed: Measurement(value: 8, unit: .kilometersPerHour), 68 | humidity: 0.70 69 | ) 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeatherItem.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/17/25. 6 | // 7 | 8 | import Foundation 9 | 10 | struct WeatherItem: Hashable, Identifiable { 11 | let id: UUID 12 | let cityName: String 13 | let date: Date 14 | let symbolName: String 15 | let description: String 16 | let temperature: Measurement 17 | let apparentTemperature: Measurement 18 | let windSpeed: Measurement 19 | let humidity: Double 20 | } 21 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherServiceWrapper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeatherServiceWrapper.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/18/25. 6 | // 7 | 8 | import Foundation 9 | import WeatherKit 10 | 11 | class WeatherServiceWrapper: HourlyWeatherService { 12 | 13 | let weatherService: WeatherService = .shared 14 | 15 | func fetchHourlyWeather(for city: City) async -> [WeatherItem] { 16 | guard let forecast = try? await weatherService.weather(for: city.location, including: .hourly) else { 17 | return [] 18 | } 19 | 20 | let items: [WeatherItem] = forecast.forecast.map { weather in 21 | return WeatherItem( 22 | id: UUID(), 23 | cityName: city.name, 24 | date: weather.date, 25 | symbolName: weather.symbolName, 26 | description: weather.condition.description, 27 | temperature: weather.temperature, 28 | apparentTemperature: weather.apparentTemperature, 29 | windSpeed: weather.wind.speed, 30 | humidity: weather.humidity 31 | ) 32 | } 33 | 34 | return items 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeatherView.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/18/25. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct WeatherView: View { 11 | 12 | @State var viewModel: WeatherViewModel 13 | 14 | var body: some View { 15 | ZStack { 16 | if !viewModel.items.isEmpty { 17 | WeatherBarListView(items: viewModel.items, selectedUnit: $viewModel.selectedUnit) 18 | } 19 | 20 | CitySelectionView( 21 | cities: viewModel.cities, 22 | selectedCity: $viewModel.selectedCity, 23 | selectedUnit: $viewModel.selectedUnit 24 | ) 25 | } 26 | .task { 27 | await viewModel.onAppear() 28 | } 29 | .onChange(of: viewModel.selectedCity) { 30 | Task { @MainActor in 31 | await viewModel.fetchWeather(for: viewModel.selectedCity) 32 | } 33 | } 34 | } 35 | } 36 | 37 | #Preview { 38 | @Previewable @State var viewModel = WeatherViewModel(service: WeatherServiceWrapper(), cities: City.all) 39 | WeatherView(viewModel: viewModel) 40 | } 41 | -------------------------------------------------------------------------------- /LumeCitySelectionRecreate/WeatherViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeatherViewModel.swift 3 | // LumeCitySelectionRecreate 4 | // 5 | // Created by Yossa Bourne on 4/18/25. 6 | // 7 | 8 | import Foundation 9 | import CoreLocation 10 | 11 | @Observable 12 | class WeatherViewModel { 13 | 14 | init(service: HourlyWeatherService, cities: [City]) { 15 | self.service = service 16 | self.cities = cities 17 | self.selectedCity = cities[0] 18 | } 19 | 20 | let service: HourlyWeatherService 21 | let cities: [City] 22 | var items: [WeatherItem] = [] 23 | var selectedCity: City 24 | var selectedUnit: UnitTemperature = .fahrenheit 25 | 26 | @MainActor 27 | func onAppear() async { 28 | await fetchWeather(for: selectedCity) 29 | } 30 | 31 | @MainActor 32 | func fetchWeather(for city: City) async { 33 | items = await service.fetchHourlyWeather(for: city) 34 | } 35 | } 36 | 37 | protocol HourlyWeatherService { 38 | func fetchHourlyWeather(for city: City) async -> [WeatherItem] 39 | } 40 | --------------------------------------------------------------------------------