├── .gitignore ├── CHANGELOG ├── FloatingToggl.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── kylefang.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── FloatingToggl.xcworkspace └── contents.xcworkspacedata ├── FloatingToggl ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-1024.png │ │ ├── Icon-128.png │ │ ├── Icon-16.png │ │ ├── Icon-256.png │ │ ├── Icon-257.png │ │ ├── Icon-32.png │ │ ├── Icon-33.png │ │ ├── Icon-512.png │ │ ├── Icon-513.png │ │ └── Icon-64.png │ ├── Contents.json │ ├── Start.imageset │ │ ├── Contents.json │ │ └── Start.pdf │ └── Stop.imageset │ │ ├── Contents.json │ │ └── Stop.pdf ├── Base.lproj │ └── Main.storyboard ├── FloatingPannel.swift ├── FloatingToggl.entitlements ├── Info.plist └── ViewController.swift ├── Podfile ├── Podfile.lock └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Pods 2 | xcuserdata 3 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | Changelog 2 | --------------- 3 | 4 | ### 1.1.1 5 | 6 | * Not stealing user focus when showing reminder 7 | * Adding 15 min as reminder interval 8 | 9 | ### 1.1.0 10 | 11 | * In recent entries, sort project by usage. 12 | * When showing recent entries, enter key autocomplete instead of start timer. 13 | * Add option to reminder you at certain interval. 14 | * Add option to auto apply yes on interval timeout. 15 | * Disable reminder when computer went to sleep. 16 | * Keep break duration in timer if it's less than 10 min 17 | -------------------------------------------------------------------------------- /FloatingToggl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 041E2BAC1F9EF0370036687C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041E2BAB1F9EF0370036687C /* AppDelegate.swift */; }; 11 | 041E2BAE1F9EF0370036687C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041E2BAD1F9EF0370036687C /* ViewController.swift */; }; 12 | 041E2BB01F9EF0370036687C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 041E2BAF1F9EF0370036687C /* Assets.xcassets */; }; 13 | 041E2BB31F9EF0370036687C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 041E2BB11F9EF0370036687C /* Main.storyboard */; }; 14 | 041E2BBC1F9EF3450036687C /* FloatingPannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 041E2BBB1F9EF3450036687C /* FloatingPannel.swift */; }; 15 | 145F4DBB4369B80B239E19AE /* Pods_FloatingToggl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3256CA209129AD71D5691BF /* Pods_FloatingToggl.framework */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 041E2BA81F9EF0370036687C /* In Time.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "In Time.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 041E2BAB1F9EF0370036687C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 041E2BAD1F9EF0370036687C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 041E2BAF1F9EF0370036687C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 041E2BB21F9EF0370036687C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | 041E2BB41F9EF0370036687C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | 041E2BB51F9EF0370036687C /* FloatingToggl.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FloatingToggl.entitlements; sourceTree = ""; }; 26 | 041E2BBB1F9EF3450036687C /* FloatingPannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPannel.swift; sourceTree = ""; }; 27 | 04D507151FCC84360038E7E0 /* CHANGELOG */ = {isa = PBXFileReference; lastKnownFileType = text; path = CHANGELOG; sourceTree = ""; }; 28 | 60799DCC63FBAD0197655FF4 /* Pods-FloatingToggl.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FloatingToggl.release.xcconfig"; path = "Pods/Target Support Files/Pods-FloatingToggl/Pods-FloatingToggl.release.xcconfig"; sourceTree = ""; }; 29 | 6A61B7517328FB18AF3456FF /* Pods-FloatingToggl.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FloatingToggl.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FloatingToggl/Pods-FloatingToggl.debug.xcconfig"; sourceTree = ""; }; 30 | B3256CA209129AD71D5691BF /* Pods_FloatingToggl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_FloatingToggl.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 041E2BA51F9EF0370036687C /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | 145F4DBB4369B80B239E19AE /* Pods_FloatingToggl.framework in Frameworks */, 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 041E2B9F1F9EF0370036687C = { 46 | isa = PBXGroup; 47 | children = ( 48 | 04D507151FCC84360038E7E0 /* CHANGELOG */, 49 | 041E2BAA1F9EF0370036687C /* FloatingToggl */, 50 | 041E2BA91F9EF0370036687C /* Products */, 51 | AB897BA953C7D862BCC1F2D0 /* Pods */, 52 | 780D2B765342EE4AC0115021 /* Frameworks */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 041E2BA91F9EF0370036687C /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 041E2BA81F9EF0370036687C /* In Time.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 041E2BAA1F9EF0370036687C /* FloatingToggl */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 041E2BAB1F9EF0370036687C /* AppDelegate.swift */, 68 | 041E2BAD1F9EF0370036687C /* ViewController.swift */, 69 | 041E2BBB1F9EF3450036687C /* FloatingPannel.swift */, 70 | 041E2BAF1F9EF0370036687C /* Assets.xcassets */, 71 | 041E2BB11F9EF0370036687C /* Main.storyboard */, 72 | 041E2BB41F9EF0370036687C /* Info.plist */, 73 | 041E2BB51F9EF0370036687C /* FloatingToggl.entitlements */, 74 | ); 75 | path = FloatingToggl; 76 | sourceTree = ""; 77 | }; 78 | 780D2B765342EE4AC0115021 /* Frameworks */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | B3256CA209129AD71D5691BF /* Pods_FloatingToggl.framework */, 82 | ); 83 | name = Frameworks; 84 | sourceTree = ""; 85 | }; 86 | AB897BA953C7D862BCC1F2D0 /* Pods */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 6A61B7517328FB18AF3456FF /* Pods-FloatingToggl.debug.xcconfig */, 90 | 60799DCC63FBAD0197655FF4 /* Pods-FloatingToggl.release.xcconfig */, 91 | ); 92 | name = Pods; 93 | sourceTree = ""; 94 | }; 95 | /* End PBXGroup section */ 96 | 97 | /* Begin PBXNativeTarget section */ 98 | 041E2BA71F9EF0370036687C /* FloatingToggl */ = { 99 | isa = PBXNativeTarget; 100 | buildConfigurationList = 041E2BB81F9EF0370036687C /* Build configuration list for PBXNativeTarget "FloatingToggl" */; 101 | buildPhases = ( 102 | 935FB9A47B402FC264260B60 /* [CP] Check Pods Manifest.lock */, 103 | 041E2BA41F9EF0370036687C /* Sources */, 104 | 041E2BA51F9EF0370036687C /* Frameworks */, 105 | 041E2BA61F9EF0370036687C /* Resources */, 106 | 2393EEAA077E0401FCB18BD5 /* [CP] Embed Pods Frameworks */, 107 | 5C66BE3562F1F3F655714C6E /* [CP] Copy Pods Resources */, 108 | ); 109 | buildRules = ( 110 | ); 111 | dependencies = ( 112 | ); 113 | name = FloatingToggl; 114 | productName = FloatingToggl; 115 | productReference = 041E2BA81F9EF0370036687C /* In Time.app */; 116 | productType = "com.apple.product-type.application"; 117 | }; 118 | /* End PBXNativeTarget section */ 119 | 120 | /* Begin PBXProject section */ 121 | 041E2BA01F9EF0370036687C /* Project object */ = { 122 | isa = PBXProject; 123 | attributes = { 124 | LastSwiftUpdateCheck = 0900; 125 | LastUpgradeCheck = 0900; 126 | ORGANIZATIONNAME = matrix; 127 | TargetAttributes = { 128 | 041E2BA71F9EF0370036687C = { 129 | CreatedOnToolsVersion = 9.0; 130 | ProvisioningStyle = Automatic; 131 | }; 132 | }; 133 | }; 134 | buildConfigurationList = 041E2BA31F9EF0370036687C /* Build configuration list for PBXProject "FloatingToggl" */; 135 | compatibilityVersion = "Xcode 8.0"; 136 | developmentRegion = en; 137 | hasScannedForEncodings = 0; 138 | knownRegions = ( 139 | en, 140 | Base, 141 | ); 142 | mainGroup = 041E2B9F1F9EF0370036687C; 143 | productRefGroup = 041E2BA91F9EF0370036687C /* Products */; 144 | projectDirPath = ""; 145 | projectRoot = ""; 146 | targets = ( 147 | 041E2BA71F9EF0370036687C /* FloatingToggl */, 148 | ); 149 | }; 150 | /* End PBXProject section */ 151 | 152 | /* Begin PBXResourcesBuildPhase section */ 153 | 041E2BA61F9EF0370036687C /* Resources */ = { 154 | isa = PBXResourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | 041E2BB01F9EF0370036687C /* Assets.xcassets in Resources */, 158 | 041E2BB31F9EF0370036687C /* Main.storyboard in Resources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXResourcesBuildPhase section */ 163 | 164 | /* Begin PBXShellScriptBuildPhase section */ 165 | 2393EEAA077E0401FCB18BD5 /* [CP] Embed Pods Frameworks */ = { 166 | isa = PBXShellScriptBuildPhase; 167 | buildActionMask = 2147483647; 168 | files = ( 169 | ); 170 | inputPaths = ( 171 | "${SRCROOT}/Pods/Target Support Files/Pods-FloatingToggl/Pods-FloatingToggl-frameworks.sh", 172 | "${BUILT_PRODUCTS_DIR}/KeychainSwift/KeychainSwift.framework", 173 | "${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework", 174 | "${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework", 175 | ); 176 | name = "[CP] Embed Pods Frameworks"; 177 | outputPaths = ( 178 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KeychainSwift.framework", 179 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework", 180 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework", 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FloatingToggl/Pods-FloatingToggl-frameworks.sh\"\n"; 185 | showEnvVarsInLog = 0; 186 | }; 187 | 5C66BE3562F1F3F655714C6E /* [CP] Copy Pods Resources */ = { 188 | isa = PBXShellScriptBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | ); 192 | inputPaths = ( 193 | ); 194 | name = "[CP] Copy Pods Resources"; 195 | outputPaths = ( 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | shellPath = /bin/sh; 199 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-FloatingToggl/Pods-FloatingToggl-resources.sh\"\n"; 200 | showEnvVarsInLog = 0; 201 | }; 202 | 935FB9A47B402FC264260B60 /* [CP] Check Pods Manifest.lock */ = { 203 | isa = PBXShellScriptBuildPhase; 204 | buildActionMask = 2147483647; 205 | files = ( 206 | ); 207 | inputPaths = ( 208 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 209 | "${PODS_ROOT}/Manifest.lock", 210 | ); 211 | name = "[CP] Check Pods Manifest.lock"; 212 | outputPaths = ( 213 | "$(DERIVED_FILE_DIR)/Pods-FloatingToggl-checkManifestLockResult.txt", 214 | ); 215 | runOnlyForDeploymentPostprocessing = 0; 216 | shellPath = /bin/sh; 217 | 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"; 218 | showEnvVarsInLog = 0; 219 | }; 220 | /* End PBXShellScriptBuildPhase section */ 221 | 222 | /* Begin PBXSourcesBuildPhase section */ 223 | 041E2BA41F9EF0370036687C /* Sources */ = { 224 | isa = PBXSourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | 041E2BAE1F9EF0370036687C /* ViewController.swift in Sources */, 228 | 041E2BBC1F9EF3450036687C /* FloatingPannel.swift in Sources */, 229 | 041E2BAC1F9EF0370036687C /* AppDelegate.swift in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | /* End PBXSourcesBuildPhase section */ 234 | 235 | /* Begin PBXVariantGroup section */ 236 | 041E2BB11F9EF0370036687C /* Main.storyboard */ = { 237 | isa = PBXVariantGroup; 238 | children = ( 239 | 041E2BB21F9EF0370036687C /* Base */, 240 | ); 241 | name = Main.storyboard; 242 | sourceTree = ""; 243 | }; 244 | /* End PBXVariantGroup section */ 245 | 246 | /* Begin XCBuildConfiguration section */ 247 | 041E2BB61F9EF0370036687C /* Debug */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ALWAYS_SEARCH_USER_PATHS = NO; 251 | CLANG_ANALYZER_NONNULL = YES; 252 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 253 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 254 | CLANG_CXX_LIBRARY = "libc++"; 255 | CLANG_ENABLE_MODULES = YES; 256 | CLANG_ENABLE_OBJC_ARC = YES; 257 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 258 | CLANG_WARN_BOOL_CONVERSION = YES; 259 | CLANG_WARN_COMMA = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 270 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 271 | CLANG_WARN_STRICT_PROTOTYPES = YES; 272 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 273 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 274 | CLANG_WARN_UNREACHABLE_CODE = YES; 275 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 276 | CODE_SIGN_IDENTITY = "Mac Developer"; 277 | COPY_PHASE_STRIP = NO; 278 | DEBUG_INFORMATION_FORMAT = dwarf; 279 | ENABLE_STRICT_OBJC_MSGSEND = YES; 280 | ENABLE_TESTABILITY = YES; 281 | GCC_C_LANGUAGE_STANDARD = gnu11; 282 | GCC_DYNAMIC_NO_PIC = NO; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_OPTIMIZATION_LEVEL = 0; 285 | GCC_PREPROCESSOR_DEFINITIONS = ( 286 | "DEBUG=1", 287 | "$(inherited)", 288 | ); 289 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 290 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 291 | GCC_WARN_UNDECLARED_SELECTOR = YES; 292 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 293 | GCC_WARN_UNUSED_FUNCTION = YES; 294 | GCC_WARN_UNUSED_VARIABLE = YES; 295 | MACOSX_DEPLOYMENT_TARGET = 10.12; 296 | MTL_ENABLE_DEBUG_INFO = YES; 297 | ONLY_ACTIVE_ARCH = YES; 298 | SDKROOT = macosx; 299 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 300 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 301 | }; 302 | name = Debug; 303 | }; 304 | 041E2BB71F9EF0370036687C /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ALWAYS_SEARCH_USER_PATHS = NO; 308 | CLANG_ANALYZER_NONNULL = YES; 309 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_COMMA = YES; 317 | CLANG_WARN_CONSTANT_CONVERSION = YES; 318 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 319 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 320 | CLANG_WARN_EMPTY_BODY = YES; 321 | CLANG_WARN_ENUM_CONVERSION = YES; 322 | CLANG_WARN_INFINITE_RECURSION = YES; 323 | CLANG_WARN_INT_CONVERSION = YES; 324 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 325 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 326 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 327 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 328 | CLANG_WARN_STRICT_PROTOTYPES = YES; 329 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 330 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 331 | CLANG_WARN_UNREACHABLE_CODE = YES; 332 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 333 | CODE_SIGN_IDENTITY = "Mac Developer"; 334 | COPY_PHASE_STRIP = NO; 335 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 336 | ENABLE_NS_ASSERTIONS = NO; 337 | ENABLE_STRICT_OBJC_MSGSEND = YES; 338 | GCC_C_LANGUAGE_STANDARD = gnu11; 339 | GCC_NO_COMMON_BLOCKS = YES; 340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 342 | GCC_WARN_UNDECLARED_SELECTOR = YES; 343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 344 | GCC_WARN_UNUSED_FUNCTION = YES; 345 | GCC_WARN_UNUSED_VARIABLE = YES; 346 | MACOSX_DEPLOYMENT_TARGET = 10.12; 347 | MTL_ENABLE_DEBUG_INFO = NO; 348 | SDKROOT = macosx; 349 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 350 | }; 351 | name = Release; 352 | }; 353 | 041E2BB91F9EF0370036687C /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | baseConfigurationReference = 6A61B7517328FB18AF3456FF /* Pods-FloatingToggl.debug.xcconfig */; 356 | buildSettings = { 357 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 358 | CODE_SIGN_ENTITLEMENTS = FloatingToggl/FloatingToggl.entitlements; 359 | CODE_SIGN_IDENTITY = "Mac Developer"; 360 | CODE_SIGN_STYLE = Automatic; 361 | COMBINE_HIDPI_IMAGES = YES; 362 | DEVELOPMENT_TEAM = 7CRYNR44B3; 363 | INFOPLIST_FILE = FloatingToggl/Info.plist; 364 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 365 | PRODUCT_BUNDLE_IDENTIFIER = com.matrix.FloatingToggl; 366 | PRODUCT_NAME = "In Time"; 367 | PROVISIONING_PROFILE_SPECIFIER = ""; 368 | SWIFT_VERSION = 4.0; 369 | }; 370 | name = Debug; 371 | }; 372 | 041E2BBA1F9EF0370036687C /* Release */ = { 373 | isa = XCBuildConfiguration; 374 | baseConfigurationReference = 60799DCC63FBAD0197655FF4 /* Pods-FloatingToggl.release.xcconfig */; 375 | buildSettings = { 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 377 | CODE_SIGN_ENTITLEMENTS = FloatingToggl/FloatingToggl.entitlements; 378 | CODE_SIGN_IDENTITY = "Mac Developer"; 379 | CODE_SIGN_STYLE = Automatic; 380 | COMBINE_HIDPI_IMAGES = YES; 381 | DEVELOPMENT_TEAM = 7CRYNR44B3; 382 | INFOPLIST_FILE = FloatingToggl/Info.plist; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 384 | PRODUCT_BUNDLE_IDENTIFIER = com.matrix.FloatingToggl; 385 | PRODUCT_NAME = "In Time"; 386 | PROVISIONING_PROFILE_SPECIFIER = ""; 387 | SWIFT_VERSION = 4.0; 388 | }; 389 | name = Release; 390 | }; 391 | /* End XCBuildConfiguration section */ 392 | 393 | /* Begin XCConfigurationList section */ 394 | 041E2BA31F9EF0370036687C /* Build configuration list for PBXProject "FloatingToggl" */ = { 395 | isa = XCConfigurationList; 396 | buildConfigurations = ( 397 | 041E2BB61F9EF0370036687C /* Debug */, 398 | 041E2BB71F9EF0370036687C /* Release */, 399 | ); 400 | defaultConfigurationIsVisible = 0; 401 | defaultConfigurationName = Release; 402 | }; 403 | 041E2BB81F9EF0370036687C /* Build configuration list for PBXNativeTarget "FloatingToggl" */ = { 404 | isa = XCConfigurationList; 405 | buildConfigurations = ( 406 | 041E2BB91F9EF0370036687C /* Debug */, 407 | 041E2BBA1F9EF0370036687C /* Release */, 408 | ); 409 | defaultConfigurationIsVisible = 0; 410 | defaultConfigurationName = Release; 411 | }; 412 | /* End XCConfigurationList section */ 413 | }; 414 | rootObject = 041E2BA01F9EF0370036687C /* Project object */; 415 | } 416 | -------------------------------------------------------------------------------- /FloatingToggl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FloatingToggl.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /FloatingToggl.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | FloatingToggl.xcscheme 8 | 9 | orderHint 10 | 4 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FloatingToggl.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FloatingToggl/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // FloatingToggl 4 | // 5 | // Created by Zhigang Fang on 10/24/17. 6 | // Copyright © 2017 matrix. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import KeychainSwift 11 | 12 | extension UserDefaults { 13 | 14 | var reminderInterval: Int { 15 | get { return UserDefaults.standard.integer(forKey: "com.floatingtoggl.reminder") } 16 | set { UserDefaults.standard.set(newValue, forKey: "com.floatingtoggl.reminder") } 17 | } 18 | 19 | var shouldAutoApply: Bool { 20 | get { return UserDefaults.standard.bool(forKey: "com.floatingtoggl.autoapply") } 21 | set { UserDefaults.standard.set(newValue, forKey: "com.floatingtoggl.autoapply") } 22 | } 23 | 24 | } 25 | 26 | extension Notification.Name { 27 | 28 | static let reminderIntervalUpdated: Notification.Name = Notification.Name("com.floatingtoggl.reminderintervalupdated") 29 | 30 | } 31 | 32 | 33 | @NSApplicationMain 34 | class AppDelegate: NSObject, NSApplicationDelegate { 35 | 36 | var reminderInterval: Int = 0 { 37 | didSet { 38 | fiveMinuteReminder.isChecked = reminderInterval == 5 39 | fifteenMinuteReminder.isChecked = reminderInterval == 15 40 | thirtyMinuteReminder.isChecked = reminderInterval == 30 41 | noReminder.isChecked = reminderInterval == 0 42 | if reminderInterval != oldValue { 43 | UserDefaults.standard.reminderInterval = reminderInterval 44 | NotificationCenter.default.post(name: .reminderIntervalUpdated, object: nil) 45 | } 46 | } 47 | } 48 | 49 | @IBOutlet weak var fiveMinuteReminder: NSMenuItem! 50 | @IBOutlet weak var fifteenMinuteReminder: NSMenuItem! 51 | @IBOutlet weak var thirtyMinuteReminder: NSMenuItem! 52 | @IBOutlet weak var noReminder: NSMenuItem! 53 | 54 | @IBAction func reminder5minTapped(_ sender: NSMenuItem) { 55 | reminderInterval = 5 56 | } 57 | 58 | @IBAction func reminder15minTapped(_ sender: NSMenuItem) { 59 | reminderInterval = 15 60 | } 61 | 62 | @IBAction func reminder30minTapped(_ sender: NSMenuItem) { 63 | reminderInterval = 30 64 | } 65 | 66 | @IBAction func reminderNoneTapped(_ sender: NSMenuItem) { 67 | reminderInterval = 0 68 | } 69 | 70 | var shouldAutoApply: Bool = false { 71 | didSet { 72 | autoApply.isChecked = shouldAutoApply 73 | if shouldAutoApply != oldValue { 74 | UserDefaults.standard.shouldAutoApply = shouldAutoApply 75 | } 76 | } 77 | } 78 | @IBOutlet weak var autoApply: NSMenuItem! 79 | @IBAction func autoApplyTapped(_ sender: NSMenuItem) { 80 | shouldAutoApply = !shouldAutoApply 81 | } 82 | 83 | 84 | func applicationDidFinishLaunching(_ aNotification: Notification) { 85 | // Insert code here to initialize your application 86 | 87 | reminderInterval = UserDefaults.standard.reminderInterval 88 | shouldAutoApply = UserDefaults.standard.shouldAutoApply 89 | 90 | } 91 | 92 | func applicationWillTerminate(_ aNotification: Notification) { 93 | // Insert code here to tear down your application 94 | } 95 | 96 | } 97 | 98 | 99 | extension NSMenuItem { 100 | 101 | var isChecked: Bool { 102 | get { return state ~= .on } 103 | set { state = newValue ? .on : .off } 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "Icon-16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "Icon-32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "Icon-33.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "Icon-64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "Icon-128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "Icon-256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "Icon-257.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "Icon-512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "Icon-513.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "Icon-1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-1024.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-128.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-16.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-256.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-257.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-257.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-32.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-33.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-512.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-513.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-513.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/AppIcon.appiconset/Icon-64.png -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/Start.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Start.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/Start.imageset/Start.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/Start.imageset/Start.pdf -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/Stop.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Stop.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /FloatingToggl/Assets.xcassets/Stop.imageset/Stop.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhigang1992/InTime/0ff62e7df116acb95d74cca679b4ea732e573cea/FloatingToggl/Assets.xcassets/Stop.imageset/Stop.pdf -------------------------------------------------------------------------------- /FloatingToggl/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | -------------------------------------------------------------------------------- /FloatingToggl/FloatingPannel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FloatingPannel.swift 3 | // FloatingToggl 4 | // 5 | // Created by Zhigang Fang on 10/24/17. 6 | // Copyright © 2017 matrix. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import RxSwift 11 | 12 | class FloatingPannel: NSWindowController { 13 | 14 | let disposebag = DisposeBag() 15 | 16 | override func windowDidLoad() { 17 | super.windowDidLoad() 18 | guard let panel = self.window as? NSPanel else { 19 | fatalError("Not loading") 20 | } 21 | panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] 22 | panel.isFloatingPanel = true 23 | panel.titleVisibility = .hidden 24 | panel.titlebarAppearsTransparent = true 25 | 26 | } 27 | 28 | override func mouseEntered(with event: NSEvent) { 29 | super.mouseEntered(with: event) 30 | } 31 | 32 | override func mouseExited(with event: NSEvent) { 33 | super.mouseEntered(with: event) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FloatingToggl/FloatingToggl.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | com.apple.security.network.client 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /FloatingToggl/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.1.0 21 | CFBundleVersion 22 | 6 23 | LSApplicationCategoryType 24 | public.app-category.productivity 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2017 matrix. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /FloatingToggl/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // FloatingToggl 4 | // 5 | // Created by Zhigang Fang on 10/24/17. 6 | // Copyright © 2017 matrix. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Cocoa 11 | import RxSwift 12 | import RxCocoa 13 | import KeychainSwift 14 | 15 | struct TimeEntry: Decodable { 16 | let id: Int64 17 | let start: Date 18 | let description: String? 19 | } 20 | 21 | struct DataResponse: Decodable { 22 | let data: T 23 | } 24 | 25 | struct Project: Decodable { 26 | let id: Int64 27 | let name: String 28 | let at: Date 29 | } 30 | 31 | struct User: Decodable { 32 | 33 | let id: Int64 34 | let fullname: String 35 | let projects: [Project]? 36 | let time_entries: [TimeEntry]? 37 | 38 | } 39 | 40 | private extension URL { 41 | 42 | static func api(_ path: String) -> URL { 43 | return URL(string: "https://www.toggl.com/api/v8/\(path)")! 44 | } 45 | 46 | } 47 | 48 | extension JSONEncoder { 49 | 50 | static var toggle: JSONEncoder { 51 | let encoder = JSONEncoder() 52 | encoder.dateEncodingStrategy = .iso8601 53 | return encoder 54 | } 55 | 56 | } 57 | 58 | extension JSONDecoder { 59 | 60 | static var toggle: JSONDecoder { 61 | let decoder = JSONDecoder() 62 | decoder.dateDecodingStrategy = .iso8601 63 | return decoder 64 | } 65 | 66 | } 67 | 68 | extension ISO8601DateFormatter { 69 | 70 | static var toggle: ISO8601DateFormatter { 71 | let formatter = ISO8601DateFormatter() 72 | formatter.timeZone = .current 73 | return formatter 74 | } 75 | 76 | } 77 | 78 | struct Endpoint { 79 | let method: String 80 | let url: URL 81 | let body: NSDictionary? 82 | 83 | init(method: String = "GET", url: URL, body: NSDictionary? = nil) { 84 | self.method = method 85 | self.url = url 86 | self.body = body 87 | } 88 | 89 | func request(with token: String) -> Observable { 90 | return Observable.deferred({ () -> Observable in 91 | let base64 = "\(token):api_token".data(using: .utf8)!.base64EncodedString() 92 | var request = URLRequest(url: self.url) 93 | request.addValue("Basic \(base64)", forHTTPHeaderField: "Authorization") 94 | request.addValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type") 95 | request.httpMethod = self.method 96 | if let body = self.body { 97 | request.httpBody = try? JSONSerialization.data(withJSONObject: body, options: []) 98 | } 99 | return URLSession.shared.rx.data(request: request).map({ data in 100 | (try JSONDecoder.toggle.decode(DataResponse.self, from: data)).data 101 | }) 102 | }) 103 | } 104 | 105 | static var me: Endpoint { return Endpoint(url: URL.api("me?with_related_data=true")) } 106 | 107 | static var currentEntry: Endpoint> { return Endpoint>(url: URL.api("time_entries/current")) } 108 | 109 | static func start(title: String, projectId: Int64?) -> Endpoint { 110 | return Endpoint(method: "POST", url: URL.api("time_entries/start"), body: [ 111 | "time_entry": [ 112 | "description": title, 113 | "pid": projectId ?? NSNull(), 114 | "created_with": "In Time" 115 | ] as NSDictionary 116 | ]) 117 | } 118 | 119 | static func stop(timeEntry: Int64) -> Endpoint { 120 | return Endpoint(method: "PUT", url: URL.api("time_entries/\(timeEntry)/stop")) 121 | } 122 | 123 | static func create(project: String) -> Endpoint { 124 | return Endpoint.init(method: "POST", url: URL.api("projects"), body: [ 125 | "project": [ 126 | "name": project, 127 | "is_private": true 128 | ] 129 | ] as NSDictionary) 130 | } 131 | 132 | static func update(timeEntry: Int64, duration: Int) -> Endpoint { 133 | return Endpoint(method: "POST", url: URL.api("time_entries/\(timeEntry)"), body: [ 134 | "time_entry": [ 135 | "duration": duration 136 | ] 137 | ]) 138 | } 139 | 140 | } 141 | 142 | 143 | class TogglViewModel { 144 | 145 | private let keychain = KeychainSwift() 146 | 147 | let token: Variable 148 | 149 | let refresh = PublishSubject() 150 | let current = Variable(nil) 151 | let user = Variable(nil) 152 | 153 | let input = Variable("") 154 | 155 | let active = Variable(NSApplication.shared.isActive) 156 | let awake = Variable(true) 157 | 158 | private let disposeBag = DisposeBag() 159 | 160 | var screenSleptAt: Date? 161 | var timeEntryWhenSlept: TimeEntry? 162 | 163 | var completions: Driver<[String]> { 164 | return user.asDriver().map({ user -> [String] in 165 | guard let user = user else { return [] } 166 | let projects = user.projects?.sorted(by: {$0.at > $1.at}).map({"#\($0.name)"}) ?? [] 167 | let entries = user.time_entries?.sorted(by: {$0.start > $1.start}).flatMap({$0.description}) ?? [] 168 | return Array(NSOrderedSet(array: projects + entries)).flatMap({$0 as? String}) 169 | }).flatMapLatest({[weak self] (completion:[String]) -> Driver<[String]> in 170 | guard let input = self?.input else { return .just(completion) } 171 | return input.asDriver().map({ input in 172 | if input.isEmpty { return completion } 173 | let predicate = NSPredicate(format: "SELF contains[c] %@", input) 174 | return completion.filter({$0 != input && predicate.evaluate(with: $0 as NSString)}) 175 | }) 176 | }).debounce(0.2) 177 | } 178 | 179 | init() { 180 | let tokenKey = "com.floatToggl.tokenKey" 181 | token = Variable(keychain.get(tokenKey)) 182 | token.asDriver().skip(1).drive(onNext: {[weak self] t in 183 | if let t = t { 184 | self?.keychain.set(t, forKey: tokenKey) 185 | } else { 186 | self?.keychain.delete(tokenKey) 187 | } 188 | }).disposed(by: self.disposeBag) 189 | 190 | Observable.merge([ 191 | NotificationCenter.default.rx 192 | .notification(NSApplication.didBecomeActiveNotification) 193 | .map({_ in true}), 194 | NotificationCenter.default.rx 195 | .notification(NSApplication.willResignActiveNotification) 196 | .map({_ in false}) 197 | ]).bind(to: self.active).disposed(by: self.disposeBag) 198 | 199 | self.active.asDriver() 200 | .distinctUntilChanged() 201 | .filter({$0}) 202 | .map({_ in ()}) 203 | .drive(refresh) 204 | .disposed(by: self.disposeBag) 205 | 206 | token.asDriver().flatMapLatest({ token -> Driver in 207 | if let token = token { 208 | return self.refresh.asDriver(onErrorJustReturn: ()).startWith(()).flatMapLatest({_ in 209 | Endpoint.currentEntry 210 | .request(with: token) 211 | .asDriver(onErrorJustReturn: nil) 212 | }) 213 | } 214 | return Driver.just(nil) 215 | }).drive(current).disposed(by: self.disposeBag) 216 | 217 | token.asDriver().flatMapLatest({[weak self] token -> Driver in 218 | if let token = token { 219 | return self?.current.asDriver().flatMapLatest({ _ in 220 | Endpoint.me.request(with: token).map(Optional.some).asDriver(onErrorJustReturn: nil) 221 | }) ?? .just(nil) 222 | } 223 | return Driver.just(nil) 224 | }).drive(user).disposed(by: self.disposeBag) 225 | 226 | NSWorkspace.shared.notificationCenter 227 | .rx.notification(NSWorkspace.screensDidSleepNotification) 228 | .subscribe(onNext: {[weak self] _ in 229 | self?.awake.value = false 230 | guard let entry = self?.current.value else { return } 231 | self?.timeEntryWhenSlept = entry 232 | self?.screenSleptAt = Date() 233 | }).disposed(by: self.disposeBag) 234 | 235 | NSWorkspace.shared.notificationCenter 236 | .rx.notification(NSWorkspace.screensDidWakeNotification) 237 | .subscribe(onNext: {[weak self] _ in 238 | self?.awake.value = true 239 | 240 | defer { 241 | self?.screenSleptAt = nil 242 | self?.timeEntryWhenSlept = nil 243 | } 244 | 245 | guard 246 | let date = self?.screenSleptAt, 247 | let timer = self?.timeEntryWhenSlept, 248 | Date().timeIntervalSince(date) > 60 * 10 249 | else { 250 | return 251 | } 252 | 253 | self?.stopTimer(entry: timer, stoppedAt: date) 254 | }).disposed(by: self.disposeBag) 255 | 256 | } 257 | 258 | var presentReminder: Observable<()> { 259 | return Observable.merge([ 260 | self.awake.asObservable().distinctUntilChanged().map({_ in ()}), 261 | NotificationCenter.default.rx.notification(.reminderIntervalUpdated).map({_ in ()}), 262 | self.input.asObservable().distinctUntilChanged().map({_ in ()}) 263 | ]).flatMapLatest({[weak self] _ -> Observable<()> in 264 | if self?.awake.value != true { return .empty() } 265 | let interval = UserDefaults.standard.reminderInterval 266 | if interval == 0 { return .empty() } 267 | return Observable.interval(RxTimeInterval(interval * 60), scheduler: MainScheduler.asyncInstance).map({ _ in ()}) 268 | }) 269 | } 270 | 271 | func startTimer() { 272 | let inputValue = input.value 273 | if let projectName = inputValue.hashKey { 274 | if let existingProject = self.user.value?.projects?.first(where: { 275 | $0.name.lowercased() == projectName.lowercased() 276 | }) { 277 | self.startTimer(input: inputValue, projectId: existingProject.id) 278 | } else { 279 | let alert = NSAlert() 280 | alert.alertStyle = .informational 281 | alert.messageText = "Project \(projectName) does not exist, should I create it?" 282 | alert.addButton(withTitle: "Create") 283 | alert.addButton(withTitle: "Cancel") 284 | alert.beginSheetModal(for: NSApplication.shared.keyWindow!) {[weak self] (response) in 285 | guard response == .alertFirstButtonReturn else { 286 | self?.startTimer(input: inputValue, projectId: nil) 287 | return 288 | } 289 | _ = self?.createProject(name: projectName).subscribe(onNext: {[weak self] project in 290 | self?.startTimer(input: inputValue, projectId: project.id) 291 | }, onError: { _ in 292 | self?.startTimer(input: inputValue, projectId: nil) 293 | }) 294 | } 295 | } 296 | } else { 297 | self.startTimer(input: inputValue, projectId: nil) 298 | } 299 | } 300 | 301 | func createProject(name: String) -> Observable { 302 | guard let token = self.token.value else { return .empty() } 303 | return Endpoint.create(project: name).request(with: token) 304 | } 305 | 306 | func startTimer(input: String, projectId: Int64?) { 307 | guard let token = self.token.value else { return } 308 | Endpoint.start(title: self.input.value, projectId: projectId) 309 | .request(with: token) 310 | .map(Optional.some) 311 | .catchErrorJustReturn(nil) 312 | .bind(to: self.current) 313 | .disposed(by: self.disposeBag) 314 | } 315 | 316 | func stopTimer(entry: TimeEntry? = nil, stoppedAt: Date? = nil) { 317 | guard let token = self.token.value else { return } 318 | guard let entry = entry ?? self.current.value else { return } 319 | Endpoint.stop(timeEntry: entry.id).request(with: token) 320 | .flatMap({ entry -> Observable in 321 | if let stopped = stoppedAt { 322 | let duration = Int(stopped.timeIntervalSince(entry.start)) 323 | return Endpoint.update(timeEntry: entry.id, duration: duration).request(with: token) 324 | } 325 | return .just(entry) 326 | }) 327 | .map({_ in nil}) 328 | .catchErrorJustReturn(nil) 329 | .bind(to: current) 330 | .disposed(by: self.disposeBag) 331 | } 332 | 333 | } 334 | 335 | class AutoGrowTextField: NSTextField { 336 | 337 | override var intrinsicContentSize: NSSize { 338 | self.isEditable = false 339 | defer { 340 | self.isEditable = true 341 | } 342 | return super.intrinsicContentSize 343 | } 344 | 345 | } 346 | 347 | class ViewController: NSViewController { 348 | 349 | let viewModel = TogglViewModel() 350 | 351 | fileprivate let disposeBag = DisposeBag() 352 | 353 | @IBOutlet weak var inputLabel: NSTextField! 354 | 355 | @IBOutlet weak var timerLabel: NSTextField! 356 | 357 | @IBOutlet weak var actionButton: NSButton! 358 | 359 | lazy var tableView: NSTableView = { 360 | let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("text")) 361 | column.isEditable = false 362 | column.width = 500 363 | let tableView = NSTableView() 364 | tableView.backgroundColor = .clear 365 | tableView.selectionHighlightStyle = .regular 366 | tableView.rowSizeStyle = .small 367 | tableView.intercellSpacing = NSSize(width: 20, height: 3) 368 | tableView.headerView = nil 369 | tableView.refusesFirstResponder = true 370 | tableView.target = self 371 | tableView.addTableColumn(column) 372 | tableView.doubleAction = #selector(self.insertSelection) 373 | tableView.dataSource = self 374 | tableView.delegate = self 375 | return tableView 376 | }() 377 | 378 | lazy var recentItemVC: NSPopover = { 379 | let sv = NSScrollView() 380 | sv.drawsBackground = false 381 | sv.hasVerticalScroller = true 382 | sv.documentView = self.tableView 383 | 384 | let vc = NSViewController() 385 | vc.view = NSView() 386 | vc.view.addSubview(sv) 387 | sv.translatesAutoresizingMaskIntoConstraints = false 388 | NSLayoutConstraint.activate([ 389 | sv.topAnchor.constraint(equalTo: vc.view.topAnchor), 390 | sv.leadingAnchor.constraint(equalTo: vc.view.leadingAnchor), 391 | sv.trailingAnchor.constraint(equalTo: vc.view.trailingAnchor), 392 | sv.bottomAnchor.constraint(equalTo: vc.view.bottomAnchor), 393 | ]) 394 | 395 | let po = NSPopover() 396 | po.appearance = NSAppearance(named: .vibrantLight) 397 | po.animates = false 398 | po.contentViewController = vc 399 | return po 400 | }() 401 | 402 | var recentItems: [String] = [] { 403 | didSet { 404 | self.tableView.reloadData() 405 | let numberOfRows = min(recentItems.count, 8) 406 | let size = CGSize( 407 | width: self.view.bounds.width, 408 | height: CGFloat(numberOfRows) * (self.tableView.rowHeight + self.tableView.intercellSpacing.height) 409 | ) 410 | self.recentItemVC.contentSize = size 411 | if inputLabel.stringValue.isEmpty { return } 412 | self.isShowingRecentEntries = !recentItems.isEmpty 413 | } 414 | } 415 | 416 | override func viewDidLoad() { 417 | super.viewDidLoad() 418 | self.timerLabel.isHidden = true 419 | self.actionButton.isHidden = true 420 | setupUI() 421 | 422 | viewModel.completions.drive(onNext: {[weak self] completions in 423 | guard let `self` = self else { return } 424 | self.recentItems = completions 425 | self.selectedRow = 0 426 | }).disposed(by: self.disposeBag) 427 | 428 | viewModel.current.asDriver().flatMapLatest({ entry -> Driver in 429 | guard let date = entry?.start else { return .empty() } 430 | return Driver.interval(1).startWith(1).map({ _ in 431 | let time: Int = Int(Date().timeIntervalSince(date)) 432 | let hours = time / 3600 433 | let minutes = (time / 60) % 60 434 | let seconds = time % 60 435 | return String(format: "%0.2d:%0.2d:%0.2d", hours, minutes, seconds) 436 | }) 437 | }).drive(onNext: {[weak self] text in 438 | self?.timerLabel.stringValue = text 439 | }).disposed(by: self.disposeBag) 440 | 441 | viewModel.current.asDriver().drive(onNext: {[weak self] current in 442 | self?.timerLabel.isHidden = current == nil 443 | self?.actionButton.isHidden = current == nil 444 | if let current = current { 445 | let text = current.description ?? "Untitled" 446 | self?.inputLabel.stringValue = text 447 | self?.viewModel.input.value = text 448 | self?.isShowingRecentEntries = false 449 | self?.inputLabel.window?.makeFirstResponder(nil) 450 | } else { 451 | self?.inputLabel.stringValue = "" 452 | self?.viewModel.input.value = "" 453 | } 454 | self?.placeCursorAtTheEnd() 455 | self?.resizeWindow() 456 | }).disposed(by: self.disposeBag) 457 | 458 | viewModel.presentReminder.subscribe(onNext: {[weak self] in 459 | self?.presentReminder() 460 | }).disposed(by: disposeBag) 461 | } 462 | 463 | var trackingRect: NSView.TrackingRectTag? 464 | override func viewDidLayout() { 465 | super.viewDidLayout() 466 | if let t = trackingRect { 467 | view.removeTrackingRect(t) 468 | } 469 | trackingRect = view.addTrackingRect(view.bounds, owner: self, userData: nil, assumeInside: false) 470 | } 471 | 472 | override func viewDidAppear() { 473 | super.viewDidAppear() 474 | if viewModel.token.value == nil { 475 | self.presentSetToken() 476 | } 477 | } 478 | 479 | var isShowingRecentEntries: Bool { 480 | get { 481 | return recentItemVC.isShown 482 | } 483 | set { 484 | guard newValue != isShowingRecentEntries else { return } 485 | 486 | if newValue { 487 | guard !recentItems.isEmpty else { return } 488 | guard inputLabel.currentEditor()?.selectedRange.length == 0 else { return } 489 | 490 | recentItemVC.show(relativeTo: .zero, of: self.view, preferredEdge: .minY) 491 | } else { 492 | recentItemVC.close() 493 | } 494 | } 495 | } 496 | 497 | func resizeWindow() { 498 | guard let window = self.view.window else { return } 499 | let minSize = self.view.fittingSize 500 | window.setFrame(NSRect(origin: window.frame.origin, size: minSize), display: true) 501 | } 502 | 503 | 504 | @IBAction func presentRecentEntries(_ sender: NSMenuItem) { 505 | self.isShowingRecentEntries = !self.isShowingRecentEntries 506 | } 507 | 508 | @IBAction func stopTimer(_ sender: NSButton) { 509 | self.viewModel.stopTimer() 510 | } 511 | 512 | func placeCursorAtTheEnd() { 513 | guard let editor = self.inputLabel.currentEditor() else { return } 514 | 515 | let string = self.inputLabel.stringValue as NSString 516 | editor.selectedRange = NSRange(location: string.length, length: 0) 517 | } 518 | 519 | func presentSetToken() { 520 | let alert = NSAlert() 521 | alert.alertStyle = .informational 522 | alert.messageText = "Toggl API Token:\nhttps://toggl.com/app/profile" 523 | 524 | let tokenField = NSTextField() 525 | tokenField.frame = NSRect(x: 0, y: 0, width: 300, height: 20) 526 | tokenField.usesSingleLineMode = true 527 | 528 | alert.accessoryView = tokenField 529 | alert.addButton(withTitle: "Set") 530 | alert.addButton(withTitle: "Cancel") 531 | alert.beginSheetModal(for: NSApplication.shared.keyWindow!) {[weak self] (response) in 532 | guard response == .alertFirstButtonReturn else { return } 533 | self?.viewModel.token.value = tokenField.stringValue 534 | } 535 | tokenField.becomeFirstResponder() 536 | } 537 | 538 | func presentDontForget() { 539 | let alert = NSAlert() 540 | alert.alertStyle = .informational 541 | alert.messageText = "Don't forget to track your time" 542 | alert.beginSheetModal(for: self.view.window!, completionHandler: nil) 543 | alert.window.resignKey() 544 | } 545 | 546 | func presentReminder() { 547 | guard let current = viewModel.current.value else { 548 | presentDontForget() 549 | return 550 | } 551 | let alert = NSAlert() 552 | alert.alertStyle = .informational 553 | alert.messageText = "Are you still working on \n \(current.description ?? "Untitled")" 554 | let button = alert.addButton(withTitle: "YES") 555 | 556 | var disposable: Disposable? 557 | 558 | if UserDefaults.standard.shouldAutoApply { 559 | let autoApplyInterval = 60 560 | disposable = Observable.interval(1, scheduler: MainScheduler.asyncInstance) 561 | .map({autoApplyInterval - $0}) 562 | .subscribe(onNext: {[weak self] countdown in 563 | if countdown > 0 { 564 | button.title = "YES (\(countdown))" 565 | } else if countdown == 0 { 566 | self?.view.window?.endSheet(alert.window) 567 | } 568 | }) 569 | 570 | button.title = "YES (\(autoApplyInterval))" 571 | } 572 | 573 | alert.addButton(withTitle: "No") 574 | alert.beginSheetModal(for: self.view.window!) { (response) in 575 | disposable?.dispose() 576 | if response == .alertSecondButtonReturn { 577 | self.viewModel.stopTimer() 578 | self.inputLabel.becomeFirstResponder() 579 | } 580 | } 581 | alert.window.resignKey() 582 | } 583 | 584 | @IBAction func setToken(_ sender: NSMenuItem) { 585 | presentSetToken() 586 | } 587 | 588 | 589 | override var representedObject: Any? { 590 | didSet { 591 | // Update the view, if already loaded. 592 | } 593 | } 594 | 595 | var selectedRow: Int { 596 | get { 597 | return tableView.selectedRow 598 | } 599 | set { 600 | let index: Int 601 | if tableView.numberOfRows == 0 { return } 602 | if newValue < 0 { 603 | index = tableView.numberOfRows - 1 604 | } else if newValue >= tableView.numberOfRows { 605 | index = 0 606 | } else { 607 | index = newValue 608 | } 609 | tableView.selectRowIndexes(IndexSet(integer: index), byExtendingSelection: false) 610 | tableView.scrollRowToVisible(index) 611 | } 612 | } 613 | 614 | } 615 | 616 | extension ViewController: NSTextFieldDelegate { 617 | 618 | @objc func insertSelection() { 619 | guard isShowingRecentEntries else { return } 620 | 621 | inputLabel.stringValue = recentItems[self.selectedRow] 622 | viewModel.input.value = recentItems[self.selectedRow] 623 | isShowingRecentEntries = false 624 | self.placeCursorAtTheEnd() 625 | } 626 | 627 | func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { 628 | switch commandSelector { 629 | case #selector(textView.cancelOperation(_:)): 630 | isShowingRecentEntries = !isShowingRecentEntries 631 | case #selector(textView.moveUp(_:)), #selector(textView.insertBacktab(_:)): 632 | selectedRow = selectedRow - 1 633 | isShowingRecentEntries = true 634 | case #selector(textView.moveDown(_:)): 635 | selectedRow = selectedRow + 1 636 | isShowingRecentEntries = true 637 | case #selector(textView.insertTab(_:)): 638 | insertSelection() 639 | case #selector(textView.insertNewline(_:)): 640 | if isShowingRecentEntries { 641 | insertSelection() 642 | } else { 643 | self.viewModel.startTimer() 644 | } 645 | default: 646 | return false 647 | } 648 | return true 649 | } 650 | 651 | override func controlTextDidChange(_ obj: Notification) { 652 | self.viewModel.input.value = inputLabel.stringValue 653 | } 654 | } 655 | 656 | extension ViewController: NSTableViewDelegate, NSTableViewDataSource { 657 | 658 | func numberOfRows(in tableView: NSTableView) -> Int { 659 | return recentItems.count 660 | } 661 | 662 | private static let identity = NSUserInterfaceItemIdentifier(rawValue: "Cell") 663 | 664 | func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { 665 | let cellView: NSTableCellView = tableView.makeView(withIdentifier: ViewController.identity, owner: self) as? NSTableCellView ?? { 666 | let cell = NSTableCellView() 667 | let textField = NSTextField() 668 | textField.isBezeled = false 669 | textField.drawsBackground = false 670 | textField.isEditable = false 671 | textField.isSelectable = false 672 | textField.usesSingleLineMode = true 673 | cell.addSubview(textField) 674 | cell.textField = textField 675 | cell.identifier = ViewController.identity 676 | return cell 677 | }() 678 | cellView.textField?.attributedStringValue = NSAttributedString( 679 | string: self.recentItems[row], 680 | attributes: [ 681 | NSAttributedStringKey.foregroundColor: NSColor.black 682 | ]) 683 | return cellView 684 | } 685 | 686 | func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? { 687 | return HighlightRow() 688 | } 689 | } 690 | 691 | class HighlightRow: NSTableRowView { 692 | 693 | override func drawSelection(in dirtyRect: NSRect) { 694 | if self.selectionHighlightStyle != .none { 695 | let c = NSColor.selectedMenuItemColor 696 | c.setFill() 697 | self.bounds.fill() 698 | } 699 | } 700 | 701 | override var interiorBackgroundStyle: NSView.BackgroundStyle { 702 | return isSelected ? .dark : .light 703 | } 704 | 705 | } 706 | 707 | private extension ViewController { 708 | 709 | func setupUI() { 710 | inputLabel.focusRingType = .none 711 | inputLabel.placeholderAttributedString = NSAttributedString( 712 | string: inputLabel.placeholderString ?? "", 713 | attributes: [ 714 | .foregroundColor: NSColor(white: 1, alpha: 0.4), 715 | .font: NSFont.systemFont(ofSize: 15) 716 | ]) 717 | } 718 | 719 | } 720 | 721 | private extension String { 722 | 723 | var hashKey: String? { 724 | do { 725 | let regex = try NSRegularExpression(pattern: "#([^ ]+)( |$)", options: []) 726 | let ns = (self as NSString) 727 | return regex.matches(in: self, options: [], range: NSRange(location: 0, length: ns.length)) 728 | .first 729 | .flatMap({ result in 730 | guard result.numberOfRanges > 1 else { return nil } 731 | return ns.substring(with: result.range(at: 1)) 732 | }) 733 | } catch { 734 | return nil 735 | } 736 | } 737 | 738 | } 739 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'FloatingToggl' do 5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for FloatingToggl 9 | pod 'RxSwift' 10 | pod 'RxCocoa' 11 | pod 'KeychainSwift' 12 | 13 | end 14 | 15 | 16 | post_install do |installer| 17 | installer.pods_project.targets.each do |target| 18 | target.build_configurations.each do |config| 19 | config.build_settings['SWIFT_VERSION'] = '3.2' 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - KeychainSwift (8.0.2) 3 | - RxCocoa (3.6.1): 4 | - RxSwift (~> 3.6) 5 | - RxSwift (3.6.1) 6 | 7 | DEPENDENCIES: 8 | - KeychainSwift 9 | - RxCocoa 10 | - RxSwift 11 | 12 | SPEC CHECKSUMS: 13 | KeychainSwift: 213db04dfe7244988e61f77c72a2afb2f775954a 14 | RxCocoa: 84a08739ab186248c7f31ce4ee92d6f8a947d690 15 | RxSwift: f9de85ea20cd2f7716ee5409fc13523dc638e4e4 16 | 17 | PODFILE CHECKSUM: 2ff1ecfdbeb49f2b0872a44c758fc852e39c2197 18 | 19 | COCOAPODS: 1.3.1 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Toggl Bar 2 | 3 | --------- 4 | 5 | 6 | A Toggl Bar Mac app that will follow you wherever you go. 7 | 8 | First you need to obtain your API token from: 9 | 10 | https://www.toggl.com/app/profile 11 | 12 | Download this app from https://github.com/zhigang1992/InTime/releases/tag/1.0.0 13 | 14 | And you're all set. 15 | 16 | 17 | ### Features 18 | 19 | 1. Using `#project` syntax to add task to a project. 20 | 1. Auto complete using your projects and recent entries. 21 | 1. Automatically stop timer when screen goes to sleep. 22 | 1. Automatically resume timer when screen goes back on within 10 min. 23 | 1. ... 24 | 25 | ![Screen Shot 2017-10-26 at 5.23.39 PM.png](https://i.loli.net/2017/10/26/59f1a9c4ad8d7.png) 26 | ![Screen Shot 2017-10-26 at 5.23.27 PM.png](https://i.loli.net/2017/10/26/59f1a9c4cbe11.png) 27 | --------------------------------------------------------------------------------