├── CustomCountdownTimer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── federico.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── CustomCountdownTimer ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Content-ViewModel.swift ├── ContentView.swift ├── CustomCountdownTimerApp.swift └── Preview Content └── Preview Assets.xcassets └── Contents.json /CustomCountdownTimer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7A6954B727FF1C5D005C0164 /* CustomCountdownTimerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6954B627FF1C5D005C0164 /* CustomCountdownTimerApp.swift */; }; 11 | 7A6954B927FF1C5D005C0164 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6954B827FF1C5D005C0164 /* ContentView.swift */; }; 12 | 7A6954BB27FF1C5E005C0164 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7A6954BA27FF1C5E005C0164 /* Assets.xcassets */; }; 13 | 7A6954BE27FF1C5E005C0164 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7A6954BD27FF1C5E005C0164 /* Preview Assets.xcassets */; }; 14 | 7A6954C627FF1CC4005C0164 /* Content-ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6954C527FF1CC4005C0164 /* Content-ViewModel.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 7A6954B327FF1C5D005C0164 /* CustomCountdownTimer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomCountdownTimer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 7A6954B627FF1C5D005C0164 /* CustomCountdownTimerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCountdownTimerApp.swift; sourceTree = ""; }; 20 | 7A6954B827FF1C5D005C0164 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | 7A6954BA27FF1C5E005C0164 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | 7A6954BD27FF1C5E005C0164 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | 7A6954C527FF1CC4005C0164 /* Content-ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Content-ViewModel.swift"; sourceTree = ""; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | 7A6954B027FF1C5D005C0164 /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | ); 32 | runOnlyForDeploymentPostprocessing = 0; 33 | }; 34 | /* End PBXFrameworksBuildPhase section */ 35 | 36 | /* Begin PBXGroup section */ 37 | 7A6954AA27FF1C5D005C0164 = { 38 | isa = PBXGroup; 39 | children = ( 40 | 7A6954B527FF1C5D005C0164 /* CustomCountdownTimer */, 41 | 7A6954B427FF1C5D005C0164 /* Products */, 42 | ); 43 | sourceTree = ""; 44 | }; 45 | 7A6954B427FF1C5D005C0164 /* Products */ = { 46 | isa = PBXGroup; 47 | children = ( 48 | 7A6954B327FF1C5D005C0164 /* CustomCountdownTimer.app */, 49 | ); 50 | name = Products; 51 | sourceTree = ""; 52 | }; 53 | 7A6954B527FF1C5D005C0164 /* CustomCountdownTimer */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 7A6954B627FF1C5D005C0164 /* CustomCountdownTimerApp.swift */, 57 | 7A6954B827FF1C5D005C0164 /* ContentView.swift */, 58 | 7A6954C527FF1CC4005C0164 /* Content-ViewModel.swift */, 59 | 7A6954BA27FF1C5E005C0164 /* Assets.xcassets */, 60 | 7A6954BC27FF1C5E005C0164 /* Preview Content */, 61 | ); 62 | path = CustomCountdownTimer; 63 | sourceTree = ""; 64 | }; 65 | 7A6954BC27FF1C5E005C0164 /* Preview Content */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 7A6954BD27FF1C5E005C0164 /* Preview Assets.xcassets */, 69 | ); 70 | path = "Preview Content"; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | 7A6954B227FF1C5D005C0164 /* CustomCountdownTimer */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = 7A6954C127FF1C5E005C0164 /* Build configuration list for PBXNativeTarget "CustomCountdownTimer" */; 79 | buildPhases = ( 80 | 7A6954AF27FF1C5D005C0164 /* Sources */, 81 | 7A6954B027FF1C5D005C0164 /* Frameworks */, 82 | 7A6954B127FF1C5D005C0164 /* Resources */, 83 | ); 84 | buildRules = ( 85 | ); 86 | dependencies = ( 87 | ); 88 | name = CustomCountdownTimer; 89 | productName = CustomCountdownTimer; 90 | productReference = 7A6954B327FF1C5D005C0164 /* CustomCountdownTimer.app */; 91 | productType = "com.apple.product-type.application"; 92 | }; 93 | /* End PBXNativeTarget section */ 94 | 95 | /* Begin PBXProject section */ 96 | 7A6954AB27FF1C5D005C0164 /* Project object */ = { 97 | isa = PBXProject; 98 | attributes = { 99 | BuildIndependentTargetsInParallel = 1; 100 | LastSwiftUpdateCheck = 1330; 101 | LastUpgradeCheck = 1330; 102 | TargetAttributes = { 103 | 7A6954B227FF1C5D005C0164 = { 104 | CreatedOnToolsVersion = 13.3; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = 7A6954AE27FF1C5D005C0164 /* Build configuration list for PBXProject "CustomCountdownTimer" */; 109 | compatibilityVersion = "Xcode 13.0"; 110 | developmentRegion = en; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | Base, 115 | ); 116 | mainGroup = 7A6954AA27FF1C5D005C0164; 117 | productRefGroup = 7A6954B427FF1C5D005C0164 /* Products */; 118 | projectDirPath = ""; 119 | projectRoot = ""; 120 | targets = ( 121 | 7A6954B227FF1C5D005C0164 /* CustomCountdownTimer */, 122 | ); 123 | }; 124 | /* End PBXProject section */ 125 | 126 | /* Begin PBXResourcesBuildPhase section */ 127 | 7A6954B127FF1C5D005C0164 /* Resources */ = { 128 | isa = PBXResourcesBuildPhase; 129 | buildActionMask = 2147483647; 130 | files = ( 131 | 7A6954BE27FF1C5E005C0164 /* Preview Assets.xcassets in Resources */, 132 | 7A6954BB27FF1C5E005C0164 /* Assets.xcassets in Resources */, 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXResourcesBuildPhase section */ 137 | 138 | /* Begin PBXSourcesBuildPhase section */ 139 | 7A6954AF27FF1C5D005C0164 /* Sources */ = { 140 | isa = PBXSourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 7A6954B927FF1C5D005C0164 /* ContentView.swift in Sources */, 144 | 7A6954B727FF1C5D005C0164 /* CustomCountdownTimerApp.swift in Sources */, 145 | 7A6954C627FF1CC4005C0164 /* Content-ViewModel.swift in Sources */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXSourcesBuildPhase section */ 150 | 151 | /* Begin XCBuildConfiguration section */ 152 | 7A6954BF27FF1C5E005C0164 /* Debug */ = { 153 | isa = XCBuildConfiguration; 154 | buildSettings = { 155 | ALWAYS_SEARCH_USER_PATHS = NO; 156 | CLANG_ANALYZER_NONNULL = YES; 157 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 158 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 159 | CLANG_ENABLE_MODULES = YES; 160 | CLANG_ENABLE_OBJC_ARC = YES; 161 | CLANG_ENABLE_OBJC_WEAK = YES; 162 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 163 | CLANG_WARN_BOOL_CONVERSION = YES; 164 | CLANG_WARN_COMMA = YES; 165 | CLANG_WARN_CONSTANT_CONVERSION = YES; 166 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 167 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 168 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 169 | CLANG_WARN_EMPTY_BODY = YES; 170 | CLANG_WARN_ENUM_CONVERSION = YES; 171 | CLANG_WARN_INFINITE_RECURSION = YES; 172 | CLANG_WARN_INT_CONVERSION = YES; 173 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 174 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 175 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 177 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 178 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 179 | CLANG_WARN_STRICT_PROTOTYPES = YES; 180 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 181 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 182 | CLANG_WARN_UNREACHABLE_CODE = YES; 183 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 184 | COPY_PHASE_STRIP = NO; 185 | DEBUG_INFORMATION_FORMAT = dwarf; 186 | ENABLE_STRICT_OBJC_MSGSEND = YES; 187 | ENABLE_TESTABILITY = YES; 188 | GCC_C_LANGUAGE_STANDARD = gnu11; 189 | GCC_DYNAMIC_NO_PIC = NO; 190 | GCC_NO_COMMON_BLOCKS = YES; 191 | GCC_OPTIMIZATION_LEVEL = 0; 192 | GCC_PREPROCESSOR_DEFINITIONS = ( 193 | "DEBUG=1", 194 | "$(inherited)", 195 | ); 196 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 197 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 198 | GCC_WARN_UNDECLARED_SELECTOR = YES; 199 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 200 | GCC_WARN_UNUSED_FUNCTION = YES; 201 | GCC_WARN_UNUSED_VARIABLE = YES; 202 | IPHONEOS_DEPLOYMENT_TARGET = 15.4; 203 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 204 | MTL_FAST_MATH = YES; 205 | ONLY_ACTIVE_ARCH = YES; 206 | SDKROOT = iphoneos; 207 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 208 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 209 | }; 210 | name = Debug; 211 | }; 212 | 7A6954C027FF1C5E005C0164 /* Release */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | ALWAYS_SEARCH_USER_PATHS = NO; 216 | CLANG_ANALYZER_NONNULL = YES; 217 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 219 | CLANG_ENABLE_MODULES = YES; 220 | CLANG_ENABLE_OBJC_ARC = YES; 221 | CLANG_ENABLE_OBJC_WEAK = YES; 222 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 223 | CLANG_WARN_BOOL_CONVERSION = YES; 224 | CLANG_WARN_COMMA = YES; 225 | CLANG_WARN_CONSTANT_CONVERSION = YES; 226 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INFINITE_RECURSION = YES; 232 | CLANG_WARN_INT_CONVERSION = YES; 233 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 234 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 235 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 236 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 237 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 238 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 239 | CLANG_WARN_STRICT_PROTOTYPES = YES; 240 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 241 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 242 | CLANG_WARN_UNREACHABLE_CODE = YES; 243 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 244 | COPY_PHASE_STRIP = NO; 245 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 246 | ENABLE_NS_ASSERTIONS = NO; 247 | ENABLE_STRICT_OBJC_MSGSEND = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu11; 249 | GCC_NO_COMMON_BLOCKS = YES; 250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 252 | GCC_WARN_UNDECLARED_SELECTOR = YES; 253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 254 | GCC_WARN_UNUSED_FUNCTION = YES; 255 | GCC_WARN_UNUSED_VARIABLE = YES; 256 | IPHONEOS_DEPLOYMENT_TARGET = 15.4; 257 | MTL_ENABLE_DEBUG_INFO = NO; 258 | MTL_FAST_MATH = YES; 259 | SDKROOT = iphoneos; 260 | SWIFT_COMPILATION_MODE = wholemodule; 261 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 262 | VALIDATE_PRODUCT = YES; 263 | }; 264 | name = Release; 265 | }; 266 | 7A6954C227FF1C5E005C0164 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 270 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 271 | CODE_SIGN_STYLE = Automatic; 272 | CURRENT_PROJECT_VERSION = 1; 273 | DEVELOPMENT_ASSET_PATHS = "\"CustomCountdownTimer/Preview Content\""; 274 | ENABLE_PREVIEWS = YES; 275 | GENERATE_INFOPLIST_FILE = YES; 276 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 277 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 278 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 279 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 280 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 281 | LD_RUNPATH_SEARCH_PATHS = ( 282 | "$(inherited)", 283 | "@executable_path/Frameworks", 284 | ); 285 | MARKETING_VERSION = 1.0; 286 | PRODUCT_BUNDLE_IDENTIFIER = com.codepalace.CustomCountdownTimer; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | SWIFT_EMIT_LOC_STRINGS = YES; 289 | SWIFT_VERSION = 5.0; 290 | TARGETED_DEVICE_FAMILY = "1,2"; 291 | }; 292 | name = Debug; 293 | }; 294 | 7A6954C327FF1C5E005C0164 /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 299 | CODE_SIGN_STYLE = Automatic; 300 | CURRENT_PROJECT_VERSION = 1; 301 | DEVELOPMENT_ASSET_PATHS = "\"CustomCountdownTimer/Preview Content\""; 302 | ENABLE_PREVIEWS = YES; 303 | GENERATE_INFOPLIST_FILE = YES; 304 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 305 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 306 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 307 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 308 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 309 | LD_RUNPATH_SEARCH_PATHS = ( 310 | "$(inherited)", 311 | "@executable_path/Frameworks", 312 | ); 313 | MARKETING_VERSION = 1.0; 314 | PRODUCT_BUNDLE_IDENTIFIER = com.codepalace.CustomCountdownTimer; 315 | PRODUCT_NAME = "$(TARGET_NAME)"; 316 | SWIFT_EMIT_LOC_STRINGS = YES; 317 | SWIFT_VERSION = 5.0; 318 | TARGETED_DEVICE_FAMILY = "1,2"; 319 | }; 320 | name = Release; 321 | }; 322 | /* End XCBuildConfiguration section */ 323 | 324 | /* Begin XCConfigurationList section */ 325 | 7A6954AE27FF1C5D005C0164 /* Build configuration list for PBXProject "CustomCountdownTimer" */ = { 326 | isa = XCConfigurationList; 327 | buildConfigurations = ( 328 | 7A6954BF27FF1C5E005C0164 /* Debug */, 329 | 7A6954C027FF1C5E005C0164 /* Release */, 330 | ); 331 | defaultConfigurationIsVisible = 0; 332 | defaultConfigurationName = Release; 333 | }; 334 | 7A6954C127FF1C5E005C0164 /* Build configuration list for PBXNativeTarget "CustomCountdownTimer" */ = { 335 | isa = XCConfigurationList; 336 | buildConfigurations = ( 337 | 7A6954C227FF1C5E005C0164 /* Debug */, 338 | 7A6954C327FF1C5E005C0164 /* Release */, 339 | ); 340 | defaultConfigurationIsVisible = 0; 341 | defaultConfigurationName = Release; 342 | }; 343 | /* End XCConfigurationList section */ 344 | }; 345 | rootObject = 7A6954AB27FF1C5D005C0164 /* Project object */; 346 | } 347 | -------------------------------------------------------------------------------- /CustomCountdownTimer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CustomCountdownTimer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CustomCountdownTimer.xcodeproj/xcuserdata/federico.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CustomCountdownTimer.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /CustomCountdownTimer/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 | -------------------------------------------------------------------------------- /CustomCountdownTimer/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" : "2x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "83.5x83.5" 82 | }, 83 | { 84 | "idiom" : "ios-marketing", 85 | "scale" : "1x", 86 | "size" : "1024x1024" 87 | } 88 | ], 89 | "info" : { 90 | "author" : "xcode", 91 | "version" : 1 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /CustomCountdownTimer/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CustomCountdownTimer/Content-ViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Content-ViewModel.swift 3 | // 5MinuteTimer 4 | // 5 | // Created by Federico on 07/04/2022. 6 | // 7 | 8 | import Foundation 9 | 10 | extension ContentView { 11 | final class ViewModel: ObservableObject { 12 | @Published var isActive = false 13 | @Published var showingAlert = false 14 | @Published var time: String = "5:00" 15 | @Published var minutes: Float = 5.0 { 16 | didSet { 17 | self.time = "\(Int(minutes)):00" 18 | } 19 | } 20 | private var initialTime = 0 21 | private var endDate = Date() 22 | 23 | // Start the timer with the given amount of minutes 24 | func start(minutes: Float) { 25 | self.initialTime = Int(minutes) 26 | self.endDate = Date() 27 | self.isActive = true 28 | self.endDate = Calendar.current.date(byAdding: .minute, value: Int(minutes), to: endDate)! 29 | } 30 | 31 | // Reset the timer 32 | func reset() { 33 | self.minutes = Float(initialTime) 34 | self.isActive = false 35 | self.time = "\(Int(minutes)):00" 36 | } 37 | 38 | // Show updates of the timer 39 | func updateCountdown(){ 40 | guard isActive else { return } 41 | 42 | // Gets the current date and makes the time difference calculation 43 | let now = Date() 44 | let diff = endDate.timeIntervalSince1970 - now.timeIntervalSince1970 45 | 46 | // Checks that the countdown is not <= 0 47 | if diff <= 0 { 48 | self.isActive = false 49 | self.time = "0:00" 50 | self.showingAlert = true 51 | return 52 | } 53 | 54 | // Turns the time difference calculation into sensible data and formats it 55 | let date = Date(timeIntervalSince1970: diff) 56 | let calendar = Calendar.current 57 | let minutes = calendar.component(.minute, from: date) 58 | let seconds = calendar.component(.second, from: date) 59 | 60 | // Updates the time string with the formatted time 61 | self.minutes = Float(minutes) 62 | self.time = String(format:"%d:%02d", minutes, seconds) 63 | } 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /CustomCountdownTimer/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // 5MinuteTimer 4 | // 5 | // Created by Federico on 07/04/2022. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | @StateObject private var vm = ViewModel() 12 | private let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() 13 | private let width: Double = 250 14 | 15 | var body: some View { 16 | VStack { 17 | Text("\(vm.time)") 18 | .font(.system(size: 70, weight: .medium, design: .rounded)) 19 | .alert("Timer done!", isPresented: $vm.showingAlert) { 20 | Button("Continue", role: .cancel) { 21 | // Code 22 | } 23 | } 24 | .padding() 25 | .frame(width: width) 26 | .background(.thinMaterial) 27 | .cornerRadius(20) 28 | .overlay( 29 | RoundedRectangle(cornerRadius: 20) 30 | .stroke(Color.gray, lineWidth: 4) 31 | ) 32 | 33 | Slider(value: $vm.minutes, in: 1...10, step: 1) 34 | .padding() 35 | .disabled(vm.isActive) 36 | .animation(.easeInOut, value: vm.minutes) 37 | .frame(width: width) 38 | 39 | HStack(spacing:50) { 40 | Button("Start") { 41 | vm.start(minutes: vm.minutes) 42 | } 43 | .disabled(vm.isActive) 44 | 45 | Button("Reset", action: vm.reset) 46 | .tint(.red) 47 | } 48 | .frame(width: width) 49 | } 50 | .onReceive(timer) { _ in 51 | vm.updateCountdown() 52 | } 53 | 54 | } 55 | } 56 | 57 | struct ContentView_Previews: PreviewProvider { 58 | static var previews: some View { 59 | ContentView() 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /CustomCountdownTimer/CustomCountdownTimerApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCountdownTimerApp.swift 3 | // CustomCountdownTimer 4 | // 5 | // Created by Federico on 07/04/2022. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct CustomCountdownTimerApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CustomCountdownTimer/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | --------------------------------------------------------------------------------