diff --git a/AppIcon.png b/AppIcon.png deleted file mode 100644 index 7812e4f..0000000 Binary files a/AppIcon.png and /dev/null differ diff --git a/Podfile b/Podfile deleted file mode 100644 index c5132e3..0000000 --- a/Podfile +++ /dev/null @@ -1,16 +0,0 @@ -# Uncomment the next line to define a global platform for your project -# platform :ios, '9.0' - -target 'StopWatch' do - # Comment the next line if you don't want to use dynamic frameworks - use_frameworks! - - # Pods for StopWatch - pod 'RealmSwift' - pod 'Realm' - pod 'SnapKit', '~> 5.0.0' - pod 'Then' - pod 'SWColorPicker' - - -end diff --git a/Podfile.lock b/Podfile.lock deleted file mode 100644 index ee17cba..0000000 --- a/Podfile.lock +++ /dev/null @@ -1,35 +0,0 @@ -PODS: - - Realm (10.39.1): - - Realm/Headers (= 10.39.1) - - Realm/Headers (10.39.1) - - RealmSwift (10.39.1): - - Realm (= 10.39.1) - - SnapKit (5.0.1) - - SWColorPicker (0.2.2) - - Then (3.0.0) - -DEPENDENCIES: - - Realm - - RealmSwift - - SnapKit (~> 5.0.0) - - SWColorPicker - - Then - -SPEC REPOS: - trunk: - - Realm - - RealmSwift - - SnapKit - - SWColorPicker - - Then - -SPEC CHECKSUMS: - Realm: 1f3157edf145f4d9036765ab550c8cb18f62b700 - RealmSwift: 8a69a1cb788cd5865966f49667b130567e07bceb - SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb - SWColorPicker: 11582e7c4153a073cb759cb2f152cc972b16ba86 - Then: 844265ae87834bbe1147d91d5d41a404da2ec27d - -PODFILE CHECKSUM: 2bc8538e3a7e41e8c11b59570633990f1d1432d3 - -COCOAPODS: 1.11.3 diff --git a/StopWatch.xcodeproj/project.pbxproj b/StopWatch.xcodeproj/project.pbxproj index efc1e28..4628be5 100644 --- a/StopWatch.xcodeproj/project.pbxproj +++ b/StopWatch.xcodeproj/project.pbxproj @@ -3,11 +3,14 @@ archiveVersion = 1; classes = { }; - objectVersion = 56; + objectVersion = 77; objects = { /* Begin PBXBuildFile section */ - 43228812FC89EC6FE9668022 /* Pods_StopWatch.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D5E8619A05D6284273C99B3 /* Pods_StopWatch.framework */; }; + B564BD102CF2081500E560C7 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B564BD0F2CF2081500E560C7 /* RealmSwift */; }; + B564BD112CF2081500E560C7 /* RealmSwift in Embed Frameworks */ = {isa = PBXBuildFile; productRef = B564BD0F2CF2081500E560C7 /* RealmSwift */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + B5AB29CC2CF2048700E6D510 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = B5AB29CB2CF2048700E6D510 /* Then */; }; + B5FC91812CF205010096D444 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = B5FC91802CF205010096D444 /* SnapKit */; }; DB08F0C32765DB88001EBBEE /* StopWatchDAO.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB08F0C22765DB88001EBBEE /* StopWatchDAO.swift */; }; DB0E89B9262842BE00533009 /* TimeSaveModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0E89B8262842BE00533009 /* TimeSaveModalView.swift */; }; DB10DB8C27E4A081000560A3 /* GodoM.ttf in Resources */ = {isa = PBXBuildFile; fileRef = DB10DB8B27E4A081000560A3 /* GodoM.ttf */; }; @@ -22,10 +25,6 @@ DB340BC82940750100795FFC /* UITextField+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB340BC72940750100795FFC /* UITextField+.swift */; }; DB340BCA2940753400795FFC /* UIColor+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB340BC92940753400795FFC /* UIColor+.swift */; }; DB3BB9D72A1904D700E4432A /* ContactViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB3BB9D62A1904D700E4432A /* ContactViewController.swift */; }; - DB40D1F92609B32C00A4E9FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB40D1F82609B32C00A4E9FC /* AppDelegate.swift */; }; - DB40D2002609B32C00A4E9FC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DB40D1FE2609B32C00A4E9FC /* Main.storyboard */; }; - DB40D2022609B32E00A4E9FC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DB40D2012609B32E00A4E9FC /* Assets.xcassets */; }; - DB40D2052609B32E00A4E9FC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DB40D2032609B32E00A4E9FC /* LaunchScreen.storyboard */; }; DB4FE82426BF80F100B1DF3E /* SegmentData.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4FE82326BF80F100B1DF3E /* SegmentData.swift */; }; DB5AE4A8276CB61C00CF737C /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB5AE4A7276CB61C00CF737C /* CalendarView.swift */; }; DB5AE4AA276CB6D800CF737C /* CalendarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB5AE4A9276CB6D800CF737C /* CalendarCell.swift */; }; @@ -60,10 +59,21 @@ DBF7E79226AFF438009902BE /* EditGoalTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF7E79126AFF438009902BE /* EditGoalTimeView.swift */; }; /* End PBXBuildFile section */ +/* Begin PBXCopyFilesBuildPhase section */ + B54A37072CF2059500067268 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + B564BD112CF2081500E560C7 /* RealmSwift in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ - 5CA68B9216F67301B7F37E82 /* Pods-StopWatch.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StopWatch.debug.xcconfig"; path = "Target Support Files/Pods-StopWatch/Pods-StopWatch.debug.xcconfig"; sourceTree = ""; }; - 8D5E8619A05D6284273C99B3 /* Pods_StopWatch.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_StopWatch.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - A46D2DC1AD4790441A1758B2 /* Pods-StopWatch.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StopWatch.release.xcconfig"; path = "Target Support Files/Pods-StopWatch/Pods-StopWatch.release.xcconfig"; sourceTree = ""; }; DB08F0C22765DB88001EBBEE /* StopWatchDAO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopWatchDAO.swift; sourceTree = ""; }; DB0E89B8262842BE00533009 /* TimeSaveModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeSaveModalView.swift; sourceTree = ""; }; DB10DB8B27E4A081000560A3 /* GodoM.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = GodoM.ttf; sourceTree = ""; }; @@ -79,11 +89,6 @@ DB340BC92940753400795FFC /* UIColor+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+.swift"; sourceTree = ""; }; DB3BB9D62A1904D700E4432A /* ContactViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactViewController.swift; sourceTree = ""; }; DB40D1F52609B32C00A4E9FC /* StopWatch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StopWatch.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB40D1F82609B32C00A4E9FC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - DB40D1FF2609B32C00A4E9FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - DB40D2012609B32E00A4E9FC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - DB40D2042609B32E00A4E9FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - DB40D2062609B32E00A4E9FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DB4FE82326BF80F100B1DF3E /* SegmentData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SegmentData.swift; path = StopWatch/Models/SegmentData.swift; sourceTree = SOURCE_ROOT; }; DB5AE4A7276CB61C00CF737C /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = ""; }; DB5AE4A9276CB6D800CF737C /* CalendarCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarCell.swift; sourceTree = ""; }; @@ -118,18 +123,73 @@ DBF7E79126AFF438009902BE /* EditGoalTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditGoalTimeView.swift; sourceTree = ""; }; /* End PBXFileReference section */ +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + B5BE64682CF2205000F28196 /* Exceptions for "App" folder in "StopWatch" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = DB40D1F42609B32C00A4E9FC /* StopWatch */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + B53CE96E2D4224DC006DD784 /* Repository */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = Repository; + sourceTree = ""; + }; + B5BFEC2C2CF22C1F00A98319 /* Entity */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = Entity; + sourceTree = ""; + }; + B5D0FB582CF20ADC00BEF154 /* App */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + B5BE64682CF2205000F28196 /* Exceptions for "App" folder in "StopWatch" target */, + ); + path = App; + sourceTree = ""; + }; + B5D0FB5A2CF20B3100BEF154 /* Core */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = Core; + sourceTree = ""; + }; + B5D0FB602CF20B6000BEF154 /* DesignSystem */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = DesignSystem; + sourceTree = ""; + }; + B5D0FB982CF2106F00BEF154 /* Screen */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = Screen; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + /* Begin PBXFrameworksBuildPhase section */ DB40D1F22609B32C00A4E9FC /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 43228812FC89EC6FE9668022 /* Pods_StopWatch.framework in Frameworks */, + B564BD102CF2081500E560C7 /* RealmSwift in Frameworks */, + B5AB29CC2CF2048700E6D510 /* Then in Frameworks */, + B5FC91812CF205010096D444 /* SnapKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + B564BD0B2CF2080F00E560C7 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; DB076D5826A696110063D3C6 /* MainView */ = { isa = PBXGroup; children = ( @@ -190,7 +250,6 @@ DB289047261C4F8000FCC4BC /* images */ = { isa = PBXGroup; children = ( - DB40D2012609B32E00A4E9FC /* Assets.xcassets */, ); path = images; sourceTree = ""; @@ -231,9 +290,8 @@ isa = PBXGroup; children = ( DB40D1F72609B32C00A4E9FC /* StopWatch */, + B564BD0B2CF2080F00E560C7 /* Frameworks */, DB40D1F62609B32C00A4E9FC /* Products */, - F95DBA0BF70FC8275FA2BE45 /* Pods */, - DB89756364217619A0677F8E /* Frameworks */, ); sourceTree = ""; }; @@ -248,16 +306,18 @@ DB40D1F72609B32C00A4E9FC /* StopWatch */ = { isa = PBXGroup; children = ( + B53CE96E2D4224DC006DD784 /* Repository */, + B5BFEC2C2CF22C1F00A98319 /* Entity */, + B5D0FB982CF2106F00BEF154 /* Screen */, + B5D0FB602CF20B6000BEF154 /* DesignSystem */, + B5D0FB5A2CF20B3100BEF154 /* Core */, + B5D0FB582CF20ADC00BEF154 /* App */, DBBFFBF0293358E800CA3FBC /* Resource */, DB8F532D26F085D50071F911 /* Custom */, DB0F172A261430F7007C8448 /* Utils */, DBA7ED5A27DDAFFF004B0D0E /* Models */, DB289048261C4FF500FCC4BC /* Views */, DB289046261C4F6600FCC4BC /* Controllers */, - DB40D1FE2609B32C00A4E9FC /* Main.storyboard */, - DB40D2032609B32E00A4E9FC /* LaunchScreen.storyboard */, - DB40D1F82609B32C00A4E9FC /* AppDelegate.swift */, - DB40D2062609B32E00A4E9FC /* Info.plist */, ); path = StopWatch; sourceTree = ""; @@ -281,14 +341,6 @@ path = CalendarView; sourceTree = ""; }; - DB89756364217619A0677F8E /* Frameworks */ = { - isa = PBXGroup; - children = ( - 8D5E8619A05D6284273C99B3 /* Pods_StopWatch.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; DB8F532D26F085D50071F911 /* Custom */ = { isa = PBXGroup; children = ( @@ -334,15 +386,6 @@ path = extension; sourceTree = ""; }; - F95DBA0BF70FC8275FA2BE45 /* Pods */ = { - isa = PBXGroup; - children = ( - 5CA68B9216F67301B7F37E82 /* Pods-StopWatch.debug.xcconfig */, - A46D2DC1AD4790441A1758B2 /* Pods-StopWatch.release.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -350,16 +393,23 @@ isa = PBXNativeTarget; buildConfigurationList = DB40D2092609B32E00A4E9FC /* Build configuration list for PBXNativeTarget "StopWatch" */; buildPhases = ( - 30A0D5039940C22D47761409 /* [CP] Check Pods Manifest.lock */, DB40D1F12609B32C00A4E9FC /* Sources */, DB40D1F22609B32C00A4E9FC /* Frameworks */, DB40D1F32609B32C00A4E9FC /* Resources */, - EFF0373BC5C2FA27D26D2271 /* [CP] Embed Pods Frameworks */, + B54A37072CF2059500067268 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( ); + fileSystemSynchronizedGroups = ( + B53CE96E2D4224DC006DD784 /* Repository */, + B5BFEC2C2CF22C1F00A98319 /* Entity */, + B5D0FB582CF20ADC00BEF154 /* App */, + B5D0FB5A2CF20B3100BEF154 /* Core */, + B5D0FB602CF20B6000BEF154 /* DesignSystem */, + B5D0FB982CF2106F00BEF154 /* Screen */, + ); name = StopWatch; productName = StopWatch; productReference = DB40D1F52609B32C00A4E9FC /* StopWatch.app */; @@ -380,7 +430,6 @@ }; }; buildConfigurationList = DB40D1F02609B32C00A4E9FC /* Build configuration list for PBXProject "StopWatch" */; - compatibilityVersion = "Xcode 14.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -388,6 +437,12 @@ Base, ); mainGroup = DB40D1EC2609B32C00A4E9FC; + packageReferences = ( + B5AB29CA2CF2048700E6D510 /* XCRemoteSwiftPackageReference "Then" */, + B5FC917F2CF205010096D444 /* XCRemoteSwiftPackageReference "SnapKit" */, + B564BD062CF2071F00E560C7 /* XCRemoteSwiftPackageReference "realm-swift" */, + ); + preferredProjectObjectVersion = 77; productRefGroup = DB40D1F62609B32C00A4E9FC /* Products */; projectDirPath = ""; projectRoot = ""; @@ -402,57 +457,12 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - DB40D2052609B32E00A4E9FC /* LaunchScreen.storyboard in Resources */, - DB40D2022609B32E00A4E9FC /* Assets.xcassets in Resources */, - DB40D2002609B32C00A4E9FC /* Main.storyboard in Resources */, DB10DB8C27E4A081000560A3 /* GodoM.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 30A0D5039940C22D47761409 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-StopWatch-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - EFF0373BC5C2FA27D26D2271 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-StopWatch/Pods-StopWatch-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-StopWatch/Pods-StopWatch-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-StopWatch/Pods-StopWatch-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ DB40D1F12609B32C00A4E9FC /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -496,7 +506,6 @@ DB30E09A29487D1800F1151A /* UIView+.swift in Sources */, DBEC226A276864380083ECDA /* ListEditItemView.swift in Sources */, DBA7ED6427E301C5004B0D0E /* CalendarMethod.swift in Sources */, - DB40D1F92609B32C00A4E9FC /* AppDelegate.swift in Sources */, DBBFFBEF29334A3500CA3FBC /* TimeLabel.swift in Sources */, DB4FE82426BF80F100B1DF3E /* SegmentData.swift in Sources */, DBA7ED5C27DDB790004B0D0E /* MenuOptionCell.swift in Sources */, @@ -509,25 +518,6 @@ }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXVariantGroup section */ - DB40D1FE2609B32C00A4E9FC /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - DB40D1FF2609B32C00A4E9FC /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - DB40D2032609B32E00A4E9FC /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - DB40D2042609B32E00A4E9FC /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ DB40D2072609B32E00A4E9FC /* Debug */ = { isa = XCBuildConfiguration; @@ -647,15 +637,14 @@ }; DB40D20A2609B32E00A4E9FC /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5CA68B9216F67301B7F37E82 /* Pods-StopWatch.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 11; DEVELOPMENT_TEAM = V2YNV9QV27; - INFOPLIST_FILE = StopWatch/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + INFOPLIST_FILE = StopWatch/App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -670,15 +659,14 @@ }; DB40D20B2609B32E00A4E9FC /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A46D2DC1AD4790441A1758B2 /* Pods-StopWatch.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 11; DEVELOPMENT_TEAM = V2YNV9QV27; - INFOPLIST_FILE = StopWatch/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + INFOPLIST_FILE = StopWatch/App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -713,6 +701,51 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + B564BD062CF2071F00E560C7 /* XCRemoteSwiftPackageReference "realm-swift" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/realm/realm-swift.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 10.54.1; + }; + }; + B5AB29CA2CF2048700E6D510 /* XCRemoteSwiftPackageReference "Then" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/devxoul/Then"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.0.0; + }; + }; + B5FC917F2CF205010096D444 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.7.1; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + B564BD0F2CF2081500E560C7 /* RealmSwift */ = { + isa = XCSwiftPackageProductDependency; + package = B564BD062CF2071F00E560C7 /* XCRemoteSwiftPackageReference "realm-swift" */; + productName = RealmSwift; + }; + B5AB29CB2CF2048700E6D510 /* Then */ = { + isa = XCSwiftPackageProductDependency; + package = B5AB29CA2CF2048700E6D510 /* XCRemoteSwiftPackageReference "Then" */; + productName = Then; + }; + B5FC91802CF205010096D444 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = B5FC917F2CF205010096D444 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = DB40D1ED2609B32C00A4E9FC /* Project object */; } diff --git a/StopWatch.xcworkspace/contents.xcworkspacedata b/StopWatch.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 7d52142..0000000 --- a/StopWatch.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/StopWatch.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/StopWatch.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/StopWatch.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/StopWatch/App/AppDelegate+DI.swift b/StopWatch/App/AppDelegate+DI.swift new file mode 100644 index 0000000..3b74717 --- /dev/null +++ b/StopWatch/App/AppDelegate+DI.swift @@ -0,0 +1,36 @@ +// +// AppDelegate+DI.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/23/25. +// + +import Foundation +import RealmSwift + +extension AppDelegate { + func injectDependency() { + do { + + Realm.Configuration.defaultConfiguration.deleteRealmIfMigrationNeeded = true + let realm = try Realm(configuration: .defaultConfiguration) + DependencyBox.live + .register((any CategoryRepository).self) { + CategoryRepositoryImpl(realm: realm) + } + .register((any TodoRepository).self) { + TodoRepositoryImpl(realm: realm) + } + .register((any TimeCheckReopsitory).self) { + TimeCheckReopsitoryImpl(realm: realm) + } +// let timeCheckRepo = TimeCheckReopsitoryImpl(realm: realm) +// +// +// let allEntity = try? timeCheckRepo.getAll() +// try? timeCheckRepo.delete(entities: allEntity ?? []) + } catch { + print("๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…\(error)๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…") + } + } +} diff --git a/StopWatch/AppDelegate.swift b/StopWatch/App/AppDelegate.swift similarity index 72% rename from StopWatch/AppDelegate.swift rename to StopWatch/App/AppDelegate.swift index f27020c..7070ea4 100644 --- a/StopWatch/AppDelegate.swift +++ b/StopWatch/App/AppDelegate.swift @@ -12,7 +12,7 @@ import RealmSwift class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - let realm = try! Realm() + let realm = try? Realm() var saveDate: String { // ์˜ค๋Š˜ ๋‚ ์งœ ๋ฐ˜ํ™˜! return self.date() @@ -24,19 +24,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var totalTime: TimeInterval { //DB์—์„œ ์ „์ฒด์‹œ๊ฐ„ ๋ฆฌํ„ด - return self.realm.object(ofType: DailyData.self, forPrimaryKey: self.saveDate)?.totalTime ?? 0 + return self.realm?.object(ofType: DailyData.self, forPrimaryKey: self.saveDate)?.totalTime ?? 0 } var totalGoalTime: TimeInterval { //DB์—์„œ ์ „์ฒด์‹œ๊ฐ„ ๋ฆฌํ„ด - return self.realm.object(ofType: DailyData.self, forPrimaryKey: self.saveDate)?.totalGoalTime ?? 0 + return self.realm?.object(ofType: DailyData.self, forPrimaryKey: self.saveDate)?.totalGoalTime ?? 0 } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. - window = UIWindow(frame: UIScreen.main.bounds) - window?.rootViewController = ContainerViewController() - window?.makeKeyAndVisible() + + injectDependency() + self.setFirstDB() // ์•„๋ฌด ๊ณผ๋ชฉ๋„ ์—†์„์‹œ ๊ธฐํƒ€ ๊ณผ๋ชฉ ์ถ”๊ฐ€ @@ -46,6 +46,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + let configuration = UISceneConfiguration( + name: nil, + sessionRole: connectingSceneSession.role + ) + if connectingSceneSession.role == .windowApplication { + configuration.delegateClass = SceneDelegate.self + } + return configuration + } + //์˜ค๋Š˜ ๋‚ ์งœ ๋ฆฌํ„ด ๋ฉ”์†Œ๋“œ func date() -> String{ let formatter = DateFormatter() @@ -71,13 +82,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { //DB ์•„๋ฌด๊ฒƒ๋„ ์—†์„ ๋•Œ ๊ธฐ๋ณธ ๊ณผ๋ชฉ ์„ค์ •. func setFirstDB(){ - try! realm.write{ - if realm.objects(Segments.self).count == 0 { + try? realm?.write{ + if realm?.objects(Segments.self).count == 0 { let data = Segments() data.colorCode = 0xECE7E0 data.name = "๊ธฐํƒ€" - realm.add(data) + realm?.add(data) } } } @@ -88,8 +99,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { for color in paints { let palettes = Palettes() palettes.colorCode = color - try! realm.write{ - realm.add(palettes) + try? realm?.write{ + realm?.add(palettes) } } let ud = UserDefaults.standard diff --git a/StopWatch/App/Appcoordinator.swift b/StopWatch/App/Appcoordinator.swift new file mode 100644 index 0000000..4080614 --- /dev/null +++ b/StopWatch/App/Appcoordinator.swift @@ -0,0 +1,60 @@ +// +// Appcoordinator.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/23/24. +// + +import UIKit + +enum AppCoordinatorParentFlow: ParentFlow { +} + + +final class AppCoordinator: CoordinatorType { + + static let shared = AppCoordinator() + + var navigationController: UINavigationController = .default() + + var childCoordinators: [any CoordinatorType] = [] + + var parentCoordinator: (any CoordinatorType)? = .none + + private init() { + setFlow(.splash) + } + + enum Flow { + case splash + case tab + } + + func setFlow(_ flow: Flow) { + switch flow { + case .splash: + let viewModel = SplashViewModel(coordinator: self) + let view = SplashView(viewModel: viewModel).viewController + navigationController.viewControllers = [view] + + case .tab: + let coordinator = MainTabCoordinator(parentCoordinator: self) + childCoordinators.append(coordinator) + coordinator.setFlow(.start) + present(coordinator.navigationController) + } + } +} + +// MARK: - ParentFlow +extension AppCoordinator { + func setParentFlow(_ flow: any ParentFlow) { +// guard let flow = flow as? AppCoordinatorParentFlow else { +// return +// } +// +// switch flow { +// +// } + } +} diff --git a/StopWatch/Base.lproj/LaunchScreen.storyboard b/StopWatch/App/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from StopWatch/Base.lproj/LaunchScreen.storyboard rename to StopWatch/App/Base.lproj/LaunchScreen.storyboard diff --git a/StopWatch/Base.lproj/Main.storyboard b/StopWatch/App/Base.lproj/Main.storyboard similarity index 100% rename from StopWatch/Base.lproj/Main.storyboard rename to StopWatch/App/Base.lproj/Main.storyboard diff --git a/StopWatch/Info.plist b/StopWatch/App/Info.plist similarity index 88% rename from StopWatch/Info.plist rename to StopWatch/App/Info.plist index 2dc1e20..ba14e13 100644 --- a/StopWatch/Info.plist +++ b/StopWatch/App/Info.plist @@ -2,6 +2,10 @@ + LSApplicationQueriesSchemes + + googlegmail + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -24,7 +28,9 @@ UIAppFonts - GodoM.ttf + Pretendard-SemiBold.otf + Pretendard-Bold.otf + Pretendard-Regular.otf UIApplicationSupportsIndirectInputEvents diff --git a/StopWatch/App/SceneDelegate.swift b/StopWatch/App/SceneDelegate.swift new file mode 100644 index 0000000..258d8db --- /dev/null +++ b/StopWatch/App/SceneDelegate.swift @@ -0,0 +1,20 @@ +// +// SceneDelegate.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/23/24. +// + +import SwiftUI + +final class SceneDelegate: NSObject, UIWindowSceneDelegate { + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + guard let windowScene = scene as? UIWindowScene else { return } + let window = UIWindow(windowScene: windowScene) + window.rootViewController = AppCoordinator.shared.navigationController + self.window = window + window.makeKeyAndVisible() + } +} diff --git a/StopWatch/Controllers/CategoryViewController.swift b/StopWatch/Controllers/CategoryViewController.swift index 4a8325b..1538362 100644 --- a/StopWatch/Controllers/CategoryViewController.swift +++ b/StopWatch/Controllers/CategoryViewController.swift @@ -111,8 +111,8 @@ final class CategoryViewController: UIViewController { //MARK: - Selector @objc func addBarButtonItemMtd(){ - let editVC = EditCategoryViewController() - self.navigationController?.pushViewController(editVC, animated: true) +// let editVC = EditCategoryViewController() +// self.navigationController?.pushViewController(editVC, animated: true) } @objc func longPressGesture(gesture: UILongPressGestureRecognizer) { @@ -158,14 +158,14 @@ extension CategoryViewController: UITableViewDelegate, UITableViewDataSource{ } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let segment = self.realm.objects(Segments.self) - let editVC = EditCategoryViewController().then { - $0.selectedSegmentRow = indexPath.row - $0.getNameTextField.text = segment[indexPath.row].name - $0.selectedColorCode = segment[indexPath.row].colorCode - } - - self.navigationController?.pushViewController(editVC, animated: true) +// let segment = self.realm.objects(Segments.self) +// let editVC = EditCategoryViewController().then { +// $0.selectedSegmentRow = indexPath.row +// $0.getNameTextField.text = segment[indexPath.row].name +// $0.selectedColorCode = segment[indexPath.row].colorCode +// } +// +// self.navigationController?.pushViewController(editVC, animated: true) } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { diff --git a/StopWatch/Controllers/ConcentrationTimeViewController.swift b/StopWatch/Controllers/ConcentrationTimeViewController.swift index 9d9b10c..d0d4df8 100644 --- a/StopWatch/Controllers/ConcentrationTimeViewController.swift +++ b/StopWatch/Controllers/ConcentrationTimeViewController.swift @@ -175,8 +175,8 @@ final class ConcentrationTimeViewController: UIViewController{ } @objc func addCategoryButtonMtd(){ - let editVC = EditCategoryViewController() - self.navigationController?.pushViewController(editVC, animated: true) +// let editVC = EditCategoryViewController() +// self.navigationController?.pushViewController(editVC, animated: true) } } diff --git a/StopWatch/Controllers/EditCategoryViewController.swift b/StopWatch/Controllers/EditCategoryViewController.swift index 45d09bc..5e647b0 100644 --- a/StopWatch/Controllers/EditCategoryViewController.swift +++ b/StopWatch/Controllers/EditCategoryViewController.swift @@ -8,318 +8,318 @@ import UIKit import RealmSwift import Then import SnapKit -import SWColorPicker - -final class EditCategoryViewController: UIViewController { - //MARK: - Properties - private let realm = try! Realm() - lazy var palette = realm.objects(Palettes.self) - - var selectedColorCode: Int? - var selectedSegmentRow: Int? - var saveDate:String = "" - - var editColorView: EditColorView? - - private let titleLabel = UILabel().then { - $0.font = .systemFont(ofSize: 16, weight: .light) - $0.textColor = .black - $0.text = "Name" - } - - private let colorLabel = UILabel().then { - $0.font = .systemFont(ofSize: 16, weight: .light) - $0.textColor = .black - $0.text = "Palette" - } - - let getNameTextField = CustomTextField().then { - $0.font = .systemFont(ofSize: 18, weight: .light) - $0.textColor = .black - $0.underLine.backgroundColor = .black - } - - private let paletteView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { - - $0.register(PaltteCell.self, forCellWithReuseIdentifier: "cell") - $0.backgroundColor = .white - } - - private let okButton = UIButton(type: .roundedRect).then { - $0.setTitle("OK", for: .normal) - $0.setTitleColor(.white, for: .normal) - $0.backgroundColor = .darkGray - $0.layer.cornerRadius = 10 - $0.tag = 1 - } - - private let cancelButton = UIButton(type: .roundedRect).then { - $0.setTitle("Cancel", for: .normal) - $0.setTitleColor(.white, for: .normal) - $0.backgroundColor = .darkGray - $0.layer.cornerRadius = 10 - $0.tag = 2 - } - - //MARK: - LifeCycle - override func viewDidLoad() { - super.viewDidLoad() - self.addSubView() - self.layout() - self.addTarget() - self.view.backgroundColor = .white - - self.paletteView.delegate = self - self.paletteView.dataSource = self - - self.hideKeyboardWhenTapped() - self.setNavigationItem() - - NotificationCenter.default.addObserver(self, selector: #selector(didRecieveCloseColorEditView(_:)), name: .closeColorEditView, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(didClickColorWell), name: .presentColorPicker, object: nil) - - self.saveDate = (UIApplication.shared.delegate as! AppDelegate).saveDate - } - - //MARK: - Method - private func setNavigationItem() { - self.navigationItem.hidesBackButton = true - self.navigationItem.title = "Category" - } - - private func addCategoryMtd(){ - guard let code = self.selectedColorCode else { // ์ƒ‰์„ ์ •ํ–ˆ๋Š”์ง€ ๊ฒ€์‚ฌ ์•ˆํ–ˆ์œผ๋ฉด ๊ฒฝ๊ณ ์ฐฝ ๋„์šฐ๊ธฐ - self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") - return - } - - guard let name = self.getNameTextField.text else { // ๊ณผ๋ชฉ๋ช…์„ ์ž…๋ ฅํ–ˆ๋Š”์ง€ ๊ฒ€์‚ฌ ์•ˆํ–ˆ์œผ๋ฉด ๊ฒฝ๊ณ ์ฐฝ ๋„์šฐ๊ธฐ - self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") - return - } - - if name == ""{ - self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") - }else{ - StopWatchDAO().addSegment(code, name: name, forDate: self.saveDate) // ๊ณผ๋ชฉ์„ DB์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฉ”์†Œ๋“œ - - self.navigationController?.popViewController(animated: true) // ์ „ ๋ทฐ๋กœ ๋Œ์•„๊ฐ€๊ธฐ - } - } - - private func editCategoryMtd(){ - guard let code = self.selectedColorCode else { - self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") - return - } - - guard let name = self.getNameTextField.text else { - self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") - return - } - - if name == ""{ - self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") - }else{ - let segment = self.realm.objects(Segments.self) - try! self.realm.write{ - segment[selectedSegmentRow!].name = name - segment[selectedSegmentRow!].colorCode = code - - } - self.navigationController?.popViewController(animated: true) - } - } - - private func findColorIndex(_ code: Int?) -> Int? { - let objects = self.realm.objects(Palettes.self) - guard let code else { return nil} - let idx = objects.firstIndex { $0.colorCode == code } - guard let idx else { return nil } - - return idx - } - - //MARK: - Selector - @objc func buttonTapped(button: UIButton){ - switch button.tag{ - case 1: - if let _ = self.selectedSegmentRow{ - self.editCategoryMtd() //์„ ํƒ๋œ ์„ธ๊ทธ๋จผํŠธ๋กœ์šฐ๊ฐ€ ์žˆ์œผ๋ฉด ํŽธ์ง‘ - }else{ - self.addCategoryMtd() // ์—†์œผ๋ฉด ์ƒˆ๋กœ ์ถ”๊ฐ€. - } - case 2: - self.navigationController?.popViewController(animated: true) - default: - break - } - } - - @objc func didRecieveLongPressGesture(_ sender: UILongPressGestureRecognizer){ - guard let row = self.paletteView.indexPathForItem(at: sender.location(in: self.paletteView))?.row else { return} - self.openEditColorView(.edit, palette: self.palette[row]) - } - - @objc func didClickColorWell(_ notification: Notification) { - if let color = notification.object as? UIColor { - let vc = SWColorPickerViewController(color) - vc.delegate = self - self.present(vc, animated: true) - } else { - let vc = SWColorPickerViewController(.white) - vc.delegate = self - self.present(vc, animated: true) - } - } - - //MARK: - EditColorViewMethod - func openEditColorView(_ mode: ColorViewMode, palette: Palettes?) { - guard self.editColorView == nil else { return } // ์ค‘๋ณต ๋ทฐ ๋ฐฉ์ง€ - self.editColorView = EditColorView(mode, palette).then { - - self.view.addSubview($0) - $0.snp.makeConstraints { make in - make.leading.equalToSuperview().offset(50) - make.trailing.equalToSuperview().offset(-50) - make.centerY.equalToSuperview() - make.height.equalTo(170) - } - } - } - - @objc private func didRecieveCloseColorEditView(_ sender: Any){ - self.paletteView.reloadData() - self.editColorView?.removeFromSuperview() - self.editColorView = nil - } - - //MARK: - AddSubView - private func addSubView(){ - self.view.addSubview(self.titleLabel) - self.view.addSubview(self.getNameTextField) - self.view.addSubview(self.colorLabel) - self.view.addSubview(self.paletteView) - self.view.addSubview(self.okButton) - self.view.addSubview(self.cancelButton) - } - - //MARK: - Layout - private func layout(){ - self.titleLabel.snp.makeConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(30) - $0.leading.equalToSuperview().offset(22) - } - - self.getNameTextField.snp.makeConstraints { - $0.top.equalTo(self.titleLabel.snp.bottom).offset(4) - $0.leading.equalToSuperview().offset(22) - $0.trailing.equalToSuperview().offset(-22) - $0.height.equalTo(50) - } - - self.colorLabel.snp.makeConstraints { - $0.top.equalTo(self.getNameTextField.snp.bottom).offset(26) - $0.leading.equalToSuperview().offset(22) - } - - self.paletteView.snp.makeConstraints { - $0.leading.equalToSuperview().offset(22) - $0.trailing.equalToSuperview().offset(-22) - $0.top.equalTo(self.colorLabel.snp.bottom).offset(10) - $0.height.equalTo(220) - } - - self.okButton.snp.makeConstraints { - $0.top.equalTo(self.paletteView.snp.bottom).offset(14) - $0.centerX.equalToSuperview().offset(-46) - $0.width.equalTo(80) - $0.height.equalTo(40) - } - - self.cancelButton.snp.makeConstraints { - $0.top.equalTo(self.paletteView.snp.bottom).offset(14) - $0.centerX.equalToSuperview().offset(46) - $0.width.equalTo(80) - $0.height.equalTo(40) - } - } - - //MARK: - AddTarget - private func addTarget(){ - self.okButton.addTarget(self, action: #selector(buttonTapped(button:)), for: .touchUpInside) - self.cancelButton.addTarget(self, action: #selector(buttonTapped(button:)), for: .touchUpInside) - } -} -//MARK: - CollectionView Delegate , datasource -extension EditCategoryViewController: UICollectionViewDelegate,UICollectionViewDataSource { - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return self.palette.count + 1 - } - - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! PaltteCell - //์ดˆ๊ธฐํ™” - cell.prepareForReuse() - - //์ƒ‰์ƒ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋งˆ์ง€๋ง‰ ์…€ ๊ตฌ์„ฑ - if indexPath.row == palette.count { - cell.checkImageView.image = UIImage(systemName: "plus") - cell.checkImageView.isHidden = false - cell.paintView.backgroundColor = .systemGray3 - }else { // ํŒ”๋ ˆํŠธ ๊ตฌ์„ฑ - //ํŒ”๋ ˆํŠธ ์ƒ‰์ƒ ๊ตฌ์„ฑ - let colorCode = palette[indexPath.row].colorCode - cell.paintView.backgroundColor = self.view.uiColorFromHexCode(colorCode) - - //์„ ํƒ๋œ ์…€์ด๋ฉด ์ฒดํฌ๋งˆํฌ! - if let row = self.findColorIndex(self.selectedColorCode) { - cell.checkImageView.isHidden = indexPath.row == row ? false : true - } - - //ํŽธ์ง‘์šฉ ์ œ์Šค์ณ ์ถ”๊ฐ€ - let longPressGeture = UILongPressGestureRecognizer(target: self, action: #selector(self.didRecieveLongPressGesture(_:))) - cell.addGestureRecognizer(longPressGeture) - } - - return cell - } - - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let object = self.realm.objects(Palettes.self) - if indexPath.row == object.count { - // ์ƒ‰์ƒ ์ถ”๊ฐ€๋ทฐ - self.openEditColorView(.add, palette: nil) - }else { // ์ƒ‰์ƒ ๊ณจ๋ž์„ ๋•Œ - self.selectedColorCode = object[indexPath.row].colorCode - collectionView.reloadData() - } - } -} - -extension EditCategoryViewController: UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize( width: 54, height: 54 ) - } -} - -//MARK:- UITextFieldDelegate -extension EditCategoryViewController: UITextFieldDelegate { - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - textField.resignFirstResponder() - return true - } -} - -extension EditCategoryViewController: SWColorPickerViewDelegate { - func didSelectColor(_ color: UIColor) { - var (r,g,b): (CGFloat,CGFloat,CGFloat) = (0,0,0) - color.getRed(&r, green: &g, blue: &b, alpha: nil) - let red = String(Int(r * 255), radix: 16).padding(toLength: 2, withPad: "0", startingAt: 0).uppercased() - let green = String(Int(g * 255), radix: 16).padding(toLength: 2, withPad: "0", startingAt: 0).uppercased() - let blue = String(Int(b * 255), radix: 16).padding(toLength: 2, withPad: "0", startingAt: 0).uppercased() - let hexCode = red + green + blue - - editColorView?.selectedColor(hexCode) - } -} +//import SWColorPicker +// +//final class EditCategoryViewController: UIViewController { +// //MARK: - Properties +// private let realm = try! Realm() +// lazy var palette = realm.objects(Palettes.self) +// +// var selectedColorCode: Int? +// var selectedSegmentRow: Int? +// var saveDate:String = "" +// +// var editColorView: EditColorView? +// +// private let titleLabel = UILabel().then { +// $0.font = .systemFont(ofSize: 16, weight: .light) +// $0.textColor = .black +// $0.text = "Name" +// } +// +// private let colorLabel = UILabel().then { +// $0.font = .systemFont(ofSize: 16, weight: .light) +// $0.textColor = .black +// $0.text = "Palette" +// } +// +// let getNameTextField = CustomTextField().then { +// $0.font = .systemFont(ofSize: 18, weight: .light) +// $0.textColor = .black +// $0.underLine.backgroundColor = .black +// } +// +// private let paletteView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { +// +// $0.register(PaltteCell.self, forCellWithReuseIdentifier: "cell") +// $0.backgroundColor = .white +// } +// +// private let okButton = UIButton(type: .roundedRect).then { +// $0.setTitle("OK", for: .normal) +// $0.setTitleColor(.white, for: .normal) +// $0.backgroundColor = .darkGray +// $0.layer.cornerRadius = 10 +// $0.tag = 1 +// } +// +// private let cancelButton = UIButton(type: .roundedRect).then { +// $0.setTitle("Cancel", for: .normal) +// $0.setTitleColor(.white, for: .normal) +// $0.backgroundColor = .darkGray +// $0.layer.cornerRadius = 10 +// $0.tag = 2 +// } +// +// //MARK: - LifeCycle +// override func viewDidLoad() { +// super.viewDidLoad() +// self.addSubView() +// self.layout() +// self.addTarget() +// self.view.backgroundColor = .white +// +// self.paletteView.delegate = self +// self.paletteView.dataSource = self +// +// self.hideKeyboardWhenTapped() +// self.setNavigationItem() +// +// NotificationCenter.default.addObserver(self, selector: #selector(didRecieveCloseColorEditView(_:)), name: .closeColorEditView, object: nil) +// NotificationCenter.default.addObserver(self, selector: #selector(didClickColorWell), name: .presentColorPicker, object: nil) +// +// self.saveDate = (UIApplication.shared.delegate as! AppDelegate).saveDate +// } +// +// //MARK: - Method +// private func setNavigationItem() { +// self.navigationItem.hidesBackButton = true +// self.navigationItem.title = "Category" +// } +// +// private func addCategoryMtd(){ +// guard let code = self.selectedColorCode else { // ์ƒ‰์„ ์ •ํ–ˆ๋Š”์ง€ ๊ฒ€์‚ฌ ์•ˆํ–ˆ์œผ๋ฉด ๊ฒฝ๊ณ ์ฐฝ ๋„์šฐ๊ธฐ +// self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") +// return +// } +// +// guard let name = self.getNameTextField.text else { // ๊ณผ๋ชฉ๋ช…์„ ์ž…๋ ฅํ–ˆ๋Š”์ง€ ๊ฒ€์‚ฌ ์•ˆํ–ˆ์œผ๋ฉด ๊ฒฝ๊ณ ์ฐฝ ๋„์šฐ๊ธฐ +// self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") +// return +// } +// +// if name == ""{ +// self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") +// }else{ +// StopWatchDAO().addSegment(code, name: name, forDate: self.saveDate) // ๊ณผ๋ชฉ์„ DB์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฉ”์†Œ๋“œ +// +// self.navigationController?.popViewController(animated: true) // ์ „ ๋ทฐ๋กœ ๋Œ์•„๊ฐ€๊ธฐ +// } +// } +// +// private func editCategoryMtd(){ +// guard let code = self.selectedColorCode else { +// self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") +// return +// } +// +// guard let name = self.getNameTextField.text else { +// self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") +// return +// } +// +// if name == ""{ +// self.notiAlert(title: "๊ฒฝ ๊ณ ", message: "์ƒ‰๊ณผ ์ด๋ฆ„์„ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") +// }else{ +// let segment = self.realm.objects(Segments.self) +// try! self.realm.write{ +// segment[selectedSegmentRow!].name = name +// segment[selectedSegmentRow!].colorCode = code +// +// } +// self.navigationController?.popViewController(animated: true) +// } +// } +// +// private func findColorIndex(_ code: Int?) -> Int? { +// let objects = self.realm.objects(Palettes.self) +// guard let code else { return nil} +// let idx = objects.firstIndex { $0.colorCode == code } +// guard let idx else { return nil } +// +// return idx +// } +// +// //MARK: - Selector +// @objc func buttonTapped(button: UIButton){ +// switch button.tag{ +// case 1: +// if let _ = self.selectedSegmentRow{ +// self.editCategoryMtd() //์„ ํƒ๋œ ์„ธ๊ทธ๋จผํŠธ๋กœ์šฐ๊ฐ€ ์žˆ์œผ๋ฉด ํŽธ์ง‘ +// }else{ +// self.addCategoryMtd() // ์—†์œผ๋ฉด ์ƒˆ๋กœ ์ถ”๊ฐ€. +// } +// case 2: +// self.navigationController?.popViewController(animated: true) +// default: +// break +// } +// } +// +// @objc func didRecieveLongPressGesture(_ sender: UILongPressGestureRecognizer){ +// guard let row = self.paletteView.indexPathForItem(at: sender.location(in: self.paletteView))?.row else { return} +// self.openEditColorView(.edit, palette: self.palette[row]) +// } +// +// @objc func didClickColorWell(_ notification: Notification) { +// if let color = notification.object as? UIColor { +// let vc = SWColorPickerViewController(color) +// vc.delegate = self +// self.present(vc, animated: true) +// } else { +// let vc = SWColorPickerViewController(.white) +// vc.delegate = self +// self.present(vc, animated: true) +// } +// } +// +// //MARK: - EditColorViewMethod +// func openEditColorView(_ mode: ColorViewMode, palette: Palettes?) { +// guard self.editColorView == nil else { return } // ์ค‘๋ณต ๋ทฐ ๋ฐฉ์ง€ +// self.editColorView = EditColorView(mode, palette).then { +// +// self.view.addSubview($0) +// $0.snp.makeConstraints { make in +// make.leading.equalToSuperview().offset(50) +// make.trailing.equalToSuperview().offset(-50) +// make.centerY.equalToSuperview() +// make.height.equalTo(170) +// } +// } +// } +// +// @objc private func didRecieveCloseColorEditView(_ sender: Any){ +// self.paletteView.reloadData() +// self.editColorView?.removeFromSuperview() +// self.editColorView = nil +// } +// +// //MARK: - AddSubView +// private func addSubView(){ +// self.view.addSubview(self.titleLabel) +// self.view.addSubview(self.getNameTextField) +// self.view.addSubview(self.colorLabel) +// self.view.addSubview(self.paletteView) +// self.view.addSubview(self.okButton) +// self.view.addSubview(self.cancelButton) +// } +// +// //MARK: - Layout +// private func layout(){ +// self.titleLabel.snp.makeConstraints { +// $0.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(30) +// $0.leading.equalToSuperview().offset(22) +// } +// +// self.getNameTextField.snp.makeConstraints { +// $0.top.equalTo(self.titleLabel.snp.bottom).offset(4) +// $0.leading.equalToSuperview().offset(22) +// $0.trailing.equalToSuperview().offset(-22) +// $0.height.equalTo(50) +// } +// +// self.colorLabel.snp.makeConstraints { +// $0.top.equalTo(self.getNameTextField.snp.bottom).offset(26) +// $0.leading.equalToSuperview().offset(22) +// } +// +// self.paletteView.snp.makeConstraints { +// $0.leading.equalToSuperview().offset(22) +// $0.trailing.equalToSuperview().offset(-22) +// $0.top.equalTo(self.colorLabel.snp.bottom).offset(10) +// $0.height.equalTo(220) +// } +// +// self.okButton.snp.makeConstraints { +// $0.top.equalTo(self.paletteView.snp.bottom).offset(14) +// $0.centerX.equalToSuperview().offset(-46) +// $0.width.equalTo(80) +// $0.height.equalTo(40) +// } +// +// self.cancelButton.snp.makeConstraints { +// $0.top.equalTo(self.paletteView.snp.bottom).offset(14) +// $0.centerX.equalToSuperview().offset(46) +// $0.width.equalTo(80) +// $0.height.equalTo(40) +// } +// } +// +// //MARK: - AddTarget +// private func addTarget(){ +// self.okButton.addTarget(self, action: #selector(buttonTapped(button:)), for: .touchUpInside) +// self.cancelButton.addTarget(self, action: #selector(buttonTapped(button:)), for: .touchUpInside) +// } +//} +////MARK: - CollectionView Delegate , datasource +//extension EditCategoryViewController: UICollectionViewDelegate,UICollectionViewDataSource { +// func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { +// return self.palette.count + 1 +// } +// +// func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { +// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! PaltteCell +// //์ดˆ๊ธฐํ™” +// cell.prepareForReuse() +// +// //์ƒ‰์ƒ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋งˆ์ง€๋ง‰ ์…€ ๊ตฌ์„ฑ +// if indexPath.row == palette.count { +// cell.checkImageView.image = UIImage(systemName: "plus") +// cell.checkImageView.isHidden = false +// cell.paintView.backgroundColor = .systemGray3 +// }else { // ํŒ”๋ ˆํŠธ ๊ตฌ์„ฑ +// //ํŒ”๋ ˆํŠธ ์ƒ‰์ƒ ๊ตฌ์„ฑ +// let colorCode = palette[indexPath.row].colorCode +// cell.paintView.backgroundColor = self.view.uiColorFromHexCode(colorCode) +// +// //์„ ํƒ๋œ ์…€์ด๋ฉด ์ฒดํฌ๋งˆํฌ! +// if let row = self.findColorIndex(self.selectedColorCode) { +// cell.checkImageView.isHidden = indexPath.row == row ? false : true +// } +// +// //ํŽธ์ง‘์šฉ ์ œ์Šค์ณ ์ถ”๊ฐ€ +// let longPressGeture = UILongPressGestureRecognizer(target: self, action: #selector(self.didRecieveLongPressGesture(_:))) +// cell.addGestureRecognizer(longPressGeture) +// } +// +// return cell +// } +// +// func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { +// let object = self.realm.objects(Palettes.self) +// if indexPath.row == object.count { +// // ์ƒ‰์ƒ ์ถ”๊ฐ€๋ทฐ +// self.openEditColorView(.add, palette: nil) +// }else { // ์ƒ‰์ƒ ๊ณจ๋ž์„ ๋•Œ +// self.selectedColorCode = object[indexPath.row].colorCode +// collectionView.reloadData() +// } +// } +//} +// +//extension EditCategoryViewController: UICollectionViewDelegateFlowLayout { +// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { +// return CGSize( width: 54, height: 54 ) +// } +//} +// +////MARK:- UITextFieldDelegate +//extension EditCategoryViewController: UITextFieldDelegate { +// func textFieldShouldReturn(_ textField: UITextField) -> Bool { +// textField.resignFirstResponder() +// return true +// } +//} +// +//extension EditCategoryViewController: SWColorPickerViewDelegate { +// func didSelectColor(_ color: UIColor) { +// var (r,g,b): (CGFloat,CGFloat,CGFloat) = (0,0,0) +// color.getRed(&r, green: &g, blue: &b, alpha: nil) +// let red = String(Int(r * 255), radix: 16).padding(toLength: 2, withPad: "0", startingAt: 0).uppercased() +// let green = String(Int(g * 255), radix: 16).padding(toLength: 2, withPad: "0", startingAt: 0).uppercased() +// let blue = String(Int(b * 255), radix: 16).padding(toLength: 2, withPad: "0", startingAt: 0).uppercased() +// let hexCode = red + green + blue +// +// editColorView?.selectedColor(hexCode) +// } +//} diff --git a/StopWatch/Core/Cooridnator/CoordinatorType+.swift b/StopWatch/Core/Cooridnator/CoordinatorType+.swift new file mode 100644 index 0000000..5557a95 --- /dev/null +++ b/StopWatch/Core/Cooridnator/CoordinatorType+.swift @@ -0,0 +1,55 @@ +// +// CoordinatorType+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 9/7/24. +// + +import UIKit + +// MARK: - Default Implement +extension CoordinatorType { + + func present( + _ viewcontroller: UIViewController, + style: UIModalPresentationStyle = .fullScreen, + animated: Bool = true + ) { + viewcontroller.modalPresentationStyle = style + navigationController.present(viewcontroller, animated: animated) + } + + func presentPanModals(_ viewController: PanModalPresentable.LayoutType) { + navigationController.presentPanModal(viewController) + } + + func dismiss(animated: Bool = true, completion: (()->Void)? = .none) { + navigationController.dismiss(animated: animated) { completion?() } + } + + func pop(_ animated: Bool = true) { + navigationController.popViewController(animated: animated) + } + + func push( + _ viewcontroller: UIViewController, + animated: Bool = true + ) { + navigationController.pushViewController(viewcontroller, animated: animated) + } + + func showToast(_ message: String, duration: Double = 2.0) { + let toastView = ToastView(message: message, duration: duration) + ToastProvider.shared.show(view: toastView, duration: duration) + } + + func showAlert(_ alert: StopWatchAlertView) { + present(alert.viewControllerClear, style: .overFullScreen, animated: false) + } + + func changeTab(tab: TabItem) { +// if let tabCoordinator = AppCoordinator.shared.childCoordinators.first(where: { $0 is MainTabCoordinator }) as? MainTabCoordinator { +// tabCoordinator.setFlow(.changeTab(tab)) +// } + } +} diff --git a/StopWatch/Core/Cooridnator/CoordinatorType.swift b/StopWatch/Core/Cooridnator/CoordinatorType.swift new file mode 100644 index 0000000..92e0a6e --- /dev/null +++ b/StopWatch/Core/Cooridnator/CoordinatorType.swift @@ -0,0 +1,22 @@ +// +// CoordinatorType.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public protocol ParentFlow { } + +public protocol CoordinatorType { + associatedtype Flow + + var childCoordinators: [any CoordinatorType] { get } + var parentCoordinator: (any CoordinatorType)? { get set } + + var navigationController: UINavigationController { get } + + func setFlow(_ flow: Flow) + func setParentFlow(_ flow: any ParentFlow) +} diff --git a/StopWatch/Core/DependecyBox/DependencyBox.swift b/StopWatch/Core/DependecyBox/DependencyBox.swift new file mode 100644 index 0000000..97126c1 --- /dev/null +++ b/StopWatch/Core/DependecyBox/DependencyBox.swift @@ -0,0 +1,80 @@ +// +// DependencyBox.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/7/24. +// + +import Foundation + +public protocol DependencyBoxProtocol { + + func register( + _ type: T.Type?, + name: String?, + scope: ObjectScope, + factory: @escaping () -> T + ) -> Self + + func resolve(name: String?) -> T +} + +extension DependencyBoxProtocol { + func key(for type: T.Type, name: String? = nil) -> String { + if let name = name { + return "\(String(describing: T.self))-\(name)" + } else { + return String(describing: T.self) + } + } +} + +public class DependencyBox: DependencyBoxProtocol { + + // ์˜์กด์„ฑ์„ ๋“ฑ๋กํ•˜๊ธฐ ์œ„ํ•œ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ (ํƒ€์ž… + ํƒœ๊ทธ ์กฐํ•ฉ์„ ํ‚ค๋กœ ์‚ฌ์šฉ) + private var registry = [String: () -> Any]() + private var singletonInstances = [String: Any]() // ์‹ฑ๊ธ€ํ†ค ์ธ์Šคํ„ด์Šค ์ €์žฅ + + public init() { } + + // ์˜์กด์„ฑ ๋“ฑ๋ก ํ•จ์ˆ˜ + @discardableResult + public func register( + _ type: T.Type? = .none, + name: String? = nil, + scope: ObjectScope = .singleton, + factory: @escaping () -> T + ) -> Self { + let key = self.key(for: T.self, name: name) + + // ์‹ฑ๊ธ€ํ†ค ์Šค์ฝ”ํ”„์ผ ๊ฒฝ์šฐ, ํŒฉํ† ๋ฆฌ ํ•จ์ˆ˜๋กœ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•˜์—ฌ ์ €์žฅ + if scope == .singleton { + let instance = factory() + singletonInstances[key] = instance + registry[key] = { instance } // ํ•ญ์ƒ ๋™์ผํ•œ ์ธ์Šคํ„ด์Šค ๋ฐ˜ํ™˜ + } else { + registry[key] = factory // ๋งค๋ฒˆ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•  ํŒฉํ† ๋ฆฌ ์ €์žฅ + } + return self + } + + // ์˜์กด์„ฑ ์ฃผ์ž…(Resolve) ํ•จ์ˆ˜ + public func resolve(name: String? = nil) -> T { + let key = self.key(for: T.self, name: name) + + guard let factory = registry[key] else { + fatalError("No registered dependency found for \(key)") + } + guard let instance = factory() as? T else { + fatalError("Dependency type mismatch for \(key)") + } + + return instance + } +} + +public extension DependencyBox { + + static let live = DependencyBox() + static let preview = DependencyBox() +} diff --git a/StopWatch/Core/DependecyBox/DependencyTag.swift b/StopWatch/Core/DependecyBox/DependencyTag.swift new file mode 100644 index 0000000..cebeade --- /dev/null +++ b/StopWatch/Core/DependecyBox/DependencyTag.swift @@ -0,0 +1,13 @@ +// +// TagList.swift +// DIContainer_Example +// +// Created by iOS์‹ ์ƒ์šฐ on 10/23/24. +// + +import Foundation + +public enum DependencyTag: String { + case live + case test +} diff --git a/StopWatch/Core/DependecyBox/ObjectScope.swift b/StopWatch/Core/DependecyBox/ObjectScope.swift new file mode 100644 index 0000000..f10a6a2 --- /dev/null +++ b/StopWatch/Core/DependecyBox/ObjectScope.swift @@ -0,0 +1,13 @@ +// +// ObjectScope.swift +// DIContainer_Example +// +// Created by iOS์‹ ์ƒ์šฐ on 10/23/24. +// + +import Foundation + +public enum ObjectScope { + case singleton // ํ•œ ๋ฒˆ ์ƒ์„ฑ๋œ ์ธ์Šคํ„ด์Šค๋ฅผ ์žฌ์‚ฌ์šฉ + case transient // ๋งค๋ฒˆ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑ +} diff --git a/StopWatch/Core/EmailSender/EmailSender.swift b/StopWatch/Core/EmailSender/EmailSender.swift new file mode 100644 index 0000000..6135574 --- /dev/null +++ b/StopWatch/Core/EmailSender/EmailSender.swift @@ -0,0 +1,80 @@ +// +// EmailSender.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import Foundation +import UIKit.UIApplication + +struct EmailSender { + let toAddress: String + let subject: String + var body: String + + // openURL + @MainActor + func send(type: EmailType) async throws { + let urlComponent = type.getUrlCompnents(toAddress: toAddress, subject: subject, body: body) + + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + if let url = urlComponent?.url { + + UIApplication.shared.open(url) { isSuccess in + if isSuccess { + continuation.resume() + } else { + continuation.resume(throwing: EmailSendError.failed) + } + } + } else { + continuation.resume(throwing: EmailSendError.invalidUrl) + } + } + } + + enum EmailSendError: Error { + case failed + case invalidUrl + } + + enum EmailType { + case apple(toAddress: String) + case gmail + + var scheme: String { + switch self { + case .apple(let toAddress): + "mailto:\(toAddress)" + case .gmail: + "googlegmail://co" + } + } + + func getUrlCompnents(toAddress: String, subject: String, body: String) -> URLComponents? { + switch self { + case .apple(_): + var urlComponent = URLComponents(string: scheme) + urlComponent?.queryItems = [ + .init(name: "subject", value: subject), + .init(name: "body", value: body) + ] + + return urlComponent + + case .gmail: + var urlComponent = URLComponents(string: scheme) + urlComponent?.queryItems = [ + .init(name: "to", value: toAddress), + .init(name: "subject", value: subject), + .init(name: "body", value: body) + ] + + return urlComponent + } + } + } +} + + diff --git a/StopWatch/Core/Modifier/PreffixModifier.swift b/StopWatch/Core/Modifier/PreffixModifier.swift new file mode 100644 index 0000000..7a3bee0 --- /dev/null +++ b/StopWatch/Core/Modifier/PreffixModifier.swift @@ -0,0 +1,21 @@ +// +// PreffixModifier.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public struct PrefixModifier: ViewModifier { + @ViewBuilder var prefix: (() -> Prefix) + + public func body(content: Content) -> some View { + return content.overlay { + HStack { + prefix() + Spacer() + } + } + } +} diff --git a/StopWatch/Core/Modifier/SuffixModifier.swift b/StopWatch/Core/Modifier/SuffixModifier.swift new file mode 100644 index 0000000..2bfdc80 --- /dev/null +++ b/StopWatch/Core/Modifier/SuffixModifier.swift @@ -0,0 +1,21 @@ +// +// SuffixModifier.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public struct SuffixModifier: ViewModifier { + @ViewBuilder var suffix: (() -> Suffix) + + public func body(content: Content) -> some View { + return content.overlay { + HStack { + Spacer() + suffix() + } + } + } +} diff --git a/StopWatch/Core/Modifier/View+Modifier.swift b/StopWatch/Core/Modifier/View+Modifier.swift new file mode 100644 index 0000000..e43ed74 --- /dev/null +++ b/StopWatch/Core/Modifier/View+Modifier.swift @@ -0,0 +1,28 @@ +// +// View+Modifier.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public extension View { + func suffix(@ViewBuilder _ suffix: (() -> Suffix)) -> some View { + self.overlay { + HStack { + Spacer() + suffix() + } + } + } + + func prefix(@ViewBuilder _ prefix: (() -> Prefix)) -> some View { + self.overlay { + HStack { + prefix() + Spacer() + } + } + } +} diff --git a/StopWatch/Core/MotionManager/MotionManager.swift b/StopWatch/Core/MotionManager/MotionManager.swift new file mode 100644 index 0000000..a4228eb --- /dev/null +++ b/StopWatch/Core/MotionManager/MotionManager.swift @@ -0,0 +1,41 @@ +// +// MotionManager.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 2/1/25. +// + +import Foundation +import CoreMotion +import Combine + +final class MotionManager: ObservableObject { + private var motionManager = CMMotionManager() + + @Published var acceleration: (x: Double, y: Double, z: Double) = (0, 0, 0) // ๊ฐ€์†๋„ ๋ฐ์ดํ„ฐ + @Published var rotationRate: (x: Double, y: Double, z: Double) = (0, 0, 0) // ์ž์ด๋กœ์Šค์ฝ”ํ”„ ๋ฐ์ดํ„ฐ + @Published var attitude: (roll: Double, pitch: Double, yaw: Double) = (0, 0, 0) // ๊ธฐ์šธ๊ธฐ ๋ฐ์ดํ„ฐ + + func startMotionUpdates() { + if motionManager.isDeviceMotionAvailable { + motionManager.deviceMotionUpdateInterval = 0.1 + + motionManager.startDeviceMotionUpdates(to: .main) { [weak self] (motion, error) in + guard let self = self, let motion = motion else { return } + + // ๊ฐ€์†๋„ ๋ฐ์ดํ„ฐ + self.acceleration = (motion.userAcceleration.x, motion.userAcceleration.y, motion.userAcceleration.z) + + // ์ž์ด๋กœ์Šค์ฝ”ํ”„ ๋ฐ์ดํ„ฐ + self.rotationRate = (motion.rotationRate.x, motion.rotationRate.y, motion.rotationRate.z) + + // ๊ธฐ์šธ๊ธฐ ๋ฐ์ดํ„ฐ + self.attitude = (motion.attitude.roll, motion.attitude.pitch, motion.attitude.yaw) + } + } + } + + func stopMotionUpdates() { + motionManager.stopDeviceMotionUpdates() + } +} diff --git a/StopWatch/Core/TimeFormatter/TimeFormatter.swift b/StopWatch/Core/TimeFormatter/TimeFormatter.swift new file mode 100644 index 0000000..1191bd2 --- /dev/null +++ b/StopWatch/Core/TimeFormatter/TimeFormatter.swift @@ -0,0 +1,61 @@ +// +// TimeFormatter.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 2/2/25. +// + +import Foundation + +struct TimeFormatter { + + static func toTimeString(with timeInterval: TimeInterval, format: TimeFormat = .basic, useCompactTimeFormat: Bool = false) -> String { + let hours = timeInterval / 3600 + let minutes = (timeInterval.truncatingRemainder(dividingBy: 3600)) / 60 + let seconds = timeInterval.truncatingRemainder(dividingBy: 60) + + if useCompactTimeFormat { + if hours.toInt > .zero { + return String(format: format.hourMinuteOnly, hours.toInt, minutes.toInt) + } else { + return String(format: format.minuteSecondOnly, minutes.toInt, seconds.toInt) + } + } else { + return String(format: format.rawValue, hours.toInt, minutes.toInt, seconds.toInt) + } + } + + enum TimeFormat: String { + /// 00 : 00 : 00 + case basic = "%02d : %02d : %02d" + + /// 00์‹œ๊ฐ„ 00๋ถ„ 00์ดˆ + case HHMMssKorean = "%02d์‹œ๊ฐ„ %02d๋ถ„ %02d์ดˆ" + + var hourMinuteOnly: String { + switch self { + case .HHMMssKorean: + "%02d์‹œ๊ฐ„ %02d๋ถ„" + // ๋ฏธ์ง€์› ํฌ๋งท + default: + self.rawValue + } + } + + var minuteSecondOnly: String { + switch self { + case .HHMMssKorean: + "%02d๋ถ„ %02d์ดˆ" + // ๋ฏธ์ง€์› ํฌ๋งท + default: + self.rawValue + } + } + } +} + +fileprivate extension Double { + var toInt: Int { + Int(self) + } +} diff --git a/StopWatch/Core/Util/DateFormat/Date+Format.swift b/StopWatch/Core/Util/DateFormat/Date+Format.swift new file mode 100644 index 0000000..c2d7f93 --- /dev/null +++ b/StopWatch/Core/Util/DateFormat/Date+Format.swift @@ -0,0 +1,41 @@ +// +// Date+.swift +// STLess +// +// Created by iOS์‹ ์ƒ์šฐ on 5/19/24. +// + +import SwiftUI + +extension String { + func date(fromFormat format: DateFormat) -> Date { + format.formatter.date(from: self) ?? Date() + } +} + +extension Date { + func formattedString( + by dateFormat: DateFormat, + local: LocaleFormat = .korea + ) -> String { + let formatter = DateFormat.cachedFormatter( + ofDateFormat: dateFormat.rawValue, + localeFormat: local + ) + + return formatter.string(from: self) + } + + func formattedString( + format: String, + local: LocaleFormat = .korea + ) -> String { + let formatter = DateFormat.cachedFormatter( + ofDateFormat: format, + localeFormat: local + ) + + return formatter.string(from: self) + } +} + diff --git a/StopWatch/Core/Util/DateFormat/DateFormat.swift b/StopWatch/Core/Util/DateFormat/DateFormat.swift new file mode 100644 index 0000000..9d2a643 --- /dev/null +++ b/StopWatch/Core/Util/DateFormat/DateFormat.swift @@ -0,0 +1,115 @@ +// +// DateFormat.swift +// STLess +// +// Created by iOS์‹ ์ƒ์šฐ on 5/29/24. +// + +// MARK: - ํ‚น ๋ฉ”์ด์Šจ๊ฑฐ ํ›”์ณ์˜ด ๐Ÿ˜Ž + +import Foundation + +enum DateFormat: String { + /// ๋…„.์›”.์ผ + case yyyyMMdd = "yyyy.MM.dd" + + /// ํ•œ๊ตญ์–ด ๋…„์›”์ผ (yyyy๋…„ MM์›” dd์ผ) + case yyyyMMddKorean = "yyyy๋…„ MM์›” dd์ผ" + + /// ํ•œ๊ตญ์–ด ๋…„์›”์ผ ์š”์ผ (yyyy๋…„ MM์›” dd์ผ EEE์š”์ผ) + case yyyyMMddEEEKorean = "yyyy๋…„ MM์›” dd์ผ EEEE" + + /// ํ•œ๊ตญ์–ด ๋…„์›”์ผ (yyyy๋…„ M์›” d์ผ) + case yyyyMdKorean = "yyyy๋…„ M์›” d์ผ" + + /// ํ•œ๊ตญ์–ด ์›”์ผ (MM์›” dd์ผ) + case MMddKorean = "MM์›” dd์ผ" + + /// ๋…„.์›” + case yyyyMM = "yyyy.MM" + + /// ์›”.์ผ + case MMdd = "MM.dd" + + /// ์›”.์ผ + case Mdd = "M.dd" + + /// ์‹œ + case HH = "HH" + + /// ๋…„.์›”.์ผ ์‹œ:๋ถ„:์ดˆ + case dateTime = "yyyy.MM.dd HH:mm:ss" + + /// ๋…„.์›”.์ผ ์‹œ:๋ถ„ + case yyyyMMddHHmm = "yyyy.MM.dd HH:mm" + + /// ๋…„.์›”.์ผ ์˜ค์ „/์˜คํ›„ ์‹œ:๋ถ„ + case yyyyMMddahhmm = "yyyy.MM.dd a hh:mm" + + /// ๋…„.์›”.์ผ ์˜ค์ „/์˜คํ›„ ์‹œ(24):๋ถ„ + case yyyyMMddaHHmm = "yyyy.MM.dd a HH:mm" + + /// ์‹œ:๋ถ„:์ดˆ + case HHmmss = "HH:mm:ss" + + /// ์‹œ:๋ถ„ + case HHmm = "HH:mm" + + /// ์˜ค์ „/์˜คํ›„ ์‹œ:๋ถ„ + case ahhmm = "a hh:mm" + + /// ์ถ•์•ฝ ์š”์ผ (์›”, ํ™”) + case ee = "EE" + + /// ์„œ๋ฒ„ ๋‚ ์งœ, ์‹œ๊ฐ„ (๋…„-์›”-์ผ ์‹œ:๋ถ„:์ดˆ) + case serverDateTime = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS" + + /// MMM, yyyy + case MMMyyyy = "MMMM, yyyy" +} + +// MARK: - DateFormatter + +extension DateFormat { + private static var cachedFormatters: [String: DateFormatter] = [:] + + // MARK: - Public + + /// ๊ฐ DateFormat์— ๋”ฐ๋ฅธ formatter + /// + /// - ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•ด๋‘” ์ธ์Šคํ„ด์Šค๋ฅผ ์žฌ์‚ฌ์šฉํ•จ + /// - DateFormatter ์˜ ์ƒ์„ฑ ๋น„์šฉ์€ ๊ต‰์žฅํžˆ ๋น„์‹ธ์„œ ์žฌ์‚ฌ์šฉ ํ•˜๋Š” ๊ฒƒ์ด ํšจ์œจ์  + /// - DateFormatter๋Š” thread-safe ํ•˜๊ธฐ์— ์ „์—ญ์ ์œผ๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅ + var formatter: DateFormatter { + Self.cachedFormatter( + ofDateFormat: rawValue, + localeFormat: .korea + ) + } + + static func cachedFormatter( + ofDateFormat dateFormat: String, + localeFormat: LocaleFormat + ) -> DateFormatter { + if let cachedFormatter = DateFormat.cachedFormatters[dateFormat+localeFormat.rawValue] { return cachedFormatter + } + + let formatter = makeFormatter( + withDateFormat: dateFormat, + localeFormat: localeFormat + ) + + DateFormat.cachedFormatters[dateFormat+localeFormat.rawValue] = formatter + return formatter + } + + // MARK: - Private Methods + + private static func makeFormatter(withDateFormat dateFormat: String, localeFormat: LocaleFormat) -> DateFormatter { + let formatter = DateFormatter() + formatter.dateFormat = dateFormat + formatter.locale = Locale(identifier: localeFormat.rawValue) + + return formatter + } +} diff --git a/StopWatch/Core/Util/Extension/Foundation/Array+.swift b/StopWatch/Core/Util/Extension/Foundation/Array+.swift new file mode 100644 index 0000000..5ca9379 --- /dev/null +++ b/StopWatch/Core/Util/Extension/Foundation/Array+.swift @@ -0,0 +1,14 @@ +// +// Array+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/27/24. +// + +import Foundation + +extension Array { + public var isNotEmpty: Bool { + !isEmpty + } +} diff --git a/StopWatch/Core/Util/Extension/Foundation/AttrubutedString+.swift b/StopWatch/Core/Util/Extension/Foundation/AttrubutedString+.swift new file mode 100644 index 0000000..140079c --- /dev/null +++ b/StopWatch/Core/Util/Extension/Foundation/AttrubutedString+.swift @@ -0,0 +1,32 @@ +// +// AttrubutedString.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 9/17/24. +// + + +import Foundation +import SwiftUI + +extension AttributedString { + init?(html: String) { + guard let data = html.data(using: .utf8) else { + return nil + } + + let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [ + .documentType: NSAttributedString.DocumentType.html, + .characterEncoding: String.Encoding.utf8.rawValue + ] + + guard let attributedString = try? NSAttributedString( + data: data, + options: options, + documentAttributes: nil + ) else { return nil } + + + self.init(attributedString) + } +} diff --git a/StopWatch/Core/Util/Extension/Foundation/Binding+.swift b/StopWatch/Core/Util/Extension/Foundation/Binding+.swift new file mode 100644 index 0000000..b91bf9c --- /dev/null +++ b/StopWatch/Core/Util/Extension/Foundation/Binding+.swift @@ -0,0 +1,18 @@ +// +// Binding+.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/28/25. +// + +import SwiftUI + +// Binding์—์„œ Binding๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์ต์Šคํ…์…˜ +extension Binding { + init(_ source: Binding, default defaultValue: Value) { + self.init( + get: { source.wrappedValue ?? defaultValue }, + set: { source.wrappedValue = $0 } + ) + } +} diff --git a/StopWatch/Core/Util/Extension/Foundation/String+.swift b/StopWatch/Core/Util/Extension/Foundation/String+.swift new file mode 100644 index 0000000..8d0e749 --- /dev/null +++ b/StopWatch/Core/Util/Extension/Foundation/String+.swift @@ -0,0 +1,20 @@ +// +// String+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/27/24. +// + +import Foundation + +extension String { + public var isNotEmpty: Bool { + !isEmpty + } +} + +extension Substring { + public var asString: String { + String(self) + } +} diff --git a/StopWatch/Core/Util/Locale/LocaleFormat.swift b/StopWatch/Core/Util/Locale/LocaleFormat.swift new file mode 100644 index 0000000..3c144c8 --- /dev/null +++ b/StopWatch/Core/Util/Locale/LocaleFormat.swift @@ -0,0 +1,13 @@ +// +// LocaleFormat.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 12/15/24. +// + +import Foundation + +enum LocaleFormat: String { + case korea = "ko_KR" + case usa = "en_US" +} diff --git a/StopWatch/Core/ViewModelable/Reducable.swift b/StopWatch/Core/ViewModelable/Reducable.swift new file mode 100644 index 0000000..2664be0 --- /dev/null +++ b/StopWatch/Core/ViewModelable/Reducable.swift @@ -0,0 +1,18 @@ +// +// Reducable.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public protocol Reduceable: ObservableObject { + + associatedtype State + associatedtype Action + + var state: State { get set } + + func reduce(_ action: Action) +} diff --git a/StopWatch/Core/ViewModelable/ViewModelable.swift b/StopWatch/Core/ViewModelable/ViewModelable.swift new file mode 100644 index 0000000..1813686 --- /dev/null +++ b/StopWatch/Core/ViewModelable/ViewModelable.swift @@ -0,0 +1,57 @@ +// +// ViewModelable.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import Foundation + +/// MVI +public protocol ViewModelable: Reduceable, ObservableObject { + +} + +// MARK: - Example + +/* + class ExampleViewModel: ViewModelable { + + @Published var state: State = .init() + + struct State { + var count: Int = 0 + } + + enum Action { + case increased + } + + func reduce(_ action: Action) { + switch action { + case .increased: + state.count+=1 + } + } + } + + struct ExampleView: View { + @ObservedObject var viewModel: ExampleViewModel + + var body: some View { + VStack { + Text("\(viewModel.state.count)") + Button { + viewModel.reduce(.increased) + } label: { + Text("์ฆ๊ฐ€") + } + } + } + } + + #Preview { + ExampleView(viewModel: ExampleViewModel()) + } + + */ diff --git a/StopWatch/DesignSystem/Component/Alert/StopWatchAlertView.swift b/StopWatch/DesignSystem/Component/Alert/StopWatchAlertView.swift new file mode 100644 index 0000000..2f694b9 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Alert/StopWatchAlertView.swift @@ -0,0 +1,179 @@ +// +// StopWatchAlertView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/24/25. +// + +import SwiftUI + +struct StopWatchAlertView: View { + @State private var animation: Bool = false + + let title: String + let message: String? + var actions: [StopWatchActionView] = [] + var inputMessage: Binding? + + init( + title: String, + message: String?, + inputMessage: Binding? = nil + ) { + self.title = title + self.message = message + self.inputMessage = inputMessage + } + + var body: some View { + ZStack { + Color.getColor(.dim) + if animation { + VStack(spacing: .zero) { + Text(title) + .setTypo(.label1) + .foregroundStyle(Color.getColor(.text_strong)) + + if let message { + FixedSpacer(4) + Text(message) + .setTypo(.body2) + .multilineTextAlignment(.center) + .foregroundStyle(Color.getColor(.text_alternative)) + } + + if let inputMessage { + FixedSpacer(8) + TextField("", text: inputMessage) + .padding(.horizontal) + .padding(.vertical, 8) + .overlay(RoundedRectangle(cornerRadius: 8).stroke(Color.getColor(.line_assistive), lineWidth: 1)) + .setTypo(.label1) + } + FixedSpacer(20) + HStack(spacing: 8) { + ForEach(Array(0..Void)? + ) -> StopWatchAlertView { + + var new = self + let newAction = StopWatchActionView( + title: title, + style: style, + action: action + ) + + new.actions.append(newAction) + return new + } + + func addTextFieldAction( + title: String, + style: StopWatchActionView.ActionStyle, + action: (()->Void)? + ) -> StopWatchAlertView { + var new = self + let newAction = StopWatchActionView( + title: title, + style: style, + action: action + ) + + new.actions.append(newAction) + return new + } +} + +struct StopWatchActionView: View { + let title: String + let style: ActionStyle + let action: (()->Void)? + + var body: some View { + Button { + action?() + } label: { + Text(title) + .setTypo(.label1) + .foregroundStyle(style.foregroundColor) + .padding(8) + .frame(maxWidth: .infinity) + .background(style.backgroundColor) + .clipShape(.rect(cornerRadius: 8)) + } + } + + enum ActionStyle { + case cancel + case destructive + case primary + } +} + +extension StopWatchActionView.ActionStyle { + var foregroundColor: Color { + switch self { + case .cancel: + Color.getColor(.gray_alternative) + case .destructive: + Color.getColor(.white) + case .primary: + Color.getColor(.white) + } + } + + var backgroundColor: Color { + switch self { + case .cancel: + Color.getColor(.fill_normal) + case .destructive: + Color.getColor(.caution_normal) + case .primary: + Color.getColor(.gray_text) + } + } +} + +#Preview { + StopWatchAlertView( + title: "๋ชจ๋‹ฌ ์ œ๋ชฉ", + message: "์ผ์ด์‚ผ์‚ฌ์˜ค์œก์น ํŒ”๊ตฌ์‹ญ์ผ์ด์‚ผ" + ) + .addAction( + title: "์ทจ์†Œ", + style: .cancel, + action: nil + ) + .addAction(title: "๋‚˜๊ฐ€๊ธฐ", style: .primary, action: nil) +} diff --git a/StopWatch/DesignSystem/Component/Calendar/CalendarService.swift b/StopWatch/DesignSystem/Component/Calendar/CalendarService.swift new file mode 100644 index 0000000..7161fe5 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Calendar/CalendarService.swift @@ -0,0 +1,121 @@ +// +// CalendarService.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 12/15/24. +// + +import Foundation + +final class CalendarService { + var calendar = Calendar.current + + /// ํŠน์ • ํ•ด๋‹น ๋‚ ์งœ + func getDate(for index: Int, date: Date) -> Date { + guard let firstDayOfMonth = calendar.date( + from: DateComponents( + year: calendar.component(.year, from: date), + month: calendar.component(.month, from: date), + day: 1 + ) + ) else { + return Date() + } + + var dateComponents = DateComponents() + dateComponents.day = index + + let timeZone = TimeZone.current + let offset = Double(timeZone.secondsFromGMT(for: firstDayOfMonth)) + dateComponents.second = Int(offset) + + let date = calendar.date(byAdding: dateComponents, to: firstDayOfMonth) ?? Date() + return date + } + + /// ํ•ด๋‹น ์›”์— ์กด์žฌํ•˜๋Š” ์ผ์ž ์ˆ˜ + func numberOfDays(in date: Date) -> Int { + return Calendar.current.range(of: .day, in: .month, for: date)?.count ?? 0 + } + + /// ํ•ด๋‹น ์›”์˜ ์ฒซ ๋‚ ์งœ๊ฐ€ ๊ฐ–๋Š” ํ•ด๋‹น ์ฃผ์˜ ๋ช‡๋ฒˆ์งธ ์š”์ผ + func firstWeekdayOfMonth(in date: Date) -> Int { + let calendar = Calendar.current + let components = calendar.dateComponents([.year, .month], from: date) + let firstDayOfMonth = calendar.date(from: components)! + + return calendar.component(.weekday, from: firstDayOfMonth) + } + + /// ์ด์ „ ์›” ๋งˆ์ง€๋ง‰ ์ผ์ž + func previousMonth(date: Date) -> Date { + let components = Calendar.current.dateComponents([.year, .month], from: date) + let firstDayOfMonth = Calendar.current.date(from: components)! + let previousMonth = Calendar.current.date(byAdding: .month, value: -1, to: firstDayOfMonth)! + + return previousMonth + } + + /// ๋‹ค์Œ ์›” ๋งˆ์ง€๋ง‰ ์ผ์ž + func nextMonth(date: Date) -> Date { + let components = Calendar.current.dateComponents([.year, .month], from: date) + let firstDayOfMonth = Calendar.current.date(from: components)! + let nextMonth = Calendar.current.date(byAdding: .month, value: +1, to: firstDayOfMonth)! + + return nextMonth + } + + /// ์ด์ „ ์›”๋กœ ์ด๋™ ๊ฐ€๋Šฅํ•œ์ง€ ํ™•์ธ + func canMoveToPreviousMonth(date: Date) -> Bool { + let calendar = Calendar.current + let targetDate = calendar.date(byAdding: .month, value: -1, to: date) ?? date + + if adjustedMonth(by: -1, date: date) < targetDate { + return false + } + + return true + } + + /// ๋‹ค์Œ ์›”๋กœ ์ด๋™ ๊ฐ€๋Šฅํ•œ์ง€ ํ™•์ธ + func canMoveToNextMonth(date: Date) -> Bool { + let calendar = Calendar.current + let targetDate = calendar.date(byAdding: .month, value: 1, to: date) ?? date + + if adjustedMonth(by: 1, date: date) > targetDate { + return false + } + return true + } + + /// ๋ณ€๊ฒฝํ•˜๋ ค๋Š” ์›” ๋ฐ˜ํ™˜ + func adjustedMonth(by value: Int, date: Date) -> Date { + if let newMonth = Calendar.current.date(byAdding: .month, value: value, to: date) { + return newMonth + } + + return date + } + + /// ๋ณ€๊ฒฝํ•˜๋ ค๋Š” ์ผ ๋ฐ˜ํ™˜ + func adjustedDay(by value: Int, date: Date) -> Date { + if let newMonth = Calendar.current.date(byAdding: .day, value: value, to: date) { + return newMonth + } + + return date + } + + func getWeekDay(with date: Date, format: WeekdayFormat) -> String { + let weekDayRawValue = calendar.component(.weekday, from: date) + return format.values[weekDayRawValue-1] + } + + func getDay(with date: Date) -> Int { + Calendar.current.component(.day, from: date) + } + + func getMonth(with date: Date) -> Int { + Calendar.current.component(.month, from: date) + } +} diff --git a/StopWatch/DesignSystem/Component/Calendar/SWCalendarCell.swift b/StopWatch/DesignSystem/Component/Calendar/SWCalendarCell.swift new file mode 100644 index 0000000..7822931 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Calendar/SWCalendarCell.swift @@ -0,0 +1,43 @@ +// +// SWCalendarCell.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/26/24. +// + +import SwiftUI + +struct SWCalendarCell: View { + var day: Int + var clicked: Bool + var isToday: Bool + + var textColor: Color { + return Color.black + } + + var backgroundColor: Color { + return Color.white + } + + init( + day: Int, + clicked: Bool = false, + isToday: Bool = false + ) { + self.day = day + self.clicked = clicked + self.isToday = isToday + } + + var body: some View { + VStack(spacing: .zero) { + Text("\(day)") + .setTypo(.label2) + .foregroundStyle(textColor) + Spacer() + } + .frame(height: 56) + } +} + diff --git a/StopWatch/DesignSystem/Component/Calendar/SWCalendarView.swift b/StopWatch/DesignSystem/Component/Calendar/SWCalendarView.swift new file mode 100644 index 0000000..a87e180 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Calendar/SWCalendarView.swift @@ -0,0 +1,109 @@ +// +// SWCalendarView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/25/24. +// + +import SwiftUI + +struct SWCalendarView: View { + private let clendarService: CalendarService = CalendarService() + + @State var displayDate: Date + @State var selectedDate: Date + + var today: Date = .now + + var body: some View { + VStack(spacing: .zero) { + weekdaysSymbolsView + TabView { + calendarGridView(date: previousMonthDate) + calendarGridView(date: displayDate) + calendarGridView(date: nextMonthDate) + } + .tabViewStyle(.page) + .frame(height: 380) + } + } +} + +private extension SWCalendarView { + var previousMonthDate: Date { + let calendar = Calendar.current + return calendar.date(byAdding: .month, value: -1, to: displayDate) ?? displayDate + } + + var nextMonthDate: Date { + let calendar = Calendar.current + return calendar.date(byAdding: .month, value: 1, to: displayDate) ?? displayDate + } + + func isToday(_ compareDate: Date) -> Bool { + return Date.now.formattedString(by: .yyyyMMdd) == compareDate.formattedString(by: .yyyyMMdd) + } + + static let weekdaySymbols: [String] = ["์ผ","์›”","ํ™”","์ˆ˜","๋ชฉ","๊ธˆ","ํ† "] + + var weekdaysSymbolsView: some View { + HStack(spacing: .zero) { + ForEach(Self.weekdaySymbols.indices, id: \.self) { symbol in + Text(Self.weekdaySymbols[symbol].uppercased()) + .foregroundColor(Color.getColor(.text_assistive)) + .setTypo(.label3) + .frame(maxWidth: .infinity) + } + } + .padding(.bottom, 5) + } + + func calendarGridView(date: Date) -> some View { + let daysInMonth: Int = clendarService.numberOfDays(in: date) + let firstWeekday: Int = clendarService.firstWeekdayOfMonth(in: date) - 1 + let lastDayOfMonthBefore = clendarService.numberOfDays(in: clendarService.previousMonth(date: date)) + let numberOfRows = Int(ceil(Double(daysInMonth + firstWeekday) / 7.0)) + let visibleDaysOfNextMonth = numberOfRows * 7 - (daysInMonth + firstWeekday) + + return LazyVGrid(columns: Array(repeating: GridItem(), count: 7)) { + ForEach(-firstWeekday ..< daysInMonth + visibleDaysOfNextMonth, id: \.self) { index in + Group { + if index > -1 && index < daysInMonth { + let date = clendarService.getDate(for: index, date: date) + let day = Calendar.current.component(.day, from: date) + let isToday = isToday(date) + SWCalendarCell(day: day, clicked: false, isToday: isToday) + + } else if let _ = Calendar.current.date( + byAdding: .day, + value: index + lastDayOfMonthBefore, + to: clendarService.previousMonth(date: date) + ) { + // TODO: ์ด์ „, ์ดํ›„ ๋‹ฌ์˜ ์ผ ํ‘œ์‹œ ํ•˜๊ณ  ์‹ถ์œผ๋ฉด ์—ฌ๊ธฐ + Color.clear + .frame(height: 56) + } + } + .onTapGesture { + if 0 <= index && index < daysInMonth { + // let date = getDate(for: index) + // TODO: ์ถ”ํ›„ ํ•„์š”์‹œ ํด๋ฆญ์ฒ˜๋ฆฌ + } + } + } + } + } + + /// ์›” ๋ณ€๊ฒฝ + func changeMonth(by value: Int) { + self.displayDate = clendarService.adjustedMonth(by: value, date: displayDate) + } +} + +#Preview { + SWCalendarView( + displayDate: .now, + selectedDate: .now, + today: .now + ) +} diff --git a/StopWatch/DesignSystem/Component/Calendar/SWWeeklyCalendarView.swift b/StopWatch/DesignSystem/Component/Calendar/SWWeeklyCalendarView.swift new file mode 100644 index 0000000..6b324a3 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Calendar/SWWeeklyCalendarView.swift @@ -0,0 +1,150 @@ +// +// SWWeeklyCalendarView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 12/15/24. +// + +import SwiftUI + +struct SWWeeklyCalendarView: View { + private let calendarService = CalendarService() + @Binding var displayDate: Date? + @State var dates: [Date] = [] + @State var isPresentedModalCalendar: Bool = false + @State var isScrolling: Bool = false + + private var currentDate: Date { displayDate ?? .now } + + init(displayDate: Binding) { + self._displayDate = displayDate + } + + var body: some View { + VStack(spacing: .zero) { + ScrollViewReader { reader in + HStack(spacing: 8) { + Text(currentDate.formattedString(by: .MMMyyyy, local: .usa)) + .setTypo(.subTitle3) + .redacted(reason: .privacy) + .animation(.spring, value: displayDate) + } + .onTapGesture { + isPresentedModalCalendar = true + } + + FixedSpacer(20) + + ScrollView(.horizontal) { + LazyHStack(spacing: .zero) { + ForEach(dates, id: \.self) { date in + let symbol = calendarService.getWeekDay(with: date, format: .english_short) + let day = calendarService.getDay(with: date) + + Group { + if date.formattedString(by: .yyyyMM) == currentDate.formattedString(by: .yyyyMM) { + CalendarLargeCell( + day: day, + weekdaySymbol: symbol, + isSelected: displayDate?.formattedString(by: .yyyyMMdd) == date.formattedString(by: .yyyyMMdd) + ) + } else { + CalendarLargeCell(day: day, weekdaySymbol: symbol) + } + } + .onTapGesture { + withAnimation { + displayDate = date + } + } + .frame(width: UIScreen.main.bounds.width/5) + .scaleEffect( + getScale( + scalar: daysBetween(start: date, end: currentDate) + ) + ) + .opacity(date.formattedString(by: .yyyyMMdd) == currentDate.formattedString(by: .yyyyMMdd) ? 1.0 : 0.6) + .animation(.spring, value: displayDate) + .id(date.formattedString(by: .yyyyMMdd) + currentDate.formattedString(by: .yyyyMM)) + } + } + .scrollTargetLayout() + } + .scrollTargetBehavior(.viewAligned) + .scrollPosition(id: $displayDate, anchor: .center) + .scrollIndicators(.hidden) + .onScrollPhaseChange { oldPhas, newPhase in + if !newPhase.isScrolling { + let days = calendarService.numberOfDays(in: currentDate) + self.dates = (-7.. Int { + let calendar = Calendar.current + let startOfDay = calendar.startOfDay(for: start) + let endOfDay = calendar.startOfDay(for: end) + + let components = calendar.dateComponents([.day], from: startOfDay, to: endOfDay) + + return abs(components.day ?? 0) + } + + private func getScale(scalar: Int) -> CGFloat { + switch scalar { + case 0: 1 + case 1: 0.8 + case 2: 0.6 + case 3: 0.4 + default: 0.8 + } + } +} + +struct CalendarLargeCell: View { + var day: Int + var weekdaySymbol: String + var isSelected: Bool = false + + var body: some View { + VStack(spacing: 6) { + Text("\(day)") + .font(.pretendard(size: 46, weight: .semibold)) +// .frame(width: 30, height: 30) +// .background(isSelected ? .gray.opacity(0.3) : .clear) +// .clipShape(.circle) + + Text(weekdaySymbol) + .font(.pretendard(size: 16, weight: .regular)) + .foregroundStyle(Color.gray) + } + .foregroundStyle(Color.black) + } +} + +#Preview(body: { + SWWeeklyCalendarView(displayDate: .constant(.now)) +}) diff --git a/StopWatch/DesignSystem/Component/Calendar/SystemCalendarModalView.swift b/StopWatch/DesignSystem/Component/Calendar/SystemCalendarModalView.swift new file mode 100644 index 0000000..5efd3da --- /dev/null +++ b/StopWatch/DesignSystem/Component/Calendar/SystemCalendarModalView.swift @@ -0,0 +1,68 @@ +// +// SystemCalendarModalView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/28/25. +// + +import SwiftUI + +struct SystemCalendarModalView: View { + @State var selectedDate: Date + @Binding var isPresented: Bool + + var action: ((Date)->Void)? + + init( + selectedDate: Date = .now, + isPresented: Binding, + action: ((Date) -> Void)? = nil + ) { + self.selectedDate = selectedDate + self._isPresented = isPresented + self.action = action + } + + var body: some View { + VStack(spacing: .zero) { + HStack(spacing: .zero) { + Spacer() + Button { + isPresented = false + } label: { + Image(systemName: "xmark.circle.fill") + .resizable() + .frame(width: 22, height: 22) + .padding(4) + .foregroundStyle(Color.getColor(.gray_text)) + } + } + + DatePicker.init("", + selection: Binding( + get: { selectedDate }, + set: { didTappedDay(with: $0) } + ), + displayedComponents: [.date] + ) + .datePickerStyle(.graphical) + .labelsHidden() + .tint(Color.getColor(.gray_text)) + } + .padding() + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 16)) + .padding(.horizontal, 38) + } + + func didTappedDay(with date: Date) { + selectedDate = date + action?(selectedDate) + isPresented = false + } +} + +#Preview { + SystemCalendarModalView(isPresented: .constant(true)) +} + diff --git a/StopWatch/DesignSystem/Component/Calendar/WeekdayFormat.swift b/StopWatch/DesignSystem/Component/Calendar/WeekdayFormat.swift new file mode 100644 index 0000000..ac29728 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Calendar/WeekdayFormat.swift @@ -0,0 +1,32 @@ +// +// WeekdayFormat.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 12/15/24. +// + +import Foundation + +enum WeekdayFormat { + case korea_short + case korea_long + case english_short + case english_long + case custom([String]) + + var values: [String] { + switch self { + + case .korea_short: + ["์ผ","์›”","ํ™”","์ˆ˜","๋ชฉ","๊ธˆ","ํ† "] + case .korea_long: + ["์ผ์š”์ผ","์›”์š”์ผ","ํ™”์š”์ผ","์ˆ˜์š”์ผ","๋ชฉ์š”์ผ","๊ธˆ์š”์ผ","ํ† ์š”์ผ"] + case .english_short: + ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"] + case .english_long: + ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] + case .custom(let array): + array + } + } +} diff --git a/StopWatch/DesignSystem/Component/CircleProgressView/CircleProgressView.swift b/StopWatch/DesignSystem/Component/CircleProgressView/CircleProgressView.swift new file mode 100644 index 0000000..6da8c5a --- /dev/null +++ b/StopWatch/DesignSystem/Component/CircleProgressView/CircleProgressView.swift @@ -0,0 +1,116 @@ +// +// CircleProgressView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/24/24. +// + +import SwiftUI + +struct CircleProgressView: View { + var value: CGFloat = 0.0 + var size: CircleProgressSize = .s + + var body: some View { + ZStack { + Circle() + .stroke(lineWidth: size.lineWidth) + .frame(width: size.length, height: size.length) + .foregroundStyle(Color.white) + .shadow(color: .black.opacity(0.1), radius: 10, x: 10, y: 10) + Circle() + .stroke(lineWidth: 0.2) + .frame(width: size.length-size.lineWidth-1, height: size.length-size.lineWidth-1) + .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.black.opacity(0.3), .clear]), startPoint: .bottomTrailing, endPoint: .topLeading)) + .overlay { + Circle() + .stroke(.black.opacity(0.1), lineWidth: 2) + .blur(radius: 5) + .mask { + Circle() + .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.black, .clear]), startPoint: .topLeading, endPoint: .bottomTrailing)) + } + } + Circle() + .trim(from: 0, to: value) + .stroke(style: StrokeStyle(lineWidth: size.lineWidth, lineCap: .round)) + .frame(width: size.length, height: size.length) + .rotationEffect(.degrees(-90)) + .foregroundStyle(Color.getColor(.gray_text)) +// .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.purple, .blue]), startPoint: .topLeading, endPoint: .bottomTrailing)) + NumValue(displayedValue: value, color: Color.getColor(.text_normal), style: size) + } + } +} + +enum CircleProgressSize { + case xs + case s + case m + case l + case xl + + var length: CGFloat { + switch self { + case .xs: + 32 + case .s: + 80 + case .m: + 120 + case .l: + 160 + case .xl: + 200 + } + } + + var lineWidth: CGFloat { + switch self { + case .xs: + 4 + case .s: + 8 + case .m: + 12 + case .l: + 16 + case .xl: + 24 + } + } + + var font: Typography { + switch self { + case .xs: + return .caption3 + case .s: + return .label2 + case .m: + return .subTitle2 + case .l: + return .subTitle1 + case .xl: + return .title1 + } + } +} + +struct NumValue: View { + var displayedValue: CGFloat + var color: Color + var style: CircleProgressSize + + var body: some View { + Text("\(Int(displayedValue*100))%") + .setTypo(style.font) + } +} + +#Preview { + CircleProgressView(size: .xs) + CircleProgressView(size: .s) + CircleProgressView(size: .m) + CircleProgressView(size: .l) + CircleProgressView(size: .xl) +} diff --git a/StopWatch/DesignSystem/Component/FixedSpacer/FixedSpacer.swift b/StopWatch/DesignSystem/Component/FixedSpacer/FixedSpacer.swift new file mode 100644 index 0000000..744a370 --- /dev/null +++ b/StopWatch/DesignSystem/Component/FixedSpacer/FixedSpacer.swift @@ -0,0 +1,21 @@ +// +// FixedSpacer.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/27/24. +// + +import SwiftUI + +public struct FixedSpacer: View { + var size: CGFloat + + public init(_ size: CGFloat) { + self.size = size + } + + public var body: some View { + Spacer() + .frame(width: size, height: size) + } +} diff --git a/StopWatch/DesignSystem/Component/FlexibleHStack/FlexibleHStack.swift b/StopWatch/DesignSystem/Component/FlexibleHStack/FlexibleHStack.swift new file mode 100644 index 0000000..d735e35 --- /dev/null +++ b/StopWatch/DesignSystem/Component/FlexibleHStack/FlexibleHStack.swift @@ -0,0 +1,194 @@ +// +// FlexibleHStack.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 9/4/24. +// + +import SwiftUI + + +/// ์ˆ˜ํ‰์œผ๋กœ ์œ ์—ฐํ•˜๊ฒŒ ๋ฐฐ์น˜ํ•ด์ฃผ๋Š” HStack ๊ธฐ์กด HStack๊ณผ ๋‹ค๋ฅด๊ฒŒ ํ•„์š”์‹œ์— ๋‹ค์Œ ๋ผ์ธ์œผ๋กœ ๋„˜์–ด๊ฐ +public struct FlexibleHStack: Layout { + + /* + Layoutํ”„๋กœํ† ์ฝœ์€ ์ปจํ…Œ์ด๋„ˆ๋ทฐ์˜ ๊ธฐํ•˜ํ•™์„ ์ •์˜ํ•˜๋Š” ํ”„๋กœํ† ์ฝœ์ž„ ( ์œ„์น˜, ํฌ๊ธฐ ์ •๋ณด ๋“ฑ ) + HStack, Grid ๋“ฑ ๋ณด๋‹ค ๋” ์ปค์Šคํ…€ํ•œ ๊ธฐ๋Šฅ์„ ์›ํ• ๋•Œ ์ง์ ‘ ์ฑ„ํƒํ•˜์—ฌ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Œ + sizeThatFits, placeSubviews ๋ฉ”์†Œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•ด์•ผํ•จ + */ + + // MARK: - Properties + + /// ์ •๋ ฌ์„ ๋‚˜ํƒ€๋ƒ„ + var alignment: Alignment = .leading + + /// ์ˆ˜ํ‰ ์ŠคํŽ˜์ด์‹ฑ + public var horizontalSpacing: CGFloat = 8 + + /// ์ˆ˜์ง ์ŠคํŽ˜์ด์‹ฑ + public var verticalSpacing: CGFloat = 8 + + /// `true`: ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ตœ๋Œ€ ๋„“์ด ๊ณต๊ฐ„์„ ์‚ฌ์šฉ + /// `false`: ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๋‚ด๋ถ€ ๋ทฐ ํฌ๊ธฐ์— ๋งž๊ฒŒ ๋„“์ด ๊ณต๊ฐ„์„ ์‚ฌ์šฉ + public var isContainerFullWidth: Bool = true + + /// ์ปจํ…Œ์ด๋„ˆ๋ทฐ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ๊ฒฐ์ •ํ•จ + public func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout Cache) -> CGSize { + let Rows = arrangeRows(proposal: proposal, subviews: subviews, cache: &cache) + + if Rows.isEmpty { return cache.minSize } + + var width: CGFloat = Rows.map { $0.width }.reduce(.zero) { max($0, $1) } + + if isContainerFullWidth, let proposalWidth = proposal.width { + width = max(width, proposalWidth) + } + + var height: CGFloat = .zero + if let lastRow = Rows.last { + height = lastRow.yOffset + lastRow.height + } + + return CGSize(width: width, height: height) + } + + /// ์ปจํ…Œ์ด๋„ˆ ํ•˜์œ„๋ทฐ์˜ ํฌ๊ธฐ์™€ ์œ„์น˜๋ฅผ ์ง€์ •ํ•จ + public func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout Cache) { + let rows = arrangeRows(proposal: proposal, subviews: subviews, cache: &cache) + + let anchor = UnitPoint(alignment) + + for row in rows { + for item in row.items { + let x: CGFloat = item.xOffset + anchor.x * (bounds.width - row.width) + let y: CGFloat = row.yOffset + anchor.y * (row.height - item.size.height) + let point = CGPoint(x: x + bounds.minX, y: y + bounds.minY) + + subviews[item.index].place(at: point, anchor: .topLeading, proposal: proposal) + } + } + } + + + // MARK: - Cache + + public struct Cache { + + /// ์ปจํ…Œ์ด๋„ˆ๋ทฐ์˜ ์ตœ์†Œํฌ๊ธฐ + var minSize: CGSize + + /// ์บ์‹ฑ๋œ ์•„์ดํ…œ + var rows: (Int, [Row])? + } + + public func makeCache(subviews: Subviews) -> Cache { + Cache(minSize: minSize(subviews: subviews)) + } + + + // MARK: - Row + + struct Row { + typealias Item = (index: Int, size: CGSize, xOffset: CGFloat) + + var items: [Item] = [] + var yOffset: CGFloat = .zero + var width: CGFloat = .zero + var height: CGFloat = .zero + } + +} + +private extension FlexibleHStack { + func computeHash(proposal: ProposedViewSize, sizes: [CGSize]) -> Int { + let proposal = proposal.replacingUnspecifiedDimensions(by: .init(width: CGFloat.infinity, height: CGFloat.infinity)) + + var hasher = Hasher() + + for size in [proposal] + sizes { + hasher.combine(size.width) + hasher.combine(size.height) + } + + return hasher.finalize() + } + + func minSize(subviews: Subviews) -> CGSize { + subviews + .map { $0.sizeThatFits(.zero) } + .reduce(CGSize.zero) { CGSize(width: max($0.width, $1.width), height: max($0.height, $1.height)) } + } + + func arrangeRows( + proposal: ProposedViewSize, + subviews: Subviews, + cache: inout Cache + ) -> [Row] { + if subviews.isEmpty { + return [] + } + + if cache.minSize.width > proposal.width ?? .infinity, + cache.minSize.height > proposal.height ?? .infinity { + return [] + } + + let sizes = subviews.map { $0.sizeThatFits(proposal) } + + let hash = computeHash(proposal: proposal, sizes: sizes) + if let (oldHash, oldRows) = cache.rows, + oldHash == hash { + return oldRows + } + + var currentX = CGFloat.zero + var curentRow = Row() + var rows = [Row]() + + for index in subviews.indices { + + let size = sizes[index] + + if currentX + size.width + horizontalSpacing > proposal.width ?? .infinity, + curentRow.items.isNotEmpty { + curentRow.width = currentX + rows.append(curentRow) + curentRow = Row() + currentX = .zero + } + + curentRow.items.append((index, sizes[index], currentX + horizontalSpacing)) + currentX += size.width + horizontalSpacing + } + + if curentRow.items.isNotEmpty { + curentRow.width = currentX + rows.append(curentRow) + } + + var currentY = CGFloat.zero + var previousMaxHeightIndex: Int? + + for index in rows.indices { + let maxHeightIndex = rows[index].items + .max { $0.size.height < $1.size.height }! + .index + + let size = sizes[maxHeightIndex] + + var spacing = CGFloat.zero + if let _ = previousMaxHeightIndex { + spacing = verticalSpacing + } + + rows[index].yOffset = currentY + spacing + currentY += size.height + spacing + rows[index].height = size.height + previousMaxHeightIndex = maxHeightIndex + } + + cache.rows = (hash, rows) + + return rows + } +} diff --git a/StopWatch/DesignSystem/Component/FlexibleHStack/UnitPoint+.swift b/StopWatch/DesignSystem/Component/FlexibleHStack/UnitPoint+.swift new file mode 100644 index 0000000..db32c74 --- /dev/null +++ b/StopWatch/DesignSystem/Component/FlexibleHStack/UnitPoint+.swift @@ -0,0 +1,33 @@ +// +// UnitPoint+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 9/4/24. +// + +import SwiftUI + +extension UnitPoint { + init(_ alignment: Alignment) { + switch alignment { + case .leading: + self = .leading + case .topLeading: + self = .topLeading + case .top: + self = .top + case .topTrailing: + self = .topTrailing + case .trailing: + self = .trailing + case .bottomTrailing: + self = .bottomTrailing + case .bottom: + self = .bottom + case .bottomLeading: + self = .bottomLeading + default: + self = .center + } + } +} diff --git a/StopWatch/DesignSystem/Component/InfinityFlipToast/InfiniteFlipToast.swift b/StopWatch/DesignSystem/Component/InfinityFlipToast/InfiniteFlipToast.swift new file mode 100644 index 0000000..3f57a16 --- /dev/null +++ b/StopWatch/DesignSystem/Component/InfinityFlipToast/InfiniteFlipToast.swift @@ -0,0 +1,33 @@ +// +// InfiniteFlipToast.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct InfiniteFlipToast: View { + @State var message: String + @State private var rotationAngle: Double = 0 + @State private var opacityValue: Double = 1.0 + + var body: some View { + Text(message) + .padding(.vertical, 8) + .padding(.horizontal, 16) + .setTypo(.body2) + .background(Color.getColor(.background_primary)) + .clipShape(.capsule) + .opacity(opacityValue) + .rotation3DEffect(.degrees(rotationAngle), axis: (x: 1, y: 0, z: 0)) + .onAppear { + withAnimation(Animation.linear(duration: 2).repeatForever(autoreverses: true)) { + rotationAngle = 180 + } + withAnimation(Animation.easeInOut(duration: 2).repeatForever(autoreverses: true)) { + opacityValue = 0.5 + } + } + } +} diff --git a/StopWatch/DesignSystem/Component/NewTodo/NewTodoView.swift b/StopWatch/DesignSystem/Component/NewTodo/NewTodoView.swift new file mode 100644 index 0000000..35331c8 --- /dev/null +++ b/StopWatch/DesignSystem/Component/NewTodo/NewTodoView.swift @@ -0,0 +1,247 @@ +// +// NewTodoView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/24/24. +// + +import SwiftUI + +struct NewTodoView: View { + + @Namespace var animation + @FocusState var isTyping: Bool + + @State var text: String = "" + @Binding var show: Bool + + @State var selectedCategory: Category? + @State var selectedDate: Date? = .now + @State var isPresentedCalendar: Bool = false + + let categoryList: [Category] + var didTapAdd: (Todo) -> Void + var didTapAddCategory: (()->Void)? + + var body: some View { + VStack(spacing: .zero) { + ZStack(alignment: show ? .topLeading : .center) { + RoundedRectangle(cornerRadius: show ? 24 : 40) + .foregroundStyle(Color.getColor(.gray_text)) + + VStack(alignment: .leading) { + if show { + editNewTodoView + } else { + addTodoView + } + } + .frame(maxWidth: .infinity, alignment: show ? .leading : .center) + } + + if show { + FixedSpacer(12) + addButton + } + } + .frame(height: show ? 280: 50) + .padding(.horizontal, show ? 16: 16) + .clipped() + .overlay { + if isPresentedCalendar { + SystemCalendarModalView( + selectedDate: selectedDate ?? .now, + isPresented: $isPresentedCalendar + ) { + selectedDate = $0 + } + .offset(y: -100) + } + } + .animation(.easeInOut, value: isPresentedCalendar) + .animation(.spring, value: show) + } +} + +private extension NewTodoView { + // MARK: - Add TodoView + var addTodoView: some View { + Text("New Todo") + .setTypo(.label2) + .foregroundStyle(Color.white) + .matchedGeometryEffect(id: "text", in: animation) + .onTapGesture { + show = true + } + } + + + // MARK: - Edit TodoView + var editNewTodoView: some View { + VStack(spacing: .zero) { + HStack(spacing: .zero) { + Spacer() + Button { + withAnimation { + resetData() + } + } label: { + Image(systemName: "xmark.circle.fill") + .resizable() + .frame(width: 20, height: 20) + .foregroundStyle(Color.white) + .padding([.top, .trailing]) + } + } + + ZStack(alignment: .topLeading) { + TextEditor(text: $text) + .focused($isTyping) + .foregroundStyle(Color.white) + .scrollContentBackground(.hidden) + if !isTyping { + Text("\(Image(systemName: "pencil")) What to do?") + .foregroundStyle(Color.init(hex: "F4F4E4") ?? .white) + .padding(.top, 8) + .fixedSize(horizontal: true, vertical: false) + .matchedGeometryEffect(id: "text", in: animation) + } + } + .setTypo(.label2) + .padding([.bottom, .horizontal]) + + Spacer() + Divider() + .hSpacing() + .background(Color.white) + .padding(.horizontal, 24) + .foregroundStyle(Color.white) + + VStack(spacing: 12) { + selectCategoryView + selectedDateView + } + .padding(.horizontal, 24) + .padding(.vertical, 12) + } + } + + var addButton: some View { + Button { + guard selectedCategory != nil else { return } + let newTodo = Todo(date: selectedDate, content: text, category: selectedCategory) + didTapAdd(newTodo) + resetData() + } label: { + Text("Add") + .hSpacing(alignment: .center) + .padding() + .background(Color.getColor(.gray_text)) + .opacity(selectedCategory != nil ? 1 : 0.7) + .clipShape(.rect(cornerRadius: 24)) + .foregroundStyle(Color.getColor(.white)) + .animation(.spring, value: selectedCategory) + } + } + + // MARK: - Select Category + var selectCategoryView: some View { + HStack(spacing: .zero) { + Menu { + Button { + didTapAddCategory?() + } label: { + Text("์นดํ…Œ๊ณ ๋ฆฌ ์ถ”๊ฐ€") + } + + ForEach(categoryList, id: \.id) { category in + Button { + selectedCategory = category + } label: { + Text(category.name) + } + } + } label: { + Text(selectedCategory?.name ?? "+ Category") + .setTypo(.label2) + .padding(.vertical, 4) + .padding(.horizontal, 12) + .background(selectedCategory != nil ? Color.getColor(.background_primary) : .clear) + .roundedBorder(selectedCategory != nil ? .clear : Color.getColor(.background_primary), radius: 14, linewidth: 1) + .foregroundStyle(selectedCategory != nil ? Color.getColor(.gray_text) : .white) + .overlay(alignment: .topTrailing) { + Text("*") + .foregroundStyle(Color.red) + .offset(x: 5,y: -6) + } + } + Spacer() + } + .foregroundStyle(Color.white) + } + + + // MARK: - Select Date + @ViewBuilder var selectedDateView: some View { + HStack(spacing: .zero) { + Button { + withAnimation { + if selectedDate == nil { + selectedDate = .now + } + + isPresentedCalendar = true + } + } label: { + Text(selectedDate?.formattedString(by: .yyyyMMddEEEKorean) ?? "+ Date") + .setTypo(.label2) + .padding(.vertical, 4) + .padding(.horizontal, 12) + .background(selectedDate != nil ? Color.getColor(.background_primary) : .clear) + .roundedBorder(selectedDate != nil ? .clear : Color.getColor(.background_primary), radius: 14, linewidth: 1) + .foregroundStyle(selectedDate != nil ? Color.getColor(.gray_text) : .white) + } + .onChange(of: selectedDate) { oldValue, newValue in + isPresentedCalendar = false + } + + if selectedDate != nil { + FixedSpacer(8) + Button { + withAnimation { + selectedDate = nil + } + } label: { + Image(systemName: "xmark.circle.fill") + .resizable() + .frame(width: 22, height: 22) + .foregroundStyle(Color.getColor(.fill_disable)) + } + } + + Spacer() + } + } +} + +// MARK: - Private Method +private extension NewTodoView { + func resetData() { + text = "" + selectedDate = .now + selectedCategory = .none + show = false + } +} + +#Preview { + NewTodoView( + show: .constant(true), + categoryList: [ + .englishMock, + .exerciseMock, + .programmingMock + ], + didTapAdd: { _ in + }) +} diff --git a/StopWatch/DesignSystem/Component/PanModal/Animator/PanModalAnimator.swift b/StopWatch/DesignSystem/Component/PanModal/Animator/PanModalAnimator.swift new file mode 100644 index 0000000..712dd5d --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Animator/PanModalAnimator.swift @@ -0,0 +1,40 @@ +// +// PanModalAnimator.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + Helper animation function to keep animations consistent. + */ +struct PanModalAnimator { + + /** + Constant Animation Properties + */ + struct Constants { + static let defaultTransitionDuration: TimeInterval = 0.5 + } + + static func animate(_ animations: @escaping PanModalPresentable.AnimationBlockType, + config: PanModalPresentable?, + _ completion: PanModalPresentable.AnimationCompletionType? = nil) { + + let transitionDuration = config?.transitionDuration ?? Constants.defaultTransitionDuration + let springDamping = config?.springDamping ?? 1.0 + let animationOptions = config?.transitionAnimationOptions ?? [] + + UIView.animate(withDuration: transitionDuration, + delay: 0, + usingSpringWithDamping: springDamping, + initialSpringVelocity: 0, + options: animationOptions, + animations: animations, + completion: completion) + } +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Animator/PanModalPresentationAnimator.swift b/StopWatch/DesignSystem/Component/PanModal/Animator/PanModalPresentationAnimator.swift new file mode 100644 index 0000000..f7fbdd0 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Animator/PanModalPresentationAnimator.swift @@ -0,0 +1,172 @@ +// +// PanModalPresentationAnimator.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + Handles the animation of the presentedViewController as it is presented or dismissed. + + This is a vertical animation that + - Animates up from the bottom of the screen + - Dismisses from the top to the bottom of the screen + + This can be used as a standalone object for transition animation, + but is primarily used in the PanModalPresentationDelegate for handling pan modal transitions. + + - Note: The presentedViewController can conform to PanModalPresentable to adjust + it's starting position through manipulating the shortFormHeight + */ + +public class PanModalPresentationAnimator: NSObject { + + /** + Enum representing the possible transition styles + */ + public enum TransitionStyle { + case presentation + case dismissal + } + + // MARK: - Properties + + /** + The transition style + */ + private let transitionStyle: TransitionStyle + + /** + Haptic feedback generator (during presentation) + */ + private var feedbackGenerator: UISelectionFeedbackGenerator? + + // MARK: - Initializers + + required public init(transitionStyle: TransitionStyle) { + self.transitionStyle = transitionStyle + super.init() + + /** + Prepare haptic feedback, only during the presentation state + */ + if case .presentation = transitionStyle { + feedbackGenerator = UISelectionFeedbackGenerator() + feedbackGenerator?.prepare() + } + } + + /** + Animate presented view controller presentation + */ + private func animatePresentation(transitionContext: UIViewControllerContextTransitioning) { + + guard + let toVC = transitionContext.viewController(forKey: .to), + let fromVC = transitionContext.viewController(forKey: .from) + else { return } + + let presentable = panModalLayoutType(from: transitionContext) + + // Calls viewWillAppear and viewWillDisappear + fromVC.beginAppearanceTransition(false, animated: true) + + // Presents the view in shortForm position, initially + let yPos: CGFloat = presentable?.shortFormYPos ?? 0.0 + + // Use panView as presentingView if it already exists within the containerView + let panView: UIView = transitionContext.containerView.panContainerView ?? toVC.view + + // Move presented view offscreen (from the bottom) + panView.frame = transitionContext.finalFrame(for: toVC) + panView.frame.origin.y = transitionContext.containerView.frame.height + + // Haptic feedback + if presentable?.isHapticFeedbackEnabled == true { + feedbackGenerator?.selectionChanged() + } + + PanModalAnimator.animate({ + panView.frame.origin.y = yPos + }, config: presentable) { [weak self] didComplete in + // Calls viewDidAppear and viewDidDisappear + fromVC.endAppearanceTransition() + transitionContext.completeTransition(didComplete) + self?.feedbackGenerator = nil + } + } + + /** + Animate presented view controller dismissal + */ + private func animateDismissal(transitionContext: UIViewControllerContextTransitioning) { + + guard + let toVC = transitionContext.viewController(forKey: .to), + let fromVC = transitionContext.viewController(forKey: .from) + else { return } + + // Calls viewWillAppear and viewWillDisappear + toVC.beginAppearanceTransition(true, animated: true) + + let presentable = panModalLayoutType(from: transitionContext) + let panView: UIView = transitionContext.containerView.panContainerView ?? fromVC.view + + PanModalAnimator.animate({ + panView.frame.origin.y = transitionContext.containerView.frame.height + }, config: presentable) { didComplete in + fromVC.view.removeFromSuperview() + // Calls viewDidAppear and viewDidDisappear + toVC.endAppearanceTransition() + transitionContext.completeTransition(didComplete) + } + } + + /** + Extracts the PanModal from the transition context, if it exists + */ + private func panModalLayoutType(from context: UIViewControllerContextTransitioning) -> PanModalPresentable.LayoutType? { + switch transitionStyle { + case .presentation: + return context.viewController(forKey: .to) as? PanModalPresentable.LayoutType + case .dismissal: + return context.viewController(forKey: .from) as? PanModalPresentable.LayoutType + } + } + +} + +// MARK: - UIViewControllerAnimatedTransitioning Delegate + +extension PanModalPresentationAnimator: UIViewControllerAnimatedTransitioning { + + /** + Returns the transition duration + */ + public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + + guard + let context = transitionContext, + let presentable = panModalLayoutType(from: context) + else { return PanModalAnimator.Constants.defaultTransitionDuration } + + return presentable.transitionDuration + } + + /** + Performs the appropriate animation based on the transition style + */ + public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { + switch transitionStyle { + case .presentation: + animatePresentation(transitionContext: transitionContext) + case .dismissal: + animateDismissal(transitionContext: transitionContext) + } + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Configure/PanModalWrapper.swift b/StopWatch/DesignSystem/Component/PanModal/Configure/PanModalWrapper.swift new file mode 100644 index 0000000..02b5e1e --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Configure/PanModalWrapper.swift @@ -0,0 +1,67 @@ +// +// PanModalWrapper.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/6/24. +// + +import SwiftUI + +public class PanModalWrapper: UIHostingController { + + private let minHeight: CGFloat? + private let maxHeight: CGFloat? + private let radius: CGFloat + + public init( + minHeight: CGFloat?, + maxHeight: CGFloat?, + backgroundColor: UIColor = .white, + radius: CGFloat, + @ViewBuilder content: () -> Content) + { + self.minHeight = minHeight + self.maxHeight = maxHeight + self.radius = radius + super.init(rootView: content()) + self.view.backgroundColor = backgroundColor + } + + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + +extension PanModalWrapper: PanModalPresentable { + public var panScrollable: UIScrollView? { + .none + } + + public var shortFormHeight: PanModalHeight { + if let minHeight { + .contentHeight(minHeight) + } else { + .intrinsicHeight + } + } + + public var longFormHeight: PanModalHeight { + if let maxHeight { + .contentHeight(maxHeight) + } else { + .intrinsicHeight + } + } + + public var showDragIndicator: Bool { + false + } + + public var springDamping: CGFloat { + 1.0 + } + + public var cornerRadius: CGFloat { + radius + } +} diff --git a/StopWatch/DesignSystem/Component/PanModal/Configure/View+PanModal.swift b/StopWatch/DesignSystem/Component/PanModal/Configure/View+PanModal.swift new file mode 100644 index 0000000..8aecce4 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Configure/View+PanModal.swift @@ -0,0 +1,37 @@ +// +// View+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/6/24. +// + +import SwiftUI + +public extension View { + func panModal( + minHeight: CGFloat? = 552, + maxHeight: CGFloat? = 552, + radius: CGFloat = 24 + ) -> PanModalWrapper { + PanModalWrapper( + minHeight: minHeight, + maxHeight: maxHeight, + radius: radius + ) { + self + } + } + + func panModal( + height: CGFloat? = 552, + radius: CGFloat = 24 + ) -> PanModalWrapper { + PanModalWrapper( + minHeight: height, + maxHeight: height, + radius: radius + ) { + self + } + } +} diff --git a/StopWatch/DesignSystem/Component/PanModal/Controller/PanModalPresentationController.swift b/StopWatch/DesignSystem/Component/PanModal/Controller/PanModalPresentationController.swift new file mode 100644 index 0000000..a8d28e4 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Controller/PanModalPresentationController.swift @@ -0,0 +1,895 @@ +// +// PanModalPresentationController.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + The PanModalPresentationController is the middle layer between the presentingViewController + and the presentedViewController. + + It controls the coordination between the individual transition classes as well as + provides an abstraction over how the presented view is presented & displayed. + + For example, we add a drag indicator view above the presented view and + a background overlay between the presenting & presented view. + + The presented view's layout configuration & presentation is defined using the PanModalPresentable. + + By conforming to the PanModalPresentable protocol & overriding values + the presented view can define its layout configuration & presentation. + */ +open class PanModalPresentationController: UIPresentationController { + + /** + Enum representing the possible presentation states + */ + public enum PresentationState { + case shortForm + case longForm + } + + /** + Constants + */ + struct Constants { + static let indicatorYOffset = CGFloat(8.0) + static let snapMovementSensitivity = CGFloat(0.7) + static let dragIndicatorSize = CGSize(width: 36.0, height: 5.0) + } + + // MARK: - Properties + + /** + A flag to track if the presented view is animating + */ + private var isPresentedViewAnimating = false + + /** + A flag to determine if scrolling should seamlessly transition + from the pan modal container view to the scroll view + once the scroll limit has been reached. + */ + private var extendsPanScrolling = true + + /** + A flag to determine if scrolling should be limited to the longFormHeight. + Return false to cap scrolling at .max height. + */ + private var anchorModalToLongForm = true + + /** + The y content offset value of the embedded scroll view + */ + private var scrollViewYOffset: CGFloat = 0.0 + + /** + An observer for the scroll view content offset + */ + private var scrollObserver: NSKeyValueObservation? + + // store the y positions so we don't have to keep re-calculating + + /** + The y value for the short form presentation state + */ + private var shortFormYPosition: CGFloat = 0 + + /** + The y value for the long form presentation state + */ + private var longFormYPosition: CGFloat = 0 + + /** + Determine anchored Y postion based on the `anchorModalToLongForm` flag + */ + private var anchoredYPosition: CGFloat { + let defaultTopOffset = presentable?.topOffset ?? 0 + return anchorModalToLongForm ? longFormYPosition : defaultTopOffset + } + + /** + Configuration object for PanModalPresentationController + */ + private var presentable: PanModalPresentable? { + return presentedViewController as? PanModalPresentable + } + + // MARK: - Views + + /** + Background view used as an overlay over the presenting view + */ + private lazy var backgroundView: DimmedView = { + let view: DimmedView + if let color = presentable?.panModalBackgroundColor { + view = DimmedView(dimColor: color) + } else { + view = DimmedView() + } + view.didTap = { [weak self] _ in + if self?.presentable?.allowsTapToDismiss == true { + self?.presentedViewController.dismiss(animated: true) + } + } + return view + }() + + /** + A wrapper around the presented view so that we can modify + the presented view apperance without changing + the presented view's properties + */ + private lazy var panContainerView: PanContainerView = { + let frame = containerView?.frame ?? .zero + return PanContainerView(presentedView: presentedViewController.view, frame: frame) + }() + + /** + Drag Indicator View + */ + private lazy var dragIndicatorView: UIView = { + let view = UIView() + view.backgroundColor = presentable?.dragIndicatorBackgroundColor + view.layer.cornerRadius = Constants.dragIndicatorSize.height / 2.0 + return view + }() + + /** + Override presented view to return the pan container wrapper + */ + public override var presentedView: UIView { + return panContainerView + } + + // MARK: - Gesture Recognizers + + /** + Gesture recognizer to detect & track pan gestures + */ + private lazy var panGestureRecognizer: UIPanGestureRecognizer = { + let gesture = UIPanGestureRecognizer(target: self, action: #selector(didPanOnPresentedView(_ :))) + gesture.minimumNumberOfTouches = 1 + gesture.maximumNumberOfTouches = 1 + gesture.delegate = self + return gesture + }() + + // MARK: - Deinitializers + + deinit { + scrollObserver?.invalidate() + } + + // MARK: - Lifecycle + + override public func containerViewWillLayoutSubviews() { + super.containerViewWillLayoutSubviews() + configureViewLayout() + } + + override public func presentationTransitionWillBegin() { + + guard let containerView = containerView + else { return } + if self.panContainerView.frame == .zero { + self.adjustPresentedViewFrame() + + } + layoutBackgroundView(in: containerView) + layoutPresentedView(in: containerView) + configureScrollViewInsets() + + guard let coordinator = presentedViewController.transitionCoordinator else { + backgroundView.dimState = .max + return + } + + coordinator.animate(alongsideTransition: { [weak self] _ in + self?.backgroundView.dimState = .max + self?.presentedViewController.setNeedsStatusBarAppearanceUpdate() + }) + } + + override public func presentationTransitionDidEnd(_ completed: Bool) { + if completed { return } + + backgroundView.removeFromSuperview() + } + + override public func dismissalTransitionWillBegin() { + presentable?.panModalWillDismiss() + + guard let coordinator = presentedViewController.transitionCoordinator else { + backgroundView.dimState = .off + return + } + + /** + Drag indicator is drawn outside of view bounds + so hiding it on view dismiss means avoiding visual bugs + */ + coordinator.animate(alongsideTransition: { [weak self] _ in + self?.dragIndicatorView.alpha = 0.0 + self?.backgroundView.dimState = .off + self?.presentingViewController.setNeedsStatusBarAppearanceUpdate() + }) + } + + override public func dismissalTransitionDidEnd(_ completed: Bool) { + if !completed { return } + + presentable?.panModalDidDismiss() + } + + /** + Update presented view size in response to size class changes + */ + override public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + coordinator.animate(alongsideTransition: { [weak self] _ in + guard + let self = self, + let presentable = self.presentable + else { return } + + self.adjustPresentedViewFrame() + if presentable.shouldRoundTopCorners { + self.addRoundedCorners(to: self.presentedView) + } + }) + } + +} + +// MARK: - Public Methods + +public extension PanModalPresentationController { + + /** + Transition the PanModalPresentationController + to the given presentation state + */ + func transition(to state: PresentationState) { + + guard presentable?.shouldTransition(to: state) == true + else { return } + + presentable?.willTransition(to: state) + + switch state { + case .shortForm: + snap(toYPosition: shortFormYPosition) + case .longForm: + snap(toYPosition: longFormYPosition) + } + } + + /** + Operations on the scroll view, such as content height changes, + or when inserting/deleting rows can cause the pan modal to jump, + caused by the pan modal responding to content offset changes. + + To avoid this, you can call this method to perform scroll view updates, + with scroll observation temporarily disabled. + */ + func performUpdates(_ updates: () -> Void) { + + guard let scrollView = presentable?.panScrollable + else { return } + + // Pause scroll observer + scrollObserver?.invalidate() + scrollObserver = nil + + // Perform updates + updates() + + // Resume scroll observer + trackScrolling(scrollView) + observe(scrollView: scrollView) + } + + /** + Updates the PanModalPresentationController layout + based on values in the PanModalPresentable + + - Note: This should be called whenever any + pan modal presentable value changes after the initial presentation + */ + func setNeedsLayoutUpdate() { + configureViewLayout() + adjustPresentedViewFrame() + observe(scrollView: presentable?.panScrollable) + configureScrollViewInsets() + } + +} + +// MARK: - Presented View Layout Configuration + +private extension PanModalPresentationController { + + /** + Boolean flag to determine if the presented view is anchored + */ + var isPresentedViewAnchored: Bool { + if !isPresentedViewAnimating + && extendsPanScrolling + && presentedView.frame.minY.rounded() <= anchoredYPosition.rounded() { + return true + } + + return false + } + + /** + Adds the presented view to the given container view + & configures the view elements such as drag indicator, rounded corners + based on the pan modal presentable. + */ + func layoutPresentedView(in containerView: UIView) { + + /** + If the presented view controller does not conform to pan modal presentable + don't configure + */ + guard let presentable = presentable + else { return } + + /** + โš ๏ธ If this class is NOT used in conjunction with the PanModalPresentationAnimator + & PanModalPresentable, the presented view should be added to the container view + in the presentation animator instead of here + */ + containerView.addSubview(presentedView) + containerView.addGestureRecognizer(panGestureRecognizer) + + if presentable.showDragIndicator { + addDragIndicatorView(to: presentedView) + } + + if presentable.shouldRoundTopCorners { + addRoundedCorners(to: presentedView) + } + + setNeedsLayoutUpdate() + adjustPanContainerBackgroundColor() + } + + /** + Reduce height of presentedView so that it sits at the bottom of the screen + */ + func adjustPresentedViewFrame() { + + guard let frame = containerView?.frame + else { return } + + let adjustedSize = CGSize(width: frame.size.width, height: frame.size.height - anchoredYPosition) + let panFrame = panContainerView.frame + panContainerView.frame.size = frame.size + + if ![shortFormYPosition, longFormYPosition].contains(panFrame.origin.y) { + // if the container is already in the correct position, no need to adjust positioning + // (rotations & size changes cause positioning to be out of sync) + let yPosition = panFrame.origin.y - panFrame.height + frame.height + presentedView.frame.origin.y = max(yPosition, anchoredYPosition) + } + panContainerView.frame.origin.x = frame.origin.x + presentedViewController.view.frame = CGRect(origin: .zero, size: adjustedSize) + } + + /** + Adds a background color to the pan container view + in order to avoid a gap at the bottom + during initial view presentation in longForm (when view bounces) + */ + func adjustPanContainerBackgroundColor() { + panContainerView.backgroundColor = presentedViewController.view.backgroundColor + ?? presentable?.panScrollable?.backgroundColor + } + + /** + Adds the background view to the view hierarchy + & configures its layout constraints. + */ + func layoutBackgroundView(in containerView: UIView) { + containerView.addSubview(backgroundView) + backgroundView.translatesAutoresizingMaskIntoConstraints = false + backgroundView.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true + backgroundView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true + backgroundView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true + backgroundView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor).isActive = true + } + + /** + Adds the drag indicator view to the view hierarchy + & configures its layout constraints. + */ + func addDragIndicatorView(to view: UIView) { + view.addSubview(dragIndicatorView) + dragIndicatorView.translatesAutoresizingMaskIntoConstraints = false + dragIndicatorView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: -Constants.indicatorYOffset).isActive = true + dragIndicatorView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true + dragIndicatorView.widthAnchor.constraint(equalToConstant: Constants.dragIndicatorSize.width).isActive = true + dragIndicatorView.heightAnchor.constraint(equalToConstant: Constants.dragIndicatorSize.height).isActive = true + } + + /** + Calculates & stores the layout anchor points & options + */ + func configureViewLayout() { + + guard let layoutPresentable = presentedViewController as? PanModalPresentable.LayoutType + else { return } + + shortFormYPosition = layoutPresentable.shortFormYPos + longFormYPosition = layoutPresentable.longFormYPos + anchorModalToLongForm = layoutPresentable.anchorModalToLongForm + extendsPanScrolling = layoutPresentable.allowsExtendedPanScrolling + + containerView?.isUserInteractionEnabled = layoutPresentable.isUserInteractionEnabled + } + + /** + Configures the scroll view insets + */ + func configureScrollViewInsets() { + + guard + let scrollView = presentable?.panScrollable, + !scrollView.isScrolling + else { return } + + /** + Disable vertical scroll indicator until we start to scroll + to avoid visual bugs + */ + scrollView.showsVerticalScrollIndicator = false + scrollView.scrollIndicatorInsets = presentable?.scrollIndicatorInsets ?? .zero + + /** + Set the appropriate contentInset as the configuration within this class + offsets it + */ + scrollView.contentInset.bottom = presentingViewController.bottomLayoutGuide.length + + /** + As we adjust the bounds during `handleScrollViewTopBounce` + we should assume that contentInsetAdjustmentBehavior will not be correct + */ + if #available(iOS 11.0, *) { + scrollView.contentInsetAdjustmentBehavior = .never + } + } + +} + +// MARK: - Pan Gesture Event Handler + +private extension PanModalPresentationController { + + /** + The designated function for handling pan gesture events + */ + @objc func didPanOnPresentedView(_ recognizer: UIPanGestureRecognizer) { + + guard + shouldRespond(to: recognizer), + let containerView = containerView + else { + recognizer.setTranslation(.zero, in: recognizer.view) + return + } + + switch recognizer.state { + case .began, .changed: + + /** + Respond accordingly to pan gesture translation + */ + respond(to: recognizer) + + /** + If presentedView is translated above the longForm threshold, treat as transition + */ + if presentedView.frame.origin.y == anchoredYPosition && extendsPanScrolling { + presentable?.willTransition(to: .longForm) + } + + default: + + /** + Use velocity sensitivity value to restrict snapping + */ + let velocity = recognizer.velocity(in: presentedView) + + if isVelocityWithinSensitivityRange(velocity.y) { + + /** + If velocity is within the sensitivity range, + transition to a presentation state or dismiss entirely. + + This allows the user to dismiss directly from long form + instead of going to the short form state first. + */ + if velocity.y < 0 { + transition(to: .longForm) + + } else if (nearest(to: presentedView.frame.minY, inValues: [longFormYPosition, containerView.bounds.height]) == longFormYPosition + && presentedView.frame.minY < shortFormYPosition) || presentable?.allowsDragToDismiss == false { + transition(to: .shortForm) + + } else { + presentedViewController.dismiss(animated: true) + } + + } else { + + /** + The `containerView.bounds.height` is used to determine + how close the presented view is to the bottom of the screen + */ + let position = nearest(to: presentedView.frame.minY, inValues: [containerView.bounds.height, shortFormYPosition, longFormYPosition]) + + if position == longFormYPosition { + transition(to: .longForm) + + } else if position == shortFormYPosition || presentable?.allowsDragToDismiss == false { + transition(to: .shortForm) + + } else { + presentedViewController.dismiss(animated: true) + } + } + } + } + + /** + Determine if the pan modal should respond to the gesture recognizer. + + If the pan modal is already being dragged & the delegate returns false, ignore until + the recognizer is back to it's original state (.began) + + โš ๏ธ This is the only time we should be cancelling the pan modal gesture recognizer + */ + func shouldRespond(to panGestureRecognizer: UIPanGestureRecognizer) -> Bool { + guard + presentable?.shouldRespond(to: panGestureRecognizer) == true || + !(panGestureRecognizer.state == .began || panGestureRecognizer.state == .cancelled) + else { + panGestureRecognizer.isEnabled = false + panGestureRecognizer.isEnabled = true + return false + } + return !shouldFail(panGestureRecognizer: panGestureRecognizer) + } + + /** + Communicate intentions to presentable and adjust subviews in containerView + */ + func respond(to panGestureRecognizer: UIPanGestureRecognizer) { + presentable?.willRespond(to: panGestureRecognizer) + + var yDisplacement = panGestureRecognizer.translation(in: presentedView).y + + /** + If the presentedView is not anchored to long form, reduce the rate of movement + above the threshold + */ + if presentedView.frame.origin.y < longFormYPosition { + yDisplacement /= 2.0 + } + adjust(toYPosition: presentedView.frame.origin.y + yDisplacement) + + panGestureRecognizer.setTranslation(.zero, in: presentedView) + } + + /** + Determines if we should fail the gesture recognizer based on certain conditions + + We fail the presented view's pan gesture recognizer if we are actively scrolling on the scroll view. + This allows the user to drag whole view controller from outside scrollView touch area. + + Unfortunately, cancelling a gestureRecognizer means that we lose the effect of transition scrolling + from one view to another in the same pan gesture so don't cancel + */ + func shouldFail(panGestureRecognizer: UIPanGestureRecognizer) -> Bool { + + /** + Allow api consumers to override the internal conditions & + decide if the pan gesture recognizer should be prioritized. + + โš ๏ธ This is the only time we should be cancelling the panScrollable recognizer, + for the purpose of ensuring we're no longer tracking the scrollView + */ + guard !shouldPrioritize(panGestureRecognizer: panGestureRecognizer) else { + presentable?.panScrollable?.panGestureRecognizer.isEnabled = false + presentable?.panScrollable?.panGestureRecognizer.isEnabled = true + return false + } + + guard + isPresentedViewAnchored, + let scrollView = presentable?.panScrollable, + scrollView.contentOffset.y > 0 + else { + return false + } + + let loc = panGestureRecognizer.location(in: presentedView) + return (scrollView.frame.contains(loc) || scrollView.isScrolling) + } + + /** + Determine if the presented view's panGestureRecognizer should be prioritized over + embedded scrollView's panGestureRecognizer. + */ + func shouldPrioritize(panGestureRecognizer: UIPanGestureRecognizer) -> Bool { + return panGestureRecognizer.state == .began && + presentable?.shouldPrioritize(panModalGestureRecognizer: panGestureRecognizer) == true + } + + /** + Check if the given velocity is within the sensitivity range + */ + func isVelocityWithinSensitivityRange(_ velocity: CGFloat) -> Bool { + return (abs(velocity) - (1000 * (1 - Constants.snapMovementSensitivity))) > 0 + } + + func snap(toYPosition yPos: CGFloat) { + PanModalAnimator.animate({ [weak self] in + self?.adjust(toYPosition: yPos) + self?.isPresentedViewAnimating = true + }, config: presentable) { [weak self] didComplete in + self?.isPresentedViewAnimating = !didComplete + } + } + + /** + Sets the y position of the presentedView & adjusts the backgroundView. + */ + func adjust(toYPosition yPos: CGFloat) { + presentedView.frame.origin.y = max(yPos, anchoredYPosition) + + guard presentedView.frame.origin.y > shortFormYPosition else { + backgroundView.dimState = .max + return + } + + let yDisplacementFromShortForm = presentedView.frame.origin.y - shortFormYPosition + + /** + Once presentedView is translated below shortForm, calculate yPos relative to bottom of screen + and apply percentage to backgroundView alpha + */ + backgroundView.dimState = .percent(1.0 - (yDisplacementFromShortForm / presentedView.frame.height)) + } + + /** + Finds the nearest value to a given number out of a given array of float values + + - Parameters: + - number: reference float we are trying to find the closest value to + - values: array of floats we would like to compare against + */ + func nearest(to number: CGFloat, inValues values: [CGFloat]) -> CGFloat { + guard let nearestVal = values.min(by: { abs(number - $0) < abs(number - $1) }) + else { return number } + return nearestVal + } +} + +// MARK: - UIScrollView Observer + +private extension PanModalPresentationController { + + /** + Creates & stores an observer on the given scroll view's content offset. + This allows us to track scrolling without overriding the scrollView delegate + */ + func observe(scrollView: UIScrollView?) { + scrollObserver?.invalidate() + scrollObserver = scrollView?.observe(\.contentOffset, options: .old) { [weak self] scrollView, change in + + /** + Incase we have a situation where we have two containerViews in the same presentation + */ + guard self?.containerView != nil + else { return } + + self?.didPanOnScrollView(scrollView, change: change) + } + } + + /** + Scroll view content offset change event handler + + Also when scrollView is scrolled to the top, we disable the scroll indicator + otherwise glitchy behaviour occurs + + This is also shown in Apple Maps (reverse engineering) + which allows us to seamlessly transition scrolling from the panContainerView to the scrollView + */ + func didPanOnScrollView(_ scrollView: UIScrollView, change: NSKeyValueObservedChange) { + + guard + !presentedViewController.isBeingDismissed, + !presentedViewController.isBeingPresented + else { return } + + if !isPresentedViewAnchored && scrollView.contentOffset.y > 0 { + + /** + Hold the scrollView in place if we're actively scrolling and not handling top bounce + */ + haltScrolling(scrollView) + + } else if scrollView.isScrolling || isPresentedViewAnimating { + + if isPresentedViewAnchored { + /** + While we're scrolling upwards on the scrollView, + store the last content offset position + */ + trackScrolling(scrollView) + } else { + /** + Keep scroll view in place while we're panning on main view + */ + haltScrolling(scrollView) + } + + } else if presentedViewController.view.isKind(of: UIScrollView.self) + && !isPresentedViewAnimating && scrollView.contentOffset.y <= 0 { + + /** + In the case where we drag down quickly on the scroll view and let go, + `handleScrollViewTopBounce` adds a nice elegant touch. + */ + handleScrollViewTopBounce(scrollView: scrollView, change: change) + } else { + trackScrolling(scrollView) + } + } + + /** + Halts the scroll of a given scroll view & anchors it at the `scrollViewYOffset` + */ + func haltScrolling(_ scrollView: UIScrollView) { + scrollView.setContentOffset(CGPoint(x: 0, y: scrollViewYOffset), animated: false) + scrollView.showsVerticalScrollIndicator = false + } + + /** + As the user scrolls, track & save the scroll view y offset. + This helps halt scrolling when we want to hold the scroll view in place. + */ + func trackScrolling(_ scrollView: UIScrollView) { + scrollViewYOffset = max(scrollView.contentOffset.y, 0) + scrollView.showsVerticalScrollIndicator = true + } + + /** + To ensure that the scroll transition between the scrollView & the modal + is completely seamless, we need to handle the case where content offset is negative. + + In this case, we follow the curve of the decelerating scroll view. + This gives the effect that the modal view and the scroll view are one view entirely. + + - Note: This works best where the view behind view controller is a UIScrollView. + So, for example, a UITableViewController. + */ + func handleScrollViewTopBounce(scrollView: UIScrollView, change: NSKeyValueObservedChange) { + + guard let oldYValue = change.oldValue?.y, scrollView.isDecelerating + else { return } + + let yOffset = scrollView.contentOffset.y + let presentedSize = containerView?.frame.size ?? .zero + + /** + Decrease the view bounds by the y offset so the scroll view stays in place + and we can still get updates on its content offset + */ + presentedView.bounds.size = CGSize(width: presentedSize.width, height: presentedSize.height + yOffset) + + if oldYValue > yOffset { + /** + Move the view in the opposite direction to the decreasing bounds + until half way through the deceleration so that it appears + as if we're transferring the scrollView drag momentum to the entire view + */ + presentedView.frame.origin.y = longFormYPosition - yOffset + } else { + scrollViewYOffset = 0 + snap(toYPosition: longFormYPosition) + } + + scrollView.showsVerticalScrollIndicator = false + } +} + +// MARK: - UIGestureRecognizerDelegate + +extension PanModalPresentationController: UIGestureRecognizerDelegate { + + /** + Do not require any other gesture recognizers to fail + */ + public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool { + return false + } + + /** + Allow simultaneous gesture recognizers only when the other gesture recognizer's view + is the pan scrollable view + */ + public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { + return otherGestureRecognizer.view == presentable?.panScrollable + } +} + +// MARK: - UIBezierPath + +private extension PanModalPresentationController { + + /** + Draws top rounded corners on a given view + We have to set a custom path for corner rounding + because we render the dragIndicator outside of view bounds + */ + func addRoundedCorners(to view: UIView) { + let radius = presentable?.cornerRadius ?? 0 + let path = UIBezierPath(roundedRect: view.bounds, + byRoundingCorners: [.topLeft, .topRight], + cornerRadii: CGSize(width: radius, height: radius)) + + // Draw around the drag indicator view, if displayed + if presentable?.showDragIndicator == true { + let indicatorLeftEdgeXPos = view.bounds.width/2.0 - Constants.dragIndicatorSize.width/2.0 + drawAroundDragIndicator(currentPath: path, indicatorLeftEdgeXPos: indicatorLeftEdgeXPos) + } + + // Set path as a mask to display optional drag indicator view & rounded corners + let mask = CAShapeLayer() + mask.path = path.cgPath + view.layer.mask = mask + + // Improve performance by rasterizing the layer + view.layer.shouldRasterize = true + view.layer.rasterizationScale = UIScreen.main.scale + } + + /** + Draws a path around the drag indicator view + */ + func drawAroundDragIndicator(currentPath path: UIBezierPath, indicatorLeftEdgeXPos: CGFloat) { + + let totalIndicatorOffset = Constants.indicatorYOffset + Constants.dragIndicatorSize.height + + // Draw around drag indicator starting from the left + path.addLine(to: CGPoint(x: indicatorLeftEdgeXPos, y: path.currentPoint.y)) + path.addLine(to: CGPoint(x: path.currentPoint.x, y: path.currentPoint.y - totalIndicatorOffset)) + path.addLine(to: CGPoint(x: path.currentPoint.x + Constants.dragIndicatorSize.width, y: path.currentPoint.y)) + path.addLine(to: CGPoint(x: path.currentPoint.x, y: path.currentPoint.y + totalIndicatorOffset)) + } +} + +// MARK: - Helper Extensions + +private extension UIScrollView { + + /** + A flag to determine if a scroll view is scrolling + */ + var isScrolling: Bool { + return isDragging && !isDecelerating || isTracking + } +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Delegate/PanModalPresentationDelegate.swift b/StopWatch/DesignSystem/Component/PanModal/Delegate/PanModalPresentationDelegate.swift new file mode 100644 index 0000000..24264b7 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Delegate/PanModalPresentationDelegate.swift @@ -0,0 +1,81 @@ +// +// PanModalPresentationDelegate.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + The PanModalPresentationDelegate conforms to the various transition delegates + and vends the appropriate object for each transition controller requested. + + Usage: + ``` + viewController.modalPresentationStyle = .custom + viewController.transitioningDelegate = PanModalPresentationDelegate.default + ``` + */ +public class PanModalPresentationDelegate: NSObject { + + /** + Returns an instance of the delegate, retained for the duration of presentation + */ + public static var `default`: PanModalPresentationDelegate = { + return PanModalPresentationDelegate() + }() + +} + +extension PanModalPresentationDelegate: UIViewControllerTransitioningDelegate { + + /** + Returns a modal presentation animator configured for the presenting state + */ + public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + return PanModalPresentationAnimator(transitionStyle: .presentation) + } + + /** + Returns a modal presentation animator configured for the dismissing state + */ + public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + return PanModalPresentationAnimator(transitionStyle: .dismissal) + } + + /** + Returns a modal presentation controller to coordinate the transition from the presenting + view controller to the presented view controller. + + Changes in size class during presentation are handled via the adaptive presentation delegate + */ + public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { + let controller = PanModalPresentationController(presentedViewController: presented, presenting: presenting) + controller.delegate = self + return controller + } + +} + +extension PanModalPresentationDelegate: UIAdaptivePresentationControllerDelegate, UIPopoverPresentationControllerDelegate { + + /** + - Note: We do not adapt to size classes due to the introduction of the UIPresentationController + & deprecation of UIPopoverController (iOS 9), there is no way to have more than one + presentation controller in use during the same presentation + + This is essential when transitioning from .popover to .custom on iPad split view... unless a custom popover view is also implemented + (popover uses UIPopoverPresentationController & we use PanModalPresentationController) + */ + + /** + Dismisses the presented view controller + */ + public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle { + return .none + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalHeight.swift b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalHeight.swift new file mode 100644 index 0000000..00654f4 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalHeight.swift @@ -0,0 +1,44 @@ +// +// PanModalHeight.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + An enum that defines the possible states of the height of a pan modal container view + for a given presentation state (shortForm, longForm) + */ +public enum PanModalHeight: Equatable { + + /** + Sets the height to be the maximum height (+ topOffset) + */ + case maxHeight + + /** + Sets the height to be the max height with a specified top inset. + - Note: A value of 0 is equivalent to .maxHeight + */ + case maxHeightWithTopInset(CGFloat) + + /** + Sets the height to be the specified content height + */ + case contentHeight(CGFloat) + + /** + Sets the height to be the specified content height + & also ignores the bottomSafeAreaInset + */ + case contentHeightIgnoringSafeArea(CGFloat) + + /** + Sets the height to be the intrinsic content height + */ + case intrinsicHeight +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+Defaults.swift b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+Defaults.swift new file mode 100644 index 0000000..76a0679 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+Defaults.swift @@ -0,0 +1,128 @@ +// +// PanModalPresentable+Defaults.swift +// PanModal +// +// Copyright ยฉ 2018 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + Default values for the PanModalPresentable. + */ +public extension PanModalPresentable where Self: UIViewController { + + var topOffset: CGFloat { + return topLayoutOffset + 21.0 + } + + var shortFormHeight: PanModalHeight { + return longFormHeight + } + + var longFormHeight: PanModalHeight { + + guard let scrollView = panScrollable + else { return .maxHeight } + + // called once during presentation and stored + scrollView.layoutIfNeeded() + return .contentHeight(scrollView.contentSize.height) + } + + var cornerRadius: CGFloat { + return 8.0 + } + + var springDamping: CGFloat { + return 0.8 + } + + var transitionDuration: Double { + return PanModalAnimator.Constants.defaultTransitionDuration + } + + var transitionAnimationOptions: UIView.AnimationOptions { + return [.curveEaseInOut, .allowUserInteraction, .beginFromCurrentState] + } + + var panModalBackgroundColor: UIColor { + return UIColor.black.withAlphaComponent(0.7) + } + + var dragIndicatorBackgroundColor: UIColor { + return UIColor.lightGray + } + + var scrollIndicatorInsets: UIEdgeInsets { + let top = shouldRoundTopCorners ? cornerRadius : 0 + return UIEdgeInsets(top: CGFloat(top), left: 0, bottom: bottomLayoutOffset, right: 0) + } + + var anchorModalToLongForm: Bool { + return true + } + + var allowsExtendedPanScrolling: Bool { + + guard let scrollView = panScrollable + else { return false } + + scrollView.layoutIfNeeded() + return scrollView.contentSize.height > (scrollView.frame.height - bottomLayoutOffset) + } + + var allowsDragToDismiss: Bool { + return true + } + + var allowsTapToDismiss: Bool { + return true + } + + var isUserInteractionEnabled: Bool { + return true + } + + var isHapticFeedbackEnabled: Bool { + return true + } + + var shouldRoundTopCorners: Bool { + return isPanModalPresented + } + + var showDragIndicator: Bool { + return shouldRoundTopCorners + } + + func shouldRespond(to panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool { + return true + } + + func willRespond(to panModalGestureRecognizer: UIPanGestureRecognizer) { + + } + + func shouldTransition(to state: PanModalPresentationController.PresentationState) -> Bool { + return true + } + + func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool { + return false + } + + func willTransition(to state: PanModalPresentationController.PresentationState) { + + } + + func panModalWillDismiss() { + + } + + func panModalDidDismiss() { + + } +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+LayoutHelpers.swift b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+LayoutHelpers.swift new file mode 100644 index 0000000..ff4805c --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+LayoutHelpers.swift @@ -0,0 +1,120 @@ +// +// PanModalPresentable+LayoutHelpers.swift +// PanModal +// +// Copyright ยฉ 2018 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + โš ๏ธ [Internal Only] โš ๏ธ + Helper extensions that handle layout in the PanModalPresentationController + */ +extension PanModalPresentable where Self: UIViewController { + + /** + Cast the presentation controller to PanModalPresentationController + so we can access PanModalPresentationController properties and methods + */ + var presentedVC: PanModalPresentationController? { + return presentationController as? PanModalPresentationController + } + + /** + Length of the top layout guide of the presenting view controller. + Gives us the safe area inset from the top. + */ + var topLayoutOffset: CGFloat { + + guard let rootVC = rootViewController + else { return 0} + + if #available(iOS 11.0, *) { return rootVC.view.safeAreaInsets.top } else { return rootVC.topLayoutGuide.length } + } + + /** + Length of the bottom layout guide of the presenting view controller. + Gives us the safe area inset from the bottom. + */ + var bottomLayoutOffset: CGFloat { + + guard let rootVC = rootViewController + else { return 0} + + if #available(iOS 11.0, *) { return rootVC.view.safeAreaInsets.bottom } else { return rootVC.bottomLayoutGuide.length } + } + + /** + Returns the short form Y position + + - Note: If voiceover is on, the `longFormYPos` is returned. + We do not support short form when voiceover is on as it would make it difficult for user to navigate. + */ + var shortFormYPos: CGFloat { + + guard !UIAccessibility.isVoiceOverRunning + else { return longFormYPos } + + let shortFormYPos = topMargin(from: shortFormHeight) + topOffset + + // shortForm shouldn't exceed longForm + return max(shortFormYPos, longFormYPos) + } + + /** + Returns the long form Y position + + - Note: We cap this value to the max possible height + to ensure content is not rendered outside of the view bounds + */ + var longFormYPos: CGFloat { + return max(topMargin(from: longFormHeight), topMargin(from: .maxHeight)) + topOffset + } + + /** + Use the container view for relative positioning as this view's frame + is adjusted in PanModalPresentationController + */ + var bottomYPos: CGFloat { + + guard let container = presentedVC?.containerView + else { return view.bounds.height } + + return container.bounds.size.height - topOffset + } + + /** + Converts a given pan modal height value into a y position value + calculated from top of view + */ + func topMargin(from: PanModalHeight) -> CGFloat { + switch from { + case .maxHeight: + return 0.0 + case .maxHeightWithTopInset(let inset): + return inset + case .contentHeight(let height): + return bottomYPos - (height + bottomLayoutOffset) + case .contentHeightIgnoringSafeArea(let height): + return bottomYPos - height + case .intrinsicHeight: + view.layoutIfNeeded() + let targetSize = CGSize(width: (presentedVC?.containerView?.bounds ?? UIScreen.main.bounds).width, + height: UIView.layoutFittingCompressedSize.height) + let intrinsicHeight = view.systemLayoutSizeFitting(targetSize).height + return bottomYPos - (intrinsicHeight + bottomLayoutOffset) + } + } + + private var rootViewController: UIViewController? { + + guard let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication + else { return nil } + + return application.keyWindow?.rootViewController + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+UIViewController.swift b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+UIViewController.swift new file mode 100644 index 0000000..8de82fd --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable+UIViewController.swift @@ -0,0 +1,63 @@ +// +// PanModalPresentable+UIViewController.swift +// PanModal +// +// Copyright ยฉ 2018 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + Extends PanModalPresentable with helper methods + when the conforming object is a UIViewController + */ +public extension PanModalPresentable where Self: UIViewController { + + typealias AnimationBlockType = () -> Void + typealias AnimationCompletionType = (Bool) -> Void + + /** + For Presentation, the object must be a UIViewController & confrom to the PanModalPresentable protocol. + */ + typealias LayoutType = UIViewController & PanModalPresentable + + /** + A function wrapper over the `transition(to state: PanModalPresentationController.PresentationState)` + function in the PanModalPresentationController. + */ + func panModalTransition(to state: PanModalPresentationController.PresentationState) { + presentedVC?.transition(to: state) + } + + /** + A function wrapper over the `setNeedsLayoutUpdate()` + function in the PanModalPresentationController. + + - Note: This should be called whenever any of the values for the PanModalPresentable protocol are changed. + */ + func panModalSetNeedsLayoutUpdate() { + presentedVC?.setNeedsLayoutUpdate() + } + + /** + Operations on the scroll view, such as content height changes, or when inserting/deleting rows can cause the pan modal to jump, + caused by the pan modal responding to content offset changes. + + To avoid this, you can call this method to perform scroll view updates, with scroll observation temporarily disabled. + */ + func panModalPerformUpdates(_ updates: () -> Void) { + presentedVC?.performUpdates(updates) + } + + /** + A function wrapper over the animate function in PanModalAnimator. + + This can be used for animation consistency on views within the presented view controller. + */ + func panModalAnimate(_ animationBlock: @escaping AnimationBlockType, _ completion: AnimationCompletionType? = nil) { + PanModalAnimator.animate(animationBlock, config: self, completion) + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable.swift b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable.swift new file mode 100644 index 0000000..76c1501 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presentable/PanModalPresentable.swift @@ -0,0 +1,237 @@ +// +// PanModalPresentable.swift +// PanModal +// +// Copyright ยฉ 2017 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + This is the configuration object for a view controller + that will be presented using the PanModal transition. + + Usage: + ``` + extension YourViewController: PanModalPresentable { + func shouldRoundTopCorners: Bool { return false } + } + ``` + */ +public protocol PanModalPresentable: AnyObject { + + /** + The scroll view embedded in the view controller. + Setting this value allows for seamless transition scrolling between the embedded scroll view + and the pan modal container view. + */ + var panScrollable: UIScrollView? { get } + + /** + The offset between the top of the screen and the top of the pan modal container view. + + Default value is the topLayoutGuide.length + 21.0. + */ + var topOffset: CGFloat { get } + + /** + The height of the pan modal container view + when in the shortForm presentation state. + + This value is capped to .max, if provided value exceeds the space available. + + Default value is the longFormHeight. + */ + var shortFormHeight: PanModalHeight { get } + + /** + The height of the pan modal container view + when in the longForm presentation state. + + This value is capped to .max, if provided value exceeds the space available. + + Default value is .max. + */ + var longFormHeight: PanModalHeight { get } + + /** + The corner radius used when `shouldRoundTopCorners` is enabled. + + Default Value is 8.0. + */ + var cornerRadius: CGFloat { get } + + /** + The springDamping value used to determine the amount of 'bounce' + seen when transitioning to short/long form. + + Default Value is 0.8. + */ + var springDamping: CGFloat { get } + + /** + The transitionDuration value is used to set the speed of animation during a transition, + including initial presentation. + + Default value is 0.5. + */ + var transitionDuration: Double { get } + + /** + The animation options used when performing animations on the PanModal, utilized mostly + during a transition. + + Default value is [.curveEaseInOut, .allowUserInteraction, .beginFromCurrentState]. + */ + var transitionAnimationOptions: UIView.AnimationOptions { get } + + /** + The background view color. + + - Note: This is only utilized at the very start of the transition. + + Default Value is black with alpha component 0.7. + */ + var panModalBackgroundColor: UIColor { get } + + /** + The drag indicator view color. + + Default value is light gray. + */ + var dragIndicatorBackgroundColor: UIColor { get } + + /** + We configure the panScrollable's scrollIndicatorInsets interally so override this value + to set custom insets. + + - Note: Use `panModalSetNeedsLayoutUpdate()` when updating insets. + */ + var scrollIndicatorInsets: UIEdgeInsets { get } + + /** + A flag to determine if scrolling should be limited to the longFormHeight. + Return false to cap scrolling at .max height. + + Default value is true. + */ + var anchorModalToLongForm: Bool { get } + + /** + A flag to determine if scrolling should seamlessly transition from the pan modal container view to + the embedded scroll view once the scroll limit has been reached. + + Default value is false. Unless a scrollView is provided and the content height exceeds the longForm height. + */ + var allowsExtendedPanScrolling: Bool { get } + + /** + A flag to determine if dismissal should be initiated when swiping down on the presented view. + + Return false to fallback to the short form state instead of dismissing. + + Default value is true. + */ + var allowsDragToDismiss: Bool { get } + + /** + A flag to determine if dismissal should be initiated when tapping on the dimmed background view. + + Default value is true. + */ + var allowsTapToDismiss: Bool { get } + + /** + A flag to toggle user interactions on the container view. + + - Note: Return false to forward touches to the presentingViewController. + + Default is true. + */ + var isUserInteractionEnabled: Bool { get } + + /** + A flag to determine if haptic feedback should be enabled during presentation. + + Default value is true. + */ + var isHapticFeedbackEnabled: Bool { get } + + /** + A flag to determine if the top corners should be rounded. + + Default value is true. + */ + var shouldRoundTopCorners: Bool { get } + + /** + A flag to determine if a drag indicator should be shown + above the pan modal container view. + + Default value is true. + */ + var showDragIndicator: Bool { get } + + /** + Asks the delegate if the pan modal should respond to the pan modal gesture recognizer. + + Return false to disable movement on the pan modal but maintain gestures on the presented view. + + Default value is true. + */ + func shouldRespond(to panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool + + /** + Notifies the delegate when the pan modal gesture recognizer state is either + `began` or `changed`. This method gives the delegate a chance to prepare + for the gesture recognizer state change. + + For example, when the pan modal view is about to scroll. + + Default value is an empty implementation. + */ + func willRespond(to panModalGestureRecognizer: UIPanGestureRecognizer) + + /** + Asks the delegate if the pan modal gesture recognizer should be prioritized. + + For example, you can use this to define a region + where you would like to restrict where the pan gesture can start. + + If false, then we rely solely on the internal conditions of when a pan gesture + should succeed or fail, such as, if we're actively scrolling on the scrollView. + + Default return value is false. + */ + func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool + + /** + Asks the delegate if the pan modal should transition to a new state. + + Default value is true. + */ + func shouldTransition(to state: PanModalPresentationController.PresentationState) -> Bool + + /** + Notifies the delegate that the pan modal is about to transition to a new state. + + Default value is an empty implementation. + */ + func willTransition(to state: PanModalPresentationController.PresentationState) + + /** + Notifies the delegate that the pan modal is about to be dismissed. + + Default value is an empty implementation. + */ + func panModalWillDismiss() + + /** + Notifies the delegate after the pan modal is dismissed. + + Default value is an empty implementation. + */ + func panModalDidDismiss() +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presenter/PanModalPresenter.swift b/StopWatch/DesignSystem/Component/PanModal/Presenter/PanModalPresenter.swift new file mode 100644 index 0000000..8763fda --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presenter/PanModalPresenter.swift @@ -0,0 +1,38 @@ +// +// PanModalPresenter.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + A protocol for objects that will present a view controller as a PanModal + + - Usage: + ``` + viewController.presentPanModal(viewControllerToPresent: presentingVC, + sourceView: presentingVC.view, + sourceRect: .zero) + ``` + */ +protocol PanModalPresenter: AnyObject { + + /** + A flag that returns true if the current presented view controller + is using the PanModalPresentationDelegate + */ + var isPanModalPresented: Bool { get } + + /** + Presents a view controller that conforms to the PanModalPresentable protocol + */ + func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, + sourceView: UIView?, + sourceRect: CGRect, + completion: (() -> Void)?) + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/Presenter/UIViewController+PanModalPresenter.swift b/StopWatch/DesignSystem/Component/PanModal/Presenter/UIViewController+PanModalPresenter.swift new file mode 100644 index 0000000..b252d8f --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/Presenter/UIViewController+PanModalPresenter.swift @@ -0,0 +1,66 @@ +// +// UIViewController+PanModalPresenterProtocol.swift +// PanModal +// +// Copyright ยฉ 2019 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + Extends the UIViewController to conform to the PanModalPresenter protocol + */ +extension UIViewController: PanModalPresenter { + + /** + A flag that returns true if the topmost view controller in the navigation stack + was presented using the custom PanModal transition + + - Warning: โš ๏ธ Calling `presentationController` in this function may cause a memory leak. โš ๏ธ + + In most cases, this check will be used early in the view lifecycle and unfortunately, + there's an Apple bug that causes multiple presentationControllers to be created if + the presentationController is referenced here and called too early resulting in + a strong reference to this view controller and in turn, creating a memory leak. + */ + public var isPanModalPresented: Bool { + return (transitioningDelegate as? PanModalPresentationDelegate) != nil + } + + /** + Configures a view controller for presentation using the PanModal transition + + - Parameters: + - viewControllerToPresent: The view controller to be presented + - sourceView: The view containing the anchor rectangle for the popover. + - sourceRect: The rectangle in the specified view in which to anchor the popover. + - completion: The block to execute after the presentation finishes. You may specify nil for this parameter. + + - Note: sourceView & sourceRect are only required for presentation on an iPad. + */ + public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, + sourceView: UIView? = nil, + sourceRect: CGRect = .zero, + completion: (() -> Void)? = nil) { + + /** + Here, we deliberately do not check for size classes. More info in `PanModalPresentationDelegate` + */ + + if UIDevice.current.userInterfaceIdiom == .pad { + viewControllerToPresent.modalPresentationStyle = .popover + viewControllerToPresent.popoverPresentationController?.sourceRect = sourceRect + viewControllerToPresent.popoverPresentationController?.sourceView = sourceView ?? view + viewControllerToPresent.popoverPresentationController?.delegate = PanModalPresentationDelegate.default + } else { + viewControllerToPresent.modalPresentationStyle = .custom + viewControllerToPresent.modalPresentationCapturesStatusBarAppearance = true + viewControllerToPresent.transitioningDelegate = PanModalPresentationDelegate.default + } + + present(viewControllerToPresent, animated: true, completion: completion) + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/View/DimmedView.swift b/StopWatch/DesignSystem/Component/PanModal/View/DimmedView.swift new file mode 100644 index 0000000..6fdd1d8 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/View/DimmedView.swift @@ -0,0 +1,76 @@ +// +// DimmedView.swift +// PanModal +// +// Copyright ยฉ 2017 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + A dim view for use as an overlay over content you want dimmed. + */ +public class DimmedView: UIView { + + /** + Represents the possible states of the dimmed view. + max, off or a percentage of dimAlpha. + */ + enum DimState { + case max + case off + case percent(CGFloat) + } + + // MARK: - Properties + + /** + The state of the dimmed view + */ + var dimState: DimState = .off { + didSet { + switch dimState { + case .max: + alpha = 1.0 + case .off: + alpha = 0.0 + case .percent(let percentage): + alpha = max(0.0, min(1.0, percentage)) + } + } + } + + /** + The closure to be executed when a tap occurs + */ + var didTap: ((_ recognizer: UIGestureRecognizer) -> Void)? + + /** + Tap gesture recognizer + */ + private lazy var tapGesture: UIGestureRecognizer = { + return UITapGestureRecognizer(target: self, action: #selector(didTapView)) + }() + + // MARK: - Initializers + + init(dimColor: UIColor = UIColor.black.withAlphaComponent(0.7)) { + super.init(frame: .zero) + alpha = 0.0 + backgroundColor = dimColor + addGestureRecognizer(tapGesture) + } + + required public init?(coder aDecoder: NSCoder) { + fatalError() + } + + // MARK: - Event Handlers + + @objc private func didTapView() { + didTap?(tapGesture) + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/PanModal/View/PanContainerView.swift b/StopWatch/DesignSystem/Component/PanModal/View/PanContainerView.swift new file mode 100644 index 0000000..f5c2892 --- /dev/null +++ b/StopWatch/DesignSystem/Component/PanModal/View/PanContainerView.swift @@ -0,0 +1,44 @@ +// +// PanContainerView.swift +// PanModal +// +// Copyright ยฉ 2018 Tiny Speck, Inc. All rights reserved. +// + +#if os(iOS) +import UIKit + +/** + A view wrapper around the presented view in a PanModal transition. + + This allows us to make modifications to the presented view without + having to do those changes directly on the view + */ +class PanContainerView: UIView { + + init(presentedView: UIView, frame: CGRect) { + super.init(frame: frame) + addSubview(presentedView) + } + + @available(*, unavailable) + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} + +extension UIView { + + /** + Convenience property for retrieving a PanContainerView instance + from the view hierachy + */ + var panContainerView: PanContainerView? { + return subviews.first(where: { view -> Bool in + view is PanContainerView + }) as? PanContainerView + } + +} +#endif diff --git a/StopWatch/DesignSystem/Component/TimeHistoryCell/TimeHistoryCell.swift b/StopWatch/DesignSystem/Component/TimeHistoryCell/TimeHistoryCell.swift new file mode 100644 index 0000000..70c5718 --- /dev/null +++ b/StopWatch/DesignSystem/Component/TimeHistoryCell/TimeHistoryCell.swift @@ -0,0 +1,30 @@ +// +// TimeHistoryCell.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct TimeHistoryCell: View { + let date: Date + let todo: String + let todoTime: String + + var body: some View { + HStack(spacing: .zero) { + Text(date.formattedString(by: .yyyyMMddHHmm)) + .setTypo(.caption1) + .foregroundStyle(Color.getColor(.text_assistive)) + FixedSpacer(12) + Text(todo) + .setTypo(.label2) + .lineLimit(1) + .foregroundStyle(Color.getColor(.text_alternative)) + Spacer() + Text(todoTime) + .setTypo(.label2) + } + } +} diff --git a/StopWatch/DesignSystem/Component/TitleView/TitleView.swift b/StopWatch/DesignSystem/Component/TitleView/TitleView.swift new file mode 100644 index 0000000..a981804 --- /dev/null +++ b/StopWatch/DesignSystem/Component/TitleView/TitleView.swift @@ -0,0 +1,28 @@ +// +// TitleView.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/4/24. +// + +import SwiftUI + +struct TitleView: View { + let title: String + let content: String? + + var body: some View { + VStack(spacing: 8) { + Text(title) + .hSpacing(alignment: .leading) + .setTypo(.subTitle1) + .foregroundStyle(Color.getColor(.text_strong)) + if let content { + Text(content) + .hSpacing(alignment: .leading) + .setTypo(.body1) + .foregroundStyle(Color.getColor(.text_alternative)) + } + } + } +} diff --git a/StopWatch/DesignSystem/Component/Toast/ToastProvider.swift b/StopWatch/DesignSystem/Component/Toast/ToastProvider.swift new file mode 100644 index 0000000..5e682ac --- /dev/null +++ b/StopWatch/DesignSystem/Component/Toast/ToastProvider.swift @@ -0,0 +1,49 @@ +// +// ToastProvider.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/3/24. +// + +import SwiftUI + +class ToastProvider { + static let shared = ToastProvider() + + private var window: UIWindow? + private var workItem: DispatchWorkItem? + + private init() { + let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene + window = UIWindow(windowScene: windowScene!) + window?.backgroundColor = .clear + window?.windowLevel = .alert + 1 + window?.rootViewController = UIHostingController(rootView: EmptyView()) + window?.isUserInteractionEnabled = false + } + + func show( + view: Content, + duration: TimeInterval = .zero + ) { + workItem?.cancel() + workItem = .none + + let hosting = UIHostingController(rootView: view) + hosting.view.backgroundColor = .clear + window?.rootViewController = hosting + window?.isHidden = false + + if duration != .zero { + workItem = DispatchWorkItem { [weak self] in + self?.hide() + } + + DispatchQueue.main.asyncAfter(deadline: .now() + duration, execute: workItem!) + } + } + + func hide() { + window?.isHidden = true + } +} diff --git a/StopWatch/DesignSystem/Component/Toast/ToastView.swift b/StopWatch/DesignSystem/Component/Toast/ToastView.swift new file mode 100644 index 0000000..ce9e2e3 --- /dev/null +++ b/StopWatch/DesignSystem/Component/Toast/ToastView.swift @@ -0,0 +1,66 @@ +// +// ToastView.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/27/24. +// + +import SwiftUI + +public struct ToastView: View { + public var message: String + public var duration: Double + + /// ๋‚˜ํƒ€๋‚˜๊ณ  ์‚ฌ๋ผ์ง€๋Š” ํŠธ๋žœ์ง€์…˜ ์‹œ๊ฐ„ + private let transitionDuration: Double = 0.3 + + @State private var isVisible: Bool = false + @State private var offsetY: CGFloat = .zero + + public var body: some View { + ZStack { + Color.clear + .ignoresSafeArea() + + VStack { + Spacer() + if isVisible { + Text(message) + .setTypo(.label1) + .foregroundStyle(Color.white) + .padding(.vertical, 16) + .padding(.horizontal, 24) + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color.getColor(.gray_text).blur(radius: 0.4)) + .clipShape(.rect(cornerRadius: 16)) + .padding(.horizontal, 24) + .offset(y: offsetY) + .opacity(1 - abs(offsetY) / 100.0) + .onAppear { + withAnimation(.easeOut(duration: transitionDuration)) { + offsetY = .zero + } + + DispatchQueue.main.asyncAfter(deadline: .now() + duration - transitionDuration) { + withAnimation(.easeIn(duration: transitionDuration)) { + offsetY = 100 + } completion: { + isVisible = false + } + } + } + } + } + } + .onAppear { + withAnimation { + offsetY = 100 + isVisible = true + } + } + } +} + +#Preview { + ToastView(message: "ํ…Œ์ŠคํŠธ ํ† ์ŠคํŠธ ๋ฉ”์„ธ์ง€ ์ž…๋‹ˆ๋‹ค.", duration: 2.0) +} diff --git a/StopWatch/DesignSystem/Component/TodoCell/TodoCell.swift b/StopWatch/DesignSystem/Component/TodoCell/TodoCell.swift new file mode 100644 index 0000000..175183f --- /dev/null +++ b/StopWatch/DesignSystem/Component/TodoCell/TodoCell.swift @@ -0,0 +1,49 @@ +// +// TodoCell.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/24/24. +// + +import SwiftUI + +struct TodoCell: View { + let todo: Todo + + var body: some View { + HStack(spacing: .zero) { + VStack(alignment: .leading, spacing: 2) { + if let category = todo.category { + Text(category.name) + .setTypo(.caption1) + .foregroundStyle(Color.getColor(.text_alternative)) + } + + Text(todo.content) + .setTypo(.label1) + .overlay { + GeometryReader { reader in + Rectangle() + .fill(Color.getColor(.gray_text)) + .offset(y: reader.size.height/2) + .frame( + width: todo.progress == 1 ? reader.size.width : 0, + height: 1 + ) + } + } + } + + Spacer() + CircleProgressView(value: todo.progress, size: .xs) + } + .foregroundStyle(Color.getColor(.text_normal)) + .frame(maxWidth: .infinity) + .padding(.horizontal, 16) + .padding(.bottom, 12) + .padding(.top, 8) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + .animation(.easeInOut(duration: 2.0), value: todo.progress) + } +} diff --git a/StopWatch/DesignSystem/Component/TodoStorageCell/TodoStorageCell.swift b/StopWatch/DesignSystem/Component/TodoStorageCell/TodoStorageCell.swift new file mode 100644 index 0000000..8b9a582 --- /dev/null +++ b/StopWatch/DesignSystem/Component/TodoStorageCell/TodoStorageCell.swift @@ -0,0 +1,41 @@ +// +// TodoStorageCell.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/30/25. +// + +import SwiftUI + +struct TodoStorageCell: View { + let todo: Todo + var isEditMode: Bool = false + var isSelected: Bool = false + + var body: some View { + HStack(spacing: .zero) { + VStack(alignment: .leading, spacing: 2) { + if let category = todo.category { + Text(category.name) + .setTypo(.caption1) + .foregroundStyle(Color.getColor(.text_alternative)) + } + + Text(todo.content) + .setTypo(.label1) + } + + Spacer() + if isEditMode { + Image(isSelected ? .checkFillOn : .checkFillOff) + } + } + .foregroundStyle(Color.getColor(.text_normal)) + .frame(maxWidth: .infinity) + .padding(.horizontal, 16) + .padding(.bottom, 12) + .padding(.top, 8) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + } +} diff --git a/StopWatch/DesignSystem/Component/TopNavigation/TopNavigation.swift b/StopWatch/DesignSystem/Component/TopNavigation/TopNavigation.swift new file mode 100644 index 0000000..2055681 --- /dev/null +++ b/StopWatch/DesignSystem/Component/TopNavigation/TopNavigation.swift @@ -0,0 +1,108 @@ +// +// TopNavigation.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public struct TopNavigation: View { + + public typealias NavigationItem = (Image, () -> Void) + + private let leadingItem: NavigationItem? + private let leadingButton: (String, () -> Void)? + + private let leadingTitle: String? + private let centerTitle: String? + + private let trailingItems: [NavigationItem] + private let trailingButton: (String, () -> Void)? + + + public init( + leadingItem: NavigationItem? = .none, + leadingButton: (String, () -> Void)? = .none, + leadingTitle: String? = .none, + centerTitle: String? = .none, + trailingItems: [NavigationItem] = [], + trailingButton: (String, () -> Void)? = .none + ) { + self.leadingItem = leadingItem + self.leadingButton = leadingButton + self.leadingTitle = leadingTitle + self.centerTitle = centerTitle + self.trailingItems = trailingItems + self.trailingButton = trailingButton + } + + + public var body: some View { + HStack(spacing: .zero) { + if let leadingItem { + navigationItem(leadingItem) + .foregroundStyle(Color.getColor(.text_normal)) + } + if let leadingTitle { + Text(leadingTitle) + .setTypo(.subTitle3) + .foregroundStyle(Color.getColor(.text_strong)) + } + if let leadingButton { + Button(action: { + leadingButton.1() + }, label: { + Text(leadingButton.0) + .setTypo(.title3) + .foregroundStyle(Color.getColor(.text_strong)) + .padding(.horizontal, 16) + }) + } + + Spacer() + if let trailingButton { + Button(action: { + trailingButton.1() + }, label: { + Text(trailingButton.0) + .setTypo(.body2) + .foregroundStyle(Color.getColor(.text_alternative)) + .padding(.horizontal, 16) + .padding(.vertical, 10) + }) + } + + if trailingItems.isNotEmpty { + ForEach(Array(0.. some View { + Button(action: { + item.1() + }, label: { + item.0 + .resizable() + .frame(width: 24, height: 24) + .padding(8) + }) + } +} diff --git a/StopWatch/DesignSystem/Component/WithDesignSystem/WithDesignSystem.swift b/StopWatch/DesignSystem/Component/WithDesignSystem/WithDesignSystem.swift new file mode 100644 index 0000000..3d9e1cc --- /dev/null +++ b/StopWatch/DesignSystem/Component/WithDesignSystem/WithDesignSystem.swift @@ -0,0 +1,40 @@ +// +// WithDesignSystem.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public struct WithDesignSystem: View { + + let background: UIColor + let topNavigation: TopNavigation + let content: Content + let bottomButton: BottomButton + + public init( + _ background: UIColor = .white, + @ViewBuilder topNavigation: () -> TopNavigation = { EmptyView() }, + @ViewBuilder content: () -> Content, + @ViewBuilder bottomButton: () -> BottomButton = { EmptyView() } + ) { + self.background = background + self.topNavigation = topNavigation() + self.content = content() + self.bottomButton = bottomButton() + } + + public var body: some View { + VStack(spacing: 0) { + topNavigation + content + Spacer(minLength: 0) + bottomButton + } + .frame(maxWidth: .infinity) + .hideKeyboardOnTapBackground(background: background) + .background(Color(uiColor: background).ignoresSafeArea(.container, edges: .all)) + } +} diff --git a/StopWatch/DesignSystem/Core/Color/Color+ColorToken.swift b/StopWatch/DesignSystem/Core/Color/Color+ColorToken.swift new file mode 100644 index 0000000..d6961f7 --- /dev/null +++ b/StopWatch/DesignSystem/Core/Color/Color+ColorToken.swift @@ -0,0 +1,32 @@ +// +// Color+ColorToken.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/23/24. +// + +import SwiftUI + +public extension Color { + static func getColor(_ color: ColorToken) -> Color { + .init(uiColor: .getColor(color)) + } + + init(hex: Int, opacity: Double = 1.0) { + let red = Double((hex >> 16) & 0xff) / 255 + let green = Double((hex >> 8) & 0xff) / 255 + let blue = Double((hex >> 0) & 0xff) / 255 + + self.init(.sRGB, red: red, green: green, blue: blue, opacity: opacity) + } + + init?(hex: String, opacity: Double = 1.0) { + let filteredHex = hex.replacingOccurrences(of: "0x", with: "") + + if let hex: Int = Int(filteredHex, radix: 16) { + self.init(hex: hex, opacity: opacity) + } else { + return nil + } + } +} diff --git a/StopWatch/DesignSystem/Core/Color/ColorToken.swift b/StopWatch/DesignSystem/Core/Color/ColorToken.swift new file mode 100644 index 0000000..65aa5d1 --- /dev/null +++ b/StopWatch/DesignSystem/Core/Color/ColorToken.swift @@ -0,0 +1,76 @@ +// +// ColorSystem.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/23/24. +// + +import SwiftUI + +public enum ColorToken { + + /// static + case black + case white + case clear + + /// primary + case primary_normal + case primary_alternative + case primary_fill_normal + case primary_fill_assistive + + /// text + case text_strong + case text_normal + case text_alternative + case text_assistive + case text_disable + + /// line + case line_normal + case line_assistive + case line_disable + + /// fill + case fill_normal + case fill_assistive + case fill_disable + case fill_disable_assistive + + /// background + case background_primary + case background_secondary + + /// gray + case gray_text + case gray_fill_normal + case gray_alternative + case gray_assistive + case gray_fill_assistive + case gray_fill_off + + /// information + case information_text + case information_fill_normal + case information_fill_assistive + + /// warning + case warning_text + case warning_fill_normal + case warning_fill_assistive + + /// caution + case caution_normal + case caution_text_alternative + case caution_fill_assistive + + /// + case dim +} + +public extension ColorToken { + var color: Color { + Color.getColor(self) + } +} diff --git a/StopWatch/DesignSystem/Core/Color/UIColor+ColorToken.swift b/StopWatch/DesignSystem/Core/Color/UIColor+ColorToken.swift new file mode 100644 index 0000000..4ee74dc --- /dev/null +++ b/StopWatch/DesignSystem/Core/Color/UIColor+ColorToken.swift @@ -0,0 +1,120 @@ +// +// UIColor+ColorToken.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/23/24. +// + +import UIKit.UIColor + +public extension UIColor { + static func getColor(_ color: ColorToken) -> UIColor { + switch color { + + /// static + case .black: + return .black + case .white: + return .white + + /// primary + case .primary_normal: + return .init(resource: .primary50) + case .primary_alternative: + return .init(resource: .primary40) + case .primary_fill_normal: + return .init(resource: .primary5) + case .primary_fill_assistive: + return .init(resource: .primary2) + + /// text + case .text_strong: + return .black + case .text_normal: + return .init(resource: .netural90) + case .text_alternative: + return .init(resource: .netural60) + case .text_assistive: + return .init(resource: .netural40) + case .text_disable: + return .init(resource: .netural30) + + /// line + case .line_normal: + return .init(resource: .coolGray15) + case .line_assistive: + return .init(resource: .coolGray10) + case .line_disable: + return .init(resource: .netural15) + + /// fill + case .fill_normal: + return .init(resource: .coolGray10) + case .fill_assistive: + return .init(resource: .coolGray5) + case .fill_disable: + return .init(resource: .netural10) + case .fill_disable_assistive: + return .init(resource: .netural5) + + /// background + case .background_primary: + return .init(resource: .coolGray2) + case .background_secondary: + return .white + + /// gray + case .gray_text: + return .init(resource: .coolGray90) + case .gray_fill_normal: + return .init(resource: .coolGray80) + case .gray_alternative: + return .init(resource: .coolGray60) + case .gray_assistive: + return .init(resource: .coolGray30) + case .gray_fill_assistive: + return .init(resource: .coolGray30) + case .gray_fill_off: + return .init(resource: .coolGray25) + + /// information + case .information_text: + return .init(resource: .information60) + case .information_fill_normal: + return .init(resource: .information50) + case .information_fill_assistive: + return .init(resource: .information5) + + /// warning + case .warning_text: + return .init(resource: .warning70) + case .warning_fill_normal: + return .init(resource: .warning50) + case .warning_fill_assistive: + return .init(resource: .warning5) + + /// caution + case .caution_normal: + return .init(resource: .caution50) + case .caution_text_alternative: + return .init(resource: .caution40) + case .caution_fill_assistive: + return .init(resource: .caution5) + + /// opacity + case .dim: + return .init(resource: .opacity3N2) + + /// other + case .clear: + return .clear + } + } +} + +/// ๋‚˜์ค‘์— ํŒจํ‚ค์ง€๋กœ ๋บ€๋‹ค๋ฉด ์‚ฌ์šฉ +public extension UIColor { +// convenience init?(name: String) { +// self.init(named: name, in: Bundle.module, compatibleWith: nil) +// } +} diff --git a/StopWatch/DesignSystem/Core/Figure/FrameToken.swift b/StopWatch/DesignSystem/Core/Figure/FrameToken.swift new file mode 100644 index 0000000..2966ad2 --- /dev/null +++ b/StopWatch/DesignSystem/Core/Figure/FrameToken.swift @@ -0,0 +1,27 @@ +// +// FrameToken.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import Foundation + + +public struct FrameToken { + public let width: CGFloat? + public let height: CGFloat? + + public init( + _ width: CGFloat?, + _ height: CGFloat? + ) { + self.width = width + self.height = height + } + + public init(all: CGFloat?) { + self.width = all + self.height = all + } +} diff --git a/StopWatch/DesignSystem/Core/Figure/PaddingToken.swift b/StopWatch/DesignSystem/Core/Figure/PaddingToken.swift new file mode 100644 index 0000000..c46e60f --- /dev/null +++ b/StopWatch/DesignSystem/Core/Figure/PaddingToken.swift @@ -0,0 +1,44 @@ +// +// PaddingToken.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import Foundation + +public struct PaddingToken { + public var vertical: CGFloat? + public var horizontal: CGFloat? + public var top: CGFloat? + public var bottom: CGFloat? + public var left: CGFloat? + public var right: CGFloat? + + public init( + vertical: CGFloat? = .zero, + horizontal: CGFloat = .zero + ) { + self.vertical = vertical + self.horizontal = horizontal + } + + public init( + top: CGFloat? = .zero, + bottom: CGFloat? = .zero, + left: CGFloat? = .zero, + right: CGFloat? = .zero + ) { + self.top = top + self.bottom = bottom + self.left = left + self.right = right + } + + public init(all: CGFloat) { + self.vertical = all + self.horizontal = all + } +} + + diff --git a/StopWatch/DesignSystem/Core/Figure/RadiusToken.swift b/StopWatch/DesignSystem/Core/Figure/RadiusToken.swift new file mode 100644 index 0000000..82fc372 --- /dev/null +++ b/StopWatch/DesignSystem/Core/Figure/RadiusToken.swift @@ -0,0 +1,34 @@ +// +// RadiusToken.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import Foundation + +public struct RadiusToken { + public var topLeft: CGFloat + public var bottomLeft: CGFloat + public var bottomRight: CGFloat + public var topRight: CGFloat + + public init( + topLeading: CGFloat = .zero, + bottomLeading: CGFloat = .zero, + bottomTrailing: CGFloat = .zero, + topTrailing: CGFloat = .zero + ) { + self.topLeft = topLeading + self.bottomLeft = bottomLeading + self.bottomRight = bottomTrailing + self.topRight = topTrailing + } + + public init(all: CGFloat) { + self.topLeft = all + self.bottomLeft = all + self.bottomRight = all + self.topRight = all + } +} diff --git a/StopWatch/DesignSystem/Core/Typography/FontWeight.swift b/StopWatch/DesignSystem/Core/Typography/FontWeight.swift new file mode 100644 index 0000000..a4b7fef --- /dev/null +++ b/StopWatch/DesignSystem/Core/Typography/FontWeight.swift @@ -0,0 +1,14 @@ +// +// FontWeight.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import SwiftUI + +public enum FontWeight: String { + case regular = "Regular" + case semibold = "SemiBold" + case bold = "Bold" +} diff --git a/StopWatch/DesignSystem/Core/Typography/LineHeightModifier.swift b/StopWatch/DesignSystem/Core/Typography/LineHeightModifier.swift new file mode 100644 index 0000000..9dacdb0 --- /dev/null +++ b/StopWatch/DesignSystem/Core/Typography/LineHeightModifier.swift @@ -0,0 +1,19 @@ +// +// LineHeightModifier.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import SwiftUI + +struct LineHeightModifier: ViewModifier { + let font: UIFont + let lineHeight: CGFloat + + func body(content: Content) -> some View { + content + .lineSpacing(lineHeight - font.lineHeight) + .padding(.vertical, (lineHeight - font.lineHeight) / 2) + } +} diff --git a/StopWatch/DesignSystem/Core/Typography/PretendardFont.swift b/StopWatch/DesignSystem/Core/Typography/PretendardFont.swift new file mode 100644 index 0000000..c018144 --- /dev/null +++ b/StopWatch/DesignSystem/Core/Typography/PretendardFont.swift @@ -0,0 +1,29 @@ +// +// PretendardFont.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import SwiftUI + + +// MARK: - SwiftUI +public extension Font { + + /// Pretenard + static func pretendard(size: CGFloat, weight: FontWeight) -> Font { + return Font.custom("Pretendard-\(weight.rawValue)", size: size) + } +} + + +// MARK: - UIKit + +public extension UIFont { + + /// Pretenard + static func pretendard(size: CGFloat, weight: FontWeight) -> UIFont { + return UIFont(name: "Pretendard-\(weight.rawValue)", size: size) ?? .systemFont(ofSize: size) + } +} diff --git a/StopWatch/DesignSystem/Core/Typography/Typography.swift b/StopWatch/DesignSystem/Core/Typography/Typography.swift new file mode 100644 index 0000000..bc0911a --- /dev/null +++ b/StopWatch/DesignSystem/Core/Typography/Typography.swift @@ -0,0 +1,151 @@ +// +// Typography.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/24/24. +// + +import SwiftUI + +public enum Typography { + /// title + case title1 + case title2 + case title3 + case title4 + case title5 + + + /// subtitle + case subTitle1 + case subTitle2 + case subTitle3 + + + /// label + case label1 + case label2 + case label3 + case label4 + + + /// body + case body1 + case body2 + + + /// caption + case caption1 + case caption2 + case caption3 + + + /// input + case input1 + case input2 +} + +extension Typography { + + /// SwiftUI Font + var font: Font { + Font(self.uiFont) + } + + + /// UIKit UIFont + var uiFont: UIFont { + switch self { + case .title1: + return .pretendard(size: 28, weight: .bold) + case .title2: + return .pretendard(size: 24, weight: .bold) + case .title3: + return .pretendard(size: 20, weight: .bold) + case .title4: + return .pretendard(size: 18, weight: .bold) + case .title5: + return .pretendard(size: 16, weight: .bold) + case .subTitle1: + return .pretendard(size: 24, weight: .semibold) + case .subTitle2: + return .pretendard(size: 20, weight: .semibold) + case .subTitle3: + return .pretendard(size: 18, weight: .semibold) + case .label1: + return .pretendard(size: 16, weight: .semibold) + case .label2: + return .pretendard(size: 14, weight: .semibold) + case .label3: + return .pretendard(size: 12, weight: .semibold) + case .label4: + return .pretendard(size: 11, weight: .semibold) + case .body1: + return .pretendard(size: 16, weight: .regular) + case .body2: + return .pretendard(size: 14, weight: .regular) + case .caption1: + return .pretendard(size: 12, weight: .regular) + case .caption2: + return .pretendard(size: 11, weight: .regular) + case .caption3: + return .pretendard(size: 10, weight: .regular) + case .input1: + return .pretendard(size: 16, weight: .regular) + case .input2: + return .pretendard(size: 14, weight: .semibold) + } + } + + var lineHeight: CGFloat { + switch self { + /// title + case .title1: 38 + case .title2: 32 + case .title3: 28 + case .title4: 26 + case .title5: 24 + + /// subTitle + case .subTitle1: 32 + case .subTitle2: 28 + case .subTitle3: 26 + + /// label + case .label1: 24 + case .label2: 20 + case .label3: 18 + case .label4: 16 + + /// body + case .body1: 24 + case .body2: 20 + + /// caption + case .caption1: 18 + case .caption2: 16 + case .caption3: 14 + + /// input + case .input1: 20 + case .input2: 18 + } + } +} + +// MARK: - ์‹ค์ œ typo ์‚ฌ์šฉ +public extension View { + + /** + Font ๋ฐ lineHeight ์ ์šฉ + ````swift + Text("Typo example") + .setTypo(.title1) + ```` + */ + func setTypo(_ typo: Typography) -> some View { + self + .font(typo.font) + .modifier(LineHeightModifier(font: typo.uiFont, lineHeight: typo.lineHeight)) + } +} diff --git a/StopWatch/DesignSystem/Core/UIHostingController/ViewWrapper.swift b/StopWatch/DesignSystem/Core/UIHostingController/ViewWrapper.swift new file mode 100644 index 0000000..16a0c9a --- /dev/null +++ b/StopWatch/DesignSystem/Core/UIHostingController/ViewWrapper.swift @@ -0,0 +1,25 @@ +// +// ViewWrapper.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public class ViewWrapper: UIHostingController { + + public init( + backgroundColor: UIColor = .systemBackground, + @ViewBuilder content: () -> Content) + { + super.init(rootView: content()) + self.view.backgroundColor = backgroundColor + self.modalPresentationStyle = .fullScreen + } + + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + diff --git a/StopWatch/Resource/images/Assets.xcassets/AccentColor.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AccentColor.colorset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/Color.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Color.colorset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/Color.colorset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/Color.colorset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/ColorWell@1x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/ColorWell@1x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/ColorWell@1x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/ColorWell@1x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/ColorWell@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/ColorWell@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/ColorWell@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/ColorWell@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/ColorWell@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/ColorWell@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/ColorWell@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/ColorWell@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/ColorWell.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/ColorWell.imageset/Contents.json diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_10.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_10.colorset/Contents.json new file mode 100644 index 0000000..1888683 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xC3", + "green" : "0xCD", + "red" : "0xFD" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_2.colorset/Contents.json new file mode 100644 index 0000000..f30d832 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF0", + "green" : "0xF3", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_20.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_20.colorset/Contents.json new file mode 100644 index 0000000..03b85dd --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_20.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x97", + "green" : "0xA8", + "red" : "0xFC" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_30.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_30.colorset/Contents.json new file mode 100644 index 0000000..6217874 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_30.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x64", + "green" : "0x7C", + "red" : "0xE7" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_40.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_40.colorset/Contents.json new file mode 100644 index 0000000..71a9757 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_40.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x42", + "green" : "0x60", + "red" : "0xF5" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_5.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_5.colorset/Contents.json new file mode 100644 index 0000000..b39bf71 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_5.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xE1", + "green" : "0xE6", + "red" : "0xFE" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_50.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_50.colorset/Contents.json new file mode 100644 index 0000000..9adf327 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_50.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x21", + "green" : "0x43", + "red" : "0xED" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_60.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_60.colorset/Contents.json new file mode 100644 index 0000000..0da4889 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_60.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x0B", + "green" : "0x2D", + "red" : "0xD5" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_70.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_70.colorset/Contents.json new file mode 100644 index 0000000..5f842af --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_70.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x04", + "green" : "0x1F", + "red" : "0xA4" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_80.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_80.colorset/Contents.json new file mode 100644 index 0000000..826f924 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_80.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x03", + "green" : "0x15", + "red" : "0x6D" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_90.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_90.colorset/Contents.json new file mode 100644 index 0000000..ba1af1a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Caution_90.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x01", + "green" : "0x0A", + "red" : "0x37" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/Resource/images/Assets.xcassets/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Caution/Contents.json diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_10.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_10.colorset/Contents.json new file mode 100644 index 0000000..4e380b4 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xED", + "green" : "0xEA", + "red" : "0xE9" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_15.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_15.colorset/Contents.json new file mode 100644 index 0000000..cfc4549 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_15.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xE3", + "green" : "0xE0", + "red" : "0xDD" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_2.colorset/Contents.json new file mode 100644 index 0000000..46534ec --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF8", + "green" : "0xF7", + "red" : "0xF6" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_20.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_20.colorset/Contents.json new file mode 100644 index 0000000..51c61f8 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_20.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xD9", + "green" : "0xD6", + "red" : "0xD3" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_25.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_25.colorset/Contents.json new file mode 100644 index 0000000..a65c2c2 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_25.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xCB", + "green" : "0xC6", + "red" : "0xC3" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_30.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_30.colorset/Contents.json new file mode 100644 index 0000000..d10ed51 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_30.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xB3", + "green" : "0xAC", + "red" : "0xA8" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_40.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_40.colorset/Contents.json new file mode 100644 index 0000000..c2cdc81 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_40.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x93", + "green" : "0x8B", + "red" : "0x85" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_5.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_5.colorset/Contents.json new file mode 100644 index 0000000..b18517d --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_5.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF4", + "green" : "0xF2", + "red" : "0xF1" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_50.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_50.colorset/Contents.json new file mode 100644 index 0000000..bf17268 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_50.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x77", + "green" : "0x6F", + "red" : "0x69" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_60.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_60.colorset/Contents.json new file mode 100644 index 0000000..b3f0e17 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_60.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x61", + "green" : "0x5B", + "red" : "0x56" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_70.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_70.colorset/Contents.json new file mode 100644 index 0000000..27b5355 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_70.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x4C", + "green" : "0x47", + "red" : "0x43" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_80.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_80.colorset/Contents.json new file mode 100644 index 0000000..951c1d4 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_80.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x37", + "green" : "0x32", + "red" : "0x2F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_90.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_90.colorset/Contents.json new file mode 100644 index 0000000..919fb32 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_90.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x21", + "green" : "0x1E", + "red" : "0x1C" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_95.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_95.colorset/Contents.json new file mode 100644 index 0000000..a8c3b5e --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_95.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_99.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_99.colorset/Contents.json new file mode 100644 index 0000000..12aaf4e --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/CoolGray/CoolGray_99.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x0B", + "green" : "0x0A", + "red" : "0x09" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_10.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_10.colorset/Contents.json new file mode 100644 index 0000000..b1ab312 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFD", + "green" : "0xEF", + "red" : "0xC3" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_2.colorset/Contents.json new file mode 100644 index 0000000..556d9ae --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFF", + "green" : "0xFB", + "red" : "0xF0" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_20.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_20.colorset/Contents.json new file mode 100644 index 0000000..52c50ad --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_20.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFC", + "green" : "0xE4", + "red" : "0x9C" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_30.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_30.colorset/Contents.json new file mode 100644 index 0000000..c0e5573 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_30.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFB", + "green" : "0xD7", + "red" : "0x6A" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_40.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_40.colorset/Contents.json new file mode 100644 index 0000000..1772ca1 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_40.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFA", + "green" : "0xCC", + "red" : "0x42" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_5.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_5.colorset/Contents.json new file mode 100644 index 0000000..1bbc262 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_5.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFE", + "green" : "0xF7", + "red" : "0xE1" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_50.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_50.colorset/Contents.json new file mode 100644 index 0000000..f24cf0b --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_50.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF2", + "green" : "0xB9", + "red" : "0x0D" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_60.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_60.colorset/Contents.json new file mode 100644 index 0000000..4753f0a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_60.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xCC", + "green" : "0x9A", + "red" : "0x05" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_70.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_70.colorset/Contents.json new file mode 100644 index 0000000..575f76f --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_70.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x9A", + "green" : "0x75", + "red" : "0x04" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_80.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_80.colorset/Contents.json new file mode 100644 index 0000000..873da4d --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_80.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x63", + "green" : "0x4B", + "red" : "0x03" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_90.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_90.colorset/Contents.json new file mode 100644 index 0000000..12ac21a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Information/Information_90.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x37", + "green" : "0x29", + "red" : "0x01" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_10.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_10.colorset/Contents.json new file mode 100644 index 0000000..87ac527 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xEB", + "green" : "0xEB", + "red" : "0xEB" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_15.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_15.colorset/Contents.json new file mode 100644 index 0000000..e7d0ceb --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_15.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xE0", + "green" : "0xE0", + "red" : "0xE0" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_2.colorset/Contents.json new file mode 100644 index 0000000..4438b24 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF7", + "green" : "0xF7", + "red" : "0xF7" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_20.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_20.colorset/Contents.json new file mode 100644 index 0000000..0bb3538 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_20.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xD6", + "green" : "0xD6", + "red" : "0xD6" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_25.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_25.colorset/Contents.json new file mode 100644 index 0000000..3fbb6ec --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_25.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xC7", + "green" : "0xC7", + "red" : "0xC7" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_30.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_30.colorset/Contents.json new file mode 100644 index 0000000..ab762a9 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_30.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xAD", + "green" : "0xAD", + "red" : "0xAD" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_40.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_40.colorset/Contents.json new file mode 100644 index 0000000..2e4a98b --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_40.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x8C", + "green" : "0x8C", + "red" : "0x8C" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_5.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_5.colorset/Contents.json new file mode 100644 index 0000000..03cea30 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_5.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF2", + "green" : "0xF2", + "red" : "0xF2" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_50.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_50.colorset/Contents.json new file mode 100644 index 0000000..94fda75 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_50.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x70", + "green" : "0x70", + "red" : "0x70" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_60.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_60.colorset/Contents.json new file mode 100644 index 0000000..537f2a2 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_60.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x5C", + "green" : "0x5C", + "red" : "0x5C" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_70.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_70.colorset/Contents.json new file mode 100644 index 0000000..c4269d2 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_70.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x47", + "green" : "0x47", + "red" : "0x47" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_80.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_80.colorset/Contents.json new file mode 100644 index 0000000..be3a0c9 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_80.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x33", + "green" : "0x33", + "red" : "0x33" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_90.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_90.colorset/Contents.json new file mode 100644 index 0000000..32e28f9 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_90.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x1F", + "green" : "0x1F", + "red" : "0x1F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_95.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_95.colorset/Contents.json new file mode 100644 index 0000000..bfb5070 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_95.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x14", + "green" : "0x14", + "red" : "0x14" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_99.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_99.colorset/Contents.json new file mode 100644 index 0000000..ae0466b --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Netural/Netural_99.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x0A", + "green" : "0x0A", + "red" : "0x0A" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_0.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_0.colorset/Contents.json new file mode 100644 index 0000000..2e3b11e --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_0.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.000", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_100.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_100.colorset/Contents.json new file mode 100644 index 0000000..a8c3b5e --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_100.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_10n1.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_10n1.colorset/Contents.json new file mode 100644 index 0000000..1ce3a46 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_10n1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.100", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_2n1.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_2n1.colorset/Contents.json new file mode 100644 index 0000000..0cc13f1 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_2n1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.500", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_3n1.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_3n1.colorset/Contents.json new file mode 100644 index 0000000..c915669 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_3n1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.330", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_3n2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_3n2.colorset/Contents.json new file mode 100644 index 0000000..9fbda83 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_3n2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.670", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_4n1.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_4n1.colorset/Contents.json new file mode 100644 index 0000000..b90a091 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_4n1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.250", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n1.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n1.colorset/Contents.json new file mode 100644 index 0000000..d8044c4 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n1.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.200", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n2.colorset/Contents.json new file mode 100644 index 0000000..e21e355 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.400", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n4.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n4.colorset/Contents.json new file mode 100644 index 0000000..dd6d837 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Opacity/Opacity_5n4.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.800", + "blue" : "0x16", + "green" : "0x14", + "red" : "0x12" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_10.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_10.colorset/Contents.json new file mode 100644 index 0000000..1053420 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFD", + "green" : "0xDC", + "red" : "0xC3" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_2.colorset/Contents.json new file mode 100644 index 0000000..09d1e4a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFF", + "green" : "0xF6", + "red" : "0xF0" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_20.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_20.colorset/Contents.json new file mode 100644 index 0000000..70fe10f --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_20.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFC", + "green" : "0xC1", + "red" : "0x97" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_30.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_30.colorset/Contents.json new file mode 100644 index 0000000..0f1ac42 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_30.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFB", + "green" : "0xA0", + "red" : "0x60" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_40.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_40.colorset/Contents.json new file mode 100644 index 0000000..56b70af --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_40.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFA", + "green" : "0x8C", + "red" : "0x3D" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_45.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_45.colorset/Contents.json new file mode 100644 index 0000000..1e99484 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_45.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF9", + "green" : "0x77", + "red" : "0x1A" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_5.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_5.colorset/Contents.json new file mode 100644 index 0000000..094c8aa --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_5.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFE", + "green" : "0xED", + "red" : "0xE1" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_50.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_50.colorset/Contents.json new file mode 100644 index 0000000..e14ad8a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_50.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF9", + "green" : "0x6B", + "red" : "0x06" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_55.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_55.colorset/Contents.json new file mode 100644 index 0000000..8ab5d1a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_55.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xDB", + "green" : "0x5E", + "red" : "0x05" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_60.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_60.colorset/Contents.json new file mode 100644 index 0000000..1880e2f --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_60.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xBD", + "green" : "0x52", + "red" : "0x05" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_70.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_70.colorset/Contents.json new file mode 100644 index 0000000..6e3bb02 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_70.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x9A", + "green" : "0x43", + "red" : "0x04" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_80.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_80.colorset/Contents.json new file mode 100644 index 0000000..2641478 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_80.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x63", + "green" : "0x2B", + "red" : "0x03" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_90.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_90.colorset/Contents.json new file mode 100644 index 0000000..0da9c4d --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Primary/Primary_90.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x37", + "green" : "0x18", + "red" : "0x01" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_10.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_10.colorset/Contents.json new file mode 100644 index 0000000..058dbab --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_10.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xBD", + "green" : "0xF3", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_2.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_2.colorset/Contents.json new file mode 100644 index 0000000..a00d7b8 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_2.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xEB", + "green" : "0xFC", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_20.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_20.colorset/Contents.json new file mode 100644 index 0000000..09d7f0a --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_20.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x94", + "green" : "0xEA", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_30.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_30.colorset/Contents.json new file mode 100644 index 0000000..49718a2 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_30.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x66", + "green" : "0xDE", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_40.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_40.colorset/Contents.json new file mode 100644 index 0000000..b3ca2e0 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_40.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x3D", + "green" : "0xCF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_5.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_5.colorset/Contents.json new file mode 100644 index 0000000..449f179 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_5.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xD6", + "green" : "0xFB", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_50.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_50.colorset/Contents.json new file mode 100644 index 0000000..871c074 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_50.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0xBF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_60.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_60.colorset/Contents.json new file mode 100644 index 0000000..3e30c7f --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_60.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0xAB", + "red" : "0xF5" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_70.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_70.colorset/Contents.json new file mode 100644 index 0000000..66dc4ae --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_70.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x88", + "red" : "0xCC" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_80.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_80.colorset/Contents.json new file mode 100644 index 0000000..f9e07fa --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_80.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x52", + "red" : "0x85" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_90.colorset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_90.colorset/Contents.json new file mode 100644 index 0000000..83a4462 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Colors/Warning/Warning_90.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x00", + "green" : "0x24", + "red" : "0x3D" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_off.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_off.imageset/Contents.json new file mode 100644 index 0000000..364aee5 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_off.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "check_fill_off.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_off.imageset/check_fill_off.pdf b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_off.imageset/check_fill_off.pdf new file mode 100644 index 0000000..11114f3 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_off.imageset/check_fill_off.pdf differ diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_on.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_on.imageset/Contents.json new file mode 100644 index 0000000..b7bc0ff --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_on.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "check_fill_on.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_on.imageset/check_fill_on.pdf b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_on.imageset/check_fill_on.pdf new file mode 100644 index 0000000..6152d91 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/check_fill_on.imageset/check_fill_on.pdf differ diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_left.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_left.imageset/Contents.json new file mode 100644 index 0000000..9f7d0d8 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_left.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "chevron_left.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_left.imageset/chevron_left.pdf b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_left.imageset/chevron_left.pdf new file mode 100644 index 0000000..4fc2058 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_left.imageset/chevron_left.pdf differ diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_right.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_right.imageset/Contents.json new file mode 100644 index 0000000..7bf9443 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_right.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "chevron_right.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_right.imageset/chevron_right.pdf b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_right.imageset/chevron_right.pdf new file mode 100644 index 0000000..39c4b55 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/chevron_right.imageset/chevron_right.pdf differ diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/handler.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/handler.imageset/Contents.json new file mode 100644 index 0000000..df1f2c0 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/handler.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "handler.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/handler.imageset/handler.pdf b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/handler.imageset/handler.pdf new file mode 100644 index 0000000..672861d Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/handler.imageset/handler.pdf differ diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/write.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/write.imageset/Contents.json new file mode 100644 index 0000000..33e7e47 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/write.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "write.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/write.imageset/write.pdf b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/write.imageset/write.pdf new file mode 100644 index 0000000..28551f1 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Assets.xcassets/Icons/write.imageset/write.pdf differ diff --git a/StopWatch/DesignSystem/Resource/Assets.xcassets/Images/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/Images/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/StopWatch/DesignSystem/Resource/Assets.xcassets/Images/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StopWatch/Resource/images/Assets.xcassets/category.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/category.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/category.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/category.imageset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/category.imageset/category.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/category.imageset/category.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/category.imageset/category.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/category.imageset/category.png diff --git a/StopWatch/Resource/images/Assets.xcassets/contact.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/contact.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/contact.imageset/contact@1x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/contact@1x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/contact.imageset/contact@1x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/contact@1x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/contact.imageset/contact@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/contact@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/contact.imageset/contact@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/contact@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/contact.imageset/contact@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/contact@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/contact.imageset/contact@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/contact.imageset/contact@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/dday.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/dday.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/dday.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/dday.imageset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/dday.imageset/calendar-2.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/dday.imageset/calendar-2.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/dday.imageset/calendar-2.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/dday.imageset/calendar-2.png diff --git a/StopWatch/Resource/images/Assets.xcassets/goalTime.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/goalTime.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/goalTime.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/goalTime.imageset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/goalTime.imageset/calendar.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/goalTime.imageset/calendar.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/goalTime.imageset/calendar.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/goalTime.imageset/calendar.png diff --git a/StopWatch/Resource/images/Assets.xcassets/send.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/send.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/send.imageset/send@1x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/send@1x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/send.imageset/send@1x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/send@1x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/send.imageset/send@2x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/send@2x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/send.imageset/send@2x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/send@2x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/send.imageset/send@3x.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/send@3x.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/send.imageset/send@3x.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/send.imageset/send@3x.png diff --git a/StopWatch/Resource/images/Assets.xcassets/statistics.imageset/Contents.json b/StopWatch/DesignSystem/Resource/Assets.xcassets/statistics.imageset/Contents.json similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/statistics.imageset/Contents.json rename to StopWatch/DesignSystem/Resource/Assets.xcassets/statistics.imageset/Contents.json diff --git a/StopWatch/Resource/images/Assets.xcassets/statistics.imageset/spreadsheet-app.png b/StopWatch/DesignSystem/Resource/Assets.xcassets/statistics.imageset/spreadsheet-app.png similarity index 100% rename from StopWatch/Resource/images/Assets.xcassets/statistics.imageset/spreadsheet-app.png rename to StopWatch/DesignSystem/Resource/Assets.xcassets/statistics.imageset/spreadsheet-app.png diff --git a/StopWatch/DesignSystem/Resource/Fonts/Pretendard-Bold.otf b/StopWatch/DesignSystem/Resource/Fonts/Pretendard-Bold.otf new file mode 100644 index 0000000..a52ef39 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Fonts/Pretendard-Bold.otf differ diff --git a/StopWatch/DesignSystem/Resource/Fonts/Pretendard-Regular.otf b/StopWatch/DesignSystem/Resource/Fonts/Pretendard-Regular.otf new file mode 100644 index 0000000..c940185 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Fonts/Pretendard-Regular.otf differ diff --git a/StopWatch/DesignSystem/Resource/Fonts/Pretendard-SemiBold.otf b/StopWatch/DesignSystem/Resource/Fonts/Pretendard-SemiBold.otf new file mode 100644 index 0000000..c375b54 Binary files /dev/null and b/StopWatch/DesignSystem/Resource/Fonts/Pretendard-SemiBold.otf differ diff --git a/StopWatch/DesignSystem/Util/Extension/SwiftUI/View+.swift b/StopWatch/DesignSystem/Util/Extension/SwiftUI/View+.swift new file mode 100644 index 0000000..ef09080 --- /dev/null +++ b/StopWatch/DesignSystem/Util/Extension/SwiftUI/View+.swift @@ -0,0 +1,99 @@ +// +// View+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import SwiftUI + +public extension View { + /// ์ž„์‹œ + static var identifier: String { "\(Self.self)" } + + var viewController: UIViewController { + ViewWrapper() { self } + } + + var viewControllerClear: UIViewController { + ViewWrapper(backgroundColor: .clear) { self } + } + + @ViewBuilder func roundedBorder( + _ color: Color = .black, + radius: CGFloat = 8, + linewidth: CGFloat = 1 + ) -> some View { + self + .clipShape(RoundedRectangle(cornerRadius: radius)) + .overlay { + RoundedRectangle(cornerRadius: radius) + .stroke(color, lineWidth: linewidth) + } + } + + @ViewBuilder func roundedBorder( + _ color: Color = .getColor(.line_assistive), + topLeftRadius: CGFloat = 8, + topRightRadius: CGFloat = 8, + bottomLeftRadius: CGFloat = 8, + bottomRightRadius: CGFloat = 8, + linewidth: CGFloat = 1 + ) -> some View { + self + .clipShape( + .rect( + topLeadingRadius: topLeftRadius, + bottomLeadingRadius: bottomLeftRadius, + bottomTrailingRadius: bottomRightRadius, + topTrailingRadius: topRightRadius + ) + ) + .overlay { + RoundedShape( + topLeft: topLeftRadius, + topRight: topRightRadius, + bottomLeft: bottomLeftRadius, + bottomRight: bottomRightRadius + ) + .stroke(color, lineWidth: linewidth) + } + } + + @ViewBuilder + func hideKeyboardOnTapBackground(background: UIColor = UIColor.systemBackground) -> some View { + self + .background( + Color(background) + .onTapGesture { + UIApplication.shared.endEditing() + } + ) + } + + @ViewBuilder + func `if`(_ condition: Bool, content: (Self) -> Content) -> some View { + if condition { + content(self) + } else { + self + } + } + + @ViewBuilder + func isLoading(_ state: Bool) -> some View { + self + .disabled(state) + .overlay { + if state { + ProgressView() + .progressViewStyle(.circular) + } + } + } + + func hSpacing(alignment: Alignment = .leading) -> some View { + self.frame(maxWidth: .infinity, alignment: alignment) + } +} + diff --git a/StopWatch/DesignSystem/Util/Extension/UIKit/NavigationController+.swift b/StopWatch/DesignSystem/Util/Extension/UIKit/NavigationController+.swift new file mode 100644 index 0000000..b3e6df5 --- /dev/null +++ b/StopWatch/DesignSystem/Util/Extension/UIKit/NavigationController+.swift @@ -0,0 +1,31 @@ +// +// NavigationController.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/28/24. +// + +import UIKit.UINavigationController + +public extension UINavigationController { + static func `default`() -> UINavigationController { + let nController = UINavigationController() + nController.isNavigationBarHidden = true + nController.modalPresentationStyle = .fullScreen + return nController + } +} + + +// MARK: - ๋„ค๋น„๊ฒŒ์ด์…˜ back์ œ์Šค์ณ ํ™œ์„ฑํ™” +extension UINavigationController: @retroactive UINavigationControllerDelegate, @retroactive UIGestureRecognizerDelegate { + open override func viewDidLoad() { + super.viewDidLoad() + interactivePopGestureRecognizer?.delegate = self + } + + public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + return viewControllers.count > 1 + } +} + diff --git a/StopWatch/DesignSystem/Util/Extension/UIKit/UIApplication+.swift b/StopWatch/DesignSystem/Util/Extension/UIKit/UIApplication+.swift new file mode 100644 index 0000000..3f2381a --- /dev/null +++ b/StopWatch/DesignSystem/Util/Extension/UIKit/UIApplication+.swift @@ -0,0 +1,39 @@ +// +// UIApplication+.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/3/24. +// + +import UIKit.UIApplication + +public extension UIApplication { + + var scene: UIWindowScene? { + UIApplication + .shared + .connectedScenes + .first as? UIWindowScene + } + + var window: UIWindow? { + scene? + .windows + .first(where: { $0.isKeyWindow }) + } + + var root: UIViewController? { + window?.rootViewController + } + + var screenSize: CGRect? { + scene?.screen.bounds + } + + func endEditing() { + sendAction( + #selector(UIResponder.resignFirstResponder), + to: nil, from: nil, for: nil + ) + } +} diff --git a/StopWatch/DesignSystem/Util/Shape/RoundedShape.swift b/StopWatch/DesignSystem/Util/Shape/RoundedShape.swift new file mode 100644 index 0000000..29d1dae --- /dev/null +++ b/StopWatch/DesignSystem/Util/Shape/RoundedShape.swift @@ -0,0 +1,95 @@ +// +// RoundedShape.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/25/24. +// + +import SwiftUI + +public struct RoundedShape: Shape { + private var topLeft: CGFloat + private var topRight: CGFloat + private var bottomLeft: CGFloat + private var bottomRight: CGFloat + + public init( + topLeft: CGFloat, + topRight: CGFloat, + bottomLeft: CGFloat, + bottomRight: CGFloat + ) { + self.topLeft = topLeft + self.topRight = topRight + self.bottomLeft = bottomLeft + self.bottomRight = bottomRight + } + + public init(all: CGFloat) { + self.topLeft = all + self.topRight = all + self.bottomLeft = all + self.bottomRight = all + } + + public init(radiusToken: RadiusToken) { + self.topLeft = radiusToken.topLeft + self.topRight = radiusToken.topRight + self.bottomLeft = radiusToken.bottomLeft + self.bottomRight = radiusToken.bottomRight + } + + public func path(in rect: CGRect) -> Path { + var path = Path() + + path.move(to: CGPoint(x: rect.minX + topLeft, y: rect.minY)) + + //top-right corner + path.addLine(to: CGPoint(x: rect.maxX - topRight, y: rect.minY)) + path.addArc( + center: CGPoint(x: rect.maxX - topRight, y: rect.minY + topRight), + radius: topRight, + startAngle: .degrees(-90), + endAngle: .degrees(0), + clockwise: false + ) + + // bottom-right corner + path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY - bottomRight)) + path.addArc( + center: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY - bottomRight), + radius: bottomRight, + startAngle: .degrees(0), + endAngle: .degrees(90), + clockwise: false + ) + + // bottom-left corner + path.addLine(to: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY)) + path.addArc( + center: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY - bottomLeft), + radius: bottomLeft, + startAngle: .degrees(90), + endAngle: .degrees(180), + clockwise: false + ) + + // top-left corner + path.addLine(to: CGPoint(x: rect.minX, y: rect.minY + topLeft)) + path.addArc( + center: CGPoint(x: rect.minX + topLeft, y: rect.minY + topLeft), + radius: topLeft, + startAngle: .degrees(180), + endAngle: .degrees(270), + clockwise: false + ) + + return path + } +} + +public extension Shape { + var asAnyShape: AnyShape { + AnyShape(self) + } +} diff --git a/StopWatch/Entity/Category.swift b/StopWatch/Entity/Category.swift new file mode 100644 index 0000000..63fdd04 --- /dev/null +++ b/StopWatch/Entity/Category.swift @@ -0,0 +1,36 @@ +// +// Category.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/24/24. +// + +import Foundation +import RealmSwift + +class Category: Object { + @Persisted(primaryKey: true) var id : String + @Persisted var name: String + + convenience init(id: String = UUID().uuidString, name: String) { + self.init() + self.id = id + self.name = name + } +} + + +// MARK: - Mock Data +extension Category { + static var programmingMock: Category { + .init(name: "ํ”„๋กœ๊ทธ๋ž˜๋ฐ") + } + + static var englishMock: Category { + .init(name: "์˜์–ด") + } + + static var exerciseMock: Category { + .init(name: "์šด๋™") + } +} diff --git a/StopWatch/Entity/TimeCheck.swift b/StopWatch/Entity/TimeCheck.swift new file mode 100644 index 0000000..ed693bb --- /dev/null +++ b/StopWatch/Entity/TimeCheck.swift @@ -0,0 +1,32 @@ +// +// TimeCheck.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/24/24. +// + +import Foundation +import RealmSwift + +class TimeCheck: Object { + @Persisted(primaryKey: true) var id : String + @Persisted var startDate: Date + @Persisted var endDate: Date + @Persisted var breakTime: Double + @Persisted var todo: Todo? + + convenience init(id : String = UUID().uuidString, startDate: Date, endDate: Date, breakTime: Double, todo: Todo) { + self.init() + self.id = id + self.startDate = startDate + self.endDate = endDate + self.breakTime = breakTime + self.todo = todo + } +} + +extension TimeCheck { + var focusTime: Double { + endDate.timeIntervalSince1970 - startDate.timeIntervalSince1970 - breakTime + } +} diff --git a/StopWatch/Entity/Todo.swift b/StopWatch/Entity/Todo.swift new file mode 100644 index 0000000..b5d995c --- /dev/null +++ b/StopWatch/Entity/Todo.swift @@ -0,0 +1,56 @@ +// +// Todo.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/24/24. +// + +import Foundation +import RealmSwift + +class Todo: Object { + @Persisted(primaryKey: true) var id: String + @Persisted var date: Date? + @Persisted var content: String + @Persisted var progress: Double + @Persisted var category: Category? + + convenience init(id: String = UUID().uuidString, date: Date? = nil, content: String, progress: Double = .zero, category: Category? = .none) { + self.init() + self.id = id + self.date = date + self.content = content + self.progress = progress + self.category = category + } +} + +// MARK: - Mock Data +extension Todo { + static var mockData1: Todo { + .init( + date: .now, + content: "๊ฐ์ฒด์ง€ํ–ฅํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ณต๋ถ€", + progress: 0, + category: .programmingMock + ) + } + + static var mockData2: Todo { + .init( + date: .now, + content: "๋‹จ์–ด 30๊ฐœ ์™ธ์šฐ๊ธฐ", + progress: 0, + category: .englishMock + ) + } + + static var mockData3: Todo { + .init( + date: .now, + content: "๊ฐ€์Šด ์šด๋™ 50๋ถ„", + progress: 0.5, + category: .exerciseMock + ) + } +} diff --git a/StopWatch/Models/Enums/CheckImage.swift b/StopWatch/Models/Enums/CheckImage.swift index 71ffd3c..7f73527 100644 --- a/StopWatch/Models/Enums/CheckImage.swift +++ b/StopWatch/Models/Enums/CheckImage.swift @@ -21,4 +21,13 @@ enum CheckImage: Int { case .xmark: return UIImage(systemName: "xmark") ?? UIImage() } } + + var title: String { + switch self { + case .null: return "" + case .circle: return "Done" + case .triangle: return "In Progress" + case .xmark: return "UnDone" + } + } } diff --git a/StopWatch/Repository/CategoryRepository.swift b/StopWatch/Repository/CategoryRepository.swift new file mode 100644 index 0000000..f88d3bf --- /dev/null +++ b/StopWatch/Repository/CategoryRepository.swift @@ -0,0 +1,62 @@ +// +// CategoryRepository.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/23/25. +// + +import Foundation +import RealmSwift + +protocol CategoryRepository: DBRepository where Entity == Category { + +} + +final class CategoryRepositoryImpl: CategoryRepository { + + + private let realm: Realm + + init(realm: Realm) { + self.realm = realm + } + + func update(entity: Category, keypaths: [(WritableKeyPath, T)]) throws { + var entityToUpdate = entity + try realm.write { + for (keyPath, newValue) in keypaths { + entityToUpdate[keyPath: keyPath] = newValue + } + } + } + + func update(entities: [Category], keypaths: [(WritableKeyPath, T)]) throws { + for entity in entities { + try update(entity: entity, keypaths: keypaths) + } + + } + + func delete(entity: Category) throws { + try realm.write { + realm.delete(entity) + } + } + + func delete(entities: [Category]) throws { + for entity in entities { + try delete(entity: entity) + } + } + + func getAll() throws -> [Category] { + let result = realm.objects(Category.self) + return result.map { $0 } + } + + func create(entity: Entity) throws { + try realm.write { + realm.add(entity) + } + } +} diff --git a/StopWatch/Repository/DBRepository.swift b/StopWatch/Repository/DBRepository.swift new file mode 100644 index 0000000..4264b3f --- /dev/null +++ b/StopWatch/Repository/DBRepository.swift @@ -0,0 +1,45 @@ +// +// DBRepository.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/24/25. +// + +import Foundation +import RealmSwift + +protocol DBRepository { + associatedtype Entity = Object + + func getAll() throws -> [Entity] + + func create(entity: Entity) throws + +// func update(id: String, keypaths: [(WritableKeyPath, T)]) throws + + func update(entity: Entity, keypaths: [(WritableKeyPath, T)]) throws + + func update(entities: [Entity], keypaths: [(WritableKeyPath, T)]) throws + + func delete(entity: Entity) throws + + func delete(entities: [Entity]) throws +} + +enum ComparisonOperator { + case greaterThan + case greaterThanOrEqual + case lessThan + case lessThanOrEqual + case equal + + func apply(_ lhs: T, _ rhs: T) -> Bool { + switch self { + case .greaterThan: return lhs > rhs + case .greaterThanOrEqual: return lhs >= rhs + case .lessThan: return lhs < rhs + case .lessThanOrEqual: return lhs <= rhs + case .equal: return lhs == rhs + } + } +} diff --git a/StopWatch/Repository/TimeCheckReopsitory.swift b/StopWatch/Repository/TimeCheckReopsitory.swift new file mode 100644 index 0000000..4e0bfa1 --- /dev/null +++ b/StopWatch/Repository/TimeCheckReopsitory.swift @@ -0,0 +1,60 @@ +// +// TimeCheckReopsitory.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 2/2/25. +// + +import Foundation +import RealmSwift + +protocol TimeCheckReopsitory: DBRepository where Entity == TimeCheck { + +} + +final class TimeCheckReopsitoryImpl: TimeCheckReopsitory { + + private let realm: Realm + + init(realm: Realm) { + self.realm = realm + } + + func getAll() throws -> [TimeCheck] { + realm.objects(TimeCheck.self).map { $0 } + } + + func create(entity: TimeCheck) throws { + try realm.write { + realm.add(entity) + } + } + + func update(entity: TimeCheck, keypaths: [(WritableKeyPath, T)]) throws { + var entityToUpdate = entity + + try? realm.write { + for (keyPath, newValue) in keypaths { + entityToUpdate[keyPath: keyPath] = newValue + } + } + } + + func update(entities: [TimeCheck], keypaths: [(WritableKeyPath, T)]) throws { + for entity in entities { + try update(entity: entity, keypaths: keypaths) + } + } + + func delete(entity: TimeCheck) throws { + try realm.write { + realm.delete(entity) + } + } + + func delete(entities: [TimeCheck]) throws { + for entity in entities { + try delete(entity: entity) + } + } +} diff --git a/StopWatch/Repository/TodoRepository.swift b/StopWatch/Repository/TodoRepository.swift new file mode 100644 index 0000000..db32d25 --- /dev/null +++ b/StopWatch/Repository/TodoRepository.swift @@ -0,0 +1,60 @@ +// +// TodoRepository.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/26/25. +// + +import Foundation +import RealmSwift + +protocol TodoRepository: DBRepository where Entity == Todo { + +} + +final class TodoRepositoryImpl: TodoRepository { + + private let realm: Realm + + init(realm: Realm) { + + self.realm = realm + } + + func getAll() throws -> [Todo] { + realm.objects(Todo.self).map { $0 } + } + + func create(entity: Todo) throws { + try realm.write { + realm.add(entity) + } + } + + func update(entity: Todo, keypaths: [(WritableKeyPath, T)]) throws { + var entityToUpdate = entity + try? realm.write { + for (keyPath, newValue) in keypaths { + entityToUpdate[keyPath: keyPath] = newValue + } + } + } + + func update(entities: [Todo], keypaths: [(WritableKeyPath, T)]) throws { + for entity in entities { + try update(entity: entity, keypaths: keypaths) + } + } + + func delete(entity: Todo) throws { + try realm.write { + realm.delete(entity) + } + } + + func delete(entities: [Todo]) throws { + for entity in entities { + try delete(entity: entity) + } + } +} diff --git a/StopWatch/Screen/MainTab/MainTabCoordinator.swift b/StopWatch/Screen/MainTab/MainTabCoordinator.swift new file mode 100644 index 0000000..ef19145 --- /dev/null +++ b/StopWatch/Screen/MainTab/MainTabCoordinator.swift @@ -0,0 +1,57 @@ +// +// MainTabCoordinator.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 8/2/24. +// + +import SwiftUI + +enum MainTabParentFlow: ParentFlow { + +} + +final class MainTabCoordinator: CoordinatorType { + + var childCoordinators: [any CoordinatorType] = [] + var parentCoordinator: (any CoordinatorType)? + var navigationController: UINavigationController = .default() + + weak var tabViewModel: TabViewModel? + + init(parentCoordinator: (any CoordinatorType)? = .none) { + self.parentCoordinator = parentCoordinator + } + + enum Flow { + case start + case changeTab(TabItem) + } + + func setFlow(_ flow: Flow) { + switch flow { + case .start: + let viewModel = TabViewModel(coordinator: self) + tabViewModel = viewModel + let view = MainTabView(viewModel: viewModel).viewController + self.navigationController.setViewControllers([view], animated: false) + + case .changeTab(let newTab): + tabViewModel?.state.currentTab = newTab + } + } + + func setParentFlow(_ flow: any ParentFlow) { +// guard let flow = flow as? MainTabParentFlow else { +// return +// } +// +// switch flow { +// case .logout: +// } + } +} + +extension MainTabCoordinator { + +} diff --git a/StopWatch/Screen/MainTab/MainTabView.swift b/StopWatch/Screen/MainTab/MainTabView.swift new file mode 100644 index 0000000..826cf30 --- /dev/null +++ b/StopWatch/Screen/MainTab/MainTabView.swift @@ -0,0 +1,89 @@ +// +// MainTabView.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/29/24. +// + +import SwiftUI + +struct MainTabView: View { + + @StateObject var viewModel: TabViewModel + + init(viewModel: TabViewModel) { + self._viewModel = .init(wrappedValue: viewModel) + UITabBar.appearance().isHidden = true + } + + var body: some View { + WithDesignSystem { + TabView(selection: $viewModel.state.currentTab) { + ForEach(TabItem.allCases, id: \.self) { tabItem in + switch viewModel.state.currentTab { + case .todo: + TodoView(viewModel: viewModel.todoViewModel) + + case .stopWatch: + StopWatchMainView(viewModel: viewModel.stopWatchViewModel) + + case .chart: + let viewModel = StatisticMainViewModel(coordinator: MainTabCoordinator(), state: .init()) + StatisticMainView(viewModel: viewModel) + + case .setting: + SettingView(viewModel: viewModel.settingViewModel) + } + } + } + mainTabBar() + } + .ignoresSafeArea() + } + + @ViewBuilder func mainTabBar() -> some View { + HStack(spacing: 43) { + ForEach(TabItem.allCases, id: \.self) { tabItem in + tabItemCell(tabItem) + } + } + .frame(maxWidth: .infinity) + .padding(.horizontal, 16) + .frame(height: 88) + .background(Color.white) + .roundedBorder( + topLeftRadius: 16, + topRightRadius: 16, + bottomLeftRadius: .zero, + bottomRightRadius: .zero + ) + } + + @ViewBuilder func tabItemCell(_ item: TabItem) -> some View { + let isCurrentTab = self.viewModel.state.currentTab == item + Button(action: { + self.viewModel.reduce(.didSelectTab(item)) + }, label: { + VStack(spacing: 4) { + item.tabIcon + .resizable() + .scaledToFit() + .frame(width: 24, height: 24) + Text(item.title) + } + .setTypo(.caption2) + .foregroundStyle(isCurrentTab ? Color.getColor(.text_normal) : .getColor(.text_disable)) + .frame(maxWidth: .infinity) + .frame(maxHeight: .infinity, alignment: .top) + .padding(.top, 12) + }) + } +} + +#Preview { + MainTabView( + viewModel: TabViewModel( + coordinator: MainTabCoordinator() + ) + ) +} diff --git a/StopWatch/Screen/MainTab/TabItem.swift b/StopWatch/Screen/MainTab/TabItem.swift new file mode 100644 index 0000000..f3d77c2 --- /dev/null +++ b/StopWatch/Screen/MainTab/TabItem.swift @@ -0,0 +1,41 @@ +// +// TabItem.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/29/24. +// + +import SwiftUI + +enum TabItem: CaseIterable { + case todo + case stopWatch + case chart + case setting + + var title: String { + switch self { + case .todo: + return "ํˆฌ๋‘" + case .stopWatch: + return "์Šคํ†ฑ์›Œ์น˜" + case .chart: + return "ํ†ต๊ณ„" + case .setting: + return "์„ค์ •" + } + } + + var tabIcon: Image { + switch self { + case .todo: + return .init(systemName: "highlighter") + case .stopWatch: + return .init(systemName: "gauge.with.needle") + case .chart: + return .init(systemName: "chart.pie.fill") + case .setting: + return .init(systemName: "gearshape.fill") + } + } +} diff --git a/StopWatch/Screen/MainTab/TabViewModel.swift b/StopWatch/Screen/MainTab/TabViewModel.swift new file mode 100644 index 0000000..4c1151b --- /dev/null +++ b/StopWatch/Screen/MainTab/TabViewModel.swift @@ -0,0 +1,74 @@ +// +// TabViewModel.swift +// Receive +// +// Created by iOS์‹ ์ƒ์šฐ on 7/29/24. +// + +import Foundation + +final class TabViewModel: ViewModelable { + let coordinator: MainTabCoordinator + + @Published var state: State = .init() + + init(coordinator: MainTabCoordinator) { + self.coordinator = coordinator + } + + struct State { + var currentTab: TabItem = .todo + } + + enum Action { + case didSelectTab(TabItem) + case onAppear + } + + + // MARK: - Child ViewModels + + lazy var todoViewModel: TodoViewModel = { + let coordinator = TodoCoordinator( + navigationController: coordinator.navigationController, + parentCoordinator: coordinator + ) + self.coordinator.childCoordinators.append(coordinator) + return .init(coordinator: coordinator, state: .init()) + }() + + lazy var stopWatchViewModel: StopWatchMainViewModel = { + let coordinator = StopWatchCoordinator( + navigationController: coordinator.navigationController, + parentCoordinator: self.coordinator + ) + self.coordinator.childCoordinators.append(coordinator) + return .init(coordinator: coordinator, state: .init()) + }() +// +// lazy var feedViewModel: FeedViewModel = { +// let coordinator = FeedCoordinator( +// navigationController: coordinator.navigationController, +// parentCoordinator: self.coordinator +// ) +// self.coordinator.childCoordinators.append(coordinator) +// return .init(coordinator: coordinator) +// }() +// + lazy var settingViewModel: SettingViewModel = { + let coordinator = SettingCoordinator( + navigationController: coordinator.navigationController, + parentCoordinator: coordinator) + self.coordinator.childCoordinators.append(coordinator) + return .init(coordinator: coordinator, state: .init()) + }() + + func reduce(_ action: Action) { + switch action { + case .onAppear: + break + case .didSelectTab(let tab): + state.currentTab = tab + } + } +} diff --git a/StopWatch/Screen/Splash/SplashView.swift b/StopWatch/Screen/Splash/SplashView.swift new file mode 100644 index 0000000..b80c9cf --- /dev/null +++ b/StopWatch/Screen/Splash/SplashView.swift @@ -0,0 +1,19 @@ +// +// SplashView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/23/24. +// + +import SwiftUI + +struct SplashView: View { + @StateObject var viewModel: SplashViewModel + + var body: some View { + Color.white + .onAppear { + viewModel.reduce(.appRoute) + } + } +} diff --git a/StopWatch/Screen/Splash/SplashViewModel.swift b/StopWatch/Screen/Splash/SplashViewModel.swift new file mode 100644 index 0000000..82cd93a --- /dev/null +++ b/StopWatch/Screen/Splash/SplashViewModel.swift @@ -0,0 +1,37 @@ +// +// SplashViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/23/24. +// + +import Foundation + +final class SplashViewModel: ViewModelable { + @Published var state: State = .init() + + let coordinator: AppCoordinator + + init(coordinator: AppCoordinator) { + self.coordinator = coordinator + } + + struct State { + + } + + enum Action { + case appRoute + } + + func reduce(_ action: Action) { + switch action { + case .appRoute: + Task { @MainActor in + try? await Task.sleep(for: .seconds(1)) + coordinator.setFlow(.tab) + } + } + } +} + diff --git a/StopWatch/Screen/Tab/Setting/Category/BottomSheet/CategoryBottomSheetView.swift b/StopWatch/Screen/Tab/Setting/Category/BottomSheet/CategoryBottomSheetView.swift new file mode 100644 index 0000000..22b93be --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Category/BottomSheet/CategoryBottomSheetView.swift @@ -0,0 +1,55 @@ +// +// CategoryBottomSheetView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/31/25. +// + +import SwiftUI + +struct CategoryBottomSheetView: View { + @StateObject var viewModel: CategoryBottomSheetViewModel + + var body: some View { + WithDesignSystem { + + } content: { + VStack(spacing: .zero) { + FixedSpacer(12) + Image(.handler) + FixedSpacer(16) + menuListView + } + } + } + + // MARK: - menuList View + var menuListView: some View { + VStack(spacing: 12) { + menuItem(image: Image(systemName: "pencil"), title: "์ด๋ฆ„ ๋ณ€๊ฒฝ") { + viewModel.reduce(.didTapUpdateCategoryName) + } + + menuItem(image: Image(systemName: "trash"), title: "์‚ญ์ œ", isDeleteCell: true) { + viewModel.reduce(.didTapDelete) + } + } + .padding(.horizontal, 24) + } + + func menuItem(image: Image, title: String, isDeleteCell: Bool = false, action: (()->Void)?) -> some View { + Button { + action?() + } label: { + HStack(spacing: 10) { + image + .resizable() + .frame(width: 20, height: 20) + Text(title) + .setTypo(.label1) + Spacer() + } + .foregroundStyle(isDeleteCell ? .getColor(.caution_text_alternative) : Color.getColor(.gray_text)) + } + } +} diff --git a/StopWatch/Screen/Tab/Setting/Category/BottomSheet/CategoryBottomSheetViewModel.swift b/StopWatch/Screen/Tab/Setting/Category/BottomSheet/CategoryBottomSheetViewModel.swift new file mode 100644 index 0000000..f891876 --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Category/BottomSheet/CategoryBottomSheetViewModel.swift @@ -0,0 +1,62 @@ +// +// CategoryBottomSheetViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/31/25. +// + +import SwiftUI + +protocol CategoryBottomSheetViewModelDelegate: AnyObject { + func deleteCategory(with category: Category) + func didTappedUpdateName(with category: Category) +} + +final class CategoryBottomSheetViewModel: ViewModelable { + let coordinator: any CoordinatorType + + let category: Category + weak var delegate: CategoryBottomSheetViewModelDelegate? + + private let dependency: DependencyBox + + @Published var state: State = .init() + + init( + coordinator: any CoordinatorType, + dependency: DependencyBox = .live, + category: Category, + delegate: CategoryBottomSheetViewModelDelegate? + ) { + self.coordinator = coordinator + self.dependency = dependency + self.category = category + self.delegate = delegate + } + + struct State { + var updateName: String = "" + } + + enum Action { + case didTapDelete + case didTapUpdateCategoryName + } + + func reduce(_ action: Action) { + switch action { + + case .didTapDelete: + delegate?.deleteCategory(with: category) + + case .didTapUpdateCategoryName: + delegate?.didTappedUpdateName(with: category) + } + } +} + +private extension CategoryBottomSheetViewModel { + var categoryRepo: any CategoryRepository { + dependency.resolve() + } +} diff --git a/StopWatch/Screen/Tab/Setting/Category/CategoryCoordinator.swift b/StopWatch/Screen/Tab/Setting/Category/CategoryCoordinator.swift new file mode 100644 index 0000000..466991a --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Category/CategoryCoordinator.swift @@ -0,0 +1,41 @@ +// +// CategoryCoordinator.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/22/25. +// + +import UIKit.UINavigationController + +final class CategoryCoordinator: CoordinatorType { + var parentCoordinator: (any CoordinatorType)? + var childCoordinators: [any CoordinatorType] = [] + var navigationController: UINavigationController + + init(navigationController: UINavigationController, parentCoordinator: (any CoordinatorType)?) { + self.navigationController = navigationController + self.parentCoordinator = parentCoordinator + } + + enum Flow { + case categoryList + case finish + } + + func setParentFlow(_ flow: any ParentFlow) { + + } + + func setFlow(_ flow: Flow) { + switch flow { + case .categoryList: + let viewModel = CategoryListViewModel(coordinator: self) + let view = CategoryListView(viewModel: viewModel).viewController + + push(view) + + case .finish: + parentCoordinator?.setParentFlow(SettingParentFlow.didFinishPop) + } + } +} diff --git a/StopWatch/Screen/Tab/Setting/Category/CategoryListView.swift b/StopWatch/Screen/Tab/Setting/Category/CategoryListView.swift new file mode 100644 index 0000000..d9509c9 --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Category/CategoryListView.swift @@ -0,0 +1,89 @@ +// +// CategoryListView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/22/25. +// + +import SwiftUI + +struct CategoryListView: View { + @StateObject var viewModel: CategoryListViewModel + + var body: some View { + WithDesignSystem { + TopNavigation( + leadingItem: (Image(.chevronLeft), { + viewModel.reduce(.pop) + }), centerTitle: "์นดํ…Œ๊ณ ๋ฆฌ ๋ชฉ๋ก" + ) + } content: { + if viewModel.state.categories.isNotEmpty { + listView + } else { + emptyView + } + } bottomButton: { + Button { + viewModel.reduce(.didTapCreate) + } label: { + Text("์นดํ…Œ๊ณ ๋ฆฌ ์ถ”๊ฐ€") + .setTypo(.body1) + .frame(maxWidth: .infinity) + .foregroundStyle(Color.white) + .padding(.vertical, 12) + .background(Color.getColor(.gray_text)) + .clipShape(.rect(cornerRadius: 16)) + .padding(.horizontal, 24) + } + } + .onAppear { + viewModel.reduce(.fetchData) + } + } + + var listView: some View { + ScrollView { + VStack(spacing: 12) { + FixedSpacer(12) + ForEach(viewModel.state.categories, id: \.id) { category in + Button { + viewModel.reduce(.didTapCategory(category: category)) + } label: { + categoryCell(with: category) + } + } + } + } + .animation(.spring, value: viewModel.state.categories) + .padding(.horizontal, 20) + } + + var emptyView: some View { + VStack(spacing: 8) { + Spacer() + Text("๐Ÿซฅ") + .font(.pretendard(size: 60, weight: .bold)) + Text("์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”") + .setTypo(.body1) + .foregroundStyle(Color.getColor(.text_normal)) + Spacer() + } + } + + func categoryCell(with category: Category) -> some View { + HStack(spacing: .zero) { + Text(category.name) + Spacer() + } + .setTypo(.label1) + .padding() + .foregroundStyle(Color.getColor(.gray_text)) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + } +} + +#Preview { + CategoryListView(viewModel: .init(coordinator: .init(navigationController: .default(), parentCoordinator: AppCoordinator.shared))) +} diff --git a/StopWatch/Screen/Tab/Setting/Category/CategoryListViewModel.swift b/StopWatch/Screen/Tab/Setting/Category/CategoryListViewModel.swift new file mode 100644 index 0000000..7b99b0f --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Category/CategoryListViewModel.swift @@ -0,0 +1,161 @@ +// +// CategoryListViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/22/25. +// + +import Foundation +import SwiftUI + +final class CategoryListViewModel: ViewModelable { + let coordinator: CategoryCoordinator + @Published var state: State + + private let dependency: DependencyBox + + init( + coordinator: CategoryCoordinator, + state: State = .init(), + dependency: DependencyBox = .live + ) { + self.coordinator = coordinator + self.state = state + self.dependency = dependency + } + + struct State { + var categories: [Category] = [] + var categoryName: String = "" + var updateName: String = "" + var isEditMode: Bool = false + var selectedList: [Category] = [] + } + + enum Action { + case fetchData + case pop + case didTapCreate + case editCategoryName(String) + case create(name: String) + case didTapCategory(category: Category) + } + + func reduce(_ action: Action) { + switch action { + + case .fetchData: + state.categories = (try? categoryRepo.getAll()) ?? [] + + case .pop: + coordinator.setFlow(.finish) + + case .editCategoryName(let name): + state.categoryName = name + + case .didTapCreate: + coordinator.showAlert( + .init( + title: "์นดํ…Œ๊ณ ๋ฆฌ ์ด๋ฆ„ ์ž…๋ ฅ", + message: .none, + inputMessage: Binding( + get: { self.state.categoryName }, + set: { self.state.categoryName = $0 } + ) + ) + .addAction(title: "์ทจ์†Œ", style: .cancel, action: { [weak self] in + self?.state.categoryName = "" + self?.coordinator.dismiss(animated: false) + }) + .addTextFieldAction(title: "์ถ”๊ฐ€", style: .primary, action: { [weak self] in + self?.coordinator.dismiss(animated: false) + self?.reduce(.create(name: self?.state.categoryName ?? "")) + self?.state.categoryName = "" + }) + ) + + case .create(let name): + do { + let newCateogry = Category(name: name) + try categoryRepo.create(entity: newCateogry) + state.categories.append(newCateogry) + } catch { + coordinator.showToast("์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ฑ ์‹คํŒจ") + } + + case .didTapCategory(let category): + let viewModel = CategoryBottomSheetViewModel(coordinator: coordinator, category: category, delegate: self) + let view = CategoryBottomSheetView(viewModel: viewModel).panModal(height: .none) + + coordinator.presentPanModals(view) + } + } + + var categoryRepo: any CategoryRepository { + dependency.resolve() + } +} + + +extension CategoryListViewModel: CategoryBottomSheetViewModelDelegate { + func deleteCategory(with category: Category) { + do { + let name = category.name + try categoryRepo.delete(entity: category) + + if let index = state.categories.firstIndex(of: category) { + state.categories.remove(at: index) + } + + coordinator.showToast("'\(name)'๊ฐ€ ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + coordinator.dismiss() + } catch { + coordinator.showToast("์‚ญ์ œ ์‹คํŒจ") + } + } + + func didTappedUpdateName(with category: Category) { + coordinator.dismiss() { [weak self] in + guard let self else { return } + + self.coordinator.showAlert( + .init( + title: "์ด๋ฆ„ ๋ณ€๊ฒฝ", + message: "'\(category.name)'์˜ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค", + inputMessage: Binding( + get: { self.state.updateName }, + set: { self.state.updateName = $0 } + ) + ) + .addAction(title: "์ทจ์†Œ", style: .cancel, action: { [weak self] in + self?.state.updateName = "" + self?.coordinator.dismiss(animated: false) + }) + .addAction(title: "๋ณ€๊ฒฝ", style: .primary, action: { [weak self] in + self?.coordinator.dismiss(animated: false) + + self?.updateName(with: category, newName: self?.state.updateName ?? "") + self?.state.updateName = "" + }) + ) + } + } + + func updateName(with category: Category, newName: String) { + do { + try categoryRepo.update( + entity: category, + keypaths: [(\.name, newName )] + ) + + if let index = state.categories.firstIndex(of: category) { + state.categories.remove(at: index) + reduce(.fetchData) + } + + coordinator.showToast("'\(category.name)'๊ฐ€ \(category.name)์œผ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + } catch { + coordinator.showToast("์—…๋ฐ์ดํŠธ ์‹คํŒจ") + } + } +} diff --git a/StopWatch/Screen/Tab/Setting/FeedBack/FeedBackView.swift b/StopWatch/Screen/Tab/Setting/FeedBack/FeedBackView.swift new file mode 100644 index 0000000..1218c12 --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/FeedBack/FeedBackView.swift @@ -0,0 +1,130 @@ +// +// FeedBackView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct FeedBackView: View { + @StateObject var viewModel: FeedBackViewModel + + var body: some View { + WithDesignSystem(.white) { + TopNavigation( + leadingItem: (Image(.chevronLeft), { + viewModel.coordinator.pop() + }), + centerTitle: "๋ฌธ์˜ํ•˜๊ธฐ" + ) + } content: { + ScrollView { + VStack(spacing: .zero) { + FixedSpacer(40) + TitleView( + title: "์—ฌ๋Ÿฌ๋ถ„์˜ ์ด์•ผ๊ธฐ๋ฅผ ๋“ค๋ ค์ฃผ์„ธ์š”", + content: "๊ถ๊ธˆํ•˜์‹  ์ , ๋”ฐ๋”ํ•œ ์กฐ์–ธ, ์‘์›์˜ ๋ฉ”์„ธ์ง€\n๋ฌด์—‡์ด๋“  ํ™˜์˜์ด์—์š”." + ) + FixedSpacer(24) + writeFeedBackView + // emailView + } + } + .scrollIndicators(.hidden) + .onTapGesture { + UIApplication.shared.endEditing() + } + .padding(.horizontal, 16) + } bottomButton: { + Button { + viewModel.reduce(.didTapSend) + } label: { + Text("์ „์†ก") + .hSpacing(alignment: .center) + .padding() + .background(viewModel.state.isActiveSendButton ? Color.getColor(.gray_text) : .getColor(.fill_disable)) + .clipShape(.rect(cornerRadius: 16)) + .foregroundStyle(.white) + .padding(16) + .disabled(!viewModel.state.isActiveSendButton) + } + } + } + + var writeFeedBackView: some View { + VStack(spacing: .zero) { + Text("์ œ๋ชฉ") + .hSpacing(alignment: .leading) + .setTypo(.label3) + .foregroundStyle(Color.getColor(.text_strong)) + .padding(.leading, 6) + FixedSpacer(8) + + HStack(spacing: 8) { + TextField("", + text: Binding( + get: { viewModel.state.title }, + set: { viewModel.reduce(.editTitle($0)) } + ) + ) + } + .padding(16) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + + FixedSpacer(12) + + Text("๋‚ด์šฉ") + .hSpacing(alignment: .leading) + .setTypo(.label3) + .foregroundStyle(Color.getColor(.text_strong)) + .padding(.leading, 6) + FixedSpacer(8) + + TextEditor(text: Binding( + get: { viewModel.state.content }, + set: { viewModel.reduce(.editContent($0)) } + ) + ) + .scrollContentBackground(.hidden) + .frame(height: 340) + .padding(16) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + } + } + + var emailView: some View { + VStack(spacing: .zero) { + Text("๊ฐœ๋ฐœ์ž ์ด๋ฉ”์ผ") + .hSpacing(alignment: .leading) + .setTypo(.label1) + .foregroundStyle(Color.getColor(.text_strong)) + FixedSpacer(8) + + HStack(spacing: 8) { + Image(systemName: "envelope.fill") + .foregroundColor(Color.getColor(.gray_assistive)) + Text(viewModel.email) + .foregroundStyle(Color.getColor(.text_normal)) + .setTypo(.label2) + Spacer() + Button { + viewModel.reduce(.copyEmail) + } label: { + Text("๋ณต์‚ฌํ•˜๊ธฐ") + .setTypo(.label3) + .foregroundStyle(Color.getColor(.primary_normal)) + } + } + .padding(16) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + } + } +} + +#Preview { + FeedBackView(viewModel: .init(coordinator: .init(navigationController: .default(), parentCoordinator: .none), state: .init())) +} diff --git a/StopWatch/Screen/Tab/Setting/FeedBack/FeedBackViewModel.swift b/StopWatch/Screen/Tab/Setting/FeedBack/FeedBackViewModel.swift new file mode 100644 index 0000000..720c736 --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/FeedBack/FeedBackViewModel.swift @@ -0,0 +1,71 @@ +// +// FeedBackViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import Foundation +import UIKit.UIPasteboard + +final class FeedBackViewModel: ViewModelable { + let coordinator: SettingCoordinator + + @Published var state: State = .init() + let email = "iosdev.sw@gmail.com" + + init(coordinator: SettingCoordinator, state: State) { + self.coordinator = coordinator + self.state = state + } + + struct State { + var title = "" + var content = "" + var isActiveSendButton: Bool { + title.isNotEmpty && content.isNotEmpty + } + } + + enum Action { + case copyEmail + case editTitle(String) + case editContent(String) + case didTapSend + } + + func reduce(_ action: Action) { + switch action { + case .copyEmail: + UIPasteboard.general.string = email + coordinator.showToast("์ด๋ฉ”์ผ ๋ณต์‚ฌ ์™„๋ฃŒ") + + case .editTitle(let title): + self.state.title = title + + case .editContent(let content): + self.state.content = content + + case .didTapSend: + let emailSender = EmailSender( + toAddress: email, + subject: state.title, + body: state.content + ) + + Task { @MainActor in + do { + try await emailSender.send(type: .apple(toAddress: email)) + + coordinator.showToast("์ด๋ฉ”์ผ ์ „์†ก ์™„๋ฃŒ") + coordinator.pop() + } catch EmailSender.EmailSendError.failed { + coordinator.showToast("์ด๋ฉ”์ผ ์ „์†ก์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๊ธฐ๊ธฐ์ž…๋‹ˆ๋‹ค.") + } + catch { + coordinator.showToast("์ด๋ฉ”์ผ ์ „์†ก ์‹คํŒจ") + } + } + } + } +} diff --git a/StopWatch/Screen/Tab/Setting/Main/SettingView.swift b/StopWatch/Screen/Tab/Setting/Main/SettingView.swift new file mode 100644 index 0000000..ab1362b --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Main/SettingView.swift @@ -0,0 +1,82 @@ +// +// SettingView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct SettingView: View { + @StateObject var viewModel: SettingViewModel + + var body: some View { + WithDesignSystem { + HStack(spacing: .zero) { + Text("์„ค์ •") + .setTypo(.subTitle1) + Spacer() + } + .padding(.horizontal, 24) + } content: { + VStack(spacing: 8) { + FixedSpacer(16) + HStack(spacing: 8) { + Text("๐Ÿ“ฃ") + Text("ํ•„์š”ํ•˜์‹  ๊ธฐ๋Šฅ, ๋ฒ„๊ทธ ๋งŽ์€ ์ œ๋ณด ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!") + } + + .padding(.horizontal, 16) + .padding(.vertical, 16) + .frame(maxWidth: .infinity) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 16)) + .setTypo(.body1) + + FixedSpacer(8) + settingCell("์นดํ…Œ๊ณ ๋ฆฌ ๊ด€๋ฆฌ", icon: .init(systemName: "list.bullet.rectangle.fill")) { + viewModel.reduce(.categoryManage) + } + settingCell("์•Œ๋ฆผ ์„ค์ •", icon: .init(systemName: "bell.fill")) { + viewModel.reduce(.notificationSetting) + } + settingCell("๋ฌธ์˜ํ•˜๊ธฐ", icon: .init(systemName: "text.document.fill")) { + viewModel.reduce(.feedback) + } + let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] ?? 1.0 + settingCell("์•ฑ ๋ฒ„์ „", icon: .init(systemName: "info.circle.fill"), content: "\(version)") { + + } + } + .padding(.horizontal, 24) + } + } + + func settingCell(_ title: String, icon: Image, content: String? = .none, action: (()->Void)?) -> some View { + Button { + action?() + } label: { + HStack(spacing: 8) { + icon + .resizable() + .frame(width: 24, height: 24) + .foregroundStyle(Color.getColor(.gray_fill_assistive)) + + Text(title) + .setTypo(.body1) + .foregroundStyle(Color.getColor(.text_normal)) + Spacer() + if let content { + Text(content) + .setTypo(.body2) + .foregroundStyle(Color.getColor(.text_assistive)) + } + } + .padding(.vertical, 8) + } + } +} + +#Preview { + SettingView(viewModel: .init(coordinator: SettingCoordinator(navigationController: .default(), parentCoordinator: AppCoordinator.shared), state: .init())) +} diff --git a/StopWatch/Screen/Tab/Setting/Main/SettingViewModel.swift b/StopWatch/Screen/Tab/Setting/Main/SettingViewModel.swift new file mode 100644 index 0000000..8a070e1 --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/Main/SettingViewModel.swift @@ -0,0 +1,42 @@ +// +// SettingViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import Foundation + +final class SettingViewModel: ViewModelable { + let coordinator: SettingCoordinator + + @Published var state: State = .init() + + init(coordinator: SettingCoordinator, state: State) { + self.coordinator = coordinator + self.state = state + } + + struct State { + + } + + enum Action { + case categoryManage + case notificationSetting + case feedback + } + + func reduce(_ action: Action) { + switch action { + case .categoryManage: + coordinator.setFlow(.categoryList) + + case .notificationSetting: + coordinator.showToast("์ถ”ํ›„ ์ง€์› ์˜ˆ์ •์ธ ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค.") + + case .feedback: + coordinator.setFlow(.feedBack) + } + } +} diff --git a/StopWatch/Screen/Tab/Setting/SettingCoordinator.swift b/StopWatch/Screen/Tab/Setting/SettingCoordinator.swift new file mode 100644 index 0000000..342b052 --- /dev/null +++ b/StopWatch/Screen/Tab/Setting/SettingCoordinator.swift @@ -0,0 +1,58 @@ +// +// SettingCoordinator.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +enum SettingParentFlow: ParentFlow { + case didFinishPop +} + +final class SettingCoordinator: CoordinatorType { + + var childCoordinators: [any CoordinatorType] = [] + var parentCoordinator: (any CoordinatorType)? + var navigationController: UINavigationController + + init(navigationController: UINavigationController, parentCoordinator: (any CoordinatorType)?) { + self.navigationController = navigationController + self.parentCoordinator = parentCoordinator + } + + func setFlow(_ flow: Flow) { + switch flow { + case .feedBack: + let viewModel = FeedBackViewModel(coordinator: self, state: .init()) + let view = FeedBackView(viewModel: viewModel).viewController + + push(view) + + case .categoryList: + let coordinator = CategoryCoordinator(navigationController: navigationController, parentCoordinator: self) + childCoordinators.append(coordinator) + coordinator.setFlow(.categoryList) + } + } + + enum Flow { + case feedBack + case categoryList + } + + + + func setParentFlow(_ flow: any ParentFlow) { + guard let parentFlow = flow as? SettingParentFlow else { + return + } + + switch parentFlow { + case .didFinishPop: + pop() + childCoordinators = [] + } + } +} diff --git a/StopWatch/Screen/Tab/Statistics/StatisticMainView.swift b/StopWatch/Screen/Tab/Statistics/StatisticMainView.swift new file mode 100644 index 0000000..0774946 --- /dev/null +++ b/StopWatch/Screen/Tab/Statistics/StatisticMainView.swift @@ -0,0 +1,38 @@ +// +// StatisticMainView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct StatisticMainView: View { + @StateObject var viewModel: StatisticMainViewModel + + var body: some View { + WithDesignSystem { + + } content: { + VStack(spacing: .zero) { + Spacer() + preparingView + Spacer() + } + } + } + + var preparingView: some View { + VStack(spacing: 16) { + Text("๐Ÿšง") + .font(.pretendard(size: 60, weight: .semibold)) + Text("ํ•ด๋‹น ๊ธฐ๋Šฅ์€ ์ค€๋น„์ค‘์ž…๋‹ˆ๋‹ค. (_ _)") + .setTypo(.label1) + .foregroundStyle(Color.getColor(.text_assistive)) + } + } +} + +#Preview { + StatisticMainView(viewModel: .init(coordinator: AppCoordinator.shared, state: .init())) +} diff --git a/StopWatch/Screen/Tab/Statistics/StatisticMainViewModel.swift b/StopWatch/Screen/Tab/Statistics/StatisticMainViewModel.swift new file mode 100644 index 0000000..2b03cb2 --- /dev/null +++ b/StopWatch/Screen/Tab/Statistics/StatisticMainViewModel.swift @@ -0,0 +1,31 @@ +// +// StatisticMainViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import Foundation + +final class StatisticMainViewModel: ViewModelable { + let coordinator: any CoordinatorType + + @Published var state: State = .init() + + init(coordinator: any CoordinatorType, state: State) { + self.coordinator = coordinator + self.state = state + } + + struct State { + + } + + enum Action { + + } + + func reduce(_ action: Action) { + + } +} diff --git a/StopWatch/Screen/Tab/StopWatch/Focus/FocusTimeView.swift b/StopWatch/Screen/Tab/StopWatch/Focus/FocusTimeView.swift new file mode 100644 index 0000000..21d12fe --- /dev/null +++ b/StopWatch/Screen/Tab/StopWatch/Focus/FocusTimeView.swift @@ -0,0 +1,111 @@ +// +// FocusTimeView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 2/2/25. +// + +import SwiftUI + +struct FocusTimeView: View { + @StateObject var viewModel: FocusTimeViewModel + + var body: some View { + WithDesignSystem { + + } content: { + VStack(spacing: .zero) { + Spacer() + displayView + Spacer() + selectTodoView + FixedSpacer(16) + saveButton + } + } + .onAppear { + viewModel.reduce(.onAppear) + } + } + + var displayView: some View { + VStack(spacing: .zero) { + TotalTimeView() + .overlay { + let endDate = viewModel.state.endDate ?? .now + let time = endDate.timeIntervalSince1970 - viewModel.state.startDate.timeIntervalSince1970 + let timeInterval = (time - viewModel.state.breakTime) + + Text(TimeFormatter.toTimeString(with: timeInterval)) + .foregroundStyle(Color.getColor(.gray_assistive)) + .font(.pretendard(size: 48, weight: .regular)) + } + .padding(.horizontal, 32) + } + } + + var selectTodoView: some View { + VStack(spacing: .zero) { + Text("์˜ค๋Š˜ ๋‚จ์€ ํ•  ์ผ") + .setTypo(.label1) + .foregroundStyle(Color.getColor(.gray_text)) + FixedSpacer(12) + + ScrollView { + VStack(spacing: 8) { + ForEach(viewModel.state.todayTodoList, id: \.id) { todo in + Button { + viewModel.reduce(.didTapTodo(todo)) + } label: { + let isSelected = viewModel.state.selectedTodo == todo + HStack(spacing: .zero) { + Text(todo.content) + .setTypo(.body1) + .foregroundStyle(Color.getColor(.gray_text)) + Spacer() + Image(isSelected ? .checkFillOn : .checkFillOff) + .resizable() + .frame(width: 20, height: 20) + } + } + } + Spacer() + } + .hSpacing(alignment: .center) + .padding(24) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 20)) + .padding(.horizontal, 24) + + } + .frame(maxHeight: 180) + .scrollIndicators(.hidden) + .scrollBounceBehavior(.basedOnSize) + } + } + + var saveButton: some View { + Button { + viewModel.reduce(.didTapSave) + } label: { + Text("Save") + .setTypo(.label1) + .foregroundStyle(Color.getColor(.white)) + .hSpacing(alignment: .center) + .padding(.vertical, 12) + .background(Color.getColor(.gray_text)) + .clipShape(.rect(cornerRadius: 20)) + .padding(.horizontal, 24) + } + } +} + +#Preview { + FocusTimeView( + viewModel: .init( + coordinator: .init(navigationController: .default()), + state: .init(startDate: .now, endDate: .now.addingTimeInterval(3820), todayTodoList: [.mockData1, .mockData2]), delegate: .none + ) + ) +} + diff --git a/StopWatch/Screen/Tab/StopWatch/Focus/FocusTimeViewModel.swift b/StopWatch/Screen/Tab/StopWatch/Focus/FocusTimeViewModel.swift new file mode 100644 index 0000000..cf5c74f --- /dev/null +++ b/StopWatch/Screen/Tab/StopWatch/Focus/FocusTimeViewModel.swift @@ -0,0 +1,87 @@ +// +// FocusTimeViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 2/2/25. +// + +import Foundation + +protocol FocusTimeViewModelDelegate: AnyObject { + func saveTimeCheck(with timeCheck: TimeCheck) +} + +final class FocusTimeViewModel: ViewModelable { + private let coordinator: StopWatchCoordinator + private let dependency: DependencyBox + + @Published var state: State + + weak var delegate: FocusTimeViewModelDelegate? + + init( + coordinator: StopWatchCoordinator, + dependency: DependencyBox = .live, + focusMode: FocusMode = .motion, + state: State, + delegate: FocusTimeViewModelDelegate? + ) { + self.coordinator = coordinator + self.dependency = dependency + self.state = state + self.delegate = delegate + } + + struct State { + var startDate: Date + var endDate: Date? = .none + var breakTime: CGFloat = .zero + var todayTodoList: [Todo] = [] + var selectedTodo: Todo? + var isFocusing: Bool = false + } + + enum Action { + case onAppear + case didTapTodo(Todo) + case didTapSave + } + + func reduce(_ action: Action) { + switch action { + + case .onAppear: + let allTodo = try? todoRepo.getAll() + state.todayTodoList = allTodo?.filter { + $0.date?.formattedString(by: .yyyyMMdd) == Date.now.formattedString(by: .yyyyMMdd) + } ?? [] + + case .didTapTodo(let todo): + state.selectedTodo = todo + + case .didTapSave: + if let selectedTodo = state.selectedTodo { + delegate?.saveTimeCheck( + with: .init( + startDate: state.startDate, + endDate: state.endDate ?? .now, + breakTime: state.breakTime, + todo: selectedTodo) + ) + } else { + coordinator.showToast("1๊ฐœ ์ด์ƒ์˜ Todo๋ฅผ ์„ ํƒํ•ด์ฃผ์„ธ์š”.") + } + } + } + + enum FocusMode { + case manual + case motion + } +} + +private extension FocusTimeViewModel { + var todoRepo: any TodoRepository { + dependency.resolve() + } +} diff --git a/StopWatch/Screen/Tab/StopWatch/Main/StopWatchMainView.swift b/StopWatch/Screen/Tab/StopWatch/Main/StopWatchMainView.swift new file mode 100644 index 0000000..709a4b1 --- /dev/null +++ b/StopWatch/Screen/Tab/StopWatch/Main/StopWatchMainView.swift @@ -0,0 +1,87 @@ +// +// StopWatchMainView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct StopWatchMainView: View { + @StateObject var viewModel: StopWatchMainViewModel + + var body: some View { + WithDesignSystem { + + } content: { + VStack(spacing: .zero) { + FixedSpacer(16) + InfiniteFlipToast(message: "๋’ค์ง‘์–ด์„œ ํƒ€์ด๋จธ๋ฅผ ์‹œ์ž‘ํ•ด์ฃผ์„ธ์š”.") + FixedSpacer(40) + displayView + Spacer() +// playPauseButton + FixedSpacer(40) + timeHistoryView + FixedSpacer(24) + } + .frame(maxWidth: .infinity) + } + .onAppear { + viewModel.reduce(.onAppear) + } + } + + var displayView: some View { + TotalTimeView(value: 0) + .overlay { + Text(TimeFormatter.toTimeString(with: viewModel.state.todayFocusTime)) + .foregroundStyle(Color.getColor(.gray_assistive)) + .font(.pretendard(size: 48, weight: .regular)) + } + .padding(.horizontal, 32) + + } + + var playPauseButton: some View { + Button { + + } label: { + Text("์‹œ์ž‘") + .foregroundStyle(Color.white) + .setTypo(.body1) + .padding(.horizontal, 36) + .padding(.vertical, 10) + .background(Color.getColor(.gray_fill_normal)) + .clipShape(.capsule) + } + } + + var timeHistoryView: some View { + VStack(spacing: 16) { + if viewModel.state.recentTimeCheckList.isEmpty { + Text("์•„์ง ์ง‘์ค‘ํ•œ ์‹œ๊ฐ„์ด ์—†์–ด์š”!") + .setTypo(.label2) + .foregroundStyle(Color.getColor(.gray_text)) + } else { + ForEach(viewModel.state.recentTimeCheckList, id: \.id) { timeCheck in + TimeHistoryCell( + date: timeCheck.startDate, + todo: timeCheck.todo?.content ?? "", + todoTime: TimeFormatter.toTimeString(with: timeCheck.focusTime, format: .HHMMssKorean, useCompactTimeFormat: true) + ) + } + } + } + .hSpacing() + .padding(.horizontal, 20) + .padding(.vertical, 16) + .background(Color.getColor(.background_primary)) + .clipShape(.rect(cornerRadius: 12)) + .padding(.horizontal, 24) + } +} + +#Preview { + StopWatchMainView(viewModel: .init(coordinator: .init(navigationController: .default()), state: .init())) +} diff --git a/StopWatch/Screen/Tab/StopWatch/Main/StopWatchMainViewModel.swift b/StopWatch/Screen/Tab/StopWatch/Main/StopWatchMainViewModel.swift new file mode 100644 index 0000000..66826d2 --- /dev/null +++ b/StopWatch/Screen/Tab/StopWatch/Main/StopWatchMainViewModel.swift @@ -0,0 +1,150 @@ +// +// StopWatchMainViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import Foundation +import UIKit.UIDevice +import Combine + +final class StopWatchMainViewModel: ViewModelable { + + let coordinator: StopWatchCoordinator + + private let dependency: DependencyBox + private var cancellable = Set() + private let motionManager: MotionManager + private var focustTimeViewModel: FocusTimeViewModel? + + @Published var state: State = .init() + + init( + coordinator: StopWatchCoordinator, + state: State = .init(), + dependency: DependencyBox = .live, + motionManager: MotionManager = .init() + ) { + self.coordinator = coordinator + self.state = state + self.dependency = dependency + self.motionManager = motionManager + } + + struct State { + var startDate: Date = .now + var endDate: Date = .now + var breakTiem: CGFloat = .zero + var recentTimeCheckList: [TimeCheck] = [] + var todayFocusTime: Double = .zero + } + + enum Action { + case onAppear + } + + func reduce(_ action: Action) { + switch action { + case .onAppear: + motionManager.startMotionUpdates() + observeAttitude() + + let allTimeCheckList = try? timecheckRepo.getAll().filter { + $0.startDate.formattedString(by: .yyyyMMdd) == Date.now.formattedString(by: .yyyyMMdd) + } + + state.todayFocusTime = allTimeCheckList?.reduce(0.0, { $0 + $1.focusTime }) ?? .zero + allTimeCheckList.flatMap { + state.recentTimeCheckList = $0.sorted(by: { $0.startDate > $1.startDate }).prefix(3).map { $0 } + } + } + } + + func observeAttitude() { + UIDevice.current.isProximityMonitoringEnabled = false + + let proximityPublisher = NotificationCenter.default + .publisher(for: UIDevice.proximityStateDidChangeNotification) + + let attitudePublisher = motionManager.$attitude + + proximityPublisher.sink { _ in + let isOnProximity = UIDevice.current.proximityState + + if isOnProximity { + + } else { + self.motionManager.startMotionUpdates() + } + } + .store(in: &cancellable) + + attitudePublisher + .sink { motion in + let degree = abs(motion.roll * 180.0 / Double.pi) + + if degree >= 100 { // 100๋„ ์ด์ƒ ๊ธฐ์šธ์–ด์ง€๋ฉด ๊ทผ์ ‘ ์„ผ์„œ ๊ฐ€๋™ + UIDevice.current.isProximityMonitoringEnabled = true + + if degree >= 160 && UIDevice.current.proximityState == true { // 160๋„ ์ด์ƒ ๊ธฐ์šธ์–ด์ง€๊ณ  ๊ทผ์ ‘ ์„ผ์„œ๊ฐ€ true์ด๋ฉด ํƒ€์ด๋จธ ์‹œ์ž‘ + + if let focustTimeViewModel = self.focustTimeViewModel { + if focustTimeViewModel.state.isFocusing == false { + let startTime = focustTimeViewModel.state.endDate?.timeIntervalSince1970 ?? 0 + let endTime = Date.now.timeIntervalSince1970 + focustTimeViewModel.state.breakTime += (endTime - startTime) + focustTimeViewModel.state.endDate = .none + focustTimeViewModel.state.isFocusing = true + } + } else { + self.focustTimeViewModel = FocusTimeViewModel( + coordinator: self.coordinator, + focusMode: .motion, + state: .init(startDate: .now, isFocusing: true), + delegate: self + ) + + let view = FocusTimeView(viewModel: self.focustTimeViewModel!).viewController + + self.coordinator.present(view) + } + + self.motionManager.stopMotionUpdates() // ์ฝ”์–ด๋ชจ์…˜ ์—…๋ฐ์ดํŠธ ๋ฉ”์†Œ๋“œ ์ค‘๋‹จ! ( ๊ทผ์ ‘์„ผ์„œ false์‹œ ์žฌ ์ž‘๋™ ) + } + } else if degree < 100 && UIDevice.current.proximityState == false { // 100๋„ ์ดํ•˜๊ณ  ๊ทผ์ ‘ ์„ผ์„œ๊ฐ€ false๋ฉด ๊ทผ์ ‘์„ผ์„œ ์ž‘๋™ ์ค‘๋‹จ + ํƒ€์ด๋จธ ๊ฐ€๋™์ค‘์ด๋ฉด ํƒ€์ด๋จธ๋„ ์ค‘๋‹จ + UIDevice.current.isProximityMonitoringEnabled = false + + if self.focustTimeViewModel?.state.isFocusing == true { + self.focustTimeViewModel?.state.isFocusing = false + self.focustTimeViewModel?.state.endDate = .now + } + } + }.store(in: &cancellable) + } +} + +extension StopWatchMainViewModel: FocusTimeViewModelDelegate { + func saveTimeCheck(with timeCheck: TimeCheck) { + do { + try timecheckRepo.create(entity: timeCheck) + state.recentTimeCheckList.insert(timeCheck, at: 0) + + if state.recentTimeCheckList.count > 3 { + state.recentTimeCheckList.removeLast() + } + + coordinator.dismiss() + focustTimeViewModel = .none + + } catch { + coordinator.showToast("์‹œ๊ฐ„ ์ €์žฅ ์‹คํŒจ") + } + } +} + +private extension StopWatchMainViewModel { + var timecheckRepo: any TimeCheckReopsitory { + dependency.resolve() + } +} diff --git a/StopWatch/Screen/Tab/StopWatch/StopWatchCoordinator.swift b/StopWatch/Screen/Tab/StopWatch/StopWatchCoordinator.swift new file mode 100644 index 0000000..1db2f97 --- /dev/null +++ b/StopWatch/Screen/Tab/StopWatch/StopWatchCoordinator.swift @@ -0,0 +1,34 @@ +// +// StopWatchCoordinator.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 2/1/25. +// + +import UIKit.UINavigationController + +final class StopWatchCoordinator: CoordinatorType { + var navigationController: UINavigationController + var parentCoordinator: (any CoordinatorType)? + var childCoordinators: [any CoordinatorType] = [] + + init( + navigationController: UINavigationController, + parentCoordinator: (any CoordinatorType)? = nil + ) { + self.navigationController = navigationController + self.parentCoordinator = parentCoordinator + } + + enum Flow { + + } + + func setFlow(_ flow: Flow) { + + } + + func setParentFlow(_ flow: any ParentFlow) { + + } +} diff --git a/StopWatch/Screen/Tab/StopWatch/Views/TotalTimeView.swift b/StopWatch/Screen/Tab/StopWatch/Views/TotalTimeView.swift new file mode 100644 index 0000000..7db41ff --- /dev/null +++ b/StopWatch/Screen/Tab/StopWatch/Views/TotalTimeView.swift @@ -0,0 +1,47 @@ +// +// TotalTimeView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +struct TotalTimeView: View { + @State var lineWidth: CGFloat = 6 + @State var value: CGFloat = 0.0 + + var body: some View { + ZStack { + Circle() + .stroke(lineWidth: lineWidth) +// .frame(width: lineWidth, height: size.length) + .foregroundStyle(Color.white) + .shadow(color: .black.opacity(0.2), radius: 15, x: 10, y: 10) +// Circle() +// .stroke(lineWidth: 0.2) +// .frame(width: size.length-size.lineWidth-1, height: size.length-size.lineWidth-1) +// .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.black.opacity(0.3), .clear]), startPoint: .bottomTrailing, endPoint: .topLeading)) +// .overlay { +// Circle() +// .stroke(.black.opacity(0.1), lineWidth: 2) +// .blur(radius: 5) +// .mask { +// Circle() +// .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.black, .clear]), startPoint: .topLeading, endPoint: .bottomTrailing)) +// } +// } + Circle() + .trim(from: 0, to: value) + .stroke(style: StrokeStyle(lineWidth: lineWidth, lineCap: .round)) +// .frame(width: size.length, height: size.length) + .rotationEffect(.degrees(-90)) +// .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.purple, .blue]), startPoint: .topLeading, endPoint: .bottomTrailing)) + .foregroundStyle(Color.getColor(.gray_text)) + } + } +} + +#Preview { + TotalTimeView(lineWidth: 6, value: 0) +} diff --git a/StopWatch/Screen/Tab/Todo/BottomSheet/TodoEditorBottomSheetView.swift b/StopWatch/Screen/Tab/Todo/BottomSheet/TodoEditorBottomSheetView.swift new file mode 100644 index 0000000..0417df2 --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/BottomSheet/TodoEditorBottomSheetView.swift @@ -0,0 +1,148 @@ +// +// TodoEditorBottomSheetView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/31/25. +// + +import SwiftUI + +struct TodoEditorBottomSheetView: View { + @StateObject var viewModel: TodoEditorBottomSheetViewModel + + var body: some View { + WithDesignSystem { + + } content: { + VStack(spacing: .zero) { + FixedSpacer(12) + Image(.handler) + FixedSpacer(16) + updateCardView + FixedSpacer(32) + menuListView + FixedSpacer(32) + progressView + FixedSpacer(12) + } + } + } + + // MARK: - UpdateCardView + var updateCardView: some View { + HStack(spacing: 16) { + Button { + viewModel.reduce(.didTapUpdateDate) + } label: { + VStack(spacing: 8) { + Image(systemName: "calendar") + Text("๋‚ ์งœ ๋ณ€๊ฒฝ") + } + .setTypo(.label1) + .padding(.vertical, 12) + .hSpacing(alignment: .center) + .background(Color.getColor(.background_primary)) + .foregroundStyle(Color.getColor(.gray_text)) + .clipShape(.rect(cornerRadius: 12)) + } + + Menu { + ForEach(viewModel.categoryList, id: \.id) { category in + Button { + viewModel.reduce(.didTapUpdateCategory(category)) + } label: { + Text(category.name) + } + } + } label: { + VStack(spacing: 8) { + Image(systemName: "folder.badge.gearshape") + Text("์นดํ…Œ๊ณ ๋ฆฌ ๋ณ€๊ฒฝ") + } + .setTypo(.label1) + .padding(.vertical, 12) + .hSpacing(alignment: .center) + .background(Color.getColor(.background_primary)) + .foregroundStyle(Color.getColor(.gray_text)) + .clipShape(.rect(cornerRadius: 12)) + } + } + .padding(.horizontal, 24) + } + + // MARK: - menuList View + var menuListView: some View { + VStack(spacing: 12) { + menuItem(image: Image(systemName: "bell"), title: "์•Œ๋ฆผ ์„ค์ •") { + viewModel.reduce(.didTapNotificationSetting) + } + + menuItem(image: Image(systemName: "archivebox"), title: "๋ณด๊ด€ํ•˜๊ธฐ") { + viewModel.reduce(.archive) + } + + menuItem(image: Image(systemName: "trash"), title: "์‚ญ์ œ", isDeleteCell: true) { + viewModel.reduce(.didTapDelete) + } + } + .padding(.horizontal, 24) + } + + // MARK: - ProgressView + var progressView: some View { + VStack(spacing: .zero) { + Text("์ง„ํ–‰๋„") + .hSpacing() + .setTypo(.label2) + .foregroundStyle(Color.getColor(.gray_text)) + .padding(.horizontal, 24) + FixedSpacer(12) + + HStack(spacing: 8) { + Slider( + value: Binding( + get: { viewModel.state.progress }, + set: { viewModel.reduce(.changeProgress($0))}) + ) { isEditing in + if !isEditing { + viewModel.reduce(.updateProgress(viewModel.state.progress)) + } + } + .setTypo(.body2) + .foregroundStyle(Color.getColor(.gray_text)) + .tint(Color.getColor(.gray_text)) + + Text("\(Int(viewModel.state.progress*100))%") + .hSpacing(alignment: .center) + .foregroundStyle(Color.getColor(.gray_text)) + .setTypo(.caption1) + .fixedSize() + } + .padding(.horizontal, 28) + } + } + + func menuItem(image: Image, title: String, isDeleteCell: Bool = false, action: (()->Void)?) -> some View { + Button { + action?() + } label: { + HStack(spacing: 10) { + image + .resizable() + .frame(width: 20, height: 20) + Text(title) + .setTypo(.label1) + Spacer() + } + .foregroundStyle(isDeleteCell ? .getColor(.caution_text_alternative) : Color.getColor(.gray_text)) + } + } +} + +#Preview { + TodoEditorBottomSheetView( + viewModel: .init( + coordinator: AppCoordinator.shared, todo: .mockData1, categoryList: [], delegate: .none, updateTodoListHandler: .none + ) + ) +} diff --git a/StopWatch/Screen/Tab/Todo/BottomSheet/TodoEditorBottomSheetViewModel.swift b/StopWatch/Screen/Tab/Todo/BottomSheet/TodoEditorBottomSheetViewModel.swift new file mode 100644 index 0000000..bdd9d20 --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/BottomSheet/TodoEditorBottomSheetViewModel.swift @@ -0,0 +1,128 @@ +// +// TodoEditorBottomSheetViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/31/25. +// + +import Foundation + +protocol TodoEditorBottomSheetViewModelDelegate: AnyObject { + func didTapUpdateDate(with todo: Todo) +} + +final class TodoEditorBottomSheetViewModel: ViewModelable { + let coordinator: any CoordinatorType + + let todo: Todo + let categoryList: [Category] + let updateTodoListHandler: (()->Void)? + + private let dependency: DependencyBox + weak var delegate: TodoEditorBottomSheetViewModelDelegate? + + @Published var state: State + + init( + coordinator: any CoordinatorType, + dependency: DependencyBox = .live, + todo: Todo, + categoryList: [Category], + delegate: TodoEditorBottomSheetViewModelDelegate?, + updateTodoListHandler: (()->Void)? + ) { + self.coordinator = coordinator + self.dependency = dependency + self.todo = todo + self.categoryList = categoryList + self.state = .init(progress: todo.progress) + self.updateTodoListHandler = updateTodoListHandler + self.delegate = delegate + } + + struct State { + var progress: CGFloat = .zero + } + + enum Action { + case didTapDelete + case didTapUpdateCategory(Category) + case didTapUpdateDate + case didTapNotificationSetting + case changeProgress(CGFloat) + case updateProgress(CGFloat) + case archive + } + + func reduce(_ action: Action) { + switch action { + + case .didTapDelete: + do { + let content = todo.content + try todoRepo.delete(entity: todo) + coordinator.showToast("'\(content)'๊ฐ€ ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + coordinator.dismiss() + updateTodoListHandler?() + + } catch { + coordinator.showToast("์‚ญ์ œ ์‹คํŒจ") + } + + case .didTapUpdateCategory(let category): + do { + try todoRepo.update( + entity: todo, + keypaths: [(\.category, category )] + ) + + coordinator.showToast("'\(todo.content)'๊ฐ€ \(category.name)์œผ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + coordinator.dismiss() + updateTodoListHandler?() + } catch { + coordinator.showToast("์—…๋ฐ์ดํŠธ ์‹คํŒจ") + } + + case .didTapUpdateDate: + delegate?.didTapUpdateDate(with: todo) + + case .didTapNotificationSetting: + coordinator.showToast("์ถ”ํ›„ ์ง€์› ์˜ˆ์ •์ธ ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค.") + + case .changeProgress(let progress): + state.progress = progress + + case .updateProgress(let progress): + do { + try todoRepo.update( + entity: todo, + keypaths: [(\.progress, progress )] + ) + let percent = "\(Int(progress*100))%" + coordinator.showToast("์ง„ํ–‰๋„๊ฐ€ \(percent)๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + updateTodoListHandler?() + } catch { + coordinator.showToast("์—…๋ฐ์ดํŠธ ์‹คํŒจ") + } + + case .archive: + do { + try todoRepo.update( + entity: todo, + keypaths: [(\.date, .none )] + ) + coordinator.showToast("'\(todo.content)'๊ฐ€ ๋ณด๊ด€ํ•จ์— ๋ณด๊ด€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + coordinator.dismiss() + updateTodoListHandler?() + } catch { + coordinator.showToast("๋ณด๊ด€ ์‹คํŒจ") + } + } + } +} + +private extension TodoEditorBottomSheetViewModel { + var todoRepo: any TodoRepository { + dependency.resolve() + } +} diff --git a/StopWatch/Screen/Tab/Todo/Main/TodoView.swift b/StopWatch/Screen/Tab/Todo/Main/TodoView.swift new file mode 100644 index 0000000..6f3bb86 --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/Main/TodoView.swift @@ -0,0 +1,151 @@ +// +// TodoView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/23/24. +// + +import SwiftUI + +struct TodoView: View { + @StateObject var viewModel: TodoViewModel + @FocusState var isTyping: Bool + + var body: some View { + WithDesignSystem { + + } content: { + ScrollView { + VStack(spacing: .zero) { + calendarView + FixedSpacer(32) + if viewModel.state.todoList.isNotEmpty { + todayTodoListView + } else { + emptyView + } + } + } + .onTapGesture { + viewModel.state.isExpendedNewTodo = false + } + .scrollIndicators(.hidden) + .overlay(alignment: .bottom) { + VStack(spacing: .zero) { + bottomButton + FixedSpacer(12) + } + } + } + .onAppear { + viewModel.reduce(.fetchDate) + } + .overlay { + if viewModel.state.isPresentedModalCalendar { + ZStack { + Color.getColor(.dim) + .ignoresSafeArea() + .onTapGesture { + viewModel.state.isPresentedModalCalendar = false + } + SystemCalendarModalView( + selectedDate: viewModel.state.currentDate, + isPresented: $viewModel.state.isPresentedModalCalendar) { date in + viewModel.reduce(.updateTodoDate(date)) + } + } + } + } + .animation(.smooth(duration: 0.25), value: viewModel.state.isExpendedNewTodo) + .animation(.easeInOut, value: viewModel.state.isPresentedModalCalendar) + } +} + +private extension TodoView { + var emptyView: some View { + VStack(spacing: .zero) { + Spacer(minLength: 200) + Text("์˜ค๋Š˜ ์ถ”๊ฐ€๋œ ํ•  ์ผ์ด ์—†์–ด์š”") + .setTypo(.label1) + .foregroundStyle(Color.getColor(.text_disable)) + Spacer() + } + } + + var calendarView: some View { + SWWeeklyCalendarView( + displayDate: Binding( + get: { viewModel.state.currentDate }, + set: { viewModel.reduce(.changeDate($0)) } + ) + ) + .zIndex(1) + } + + var todayTodoListView: some View { + VStack(spacing: 8) { + if viewModel.state.currentDate.formattedString(by: .yyyyMMdd) == Date.now.formattedString(by: .yyyyMMdd) { + HStack(spacing: .zero) { + Text("Today") + .setTypo(.label2) + .foregroundStyle(Color.getColor(.text_assistive)) + Spacer() + } + .padding(.horizontal, 16) + } + + VStack(spacing: 8) { + ForEach(viewModel.state.todoList, id: \.id) { todo in + Button { + viewModel.reduce(.didTapTodo(todo)) + } label: { + TodoCell(todo: todo) + .gesture( + DragGesture() + .onChanged { drag in + if drag.translation.width > 80 { + viewModel.reduce(.rightDrag(todo)) + } else if drag.translation.width < -80 { + viewModel.reduce(.leftDrag(todo)) + } + } + ) + } + } + } + .padding(.horizontal, 12) + } + } + + var bottomButton: some View { + HStack(spacing: .zero) { + NewTodoView( + isTyping: _isTyping, + show: $viewModel.state.isExpendedNewTodo, + categoryList: viewModel.state.categoryList + ) { todo in + viewModel.reduce(.addTodo(todo)) + } didTapAddCategory: { + viewModel.reduce(.didTapCreateCategory) + } + + if !viewModel.state.isExpendedNewTodo { + Button { + viewModel.reduce(.didTapStorage) + } label: { + Image(systemName: "archivebox.fill") + .padding() + .foregroundStyle(Color.getColor(.white)) + .background(Color.getColor(.gray_text)) + .clipShape(.circle) + } + FixedSpacer(12) + } + } + } +} + +#Preview(body: { + TodoView(viewModel: .init(coordinator: TodoCoordinator.init(navigationController: .default(), parentCoordinator: .none), state: .init())) +}) + diff --git a/StopWatch/Screen/Tab/Todo/Main/TodoViewModel.swift b/StopWatch/Screen/Tab/Todo/Main/TodoViewModel.swift new file mode 100644 index 0000000..cd5cc1f --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/Main/TodoViewModel.swift @@ -0,0 +1,205 @@ +// +// TodoViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 11/23/24. +// + +import SwiftUI + +class TodoViewModel: ViewModelable { + private let coordinator: TodoCoordinator + private let dependency: DependencyBox + + @Published var state: State = .init() + + init( + coordinator: TodoCoordinator, + state: State, + dependency: DependencyBox = .live + ) { + self.coordinator = coordinator + self.state = state + self.dependency = dependency + } + + struct State { + var isExpendedNewTodo: Bool = false + var isPresentedModalCalendar: Bool = false + var selectedTodo: Todo? + var currentDate: Date = .now + var todoList: [Todo] = [] + var categoryList: [Category] = [] + var categoryName: String = "" + } + + enum Action { + case fetchDate + case changeDate(Date?) + + case didTapCreateCategory + case createCategory(name: String) + case editCategoryName(String) + + case didTapStorage + + case didTapTodo(Todo) + case addTodo(Todo) + case updateTodoDate(Date) + + case rightDrag(Todo) + case leftDrag(Todo) + } + + func reduce(_ action: Action) { + switch action { + case .fetchDate: + let categoryList = try? categoryRepo.getAll() + state.categoryList = categoryList ?? [] + reduce(.changeDate(state.currentDate)) + + case .changeDate(let newDate): + self.state.currentDate = newDate ?? .now + let todoList = try? todoRepo.getAll() + .filter { $0.date?.formattedString(by: .yyyyMMdd) == newDate?.formattedString(by: .yyyyMMdd) } + state.isExpendedNewTodo = false + state.todoList = todoList ?? [] + + case .addTodo(let newTodo): + do { + try todoRepo.create(entity: newTodo) + + if newTodo.date?.formattedString(by: .yyyyMMdd) == state.currentDate.formattedString(by: .yyyyMMdd) { + state.todoList.append(newTodo) + } else if newTodo.date == nil { + coordinator.showToast("์ถ”๊ฐ€ํ•œ Todo๊ฐ€ ๋ณด๊ด€ํ•จ์— ๋ณด๊ด€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + } + + } catch { + coordinator.showToast("์ƒ์„ฑ ์‹คํŒจ") + } + + case .didTapCreateCategory: + coordinator.showAlert( + .init( + title: "์นดํ…Œ๊ณ ๋ฆฌ ์ด๋ฆ„ ์ž…๋ ฅ", + message: .none, + inputMessage: Binding( + get: { self.state.categoryName }, + set: { self.state.categoryName = $0 } + ) + ) + .addAction(title: "์ทจ์†Œ", style: .cancel, action: { [weak self] in + self?.state.categoryName = "" + self?.coordinator.dismiss(animated: false) + }) + .addAction(title: "์ถ”๊ฐ€", style: .primary, action: { [weak self] in + self?.coordinator.dismiss(animated: false) + self?.reduce(.createCategory(name: self?.state.categoryName ?? "")) + }) + ) + + case .createCategory(let name): + do { + let newCateogry = Category(name: name) + try categoryRepo.create(entity: newCateogry) + state.categoryList.append(newCateogry) + } catch { + coordinator.showToast("์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ฑ ์‹คํŒจ") + } + + case .editCategoryName(let name): + state.categoryName = name + + case .didTapStorage: + state.isExpendedNewTodo = false + coordinator.setFlow(.storage) + + case .didTapTodo(let todo): + state.isExpendedNewTodo = false + let viewModel = TodoEditorBottomSheetViewModel( + coordinator: self.coordinator, + todo: todo, + categoryList: state.categoryList, + delegate: self + ) { [weak self] in + self?.state.todoList.removeAll() + self?.reduce(.fetchDate) + } + + let view = TodoEditorBottomSheetView(viewModel: viewModel).panModal(height: .none) + + coordinator.presentPanModals(view) + + case .rightDrag(let todo): + if todo.progress < 1.0 { + updateProgress(with: todo, to: 1) + } + + case .leftDrag(let todo): + if todo.progress > 0.0 { + updateProgress(with: todo, to: 0) + } + + case .updateTodoDate(let newDate): + + do { + if let selectedTodo = state.selectedTodo { + try todoRepo.update( + entity: selectedTodo, + keypaths: [(\.date, newDate)] + ) + + coordinator.showToast("'\(selectedTodo.content)'๊ฐ€ \(newDate.formattedString(by: .yyyyMMdd)) ๋‚ ์งœ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + + reduce(.fetchDate) + } + + } catch { + coordinator.showToast("์—…๋ฐ์ดํŠธ ์‹คํŒจ") + } + + state.isPresentedModalCalendar = false + state.selectedTodo = .none + } + } +} + +// MARK: - private Method +private extension TodoViewModel { + func updateProgress(with todo: Todo, to progress: CGFloat) { + do { + let percent = "\(Int(progress*100))%" + + try todoRepo.update( + entity: todo, + keypaths: [(\.progress, progress )] + ) + + coordinator.showToast("์ง„ํ–‰๋„๊ฐ€ \(percent)๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.") + + self.state.todoList.removeAll() + self.reduce(.fetchDate) + + } catch { + coordinator.showToast("์—…๋ฐ์ดํŠธ ์‹คํŒจ") + } + } +} + + +// MARK: - UseCase DI +private extension TodoViewModel { + var todoRepo: any TodoRepository { dependency.resolve() } + + var categoryRepo: any CategoryRepository { dependency.resolve() } +} + +// MARK: - EditBottomSheetDelegateMethod +extension TodoViewModel: TodoEditorBottomSheetViewModelDelegate { + func didTapUpdateDate(with todo: Todo) { + coordinator.dismiss() + state.isPresentedModalCalendar = true + state.selectedTodo = todo + } +} diff --git a/StopWatch/Screen/Tab/Todo/Storage/TodoStorageView.swift b/StopWatch/Screen/Tab/Todo/Storage/TodoStorageView.swift new file mode 100644 index 0000000..443c564 --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/Storage/TodoStorageView.swift @@ -0,0 +1,130 @@ +// +// TodoStorageView.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/29/25. +// + +import SwiftUI + +struct TodoStorageView: View { + @StateObject var viewModel: TodoStorageViewModel + + var body: some View { + WithDesignSystem { + TopNavigation( + leadingItem: (Image(.chevronLeft), { + viewModel.reduce(.pop) + }), centerTitle: "๋ณด๊ด€ํ•จ" + ) + .suffix { + Button { + viewModel.reduce(.changeEditMode) + } label: { + Text(viewModel.state.isEditMode ? "Done" :"Edit") + .setTypo(.label2) + } + FixedSpacer(24) + } + } content: { + VStack(spacing: .zero) { + if viewModel.state.todoList.isNotEmpty { + listView + } else { + emptyView + } + } + .overlay { + if viewModel.state.isPresentedModalCalendar { + SystemCalendarModalView( + isPresented: $viewModel.state.isPresentedModalCalendar + ) { + viewModel.reduce(.changeDate($0)) + } + } + } + + } bottomButton: { + if viewModel.state.isEditMode { + editModeBottomView + } + } + .onAppear { + viewModel.reduce(.fetchData) + } + .animation(.spring, value: viewModel.state.isEditMode) + .animation(.spring, value: viewModel.state.todoList) + .animation(.spring, value: viewModel.state.isPresentedModalCalendar) + .animation(.spring, value: viewModel.state.selectedList) + } + + var listView: some View { + ScrollView { + VStack(spacing: 12) { + FixedSpacer(12) + ForEach(viewModel.state.todoList, id: \.id) { todo in + Button { + viewModel.reduce(.selectTodo(todo)) + } label: { + TodoStorageCell( + todo: todo, + isEditMode: viewModel.state.isEditMode, + isSelected: viewModel.state.selectedList.contains(todo) + ) + } + .disabled(!viewModel.state.isEditMode) + } + } + } + .animation(.spring, value: viewModel.state.todoList) + .padding(.horizontal, 20) + } + + var emptyView: some View { + VStack(spacing: 8) { + Spacer() + Text("๐Ÿซฅ") + .font(.pretendard(size: 60, weight: .bold)) + Text("๋ณด๊ด€ํ•จ์ด ๋น„์—ˆ์–ด์š” ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”") + .setTypo(.body1) + .foregroundStyle(Color.getColor(.text_normal)) + Spacer() + } + } + + var editModeBottomView: some View { + HStack(spacing: 12) { + Button { + viewModel.reduce(.delete) + } label: { + Text("์‚ญ์ œ") + .hSpacing(alignment: .center) + .setTypo(.label1) + .foregroundStyle(Color.white) + .padding(.vertical, 12) + .background(viewModel.state.selectedList.isNotEmpty ? Color.getColor(.gray_text) : .getColor(.fill_disable)) + .clipShape(.rect(cornerRadius: 12)) + .disabled(viewModel.state.selectedList.isEmpty) + } + + Button { + viewModel.reduce(.exportTodo) + + } label: { + Text("๊บผ๋‚ด๊ธฐ") + .hSpacing(alignment: .center) + .setTypo(.label1) + .foregroundStyle(Color.white) + .padding(.vertical, 12) + .background(viewModel.state.selectedList.isNotEmpty ? Color.getColor(.gray_text) : .getColor(.fill_disable)) + .clipShape(.rect(cornerRadius: 12)) + .disabled(viewModel.state.selectedList.isEmpty) + } + } + .padding(.horizontal, 16) + } +} + +#Preview { + TodoStorageView(viewModel: .init(coordinator: .init(navigationController: .default(), parentCoordinator: .none), state: .init())) +} diff --git a/StopWatch/Screen/Tab/Todo/Storage/TodoStorageViewModel.swift b/StopWatch/Screen/Tab/Todo/Storage/TodoStorageViewModel.swift new file mode 100644 index 0000000..536cc07 --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/Storage/TodoStorageViewModel.swift @@ -0,0 +1,109 @@ +// +// TodoStorageViewModel.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/29/25. +// + +import Foundation + +class TodoStorageViewModel: ViewModelable { + private let coordinator: TodoCoordinator + private let dependency: DependencyBox + + @Published var state: State = .init() + + init( + coordinator: TodoCoordinator, + state: State, + dependency: DependencyBox = .live + ) { + self.coordinator = coordinator + self.state = state + self.dependency = dependency + } + + struct State { + var isEditMode: Bool = false + var todoList: [Todo] = [] + var selectedList: [Todo] = [] + var isPresentedModalCalendar: Bool = false + } + + enum Action { + case pop + case changeEditMode + case fetchData + case didTapTodo(Todo) + case selectTodo(Todo) + case delete + case exportTodo + case changeDate(Date) + } + + func reduce(_ action: Action) { + switch action { + case .fetchData: + let todoList = try? todoRepo.getAll().filter { $0.date == nil } + state.todoList = todoList ?? [] + + case .pop: + coordinator.pop() + + case .changeEditMode: + state.isEditMode.toggle() + state.selectedList = [] + + case .didTapTodo(_): + break + + case .selectTodo(let todo): + if let index = state.selectedList.firstIndex(of: todo) { + state.selectedList.remove(at: index) + } else { + state.selectedList.append(todo) + } + + case .delete: + do { + let count = state.selectedList.count + try todoRepo.delete(entities: state.selectedList) + state.todoList.removeAll { state.selectedList.contains($0) } + reduce(.changeEditMode) + coordinator.showToast("\(count)๊ฐœ์˜ Todo๊ฐ€ ๋ณด๊ด€ํ•จ์—์„œ ์‚ญ์ œ๋˜์—ˆ์–ด์š”!") + } catch { + coordinator.showToast("Todo ์‚ญ์ œ ์‹คํŒจ") + } + + case .exportTodo: + state.isPresentedModalCalendar = true + + case .changeDate(let date): + guard state.isPresentedModalCalendar else { + return + } + + do { + try todoRepo.update( + entities: state.selectedList, + keypaths: [ + (\.date, date) + ] + ) + + state.todoList.removeAll { state.selectedList.contains($0) } + reduce(.changeEditMode) + state.isPresentedModalCalendar = false + + coordinator.showToast("\(date.formattedString(by: .yyyyMMdd))๋‚ ์งœ์— ์ถ”๊ฐ€๋˜์—ˆ์–ด์š”!") + } catch { + coordinator.showToast("Todo ๋‚ด๋ณด๋‚ด๊ธฐ ์‹คํŒจ") + } + } + } +} + +// MARK: - UseCase DI +private extension TodoStorageViewModel { + var todoRepo: any TodoRepository { dependency.resolve() } +} diff --git a/StopWatch/Screen/Tab/Todo/TodoCoordinator.swift b/StopWatch/Screen/Tab/Todo/TodoCoordinator.swift new file mode 100644 index 0000000..c802b84 --- /dev/null +++ b/StopWatch/Screen/Tab/Todo/TodoCoordinator.swift @@ -0,0 +1,38 @@ +// +// TodoCoordinator.swift +// StopWatch +// +// Created by iOS์‹ ์ƒ์šฐ on 1/18/25. +// + +import SwiftUI + +final class TodoCoordinator: CoordinatorType { + + var childCoordinators: [any CoordinatorType] = [] + var parentCoordinator: (any CoordinatorType)? + var navigationController: UINavigationController + + init(navigationController: UINavigationController, parentCoordinator: (any CoordinatorType)?) { + self.navigationController = navigationController + self.parentCoordinator = parentCoordinator + } + + func setFlow(_ flow: Flow) { + switch flow { + case .storage: + let viewModel = TodoStorageViewModel(coordinator: self, state: .init()) + let view = TodoStorageView(viewModel: viewModel).viewController + + push(view) + } + } + + enum Flow { + case storage + } + + func setParentFlow(_ flow: any ParentFlow) { + + } +}