From 0b37213f8357492e4d50ca11405249c895e486d9 Mon Sep 17 00:00:00 2001 From: pro648 Date: Tue, 21 Jan 2020 19:20:02 +0800 Subject: [PATCH] =?UTF-8?q?Timer=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + Timer/Timer.xcodeproj/project.pbxproj | 355 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + Timer/Timer/AppDelegate.swift | 37 ++ .../AppIcon.appiconset/Contents.json | 98 +++++ Timer/Timer/Assets.xcassets/Contents.json | 6 + .../rw-dark.colorset/Contents.json | 20 + .../rw-green.colorset/Contents.json | 20 + .../rw-light.colorset/Contents.json | 20 + Timer/Timer/Balloon.swift | 43 +++ .../Timer/Base.lproj/LaunchScreen.storyboard | 25 ++ Timer/Timer/Base.lproj/Main.storyboard | 112 ++++++ Timer/Timer/Info.plist | 64 ++++ Timer/Timer/SceneDelegate.swift | 53 +++ Timer/Timer/Task.swift | 19 + Timer/Timer/TaskTableViewCell.swift | 74 ++++ Timer/Timer/ViewController.swift | 192 ++++++++++ "Timer\346\250\241\347\211\210/README.md" | 10 + .../Timer.xcodeproj/project.pbxproj" | 353 +++++++++++++++++ .../contents.xcworkspacedata" | 7 + .../Timer/AppDelegate.swift" | 37 ++ .../AppIcon.appiconset/Contents.json" | 98 +++++ .../Timer/Assets.xcassets/Contents.json" | 6 + .../rw-dark.colorset/Contents.json" | 20 + .../rw-green.colorset/Contents.json" | 20 + .../rw-light.colorset/Contents.json" | 20 + .../Timer/Balloon.swift" | 43 +++ .../Timer/Base.lproj/LaunchScreen.storyboard" | 25 ++ .../Timer/Base.lproj/Main.storyboard" | 112 ++++++ .../Timer/Info.plist" | 64 ++++ .../Timer/SceneDelegate.swift" | 53 +++ .../Timer/Task.swift" | 19 + .../Timer/TaskTableViewCell.swift" | 74 ++++ .../Timer/ViewController.swift" | 86 +++++ 34 files changed, 2193 insertions(+) create mode 100644 Timer/Timer.xcodeproj/project.pbxproj create mode 100644 Timer/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Timer/Timer/AppDelegate.swift create mode 100644 Timer/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Timer/Timer/Assets.xcassets/Contents.json create mode 100644 Timer/Timer/Assets.xcassets/rw-dark.colorset/Contents.json create mode 100644 Timer/Timer/Assets.xcassets/rw-green.colorset/Contents.json create mode 100644 Timer/Timer/Assets.xcassets/rw-light.colorset/Contents.json create mode 100644 Timer/Timer/Balloon.swift create mode 100644 Timer/Timer/Base.lproj/LaunchScreen.storyboard create mode 100644 Timer/Timer/Base.lproj/Main.storyboard create mode 100644 Timer/Timer/Info.plist create mode 100644 Timer/Timer/SceneDelegate.swift create mode 100644 Timer/Timer/Task.swift create mode 100644 Timer/Timer/TaskTableViewCell.swift create mode 100644 Timer/Timer/ViewController.swift create mode 100755 "Timer\346\250\241\347\211\210/README.md" create mode 100644 "Timer\346\250\241\347\211\210/Timer.xcodeproj/project.pbxproj" create mode 100644 "Timer\346\250\241\347\211\210/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata" create mode 100644 "Timer\346\250\241\347\211\210/Timer/AppDelegate.swift" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Assets.xcassets/Contents.json" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-dark.colorset/Contents.json" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-green.colorset/Contents.json" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-light.colorset/Contents.json" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Balloon.swift" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Base.lproj/LaunchScreen.storyboard" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Base.lproj/Main.storyboard" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Info.plist" create mode 100644 "Timer\346\250\241\347\211\210/Timer/SceneDelegate.swift" create mode 100644 "Timer\346\250\241\347\211\210/Timer/Task.swift" create mode 100644 "Timer\346\250\241\347\211\210/Timer/TaskTableViewCell.swift" create mode 100644 "Timer\346\250\241\347\211\210/Timer/ViewController.swift" diff --git a/README.md b/README.md index 590f5d9..c3f36df 100755 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ iOS学习进程中的demo汇总 | SimpleFactory | [工厂模式 Factory Pattern](https://github.com/pro648/tips/wiki/%E5%B7%A5%E5%8E%82%E6%A8%A1%E5%BC%8F-Factory-Pattern) | | StackView | [Auto Layout中Stack View的使用](https://github.com/pro648/tips/wiki/Auto-Layout%E4%B8%ADStack-View%E7%9A%84%E4%BD%BF%E7%94%A8) | | StrategyPattern | [策略模式 Strategy Pattern](https://github.com/pro648/tips/wiki/%E7%AD%96%E7%95%A5%E6%A8%A1%E5%BC%8F-Design-Pattern) | +| Timer | [Timer的使用](https://github.com/pro648/tips/wiki/Timer%E7%9A%84%E4%BD%BF%E7%94%A8) | | UIKitDynamics | [一篇文章学会使用UIKit Dynamics](https://github.com/pro648/tips/wiki/%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0%E5%AD%A6%E4%BC%9A%E4%BD%BF%E7%94%A8UIKit%20Dynamics) | | URLSession | [URLSession详解](https://github.com/pro648/tips/wiki/URLSession%E8%AF%A6%E8%A7%A3) | | UserNotifications | [UserNotifications框架详解](https://github.com/pro648/tips/wiki/UserNotifications%E6%A1%86%E6%9E%B6%E8%AF%A6%E8%A7%A3)| diff --git a/Timer/Timer.xcodeproj/project.pbxproj b/Timer/Timer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..7d43843 --- /dev/null +++ b/Timer/Timer.xcodeproj/project.pbxproj @@ -0,0 +1,355 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 0D9E2A7E23D44336007D521B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A7D23D44336007D521B /* AppDelegate.swift */; }; + 0D9E2A8023D44336007D521B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A7F23D44336007D521B /* SceneDelegate.swift */; }; + 0D9E2A8223D44336007D521B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8123D44336007D521B /* ViewController.swift */; }; + 0D9E2A8523D44336007D521B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8323D44336007D521B /* Main.storyboard */; }; + 0D9E2A8723D44338007D521B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8623D44338007D521B /* Assets.xcassets */; }; + 0D9E2A8A23D44338007D521B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8823D44338007D521B /* LaunchScreen.storyboard */; }; + 0D9E2A9223D4438B007D521B /* Balloon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A9123D4438B007D521B /* Balloon.swift */; }; + 0D9E2A9423D44967007D521B /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A9323D44967007D521B /* Task.swift */; }; + 0D9E2A9623D449C0007D521B /* TaskTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A9523D449C0007D521B /* TaskTableViewCell.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0D9E2A7A23D44336007D521B /* Timer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Timer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0D9E2A7D23D44336007D521B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 0D9E2A7F23D44336007D521B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 0D9E2A8123D44336007D521B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 0D9E2A8423D44336007D521B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 0D9E2A8623D44338007D521B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0D9E2A8923D44338007D521B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 0D9E2A8B23D44338007D521B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0D9E2A9123D4438B007D521B /* Balloon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Balloon.swift; sourceTree = ""; }; + 0D9E2A9323D44967007D521B /* Task.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = ""; }; + 0D9E2A9523D449C0007D521B /* TaskTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTableViewCell.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0D9E2A7723D44336007D521B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0D9E2A7123D44336007D521B = { + isa = PBXGroup; + children = ( + 0D9E2A7C23D44336007D521B /* Timer */, + 0D9E2A7B23D44336007D521B /* Products */, + ); + sourceTree = ""; + }; + 0D9E2A7B23D44336007D521B /* Products */ = { + isa = PBXGroup; + children = ( + 0D9E2A7A23D44336007D521B /* Timer.app */, + ); + name = Products; + sourceTree = ""; + }; + 0D9E2A7C23D44336007D521B /* Timer */ = { + isa = PBXGroup; + children = ( + 0D9E2A7D23D44336007D521B /* AppDelegate.swift */, + 0D9E2A7F23D44336007D521B /* SceneDelegate.swift */, + 0D9E2A8123D44336007D521B /* ViewController.swift */, + 0D9E2A9523D449C0007D521B /* TaskTableViewCell.swift */, + 0D9E2A9323D44967007D521B /* Task.swift */, + 0D9E2A9123D4438B007D521B /* Balloon.swift */, + 0D9E2A8323D44336007D521B /* Main.storyboard */, + 0D9E2A8623D44338007D521B /* Assets.xcassets */, + 0D9E2A8823D44338007D521B /* LaunchScreen.storyboard */, + 0D9E2A8B23D44338007D521B /* Info.plist */, + ); + path = Timer; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0D9E2A7923D44336007D521B /* Timer */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0D9E2A8E23D44338007D521B /* Build configuration list for PBXNativeTarget "Timer" */; + buildPhases = ( + 0D9E2A7623D44336007D521B /* Sources */, + 0D9E2A7723D44336007D521B /* Frameworks */, + 0D9E2A7823D44336007D521B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Timer; + productName = Timer; + productReference = 0D9E2A7A23D44336007D521B /* Timer.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0D9E2A7223D44336007D521B /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1130; + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = pro648; + TargetAttributes = { + 0D9E2A7923D44336007D521B = { + CreatedOnToolsVersion = 11.3; + }; + }; + }; + buildConfigurationList = 0D9E2A7523D44336007D521B /* Build configuration list for PBXProject "Timer" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0D9E2A7123D44336007D521B; + productRefGroup = 0D9E2A7B23D44336007D521B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0D9E2A7923D44336007D521B /* Timer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0D9E2A7823D44336007D521B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0D9E2A8A23D44338007D521B /* LaunchScreen.storyboard in Resources */, + 0D9E2A8723D44338007D521B /* Assets.xcassets in Resources */, + 0D9E2A8523D44336007D521B /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0D9E2A7623D44336007D521B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0D9E2A8223D44336007D521B /* ViewController.swift in Sources */, + 0D9E2A7E23D44336007D521B /* AppDelegate.swift in Sources */, + 0D9E2A9623D449C0007D521B /* TaskTableViewCell.swift in Sources */, + 0D9E2A9423D44967007D521B /* Task.swift in Sources */, + 0D9E2A8023D44336007D521B /* SceneDelegate.swift in Sources */, + 0D9E2A9223D4438B007D521B /* Balloon.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 0D9E2A8323D44336007D521B /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0D9E2A8423D44336007D521B /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 0D9E2A8823D44338007D521B /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0D9E2A8923D44338007D521B /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 0D9E2A8C23D44338007D521B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 0D9E2A8D23D44338007D521B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 0D9E2A8F23D44338007D521B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6GTWBXFMR4; + INFOPLIST_FILE = Timer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = pro648.Timer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0D9E2A9023D44338007D521B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6GTWBXFMR4; + INFOPLIST_FILE = Timer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = pro648.Timer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0D9E2A7523D44336007D521B /* Build configuration list for PBXProject "Timer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0D9E2A8C23D44338007D521B /* Debug */, + 0D9E2A8D23D44338007D521B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0D9E2A8E23D44338007D521B /* Build configuration list for PBXNativeTarget "Timer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0D9E2A8F23D44338007D521B /* Debug */, + 0D9E2A9023D44338007D521B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0D9E2A7223D44336007D521B /* Project object */; +} diff --git a/Timer/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Timer/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..5dae58e --- /dev/null +++ b/Timer/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Timer/Timer/AppDelegate.swift b/Timer/Timer/AppDelegate.swift new file mode 100644 index 0000000..e631e05 --- /dev/null +++ b/Timer/Timer/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Timer/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json b/Timer/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/Timer/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Timer/Timer/Assets.xcassets/Contents.json b/Timer/Timer/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Timer/Timer/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Timer/Timer/Assets.xcassets/rw-dark.colorset/Contents.json b/Timer/Timer/Assets.xcassets/rw-dark.colorset/Contents.json new file mode 100644 index 0000000..f9b0b98 --- /dev/null +++ b/Timer/Timer/Assets.xcassets/rw-dark.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x33", + "alpha" : "1.000", + "blue" : "0x33", + "green" : "0x33" + } + } + } + ] +} \ No newline at end of file diff --git a/Timer/Timer/Assets.xcassets/rw-green.colorset/Contents.json b/Timer/Timer/Assets.xcassets/rw-green.colorset/Contents.json new file mode 100644 index 0000000..9c61805 --- /dev/null +++ b/Timer/Timer/Assets.xcassets/rw-green.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x00", + "alpha" : "1.000", + "blue" : "0x37", + "green" : "0x68" + } + } + } + ] +} \ No newline at end of file diff --git a/Timer/Timer/Assets.xcassets/rw-light.colorset/Contents.json b/Timer/Timer/Assets.xcassets/rw-light.colorset/Contents.json new file mode 100644 index 0000000..649d087 --- /dev/null +++ b/Timer/Timer/Assets.xcassets/rw-light.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF2", + "alpha" : "1.000", + "blue" : "0xFA", + "green" : "0xF6" + } + } + } + ] +} \ No newline at end of file diff --git a/Timer/Timer/Balloon.swift b/Timer/Timer/Balloon.swift new file mode 100644 index 0000000..f3369f7 --- /dev/null +++ b/Timer/Timer/Balloon.swift @@ -0,0 +1,43 @@ +// +// Balloon.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +@IBDesignable class Balloon: UIView { + override func draw(_ rect: CGRect) { + let balloonColor = UIColor(named: "rw-green") ?? .green + let cordColor = UIColor(named: "rw-dark") ?? .black + + let ovalPath = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 66, height: 93)) + balloonColor.setFill() + ovalPath.fill() + + let trianglePath = UIBezierPath() + trianglePath.move(to: CGPoint(x: 33, y: 81.5)) + trianglePath.addLine(to: CGPoint(x: 42.96, y: 98.75)) + trianglePath.addLine(to: CGPoint(x: 23.04, y: 98.75)) + trianglePath.close() + balloonColor.setFill() + trianglePath.fill() + + let cordPath = UIBezierPath() + cordPath.move(to: CGPoint(x: 33.29, y: 98.5)) + cordPath.addCurve(to: CGPoint(x: 33.29, y: 98.5), + controlPoint1: CGPoint(x: 33.29, y: 126.5), + controlPoint2: CGPoint(x: 27.01, y: 114.06)) + cordPath.addCurve(to: CGPoint(x: 33.29, y: 157.61), + controlPoint1: CGPoint(x: 39.57, y: 138.94), + controlPoint2: CGPoint(x: 39.57, y: 145.17)) + cordPath.addCurve(to: CGPoint(x: 33.29, y: 182.5), + controlPoint1: CGPoint(x: 27.01, y: 170.06), + controlPoint2: CGPoint(x: 33.29, y: 182.5)) + cordColor.setStroke() + cordPath.lineWidth = 1 + cordPath.stroke() + } +} diff --git a/Timer/Timer/Base.lproj/LaunchScreen.storyboard b/Timer/Timer/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Timer/Timer/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Timer/Timer/Base.lproj/Main.storyboard b/Timer/Timer/Base.lproj/Main.storyboard new file mode 100644 index 0000000..d9f1c54 --- /dev/null +++ b/Timer/Timer/Base.lproj/Main.storyboard @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Timer/Timer/Info.plist b/Timer/Timer/Info.plist new file mode 100644 index 0000000..2a3483c --- /dev/null +++ b/Timer/Timer/Info.plist @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Timer/Timer/SceneDelegate.swift b/Timer/Timer/SceneDelegate.swift new file mode 100644 index 0000000..88d508a --- /dev/null +++ b/Timer/Timer/SceneDelegate.swift @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/Timer/Timer/Task.swift b/Timer/Timer/Task.swift new file mode 100644 index 0000000..414be8e --- /dev/null +++ b/Timer/Timer/Task.swift @@ -0,0 +1,19 @@ +// +// Task.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import Foundation + +class Task { + let name: String + let creationDate = Date() + var completed = false + + init(name: String) { + self.name = name + } +} diff --git a/Timer/Timer/TaskTableViewCell.swift b/Timer/Timer/TaskTableViewCell.swift new file mode 100644 index 0000000..e84be7f --- /dev/null +++ b/Timer/Timer/TaskTableViewCell.swift @@ -0,0 +1,74 @@ +// +// TaskTableViewCell.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +class TaskTableViewCell: UITableViewCell { + + @IBOutlet weak var taskLabel: UILabel! + @IBOutlet weak var timeLabel: UILabel! + + var task: Task? { + didSet { + taskLabel.text = task?.name + setState() + updateTime() + } + } + + func updateState() { + guard let task = task else { + return + } + + task.completed.toggle() + + setState() + updateTime() + } + + func updateTime() { + guard let task = task else { + return + } + + if task.completed { + timeLabel.text = "Completed" + } else { + let time = Date().timeIntervalSince(task.creationDate) + + let hours = Int(time) / 3600 + let minutes = Int(time) / 60 % 60 + let seconds = Int(time) % 60 + + var times: [String] = [] + if hours > 0 { + times.append("\(hours)h") + } + if minutes > 0 { + times.append("\(minutes)m") + } + times.append("\(seconds)s") + + timeLabel.text = times.joined(separator: " ") + } + } + + private func setState() { + guard let task = task else { + return + } + + if task.completed { + taskLabel.attributedText = NSAttributedString(string: task.name, attributes: [.strikethroughStyle: 1]) + } else { + taskLabel.attributedText = NSAttributedString(string: task.name, attributes: nil) + } + } + +} diff --git a/Timer/Timer/ViewController.swift b/Timer/Timer/ViewController.swift new file mode 100644 index 0000000..2f0d330 --- /dev/null +++ b/Timer/Timer/ViewController.swift @@ -0,0 +1,192 @@ +// +// ViewController.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var balloon: Balloon! + + var timer: Timer? + + var taskList: [Task] = [] + +// var animationTimer: Timer? +// var startTime: TimeInterval?, endTime: TimeInterval? + var displayLink: CADisplayLink? + var startTime: CFTimeInterval?, endTime: CFTimeInterval? + let animationDuration = 3.0 + var height: CGFloat = 0 + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + + navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(presentAlertController(_:))) + } +} + +// MARK: - UITableViewDelegate +extension ViewController: UITableViewDelegate { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + guard let cell = tableView.cellForRow(at: indexPath) as? TaskTableViewCell else { return } + + cell.updateState() + + showCongratulationsIfNeeded() + } +} + +// MARK: - UITableViewDataSource +extension ViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return taskList.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "TaskCell", for: indexPath) + + if let cell = cell as? TaskTableViewCell { + cell.task = taskList[indexPath.row] + } + + return cell + } +} + +// MARK: - Actions +extension ViewController { + @objc func presentAlertController(_ sender: UIBarButtonItem) { + createTimer() + + let alertController = UIAlertController(title: "Task Name", message: nil, preferredStyle: .alert) + alertController.addTextField { (textField) in + textField.placeholder = "Task name" + textField.autocapitalizationType = .sentences + } + + let createAction = UIAlertAction(title: "OK", style: .default) { [weak self, weak alertController] _ in + guard let self = self, + let text = alertController?.textFields?.first?.text else { + return + } + + DispatchQueue.main.async { + let task = Task(name: text) + self.taskList.append(task) + let indexPath = IndexPath(row: self.taskList.count - 1, section: 0) + + self.tableView.beginUpdates() + self.tableView.insertRows(at: [indexPath], with: .top) + self.tableView.endUpdates() + } + } + + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + + alertController.addAction(createAction) + alertController.addAction(cancelAction) + + present(alertController, animated: true, completion: nil) + } +} + +// MARK: - Timer +extension ViewController { + func createTimer() { + if timer == nil { +// timer = Timer.scheduledTimer(timeInterval: 1.0, +// target: self, +// selector: #selector(updateTimer), +// userInfo: nil, +// repeats: true) +// timer?.tolerance = 0.15 + + let timer = Timer(timeInterval: 1.0, + target: self, + selector: #selector(updateTimer), + userInfo: nil, + repeats: true) + RunLoop.current.add(timer, forMode: .common) + timer.tolerance = 0.15 + + self.timer = timer + } + } + + func cancelTimer() { + timer?.invalidate() + timer = nil + } + + @objc func updateTimer() { + if let fireDateDescription = timer?.fireDate.description { + print(fireDateDescription) + } + + guard let visibleRowsIndexPaths = tableView.indexPathsForVisibleRows else { + return + } + + for indexPath in visibleRowsIndexPaths { + if let cell = tableView.cellForRow(at: indexPath) as? TaskTableViewCell { + cell.updateTime() + } + } + } +} + +// MARK: - Animation +extension ViewController { + func showCongratulationAnimation() { + height = UIScreen.main.bounds.height + balloon.frame.size.height + balloon.center = CGPoint(x: UIScreen.main.bounds.width / 2, y: height + balloon.frame.size.height / 2) + balloon.isHidden = false + + startTime = Date().timeIntervalSince1970 + endTime = animationDuration + startTime! + +// animationTimer = Timer.scheduledTimer(withTimeInterval: 1 / 60, repeats: true, block: { (timer) in +// self.updateAnimation() +// }) + displayLink = CADisplayLink(target: self, + selector: #selector(updateAnimation)) + displayLink?.add(to: RunLoop.main, forMode: .common) + } + + @objc func updateAnimation() { + guard let endTime = endTime, + let startTime = startTime else { return } + +// let now = Date().timeIntervalSince1970 + let now = CACurrentMediaTime() + + if now >= endTime { +// animationTimer?.invalidate() + displayLink?.isPaused = true + displayLink?.invalidate() + balloon.isHidden = true + } + + let percentage = (now - startTime) * 100 / animationDuration + let y = height - ((height + balloon.frame.height / 2) / 100 * CGFloat(percentage)) + + balloon.center = CGPoint(x: balloon.center.x + CGFloat.random(in: -0.5...0.5), y: y) + } + + func showCongratulationsIfNeeded() { + if taskList.filter({ !$0.completed }).count == 0 { + cancelTimer() + showCongratulationAnimation() + } else { + createTimer() + } + } +} diff --git "a/Timer\346\250\241\347\211\210/README.md" "b/Timer\346\250\241\347\211\210/README.md" new file mode 100755 index 0000000..306577b --- /dev/null +++ "b/Timer\346\250\241\347\211\210/README.md" @@ -0,0 +1,10 @@ +### Timer的使用 + +`Timer`继承自`NSObject`,用以提供延迟(周期性)触发动作的方法。通常,定时器会在指定间隔后自动触发,向指定对象发送消息。如果 timer 是非重复定时器,则触发一次后自动失效,从而防止定时器再次触发;如果是重复定时器,则会在指定间隔后重复触发,需手动调用`invaliate()`方法使计时器无效。 + +这篇文章将介绍计时器(Timer)如何使用,与 run loop 的关系,对性能、电量的影响,以及如何使用`CADisplayLink`处理动画。 + +详细介绍查看下面文章: + + + diff --git "a/Timer\346\250\241\347\211\210/Timer.xcodeproj/project.pbxproj" "b/Timer\346\250\241\347\211\210/Timer.xcodeproj/project.pbxproj" new file mode 100644 index 0000000..6da5f9c --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer.xcodeproj/project.pbxproj" @@ -0,0 +1,353 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 0D9E2A7E23D44336007D521B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A7D23D44336007D521B /* AppDelegate.swift */; }; + 0D9E2A8023D44336007D521B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A7F23D44336007D521B /* SceneDelegate.swift */; }; + 0D9E2A8223D44336007D521B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8123D44336007D521B /* ViewController.swift */; }; + 0D9E2A8523D44336007D521B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8323D44336007D521B /* Main.storyboard */; }; + 0D9E2A8723D44338007D521B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8623D44338007D521B /* Assets.xcassets */; }; + 0D9E2A8A23D44338007D521B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0D9E2A8823D44338007D521B /* LaunchScreen.storyboard */; }; + 0D9E2A9223D4438B007D521B /* Balloon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A9123D4438B007D521B /* Balloon.swift */; }; + 0D9E2A9423D44967007D521B /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A9323D44967007D521B /* Task.swift */; }; + 0D9E2A9623D449C0007D521B /* TaskTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D9E2A9523D449C0007D521B /* TaskTableViewCell.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0D9E2A7A23D44336007D521B /* Timer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Timer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0D9E2A7D23D44336007D521B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 0D9E2A7F23D44336007D521B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 0D9E2A8123D44336007D521B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 0D9E2A8423D44336007D521B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 0D9E2A8623D44338007D521B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0D9E2A8923D44338007D521B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 0D9E2A8B23D44338007D521B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0D9E2A9123D4438B007D521B /* Balloon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Balloon.swift; sourceTree = ""; }; + 0D9E2A9323D44967007D521B /* Task.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = ""; }; + 0D9E2A9523D449C0007D521B /* TaskTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTableViewCell.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0D9E2A7723D44336007D521B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0D9E2A7123D44336007D521B = { + isa = PBXGroup; + children = ( + 0D9E2A7C23D44336007D521B /* Timer */, + 0D9E2A7B23D44336007D521B /* Products */, + ); + sourceTree = ""; + }; + 0D9E2A7B23D44336007D521B /* Products */ = { + isa = PBXGroup; + children = ( + 0D9E2A7A23D44336007D521B /* Timer.app */, + ); + name = Products; + sourceTree = ""; + }; + 0D9E2A7C23D44336007D521B /* Timer */ = { + isa = PBXGroup; + children = ( + 0D9E2A7D23D44336007D521B /* AppDelegate.swift */, + 0D9E2A7F23D44336007D521B /* SceneDelegate.swift */, + 0D9E2A8123D44336007D521B /* ViewController.swift */, + 0D9E2A9523D449C0007D521B /* TaskTableViewCell.swift */, + 0D9E2A9323D44967007D521B /* Task.swift */, + 0D9E2A9123D4438B007D521B /* Balloon.swift */, + 0D9E2A8323D44336007D521B /* Main.storyboard */, + 0D9E2A8623D44338007D521B /* Assets.xcassets */, + 0D9E2A8823D44338007D521B /* LaunchScreen.storyboard */, + 0D9E2A8B23D44338007D521B /* Info.plist */, + ); + path = Timer; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0D9E2A7923D44336007D521B /* Timer */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0D9E2A8E23D44338007D521B /* Build configuration list for PBXNativeTarget "Timer" */; + buildPhases = ( + 0D9E2A7623D44336007D521B /* Sources */, + 0D9E2A7723D44336007D521B /* Frameworks */, + 0D9E2A7823D44336007D521B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Timer; + productName = Timer; + productReference = 0D9E2A7A23D44336007D521B /* Timer.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0D9E2A7223D44336007D521B /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1130; + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = pro648; + TargetAttributes = { + 0D9E2A7923D44336007D521B = { + CreatedOnToolsVersion = 11.3; + }; + }; + }; + buildConfigurationList = 0D9E2A7523D44336007D521B /* Build configuration list for PBXProject "Timer" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0D9E2A7123D44336007D521B; + productRefGroup = 0D9E2A7B23D44336007D521B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0D9E2A7923D44336007D521B /* Timer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0D9E2A7823D44336007D521B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0D9E2A8A23D44338007D521B /* LaunchScreen.storyboard in Resources */, + 0D9E2A8723D44338007D521B /* Assets.xcassets in Resources */, + 0D9E2A8523D44336007D521B /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0D9E2A7623D44336007D521B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0D9E2A8223D44336007D521B /* ViewController.swift in Sources */, + 0D9E2A7E23D44336007D521B /* AppDelegate.swift in Sources */, + 0D9E2A9623D449C0007D521B /* TaskTableViewCell.swift in Sources */, + 0D9E2A9423D44967007D521B /* Task.swift in Sources */, + 0D9E2A8023D44336007D521B /* SceneDelegate.swift in Sources */, + 0D9E2A9223D4438B007D521B /* Balloon.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 0D9E2A8323D44336007D521B /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0D9E2A8423D44336007D521B /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 0D9E2A8823D44338007D521B /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0D9E2A8923D44338007D521B /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 0D9E2A8C23D44338007D521B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 0D9E2A8D23D44338007D521B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 0D9E2A8F23D44338007D521B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Timer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = pro648.Timer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0D9E2A9023D44338007D521B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Timer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = pro648.Timer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0D9E2A7523D44336007D521B /* Build configuration list for PBXProject "Timer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0D9E2A8C23D44338007D521B /* Debug */, + 0D9E2A8D23D44338007D521B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0D9E2A8E23D44338007D521B /* Build configuration list for PBXNativeTarget "Timer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0D9E2A8F23D44338007D521B /* Debug */, + 0D9E2A9023D44338007D521B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0D9E2A7223D44336007D521B /* Project object */; +} diff --git "a/Timer\346\250\241\347\211\210/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata" "b/Timer\346\250\241\347\211\210/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata" new file mode 100644 index 0000000..5dae58e --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer.xcodeproj/project.xcworkspace/contents.xcworkspacedata" @@ -0,0 +1,7 @@ + + + + + diff --git "a/Timer\346\250\241\347\211\210/Timer/AppDelegate.swift" "b/Timer\346\250\241\347\211\210/Timer/AppDelegate.swift" new file mode 100644 index 0000000..e631e05 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/AppDelegate.swift" @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git "a/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json" "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json" new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/AppIcon.appiconset/Contents.json" @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git "a/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/Contents.json" "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/Contents.json" new file mode 100644 index 0000000..da4a164 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/Contents.json" @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git "a/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-dark.colorset/Contents.json" "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-dark.colorset/Contents.json" new file mode 100644 index 0000000..f9b0b98 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-dark.colorset/Contents.json" @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x33", + "alpha" : "1.000", + "blue" : "0x33", + "green" : "0x33" + } + } + } + ] +} \ No newline at end of file diff --git "a/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-green.colorset/Contents.json" "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-green.colorset/Contents.json" new file mode 100644 index 0000000..9c61805 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-green.colorset/Contents.json" @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0x00", + "alpha" : "1.000", + "blue" : "0x37", + "green" : "0x68" + } + } + } + ] +} \ No newline at end of file diff --git "a/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-light.colorset/Contents.json" "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-light.colorset/Contents.json" new file mode 100644 index 0000000..649d087 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Assets.xcassets/rw-light.colorset/Contents.json" @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0xF2", + "alpha" : "1.000", + "blue" : "0xFA", + "green" : "0xF6" + } + } + } + ] +} \ No newline at end of file diff --git "a/Timer\346\250\241\347\211\210/Timer/Balloon.swift" "b/Timer\346\250\241\347\211\210/Timer/Balloon.swift" new file mode 100644 index 0000000..f3369f7 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Balloon.swift" @@ -0,0 +1,43 @@ +// +// Balloon.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +@IBDesignable class Balloon: UIView { + override func draw(_ rect: CGRect) { + let balloonColor = UIColor(named: "rw-green") ?? .green + let cordColor = UIColor(named: "rw-dark") ?? .black + + let ovalPath = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 66, height: 93)) + balloonColor.setFill() + ovalPath.fill() + + let trianglePath = UIBezierPath() + trianglePath.move(to: CGPoint(x: 33, y: 81.5)) + trianglePath.addLine(to: CGPoint(x: 42.96, y: 98.75)) + trianglePath.addLine(to: CGPoint(x: 23.04, y: 98.75)) + trianglePath.close() + balloonColor.setFill() + trianglePath.fill() + + let cordPath = UIBezierPath() + cordPath.move(to: CGPoint(x: 33.29, y: 98.5)) + cordPath.addCurve(to: CGPoint(x: 33.29, y: 98.5), + controlPoint1: CGPoint(x: 33.29, y: 126.5), + controlPoint2: CGPoint(x: 27.01, y: 114.06)) + cordPath.addCurve(to: CGPoint(x: 33.29, y: 157.61), + controlPoint1: CGPoint(x: 39.57, y: 138.94), + controlPoint2: CGPoint(x: 39.57, y: 145.17)) + cordPath.addCurve(to: CGPoint(x: 33.29, y: 182.5), + controlPoint1: CGPoint(x: 27.01, y: 170.06), + controlPoint2: CGPoint(x: 33.29, y: 182.5)) + cordColor.setStroke() + cordPath.lineWidth = 1 + cordPath.stroke() + } +} diff --git "a/Timer\346\250\241\347\211\210/Timer/Base.lproj/LaunchScreen.storyboard" "b/Timer\346\250\241\347\211\210/Timer/Base.lproj/LaunchScreen.storyboard" new file mode 100644 index 0000000..865e932 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Base.lproj/LaunchScreen.storyboard" @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/Timer\346\250\241\347\211\210/Timer/Base.lproj/Main.storyboard" "b/Timer\346\250\241\347\211\210/Timer/Base.lproj/Main.storyboard" new file mode 100644 index 0000000..8f26ebc --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Base.lproj/Main.storyboard" @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/Timer\346\250\241\347\211\210/Timer/Info.plist" "b/Timer\346\250\241\347\211\210/Timer/Info.plist" new file mode 100644 index 0000000..2a3483c --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Info.plist" @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git "a/Timer\346\250\241\347\211\210/Timer/SceneDelegate.swift" "b/Timer\346\250\241\347\211\210/Timer/SceneDelegate.swift" new file mode 100644 index 0000000..88d508a --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/SceneDelegate.swift" @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git "a/Timer\346\250\241\347\211\210/Timer/Task.swift" "b/Timer\346\250\241\347\211\210/Timer/Task.swift" new file mode 100644 index 0000000..414be8e --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/Task.swift" @@ -0,0 +1,19 @@ +// +// Task.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import Foundation + +class Task { + let name: String + let creationDate = Date() + var completed = false + + init(name: String) { + self.name = name + } +} diff --git "a/Timer\346\250\241\347\211\210/Timer/TaskTableViewCell.swift" "b/Timer\346\250\241\347\211\210/Timer/TaskTableViewCell.swift" new file mode 100644 index 0000000..e84be7f --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/TaskTableViewCell.swift" @@ -0,0 +1,74 @@ +// +// TaskTableViewCell.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +class TaskTableViewCell: UITableViewCell { + + @IBOutlet weak var taskLabel: UILabel! + @IBOutlet weak var timeLabel: UILabel! + + var task: Task? { + didSet { + taskLabel.text = task?.name + setState() + updateTime() + } + } + + func updateState() { + guard let task = task else { + return + } + + task.completed.toggle() + + setState() + updateTime() + } + + func updateTime() { + guard let task = task else { + return + } + + if task.completed { + timeLabel.text = "Completed" + } else { + let time = Date().timeIntervalSince(task.creationDate) + + let hours = Int(time) / 3600 + let minutes = Int(time) / 60 % 60 + let seconds = Int(time) % 60 + + var times: [String] = [] + if hours > 0 { + times.append("\(hours)h") + } + if minutes > 0 { + times.append("\(minutes)m") + } + times.append("\(seconds)s") + + timeLabel.text = times.joined(separator: " ") + } + } + + private func setState() { + guard let task = task else { + return + } + + if task.completed { + taskLabel.attributedText = NSAttributedString(string: task.name, attributes: [.strikethroughStyle: 1]) + } else { + taskLabel.attributedText = NSAttributedString(string: task.name, attributes: nil) + } + } + +} diff --git "a/Timer\346\250\241\347\211\210/Timer/ViewController.swift" "b/Timer\346\250\241\347\211\210/Timer/ViewController.swift" new file mode 100644 index 0000000..328e7b5 --- /dev/null +++ "b/Timer\346\250\241\347\211\210/Timer/ViewController.swift" @@ -0,0 +1,86 @@ +// +// ViewController.swift +// Timer +// +// Created by pro648 on 2020/1/19. +// Copyright © 2020 pro648. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var balloon: Balloon! + + var taskList: [Task] = [] + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + + navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(presentAlertController(_:))) + } +} + +// MARK: - UITableViewDelegate +extension ViewController: UITableViewDelegate { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + guard let cell = tableView.cellForRow(at: indexPath) as? TaskTableViewCell else { return } + + cell.updateState() + } +} + +// MARK: - UITableViewDataSource +extension ViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return taskList.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "TaskCell", for: indexPath) + + if let cell = cell as? TaskTableViewCell { + cell.task = taskList[indexPath.row] + } + + return cell + } +} + +// MARK: - Actions +extension ViewController { + @objc func presentAlertController(_ sender: UIBarButtonItem) { + let alertController = UIAlertController(title: "Task Name", message: nil, preferredStyle: .alert) + alertController.addTextField { (textField) in + textField.placeholder = "Task name" + textField.autocapitalizationType = .sentences + } + + let createAction = UIAlertAction(title: "OK", style: .default) { [weak self, weak alertController] _ in + guard let self = self, + let text = alertController?.textFields?.first?.text else { + return + } + + DispatchQueue.main.async { + let task = Task(name: text) + self.taskList.append(task) + let indexPath = IndexPath(row: self.taskList.count - 1, section: 0) + + self.tableView.beginUpdates() + self.tableView.insertRows(at: [indexPath], with: .top) + self.tableView.endUpdates() + } + } + + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + + alertController.addAction(createAction) + alertController.addAction(cancelAction) + + present(alertController, animated: true, completion: nil) + } +}