├── Analog Clock.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── derekchan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── derekchan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Analog Clock ├── Analog_ClockApp.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Color.colorset │ │ └── Contents.json │ └── Contents.json ├── ContentView.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── Time.swift ├── README.md └── Screenshots ├── Simulator Screen Shot - iPhone 11 Pro - 2020-09-11 at 13.34.23.png └── Simulator Screen Shot - iPhone 11 Pro - 2020-09-11 at 13.34.32.png /Analog Clock.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ADA9683525090F260035FB0C /* Analog_ClockApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADA9683425090F260035FB0C /* Analog_ClockApp.swift */; }; 11 | ADA9683725090F260035FB0C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADA9683625090F260035FB0C /* ContentView.swift */; }; 12 | ADA9683925090F280035FB0C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ADA9683825090F280035FB0C /* Assets.xcassets */; }; 13 | ADA9683C25090F280035FB0C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ADA9683B25090F280035FB0C /* Preview Assets.xcassets */; }; 14 | ADA96844250917710035FB0C /* Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADA96843250917710035FB0C /* Time.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | ADA9683125090F260035FB0C /* Analog Clock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Analog Clock.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | ADA9683425090F260035FB0C /* Analog_ClockApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Analog_ClockApp.swift; sourceTree = ""; }; 20 | ADA9683625090F260035FB0C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | ADA9683825090F280035FB0C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | ADA9683B25090F280035FB0C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | ADA9683D25090F280035FB0C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | ADA96843250917710035FB0C /* Time.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Time.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | ADA9682E25090F260035FB0C /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | ADA9682825090F260035FB0C = { 39 | isa = PBXGroup; 40 | children = ( 41 | ADA9683325090F260035FB0C /* Analog Clock */, 42 | ADA9683225090F260035FB0C /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | ADA9683225090F260035FB0C /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | ADA9683125090F260035FB0C /* Analog Clock.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | ADA9683325090F260035FB0C /* Analog Clock */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | ADA9683425090F260035FB0C /* Analog_ClockApp.swift */, 58 | ADA9683625090F260035FB0C /* ContentView.swift */, 59 | ADA96843250917710035FB0C /* Time.swift */, 60 | ADA9683825090F280035FB0C /* Assets.xcassets */, 61 | ADA9683D25090F280035FB0C /* Info.plist */, 62 | ADA9683A25090F280035FB0C /* Preview Content */, 63 | ); 64 | path = "Analog Clock"; 65 | sourceTree = ""; 66 | }; 67 | ADA9683A25090F280035FB0C /* Preview Content */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | ADA9683B25090F280035FB0C /* Preview Assets.xcassets */, 71 | ); 72 | path = "Preview Content"; 73 | sourceTree = ""; 74 | }; 75 | /* End PBXGroup section */ 76 | 77 | /* Begin PBXNativeTarget section */ 78 | ADA9683025090F260035FB0C /* Analog Clock */ = { 79 | isa = PBXNativeTarget; 80 | buildConfigurationList = ADA9684025090F280035FB0C /* Build configuration list for PBXNativeTarget "Analog Clock" */; 81 | buildPhases = ( 82 | ADA9682D25090F260035FB0C /* Sources */, 83 | ADA9682E25090F260035FB0C /* Frameworks */, 84 | ADA9682F25090F260035FB0C /* Resources */, 85 | ); 86 | buildRules = ( 87 | ); 88 | dependencies = ( 89 | ); 90 | name = "Analog Clock"; 91 | productName = "Analog Clock"; 92 | productReference = ADA9683125090F260035FB0C /* Analog Clock.app */; 93 | productType = "com.apple.product-type.application"; 94 | }; 95 | /* End PBXNativeTarget section */ 96 | 97 | /* Begin PBXProject section */ 98 | ADA9682925090F260035FB0C /* Project object */ = { 99 | isa = PBXProject; 100 | attributes = { 101 | LastSwiftUpdateCheck = 1200; 102 | LastUpgradeCheck = 1200; 103 | TargetAttributes = { 104 | ADA9683025090F260035FB0C = { 105 | CreatedOnToolsVersion = 12.0; 106 | }; 107 | }; 108 | }; 109 | buildConfigurationList = ADA9682C25090F260035FB0C /* Build configuration list for PBXProject "Analog Clock" */; 110 | compatibilityVersion = "Xcode 9.3"; 111 | developmentRegion = en; 112 | hasScannedForEncodings = 0; 113 | knownRegions = ( 114 | en, 115 | Base, 116 | ); 117 | mainGroup = ADA9682825090F260035FB0C; 118 | productRefGroup = ADA9683225090F260035FB0C /* Products */; 119 | projectDirPath = ""; 120 | projectRoot = ""; 121 | targets = ( 122 | ADA9683025090F260035FB0C /* Analog Clock */, 123 | ); 124 | }; 125 | /* End PBXProject section */ 126 | 127 | /* Begin PBXResourcesBuildPhase section */ 128 | ADA9682F25090F260035FB0C /* Resources */ = { 129 | isa = PBXResourcesBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | ADA9683C25090F280035FB0C /* Preview Assets.xcassets in Resources */, 133 | ADA9683925090F280035FB0C /* Assets.xcassets in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | ADA9682D25090F260035FB0C /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | ADA96844250917710035FB0C /* Time.swift in Sources */, 145 | ADA9683725090F260035FB0C /* ContentView.swift in Sources */, 146 | ADA9683525090F260035FB0C /* Analog_ClockApp.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | ADA9683E25090F280035FB0C /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_ANALYZER_NONNULL = YES; 158 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 159 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 160 | CLANG_CXX_LIBRARY = "libc++"; 161 | CLANG_ENABLE_MODULES = YES; 162 | CLANG_ENABLE_OBJC_ARC = YES; 163 | CLANG_ENABLE_OBJC_WEAK = YES; 164 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 165 | CLANG_WARN_BOOL_CONVERSION = YES; 166 | CLANG_WARN_COMMA = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 180 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 181 | CLANG_WARN_STRICT_PROTOTYPES = YES; 182 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 183 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | COPY_PHASE_STRIP = NO; 187 | DEBUG_INFORMATION_FORMAT = dwarf; 188 | ENABLE_STRICT_OBJC_MSGSEND = YES; 189 | ENABLE_TESTABILITY = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu11; 191 | GCC_DYNAMIC_NO_PIC = NO; 192 | GCC_NO_COMMON_BLOCKS = YES; 193 | GCC_OPTIMIZATION_LEVEL = 0; 194 | GCC_PREPROCESSOR_DEFINITIONS = ( 195 | "DEBUG=1", 196 | "$(inherited)", 197 | ); 198 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 200 | GCC_WARN_UNDECLARED_SELECTOR = YES; 201 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 202 | GCC_WARN_UNUSED_FUNCTION = YES; 203 | GCC_WARN_UNUSED_VARIABLE = YES; 204 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 205 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 206 | MTL_FAST_MATH = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | }; 212 | name = Debug; 213 | }; 214 | ADA9683F25090F280035FB0C /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_ENABLE_OBJC_WEAK = YES; 225 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_COMMA = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 238 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 241 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 242 | CLANG_WARN_STRICT_PROTOTYPES = YES; 243 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 244 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 245 | CLANG_WARN_UNREACHABLE_CODE = YES; 246 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu11; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | MTL_FAST_MATH = YES; 262 | SDKROOT = iphoneos; 263 | SWIFT_COMPILATION_MODE = wholemodule; 264 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 265 | VALIDATE_PRODUCT = YES; 266 | }; 267 | name = Release; 268 | }; 269 | ADA9684125090F280035FB0C /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 274 | CODE_SIGN_STYLE = Automatic; 275 | DEVELOPMENT_ASSET_PATHS = "\"Analog Clock/Preview Content\""; 276 | DEVELOPMENT_TEAM = YM9U6GJ233; 277 | ENABLE_PREVIEWS = YES; 278 | INFOPLIST_FILE = "Analog Clock/Info.plist"; 279 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 280 | LD_RUNPATH_SEARCH_PATHS = ( 281 | "$(inherited)", 282 | "@executable_path/Frameworks", 283 | ); 284 | PRODUCT_BUNDLE_IDENTIFIER = "com.derek.Analog-Clock"; 285 | PRODUCT_NAME = "$(TARGET_NAME)"; 286 | SWIFT_VERSION = 5.0; 287 | TARGETED_DEVICE_FAMILY = "1,2"; 288 | }; 289 | name = Debug; 290 | }; 291 | ADA9684225090F280035FB0C /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 296 | CODE_SIGN_STYLE = Automatic; 297 | DEVELOPMENT_ASSET_PATHS = "\"Analog Clock/Preview Content\""; 298 | DEVELOPMENT_TEAM = YM9U6GJ233; 299 | ENABLE_PREVIEWS = YES; 300 | INFOPLIST_FILE = "Analog Clock/Info.plist"; 301 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 302 | LD_RUNPATH_SEARCH_PATHS = ( 303 | "$(inherited)", 304 | "@executable_path/Frameworks", 305 | ); 306 | PRODUCT_BUNDLE_IDENTIFIER = "com.derek.Analog-Clock"; 307 | PRODUCT_NAME = "$(TARGET_NAME)"; 308 | SWIFT_VERSION = 5.0; 309 | TARGETED_DEVICE_FAMILY = "1,2"; 310 | }; 311 | name = Release; 312 | }; 313 | /* End XCBuildConfiguration section */ 314 | 315 | /* Begin XCConfigurationList section */ 316 | ADA9682C25090F260035FB0C /* Build configuration list for PBXProject "Analog Clock" */ = { 317 | isa = XCConfigurationList; 318 | buildConfigurations = ( 319 | ADA9683E25090F280035FB0C /* Debug */, 320 | ADA9683F25090F280035FB0C /* Release */, 321 | ); 322 | defaultConfigurationIsVisible = 0; 323 | defaultConfigurationName = Release; 324 | }; 325 | ADA9684025090F280035FB0C /* Build configuration list for PBXNativeTarget "Analog Clock" */ = { 326 | isa = XCConfigurationList; 327 | buildConfigurations = ( 328 | ADA9684125090F280035FB0C /* Debug */, 329 | ADA9684225090F280035FB0C /* Release */, 330 | ); 331 | defaultConfigurationIsVisible = 0; 332 | defaultConfigurationName = Release; 333 | }; 334 | /* End XCConfigurationList section */ 335 | }; 336 | rootObject = ADA9682925090F260035FB0C /* Project object */; 337 | } 338 | -------------------------------------------------------------------------------- /Analog Clock.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Analog Clock.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Analog Clock.xcodeproj/project.xcworkspace/xcuserdata/derekchan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0407-zh/Analog-Clock-SwiftUI/0ec0c7d8b14c01fc71a2bc085ce0ec6591ebf44a/Analog Clock.xcodeproj/project.xcworkspace/xcuserdata/derekchan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Analog Clock.xcodeproj/xcuserdata/derekchan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Analog Clock.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Analog Clock/Analog_ClockApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Analog_ClockApp.swift 3 | // Analog Clock 4 | // 5 | // Created by Derek Chan on 2020/9/9. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct Analog_ClockApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Analog Clock/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 | -------------------------------------------------------------------------------- /Analog Clock/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Analog Clock/Assets.xcassets/Color.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "platform" : "ios", 6 | "reference" : "groupTableViewBackgroundColor" 7 | }, 8 | "idiom" : "universal" 9 | }, 10 | { 11 | "appearances" : [ 12 | { 13 | "appearance" : "luminosity", 14 | "value" : "dark" 15 | } 16 | ], 17 | "color" : { 18 | "platform" : "ios", 19 | "reference" : "separatorColor" 20 | }, 21 | "idiom" : "universal" 22 | } 23 | ], 24 | "info" : { 25 | "author" : "xcode", 26 | "version" : 1 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Analog Clock/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Analog Clock/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Analog Clock 4 | // 5 | // Created by Derek Chan on 2020/9/9. 6 | // 7 | 8 | import SwiftUI 9 | import UserNotificationsUI 10 | 11 | struct ContentView: View { 12 | @State var isDark: Bool = false 13 | @State var is12h: Bool = false 14 | var body: some View { 15 | Home(is12h: $is12h, isDark: $isDark) 16 | .navigationBarHidden(true) 17 | .preferredColorScheme(isDark ? .dark : .light) 18 | } 19 | } 20 | 21 | struct ContentView_Previews: PreviewProvider { 22 | static var previews: some View { 23 | ContentView() 24 | } 25 | } 26 | 27 | struct Home: View { 28 | @State var currentTime = Time(sec: 0, min: 0, hour: 0) 29 | @State var receiver = Timer.publish(every: 1, on: .current, in: .default).autoconnect() 30 | @Binding var is12h: Bool 31 | @Binding var isDark: Bool 32 | var width = UIScreen.main.bounds.width 33 | 34 | var body: some View { 35 | VStack { 36 | HStack { 37 | Text(Locale.current.localizedString(forRegionCode: Locale.current.regionCode!) ?? "") 38 | .font(.largeTitle) 39 | .fontWeight(.heavy) 40 | // .padding(.top, 35) 41 | 42 | Spacer() 43 | 44 | Button(action: { 45 | isDark.toggle() 46 | vibrationFeedback() 47 | }, label: { 48 | Image(systemName: isDark ? "sun.min.fill" : "moon.fill") 49 | .font(.system(size: 22)) 50 | .foregroundColor(isDark ? .black : .white) 51 | .padding() 52 | .background(Color.primary) 53 | .clipShape(Circle()) 54 | }) 55 | } 56 | .padding() 57 | 58 | Spacer() 59 | 60 | Text(getTime()) 61 | .font(.system(size: 45)) 62 | .fontWeight(.heavy) 63 | .padding(.top, 10) 64 | 65 | Spacer() 66 | 67 | ZStack {// Dial 68 | Circle() 69 | .fill(Color("Color")) 70 | 71 | // Seconds And Min dots... 72 | ForEach(0..<60, id: \.self){ i in 73 | Rectangle() 74 | .fill(Color.primary) 75 | .frame(width: 2, height: (i % 5) == 0 ? 15 : 5)// 60/12 = 5 76 | .offset(y: (width - 110) / 2) 77 | .rotationEffect(.init(degrees: Double(i) * 6)) 78 | } 79 | 80 | //Minutes 81 | Rectangle() 82 | .fill(Color.primary) 83 | .frame(width: 4, height: (width - 150) / 2) 84 | .offset(y: -(width - 200) / 4) 85 | .rotationEffect(.init(degrees: Double(currentTime.min) * 6)) 86 | 87 | //Hours 88 | Rectangle() 89 | .fill(Color.primary) 90 | .frame(width: 4.5, height: (width - 240) / 2) 91 | .offset(y: -(width - 240) / 4) 92 | .rotationEffect(.init(degrees: Double(currentTime.hour + currentTime.min / 60) * 30)) 93 | 94 | //Seconds 95 | Rectangle() 96 | .fill(Color.red) 97 | .frame(width: 2, height: (width - 180) / 2) 98 | .offset(y: -(width - 180) / 4) 99 | .rotationEffect(.init(degrees: Double(currentTime.sec) * 6)) 100 | 101 | Circle() 102 | .fill(Color.primary) 103 | .frame(width: 15, height: 15) 104 | } 105 | .frame(width: width - 80, height: width - 80) 106 | 107 | Button(action: { 108 | is12h.toggle() 109 | }, label: { 110 | if is12h { 111 | Text("12h") 112 | .modifier(FormatFomt()) 113 | } else { 114 | Text("24h") 115 | .modifier(FormatFomt()) 116 | } 117 | }) 118 | 119 | Spacer() 120 | } 121 | .onAppear(perform: { 122 | let calender = Calendar.current 123 | 124 | let sec = calender.component(.second, from: Date()) 125 | let min = calender.component(.minute, from: Date()) 126 | let hour = calender.component(.hour, from: Date()) 127 | 128 | withAnimation(Animation.linear(duration: 0.01)){ 129 | currentTime = Time(sec: sec, min: min, hour: hour) 130 | } 131 | }) 132 | .onReceive(receiver){ _ in 133 | let calender = Calendar.current 134 | 135 | let sec = calender.component(.second, from: Date()) 136 | let min = calender.component(.minute, from: Date()) 137 | let hour = calender.component(.hour, from: Date()) 138 | 139 | withAnimation(Animation.linear(duration: 0.01)){ 140 | currentTime = Time(sec: sec, min: min, hour: hour) 141 | } 142 | } 143 | } 144 | 145 | func vibrationFeedback() { 146 | let generator = UINotificationFeedbackGenerator() 147 | generator.notificationOccurred(.success) 148 | } 149 | 150 | func getTime() -> String { 151 | let format = DateFormatter() 152 | if is12h { 153 | format.dateFormat = "hh:mm a" 154 | } else { 155 | format.dateFormat = "HH:mm" 156 | } 157 | 158 | // format.dateFormat = "HH:mm" 159 | return format.string(from: Date()) 160 | } 161 | } 162 | 163 | struct FormatFomt: ViewModifier { 164 | func body(content: Content) -> some View { 165 | content 166 | .font(.system(size: 35)) 167 | .foregroundColor(.primary) 168 | .cornerRadius(20) 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Analog Clock/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Clock 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIApplicationSceneManifest 26 | 27 | UIApplicationSupportsMultipleScenes 28 | 29 | 30 | UIApplicationSupportsIndirectInputEvents 31 | 32 | UILaunchScreen 33 | 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Analog Clock/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Analog Clock/Time.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Time.swift 3 | // Analog Clock 4 | // 5 | // Created by Derek Chan on 2020/9/9. 6 | // 7 | 8 | import Foundation 9 | 10 | struct Time { 11 | var sec: Int 12 | var min: Int 13 | var hour: Int 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Analog Clock 2 | #### SwiftUI 2.0 3 | 4 | #### Requirement 5 | * iOS 14.0 + 6 | * Xcode 12 7 | * macOS Big Sur 8 | **** 9 | #### Screenshots 10 | ![images](https://github.com/OrangeFlavoredDerek/Analog-Clock-SwiftUI-2.0-/blob/main/Screenshots/Simulator%20Screen%20Shot%20-%20iPhone%2011%20Pro%20-%202020-09-11%20at%2013.34.23.png) 11 | ![images](https://github.com/OrangeFlavoredDerek/Analog-Clock-SwiftUI-2.0-/blob/main/Screenshots/Simulator%20Screen%20Shot%20-%20iPhone%2011%20Pro%20-%202020-09-11%20at%2013.34.32.png) -------------------------------------------------------------------------------- /Screenshots/Simulator Screen Shot - iPhone 11 Pro - 2020-09-11 at 13.34.23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0407-zh/Analog-Clock-SwiftUI/0ec0c7d8b14c01fc71a2bc085ce0ec6591ebf44a/Screenshots/Simulator Screen Shot - iPhone 11 Pro - 2020-09-11 at 13.34.23.png -------------------------------------------------------------------------------- /Screenshots/Simulator Screen Shot - iPhone 11 Pro - 2020-09-11 at 13.34.32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0407-zh/Analog-Clock-SwiftUI/0ec0c7d8b14c01fc71a2bc085ce0ec6591ebf44a/Screenshots/Simulator Screen Shot - iPhone 11 Pro - 2020-09-11 at 13.34.32.png --------------------------------------------------------------------------------