From 69c4c791d50c5b2f0168dbbe511c0ecb22e42849 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 24 Jan 2023 15:16:41 +0100 Subject: [PATCH] first commit --- LeCountdown.xcodeproj/project.pbxproj | 619 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + LeCountdown/Assets.xcassets/Contents.json | 6 + LeCountdown/ContentView.swift | 83 +++ LeCountdown/Info.plist | 10 + .../.xccurrentversion | 8 + .../LeCountdown.xcdatamodel/contents | 12 + LeCountdown/LeCountdownApp.swift | 21 + LeCountdown/NewCountdownView.swift | 110 ++++ LeCountdown/Persistence.swift | 58 ++ .../Preview Assets.xcassets/Contents.json | 6 + LeCountdown/TimeInterval+Extensions.swift | 31 + LeCountdownTests/LeCountdownTests.swift | 36 + LeCountdownUITests/LeCountdownUITests.swift | 41 ++ .../LeCountdownUITestsLaunchTests.swift | 32 + 18 files changed, 1112 insertions(+) create mode 100644 LeCountdown.xcodeproj/project.pbxproj create mode 100644 LeCountdown.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 LeCountdown.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 LeCountdown/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 LeCountdown/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 LeCountdown/Assets.xcassets/Contents.json create mode 100644 LeCountdown/ContentView.swift create mode 100644 LeCountdown/Info.plist create mode 100644 LeCountdown/LeCountdown.xcdatamodeld/.xccurrentversion create mode 100644 LeCountdown/LeCountdown.xcdatamodeld/LeCountdown.xcdatamodel/contents create mode 100644 LeCountdown/LeCountdownApp.swift create mode 100644 LeCountdown/NewCountdownView.swift create mode 100644 LeCountdown/Persistence.swift create mode 100644 LeCountdown/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 LeCountdown/TimeInterval+Extensions.swift create mode 100644 LeCountdownTests/LeCountdownTests.swift create mode 100644 LeCountdownUITests/LeCountdownUITests.swift create mode 100644 LeCountdownUITests/LeCountdownUITestsLaunchTests.swift diff --git a/LeCountdown.xcodeproj/project.pbxproj b/LeCountdown.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2cfff0e --- /dev/null +++ b/LeCountdown.xcodeproj/project.pbxproj @@ -0,0 +1,619 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + C4060DC0297AE73B003FAB80 /* LeCountdownApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DBF297AE73B003FAB80 /* LeCountdownApp.swift */; }; + C4060DC2297AE73B003FAB80 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DC1297AE73B003FAB80 /* ContentView.swift */; }; + C4060DC4297AE73D003FAB80 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C4060DC3297AE73D003FAB80 /* Assets.xcassets */; }; + C4060DC7297AE73D003FAB80 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C4060DC6297AE73D003FAB80 /* Preview Assets.xcassets */; }; + C4060DC9297AE73D003FAB80 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DC8297AE73D003FAB80 /* Persistence.swift */; }; + C4060DCC297AE73D003FAB80 /* LeCountdown.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C4060DCA297AE73D003FAB80 /* LeCountdown.xcdatamodeld */; }; + C4060DD7297AE73D003FAB80 /* LeCountdownTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DD6297AE73D003FAB80 /* LeCountdownTests.swift */; }; + C4060DE1297AE73D003FAB80 /* LeCountdownUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DE0297AE73D003FAB80 /* LeCountdownUITests.swift */; }; + C4060DE3297AE73D003FAB80 /* LeCountdownUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DE2297AE73D003FAB80 /* LeCountdownUITestsLaunchTests.swift */; }; + C4060DF5297AE9A7003FAB80 /* TimeInterval+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DF4297AE9A7003FAB80 /* TimeInterval+Extensions.swift */; }; + C4060DF7297AFEF2003FAB80 /* NewCountdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4060DF6297AFEF2003FAB80 /* NewCountdownView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + C4060DD3297AE73D003FAB80 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C4060DB4297AE73B003FAB80 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C4060DBB297AE73B003FAB80; + remoteInfo = LeCountdown; + }; + C4060DDD297AE73D003FAB80 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C4060DB4297AE73B003FAB80 /* Project object */; + proxyType = 1; + remoteGlobalIDString = C4060DBB297AE73B003FAB80; + remoteInfo = LeCountdown; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + C4060DBC297AE73B003FAB80 /* LeCountdown.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LeCountdown.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C4060DBF297AE73B003FAB80 /* LeCountdownApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeCountdownApp.swift; sourceTree = ""; }; + C4060DC1297AE73B003FAB80 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + C4060DC3297AE73D003FAB80 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C4060DC6297AE73D003FAB80 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + C4060DC8297AE73D003FAB80 /* Persistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = ""; }; + C4060DCB297AE73D003FAB80 /* LeCountdown.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LeCountdown.xcdatamodel; sourceTree = ""; }; + C4060DCD297AE73D003FAB80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C4060DD2297AE73D003FAB80 /* LeCountdownTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LeCountdownTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C4060DD6297AE73D003FAB80 /* LeCountdownTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeCountdownTests.swift; sourceTree = ""; }; + C4060DDC297AE73D003FAB80 /* LeCountdownUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LeCountdownUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C4060DE0297AE73D003FAB80 /* LeCountdownUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeCountdownUITests.swift; sourceTree = ""; }; + C4060DE2297AE73D003FAB80 /* LeCountdownUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeCountdownUITestsLaunchTests.swift; sourceTree = ""; }; + C4060DF4297AE9A7003FAB80 /* TimeInterval+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TimeInterval+Extensions.swift"; sourceTree = ""; }; + C4060DF6297AFEF2003FAB80 /* NewCountdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewCountdownView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C4060DB9297AE73B003FAB80 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C4060DCF297AE73D003FAB80 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C4060DD9297AE73D003FAB80 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C4060DB3297AE73B003FAB80 = { + isa = PBXGroup; + children = ( + C4060DBE297AE73B003FAB80 /* LeCountdown */, + C4060DD5297AE73D003FAB80 /* LeCountdownTests */, + C4060DDF297AE73D003FAB80 /* LeCountdownUITests */, + C4060DBD297AE73B003FAB80 /* Products */, + ); + sourceTree = ""; + }; + C4060DBD297AE73B003FAB80 /* Products */ = { + isa = PBXGroup; + children = ( + C4060DBC297AE73B003FAB80 /* LeCountdown.app */, + C4060DD2297AE73D003FAB80 /* LeCountdownTests.xctest */, + C4060DDC297AE73D003FAB80 /* LeCountdownUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + C4060DBE297AE73B003FAB80 /* LeCountdown */ = { + isa = PBXGroup; + children = ( + C4060DBF297AE73B003FAB80 /* LeCountdownApp.swift */, + C4060DC1297AE73B003FAB80 /* ContentView.swift */, + C4060DF6297AFEF2003FAB80 /* NewCountdownView.swift */, + C4060DC3297AE73D003FAB80 /* Assets.xcassets */, + C4060DC8297AE73D003FAB80 /* Persistence.swift */, + C4060DF4297AE9A7003FAB80 /* TimeInterval+Extensions.swift */, + C4060DCD297AE73D003FAB80 /* Info.plist */, + C4060DCA297AE73D003FAB80 /* LeCountdown.xcdatamodeld */, + C4060DC5297AE73D003FAB80 /* Preview Content */, + ); + path = LeCountdown; + sourceTree = ""; + }; + C4060DC5297AE73D003FAB80 /* Preview Content */ = { + isa = PBXGroup; + children = ( + C4060DC6297AE73D003FAB80 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + C4060DD5297AE73D003FAB80 /* LeCountdownTests */ = { + isa = PBXGroup; + children = ( + C4060DD6297AE73D003FAB80 /* LeCountdownTests.swift */, + ); + path = LeCountdownTests; + sourceTree = ""; + }; + C4060DDF297AE73D003FAB80 /* LeCountdownUITests */ = { + isa = PBXGroup; + children = ( + C4060DE0297AE73D003FAB80 /* LeCountdownUITests.swift */, + C4060DE2297AE73D003FAB80 /* LeCountdownUITestsLaunchTests.swift */, + ); + path = LeCountdownUITests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C4060DBB297AE73B003FAB80 /* LeCountdown */ = { + isa = PBXNativeTarget; + buildConfigurationList = C4060DE6297AE73D003FAB80 /* Build configuration list for PBXNativeTarget "LeCountdown" */; + buildPhases = ( + C4060DB8297AE73B003FAB80 /* Sources */, + C4060DB9297AE73B003FAB80 /* Frameworks */, + C4060DBA297AE73B003FAB80 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = LeCountdown; + productName = LeCountdown; + productReference = C4060DBC297AE73B003FAB80 /* LeCountdown.app */; + productType = "com.apple.product-type.application"; + }; + C4060DD1297AE73D003FAB80 /* LeCountdownTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C4060DE9297AE73D003FAB80 /* Build configuration list for PBXNativeTarget "LeCountdownTests" */; + buildPhases = ( + C4060DCE297AE73D003FAB80 /* Sources */, + C4060DCF297AE73D003FAB80 /* Frameworks */, + C4060DD0297AE73D003FAB80 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C4060DD4297AE73D003FAB80 /* PBXTargetDependency */, + ); + name = LeCountdownTests; + productName = LeCountdownTests; + productReference = C4060DD2297AE73D003FAB80 /* LeCountdownTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + C4060DDB297AE73D003FAB80 /* LeCountdownUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C4060DEC297AE73D003FAB80 /* Build configuration list for PBXNativeTarget "LeCountdownUITests" */; + buildPhases = ( + C4060DD8297AE73D003FAB80 /* Sources */, + C4060DD9297AE73D003FAB80 /* Frameworks */, + C4060DDA297AE73D003FAB80 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C4060DDE297AE73D003FAB80 /* PBXTargetDependency */, + ); + name = LeCountdownUITests; + productName = LeCountdownUITests; + productReference = C4060DDC297AE73D003FAB80 /* LeCountdownUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C4060DB4297AE73B003FAB80 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + C4060DBB297AE73B003FAB80 = { + CreatedOnToolsVersion = 14.2; + }; + C4060DD1297AE73D003FAB80 = { + CreatedOnToolsVersion = 14.2; + TestTargetID = C4060DBB297AE73B003FAB80; + }; + C4060DDB297AE73D003FAB80 = { + CreatedOnToolsVersion = 14.2; + TestTargetID = C4060DBB297AE73B003FAB80; + }; + }; + }; + buildConfigurationList = C4060DB7297AE73B003FAB80 /* Build configuration list for PBXProject "LeCountdown" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C4060DB3297AE73B003FAB80; + productRefGroup = C4060DBD297AE73B003FAB80 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C4060DBB297AE73B003FAB80 /* LeCountdown */, + C4060DD1297AE73D003FAB80 /* LeCountdownTests */, + C4060DDB297AE73D003FAB80 /* LeCountdownUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C4060DBA297AE73B003FAB80 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C4060DC7297AE73D003FAB80 /* Preview Assets.xcassets in Resources */, + C4060DC4297AE73D003FAB80 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C4060DD0297AE73D003FAB80 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C4060DDA297AE73D003FAB80 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C4060DB8297AE73B003FAB80 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C4060DC9297AE73D003FAB80 /* Persistence.swift in Sources */, + C4060DC2297AE73B003FAB80 /* ContentView.swift in Sources */, + C4060DF5297AE9A7003FAB80 /* TimeInterval+Extensions.swift in Sources */, + C4060DF7297AFEF2003FAB80 /* NewCountdownView.swift in Sources */, + C4060DCC297AE73D003FAB80 /* LeCountdown.xcdatamodeld in Sources */, + C4060DC0297AE73B003FAB80 /* LeCountdownApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C4060DCE297AE73D003FAB80 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C4060DD7297AE73D003FAB80 /* LeCountdownTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C4060DD8297AE73D003FAB80 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C4060DE1297AE73D003FAB80 /* LeCountdownUITests.swift in Sources */, + C4060DE3297AE73D003FAB80 /* LeCountdownUITestsLaunchTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + C4060DD4297AE73D003FAB80 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C4060DBB297AE73B003FAB80 /* LeCountdown */; + targetProxy = C4060DD3297AE73D003FAB80 /* PBXContainerItemProxy */; + }; + C4060DDE297AE73D003FAB80 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C4060DBB297AE73B003FAB80 /* LeCountdown */; + targetProxy = C4060DDD297AE73D003FAB80 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + C4060DE4297AE73D003FAB80 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + C4060DE5297AE73D003FAB80 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C4060DE7297AE73D003FAB80 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"LeCountdown/Preview Content\""; + DEVELOPMENT_TEAM = 526E96RFNP; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.staxriver.LeCountdown; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C4060DE8297AE73D003FAB80 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"LeCountdown/Preview Content\""; + DEVELOPMENT_TEAM = 526E96RFNP; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.staxriver.LeCountdown; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + C4060DEA297AE73D003FAB80 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 526E96RFNP; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.staxriver.LeCountdownTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LeCountdown.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/LeCountdown"; + }; + name = Debug; + }; + C4060DEB297AE73D003FAB80 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 526E96RFNP; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.staxriver.LeCountdownTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LeCountdown.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/LeCountdown"; + }; + name = Release; + }; + C4060DED297AE73D003FAB80 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 526E96RFNP; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.staxriver.LeCountdownUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = LeCountdown; + }; + name = Debug; + }; + C4060DEE297AE73D003FAB80 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 526E96RFNP; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.staxriver.LeCountdownUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = LeCountdown; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C4060DB7297AE73B003FAB80 /* Build configuration list for PBXProject "LeCountdown" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C4060DE4297AE73D003FAB80 /* Debug */, + C4060DE5297AE73D003FAB80 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C4060DE6297AE73D003FAB80 /* Build configuration list for PBXNativeTarget "LeCountdown" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C4060DE7297AE73D003FAB80 /* Debug */, + C4060DE8297AE73D003FAB80 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C4060DE9297AE73D003FAB80 /* Build configuration list for PBXNativeTarget "LeCountdownTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C4060DEA297AE73D003FAB80 /* Debug */, + C4060DEB297AE73D003FAB80 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C4060DEC297AE73D003FAB80 /* Build configuration list for PBXNativeTarget "LeCountdownUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C4060DED297AE73D003FAB80 /* Debug */, + C4060DEE297AE73D003FAB80 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + C4060DCA297AE73D003FAB80 /* LeCountdown.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + C4060DCB297AE73D003FAB80 /* LeCountdown.xcdatamodel */, + ); + currentVersion = C4060DCB297AE73D003FAB80 /* LeCountdown.xcdatamodel */; + path = LeCountdown.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = C4060DB4297AE73B003FAB80 /* Project object */; +} diff --git a/LeCountdown.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LeCountdown.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/LeCountdown.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/LeCountdown.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/LeCountdown.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/LeCountdown.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/LeCountdown/Assets.xcassets/AccentColor.colorset/Contents.json b/LeCountdown/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/LeCountdown/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LeCountdown/Assets.xcassets/AppIcon.appiconset/Contents.json b/LeCountdown/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/LeCountdown/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LeCountdown/Assets.xcassets/Contents.json b/LeCountdown/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/LeCountdown/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LeCountdown/ContentView.swift b/LeCountdown/ContentView.swift new file mode 100644 index 0000000..b2da19e --- /dev/null +++ b/LeCountdown/ContentView.swift @@ -0,0 +1,83 @@ +// +// ContentView.swift +// LeCountdown +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import SwiftUI +import CoreData + +struct ContentView: View { + @Environment(\.managedObjectContext) private var viewContext + + @FetchRequest( + sortDescriptors: [NSSortDescriptor(keyPath: \Countdown.order, ascending: true)], + animation: .default) + private var countdowns: FetchedResults + + fileprivate let itemSpacing: CGFloat = 10.0 + + @State private var isShowingNewCountdown = false + + private var columns: [GridItem] = [ + GridItem(spacing: 10.0), + GridItem(spacing: 10.0), + ] + + var body: some View { + + NavigationStack { + + LazyVGrid( + columns: columns, + spacing: itemSpacing + ) { + + ForEach(countdowns) { item in + NavigationLink { + Text("Item at \(item.order)") + } label: { + Text(item.duration.minuteSecond) + .aspectRatio(contentMode: .fill) + .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) + .aspectRatio(1, contentMode: .fit) + .background(Color(red: 0.9, green: 0.95, blue: 1.0)) + .cornerRadius(40.0) + }.onAppear { + + } + } + + }.padding(itemSpacing) + .navigationTitle("Youpi") + .sheet(isPresented: self.$isShowingNewCountdown, content: { + NewCountdownView(isPresented: $isShowingNewCountdown) .environment(\.managedObjectContext, viewContext) + }) + .toolbar { + ToolbarItemGroup(placement: .bottomBar) { + Button { + self.isShowingNewCountdown = true + } label: { + Image(systemName: "plus") + } + } + } + } + + } + +} + +private let itemFormatter: DateFormatter = { + let formatter = DateFormatter() + formatter.dateStyle = .short + formatter.timeStyle = .medium + return formatter +}() + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) + } +} diff --git a/LeCountdown/Info.plist b/LeCountdown/Info.plist new file mode 100644 index 0000000..ca9a074 --- /dev/null +++ b/LeCountdown/Info.plist @@ -0,0 +1,10 @@ + + + + + UIBackgroundModes + + remote-notification + + + diff --git a/LeCountdown/LeCountdown.xcdatamodeld/.xccurrentversion b/LeCountdown/LeCountdown.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..8d5c1e6 --- /dev/null +++ b/LeCountdown/LeCountdown.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + LeCountdown.xcdatamodel + + diff --git a/LeCountdown/LeCountdown.xcdatamodeld/LeCountdown.xcdatamodel/contents b/LeCountdown/LeCountdown.xcdatamodeld/LeCountdown.xcdatamodel/contents new file mode 100644 index 0000000..164f4c2 --- /dev/null +++ b/LeCountdown/LeCountdown.xcdatamodeld/LeCountdown.xcdatamodel/contents @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/LeCountdown/LeCountdownApp.swift b/LeCountdown/LeCountdownApp.swift new file mode 100644 index 0000000..4caf81a --- /dev/null +++ b/LeCountdown/LeCountdownApp.swift @@ -0,0 +1,21 @@ +// +// LeCountdownApp.swift +// LeCountdown +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import SwiftUI + +@main +struct LeCountdownApp: App { + + let persistenceController = PersistenceController.shared + + var body: some Scene { + WindowGroup { + ContentView() + .environment(\.managedObjectContext, persistenceController.container.viewContext) + } + } +} diff --git a/LeCountdown/NewCountdownView.swift b/LeCountdown/NewCountdownView.swift new file mode 100644 index 0000000..eb14505 --- /dev/null +++ b/LeCountdown/NewCountdownView.swift @@ -0,0 +1,110 @@ +// +// NewCountdownView.swift +// LeCountdown +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import SwiftUI +import CoreData + +struct NewCountdownView: View { + + @Environment(\.managedObjectContext) private var viewContext + + + + @Binding var isPresented: Bool + + @State var secondsString: String = "" + @State var minutesString: String = "" + + @State var errorShown: Bool = false + @State var error: Error? = nil + + @FocusState private var textFieldIsFocused: Bool + + @FetchRequest(sortDescriptors: []) + private var countdowns: FetchedResults + + var body: some View { + NavigationStack { + + Form { + Section(header: Text("Duration")) { + TextField("minutes", text: $minutesString) + .keyboardType(.numberPad) + .focused($textFieldIsFocused) + TextField("seconds", text: $secondsString) + .keyboardType(.numberPad) + .focused($textFieldIsFocused) + } + Section(header: Text("Properties")) { + Text("Image") + Text("Sound") + } + } + .alert("", isPresented: $errorShown, actions: { }, message: { + Text(error?.localizedDescription ?? "error") + }) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button("Cancel") { + self._cancel() + } + } + ToolbarItem(placement: .navigationBarTrailing) { + Button("Save") { + self._save() + } + } + ToolbarItemGroup(placement: .keyboard) { + Button { + textFieldIsFocused = false + } label: { + Image(systemName: "checkmark") + } + } + } + .navigationTitle("New countdown") + } + + } + + fileprivate let _numberFormatter = NumberFormatter() + + fileprivate var _seconds: Double { + return self._numberFormatter.number(from: self.secondsString)?.doubleValue ?? 0.0 + } + + fileprivate var _minutes: Double { + return self._numberFormatter.number(from: self.minutesString)?.doubleValue ?? 0.0 + } + + fileprivate func _cancel() { + self.isPresented = false + } + + fileprivate func _save() { + + let countdown = Countdown(context: self.viewContext) + countdown.duration = self._minutes * 60.0 + self._seconds + countdown.order = Int16(self.countdowns.count) + + do { + try viewContext.save() + } catch { + self.errorShown = true + self.error = error + } + + self.isPresented = false + } + +} + +struct NewCountdownView_Previews: PreviewProvider { + static var previews: some View { + NewCountdownView(isPresented: .constant(true)) + } +} diff --git a/LeCountdown/Persistence.swift b/LeCountdown/Persistence.swift new file mode 100644 index 0000000..b0f7245 --- /dev/null +++ b/LeCountdown/Persistence.swift @@ -0,0 +1,58 @@ +// +// Persistence.swift +// LeCountdown +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import CoreData + +struct PersistenceController { + static let shared = PersistenceController() + + static var preview: PersistenceController = { + + let result = PersistenceController(inMemory: true) + let viewContext = result.container.viewContext + for i in 0..<3 { + let newItem = Countdown(context: viewContext) + newItem.order = Int16(i) + } + do { + try viewContext.save() + } catch { + // Replace this implementation with code to handle the error appropriately. + // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + let nsError = error as NSError + fatalError("Unresolved error \(nsError), \(nsError.userInfo)") + } + return result + }() + + let container: NSPersistentCloudKitContainer + + init(inMemory: Bool = false) { + container = NSPersistentCloudKitContainer(name: "LeCountdown") + if inMemory { + container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null") + } + container.loadPersistentStores(completionHandler: { (storeDescription, error) in + if let error = error as NSError? { + // Replace this implementation with code to handle the error appropriately. + // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + + /* + Typical reasons for an error here include: + * The parent directory does not exist, cannot be created, or disallows writing. + * The persistent store is not accessible, due to permissions or data protection when the device is locked. + * The device is out of space. + * The store could not be migrated to the current model version. + Check the error message to determine what the actual problem was. + */ + fatalError("Unresolved error \(error), \(error.userInfo)") + } + }) + container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy + container.viewContext.automaticallyMergesChangesFromParent = true + } +} diff --git a/LeCountdown/Preview Content/Preview Assets.xcassets/Contents.json b/LeCountdown/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/LeCountdown/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LeCountdown/TimeInterval+Extensions.swift b/LeCountdown/TimeInterval+Extensions.swift new file mode 100644 index 0000000..5b26c39 --- /dev/null +++ b/LeCountdown/TimeInterval+Extensions.swift @@ -0,0 +1,31 @@ +// +// TimeInterval+Extensions.swift +// LeCountdown +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import Foundation + +extension TimeInterval { + + var hourMinuteSecondMS: String { + String(format:"%d:%02d:%02d.%03d", hour, minute, second, millisecond) + } + var minuteSecond: String { + String(format:"%d:%02d", minute, second) + } + var hour: Int { + Int((self/3600).truncatingRemainder(dividingBy: 3600)) + } + var minute: Int { + Int((self/60).truncatingRemainder(dividingBy: 60)) + } + var second: Int { + Int(truncatingRemainder(dividingBy: 60)) + } + var millisecond: Int { + Int((self*1000).truncatingRemainder(dividingBy: 1000)) + } + +} diff --git a/LeCountdownTests/LeCountdownTests.swift b/LeCountdownTests/LeCountdownTests.swift new file mode 100644 index 0000000..09cb1cf --- /dev/null +++ b/LeCountdownTests/LeCountdownTests.swift @@ -0,0 +1,36 @@ +// +// LeCountdownTests.swift +// LeCountdownTests +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import XCTest +@testable import LeCountdown + +final class LeCountdownTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/LeCountdownUITests/LeCountdownUITests.swift b/LeCountdownUITests/LeCountdownUITests.swift new file mode 100644 index 0000000..3a8bbc4 --- /dev/null +++ b/LeCountdownUITests/LeCountdownUITests.swift @@ -0,0 +1,41 @@ +// +// LeCountdownUITests.swift +// LeCountdownUITests +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import XCTest + +final class LeCountdownUITests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testLaunchPerformance() throws { + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { + // This measures how long it takes to launch your application. + measure(metrics: [XCTApplicationLaunchMetric()]) { + XCUIApplication().launch() + } + } + } +} diff --git a/LeCountdownUITests/LeCountdownUITestsLaunchTests.swift b/LeCountdownUITests/LeCountdownUITestsLaunchTests.swift new file mode 100644 index 0000000..ee2c788 --- /dev/null +++ b/LeCountdownUITests/LeCountdownUITestsLaunchTests.swift @@ -0,0 +1,32 @@ +// +// LeCountdownUITestsLaunchTests.swift +// LeCountdownUITests +// +// Created by Laurent Morvillier on 20/01/2023. +// + +import XCTest + +final class LeCountdownUITestsLaunchTests: XCTestCase { + + override class var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + + override func setUpWithError() throws { + continueAfterFailure = false + } + + func testLaunch() throws { + let app = XCUIApplication() + app.launch() + + // Insert steps here to perform after app launch but before taking a screenshot, + // such as logging into a test account or navigating somewhere in the app + + let attachment = XCTAttachment(screenshot: app.screenshot()) + attachment.name = "Launch Screen" + attachment.lifetime = .keepAlways + add(attachment) + } +}