├── .gitignore ├── LICENSE.md ├── README.md ├── images ├── screenshot_list.PNG └── screenshot_map.PNG ├── walktracker.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── walktracker ├── AnimatedStartButton.swift ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── add_button.imageset │ │ ├── Contents.json │ │ └── add_button.pdf │ └── add_button_no_shadow.imageset │ │ ├── Contents.json │ │ └── add_button_no_shadow.pdf ├── Info.plist ├── MapViewController.swift ├── Walk.swift ├── WalkStore.swift ├── WalksViewController.swift └── walktracker.xcdatamodeld │ └── walktracker.xcdatamodel │ └── contents └── walktrackerTests ├── Info.plist └── walktrackerTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Kevin VanderLugt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift-Walk-Tracker 2 | An open source walk tracking iOS App written in Swift 3 | 4 | ## About 5 | The walk tracking application was intended to be incredibly simplistic. While visiting Seville we wanted to track all our walks around the various amazing streets. This project was created to help learn a full application in Swift while also accomplishing a simple walking tracker. 6 | 7 | ## Features 8 | There are really only two major features, track current walks using the GPS and review previous walks. This project was intended to be a small scope of features done really well. 9 | 10 | ![Walk Tracker Map](images/screenshot_map.PNG) 11 | ![Walk Tracker List](images/screenshot_list.PNG) 12 | 13 | 14 | ## Want to help? 15 | I am definitely interested in seeing what other people would be interested in adding. Send over any questions or pull requests! I would also love to work with an app designer to create an icon and loading screen. 16 | -------------------------------------------------------------------------------- /images/screenshot_list.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinvanderlugt/Swift-Walk-Tracker/825d5f56111c27b18b704fbf78633a4206ce9cd1/images/screenshot_list.PNG -------------------------------------------------------------------------------- /images/screenshot_map.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinvanderlugt/Swift-Walk-Tracker/825d5f56111c27b18b704fbf78633a4206ce9cd1/images/screenshot_map.PNG -------------------------------------------------------------------------------- /walktracker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 923489B81A600007002C0B33 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 923489B71A600007002C0B33 /* MapKit.framework */; }; 11 | 923489BB1A606EB3002C0B33 /* walktracker.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 923489B91A606EB3002C0B33 /* walktracker.xcdatamodeld */; }; 12 | 9264BE4D1A60759F0039824A /* Walk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264BE4C1A60759F0039824A /* Walk.swift */; }; 13 | 9264BE821A6164580039824A /* WalkStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264BE811A6164580039824A /* WalkStore.swift */; }; 14 | 9264BEB61A6550350039824A /* AnimatedStartButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264BEB51A6550350039824A /* AnimatedStartButton.swift */; }; 15 | 92C338AF1A5FF18200DA1532 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92C338AE1A5FF18200DA1532 /* AppDelegate.swift */; }; 16 | 92C338B11A5FF18200DA1532 /* MapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92C338B01A5FF18200DA1532 /* MapViewController.swift */; }; 17 | 92C338B61A5FF18200DA1532 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 92C338B41A5FF18200DA1532 /* Main.storyboard */; }; 18 | 92C338B81A5FF18200DA1532 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92C338B71A5FF18200DA1532 /* Images.xcassets */; }; 19 | 92C338BB1A5FF18200DA1532 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 92C338B91A5FF18200DA1532 /* LaunchScreen.xib */; }; 20 | 92C338C71A5FF18200DA1532 /* walktrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92C338C61A5FF18200DA1532 /* walktrackerTests.swift */; }; 21 | 92EE08391A72891E00D3313B /* WalksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92EE08381A72891E00D3313B /* WalksViewController.swift */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 92C338C11A5FF18200DA1532 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 92C338A11A5FF18200DA1532 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 92C338A81A5FF18200DA1532; 30 | remoteInfo = walktracker; 31 | }; 32 | /* End PBXContainerItemProxy section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | 923489B71A600007002C0B33 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; 36 | 923489BA1A606EB3002C0B33 /* walktracker.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = walktracker.xcdatamodel; sourceTree = ""; }; 37 | 9264BE4C1A60759F0039824A /* Walk.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Walk.swift; sourceTree = ""; }; 38 | 9264BE811A6164580039824A /* WalkStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalkStore.swift; sourceTree = ""; }; 39 | 9264BEB51A6550350039824A /* AnimatedStartButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedStartButton.swift; sourceTree = ""; }; 40 | 92C338A91A5FF18200DA1532 /* walktracker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = walktracker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 92C338AD1A5FF18200DA1532 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 92C338AE1A5FF18200DA1532 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 43 | 92C338B01A5FF18200DA1532 /* MapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewController.swift; sourceTree = ""; }; 44 | 92C338B51A5FF18200DA1532 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 92C338B71A5FF18200DA1532 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 46 | 92C338BA1A5FF18200DA1532 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 47 | 92C338C01A5FF18200DA1532 /* walktrackerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = walktrackerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 92C338C51A5FF18200DA1532 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 92C338C61A5FF18200DA1532 /* walktrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = walktrackerTests.swift; sourceTree = ""; }; 50 | 92EE08381A72891E00D3313B /* WalksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalksViewController.swift; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 92C338A61A5FF18200DA1532 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 923489B81A600007002C0B33 /* MapKit.framework in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | 92C338BD1A5FF18200DA1532 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 92C338A01A5FF18200DA1532 = { 73 | isa = PBXGroup; 74 | children = ( 75 | 923489B71A600007002C0B33 /* MapKit.framework */, 76 | 92C338AB1A5FF18200DA1532 /* walktracker */, 77 | 92C338C31A5FF18200DA1532 /* walktrackerTests */, 78 | 92C338AA1A5FF18200DA1532 /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | 92C338AA1A5FF18200DA1532 /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 92C338A91A5FF18200DA1532 /* walktracker.app */, 86 | 92C338C01A5FF18200DA1532 /* walktrackerTests.xctest */, 87 | ); 88 | name = Products; 89 | sourceTree = ""; 90 | }; 91 | 92C338AB1A5FF18200DA1532 /* walktracker */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 92C338AE1A5FF18200DA1532 /* AppDelegate.swift */, 95 | 92C338B01A5FF18200DA1532 /* MapViewController.swift */, 96 | 92EE08381A72891E00D3313B /* WalksViewController.swift */, 97 | 9264BE811A6164580039824A /* WalkStore.swift */, 98 | 9264BE4C1A60759F0039824A /* Walk.swift */, 99 | 92C338B41A5FF18200DA1532 /* Main.storyboard */, 100 | 92C338B71A5FF18200DA1532 /* Images.xcassets */, 101 | 923489B91A606EB3002C0B33 /* walktracker.xcdatamodeld */, 102 | 92C338B91A5FF18200DA1532 /* LaunchScreen.xib */, 103 | 92C338AC1A5FF18200DA1532 /* Supporting Files */, 104 | 9264BEB51A6550350039824A /* AnimatedStartButton.swift */, 105 | ); 106 | path = walktracker; 107 | sourceTree = ""; 108 | }; 109 | 92C338AC1A5FF18200DA1532 /* Supporting Files */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 92C338AD1A5FF18200DA1532 /* Info.plist */, 113 | ); 114 | name = "Supporting Files"; 115 | sourceTree = ""; 116 | }; 117 | 92C338C31A5FF18200DA1532 /* walktrackerTests */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 92C338C61A5FF18200DA1532 /* walktrackerTests.swift */, 121 | 92C338C41A5FF18200DA1532 /* Supporting Files */, 122 | ); 123 | path = walktrackerTests; 124 | sourceTree = ""; 125 | }; 126 | 92C338C41A5FF18200DA1532 /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 92C338C51A5FF18200DA1532 /* Info.plist */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | 92C338A81A5FF18200DA1532 /* walktracker */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = 92C338CA1A5FF18200DA1532 /* Build configuration list for PBXNativeTarget "walktracker" */; 140 | buildPhases = ( 141 | 92C338A51A5FF18200DA1532 /* Sources */, 142 | 92C338A61A5FF18200DA1532 /* Frameworks */, 143 | 92C338A71A5FF18200DA1532 /* Resources */, 144 | ); 145 | buildRules = ( 146 | ); 147 | dependencies = ( 148 | ); 149 | name = walktracker; 150 | productName = walktracker; 151 | productReference = 92C338A91A5FF18200DA1532 /* walktracker.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | 92C338BF1A5FF18200DA1532 /* walktrackerTests */ = { 155 | isa = PBXNativeTarget; 156 | buildConfigurationList = 92C338CD1A5FF18200DA1532 /* Build configuration list for PBXNativeTarget "walktrackerTests" */; 157 | buildPhases = ( 158 | 92C338BC1A5FF18200DA1532 /* Sources */, 159 | 92C338BD1A5FF18200DA1532 /* Frameworks */, 160 | 92C338BE1A5FF18200DA1532 /* Resources */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | 92C338C21A5FF18200DA1532 /* PBXTargetDependency */, 166 | ); 167 | name = walktrackerTests; 168 | productName = walktrackerTests; 169 | productReference = 92C338C01A5FF18200DA1532 /* walktrackerTests.xctest */; 170 | productType = "com.apple.product-type.bundle.unit-test"; 171 | }; 172 | /* End PBXNativeTarget section */ 173 | 174 | /* Begin PBXProject section */ 175 | 92C338A11A5FF18200DA1532 /* Project object */ = { 176 | isa = PBXProject; 177 | attributes = { 178 | LastUpgradeCheck = 0610; 179 | ORGANIZATIONNAME = "Alpine Pipeline"; 180 | TargetAttributes = { 181 | 92C338A81A5FF18200DA1532 = { 182 | CreatedOnToolsVersion = 6.1.1; 183 | SystemCapabilities = { 184 | com.apple.Maps.iOS = { 185 | enabled = 1; 186 | }; 187 | }; 188 | }; 189 | 92C338BF1A5FF18200DA1532 = { 190 | CreatedOnToolsVersion = 6.1.1; 191 | TestTargetID = 92C338A81A5FF18200DA1532; 192 | }; 193 | }; 194 | }; 195 | buildConfigurationList = 92C338A41A5FF18200DA1532 /* Build configuration list for PBXProject "walktracker" */; 196 | compatibilityVersion = "Xcode 3.2"; 197 | developmentRegion = English; 198 | hasScannedForEncodings = 0; 199 | knownRegions = ( 200 | en, 201 | Base, 202 | ); 203 | mainGroup = 92C338A01A5FF18200DA1532; 204 | productRefGroup = 92C338AA1A5FF18200DA1532 /* Products */; 205 | projectDirPath = ""; 206 | projectRoot = ""; 207 | targets = ( 208 | 92C338A81A5FF18200DA1532 /* walktracker */, 209 | 92C338BF1A5FF18200DA1532 /* walktrackerTests */, 210 | ); 211 | }; 212 | /* End PBXProject section */ 213 | 214 | /* Begin PBXResourcesBuildPhase section */ 215 | 92C338A71A5FF18200DA1532 /* Resources */ = { 216 | isa = PBXResourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | 92C338B61A5FF18200DA1532 /* Main.storyboard in Resources */, 220 | 92C338BB1A5FF18200DA1532 /* LaunchScreen.xib in Resources */, 221 | 92C338B81A5FF18200DA1532 /* Images.xcassets in Resources */, 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | 92C338BE1A5FF18200DA1532 /* Resources */ = { 226 | isa = PBXResourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXResourcesBuildPhase section */ 233 | 234 | /* Begin PBXSourcesBuildPhase section */ 235 | 92C338A51A5FF18200DA1532 /* Sources */ = { 236 | isa = PBXSourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | 9264BE4D1A60759F0039824A /* Walk.swift in Sources */, 240 | 92C338AF1A5FF18200DA1532 /* AppDelegate.swift in Sources */, 241 | 92C338B11A5FF18200DA1532 /* MapViewController.swift in Sources */, 242 | 9264BEB61A6550350039824A /* AnimatedStartButton.swift in Sources */, 243 | 923489BB1A606EB3002C0B33 /* walktracker.xcdatamodeld in Sources */, 244 | 9264BE821A6164580039824A /* WalkStore.swift in Sources */, 245 | 92EE08391A72891E00D3313B /* WalksViewController.swift in Sources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | 92C338BC1A5FF18200DA1532 /* Sources */ = { 250 | isa = PBXSourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 92C338C71A5FF18200DA1532 /* walktrackerTests.swift in Sources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | /* End PBXSourcesBuildPhase section */ 258 | 259 | /* Begin PBXTargetDependency section */ 260 | 92C338C21A5FF18200DA1532 /* PBXTargetDependency */ = { 261 | isa = PBXTargetDependency; 262 | target = 92C338A81A5FF18200DA1532 /* walktracker */; 263 | targetProxy = 92C338C11A5FF18200DA1532 /* PBXContainerItemProxy */; 264 | }; 265 | /* End PBXTargetDependency section */ 266 | 267 | /* Begin PBXVariantGroup section */ 268 | 92C338B41A5FF18200DA1532 /* Main.storyboard */ = { 269 | isa = PBXVariantGroup; 270 | children = ( 271 | 92C338B51A5FF18200DA1532 /* Base */, 272 | ); 273 | name = Main.storyboard; 274 | sourceTree = ""; 275 | }; 276 | 92C338B91A5FF18200DA1532 /* LaunchScreen.xib */ = { 277 | isa = PBXVariantGroup; 278 | children = ( 279 | 92C338BA1A5FF18200DA1532 /* Base */, 280 | ); 281 | name = LaunchScreen.xib; 282 | sourceTree = ""; 283 | }; 284 | /* End PBXVariantGroup section */ 285 | 286 | /* Begin XCBuildConfiguration section */ 287 | 92C338C81A5FF18200DA1532 /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ALWAYS_SEARCH_USER_PATHS = NO; 291 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 292 | CLANG_CXX_LIBRARY = "libc++"; 293 | CLANG_ENABLE_MODULES = YES; 294 | CLANG_ENABLE_OBJC_ARC = YES; 295 | CLANG_WARN_BOOL_CONVERSION = YES; 296 | CLANG_WARN_CONSTANT_CONVERSION = YES; 297 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 298 | CLANG_WARN_EMPTY_BODY = YES; 299 | CLANG_WARN_ENUM_CONVERSION = YES; 300 | CLANG_WARN_INT_CONVERSION = YES; 301 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 302 | CLANG_WARN_UNREACHABLE_CODE = YES; 303 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 304 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 305 | COPY_PHASE_STRIP = NO; 306 | ENABLE_STRICT_OBJC_MSGSEND = YES; 307 | GCC_C_LANGUAGE_STANDARD = gnu99; 308 | GCC_DYNAMIC_NO_PIC = NO; 309 | GCC_OPTIMIZATION_LEVEL = 0; 310 | GCC_PREPROCESSOR_DEFINITIONS = ( 311 | "DEBUG=1", 312 | "$(inherited)", 313 | ); 314 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 315 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 316 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 317 | GCC_WARN_UNDECLARED_SELECTOR = YES; 318 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 319 | GCC_WARN_UNUSED_FUNCTION = YES; 320 | GCC_WARN_UNUSED_VARIABLE = YES; 321 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 322 | MTL_ENABLE_DEBUG_INFO = YES; 323 | ONLY_ACTIVE_ARCH = YES; 324 | SDKROOT = iphoneos; 325 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 326 | TARGETED_DEVICE_FAMILY = "1,2"; 327 | }; 328 | name = Debug; 329 | }; 330 | 92C338C91A5FF18200DA1532 /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 335 | CLANG_CXX_LIBRARY = "libc++"; 336 | CLANG_ENABLE_MODULES = YES; 337 | CLANG_ENABLE_OBJC_ARC = YES; 338 | CLANG_WARN_BOOL_CONVERSION = YES; 339 | CLANG_WARN_CONSTANT_CONVERSION = YES; 340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 341 | CLANG_WARN_EMPTY_BODY = YES; 342 | CLANG_WARN_ENUM_CONVERSION = YES; 343 | CLANG_WARN_INT_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = YES; 349 | ENABLE_NS_ASSERTIONS = NO; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu99; 352 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 353 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 354 | GCC_WARN_UNDECLARED_SELECTOR = YES; 355 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 356 | GCC_WARN_UNUSED_FUNCTION = YES; 357 | GCC_WARN_UNUSED_VARIABLE = YES; 358 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 359 | MTL_ENABLE_DEBUG_INFO = NO; 360 | SDKROOT = iphoneos; 361 | TARGETED_DEVICE_FAMILY = "1,2"; 362 | VALIDATE_PRODUCT = YES; 363 | }; 364 | name = Release; 365 | }; 366 | 92C338CB1A5FF18200DA1532 /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 370 | CODE_SIGN_IDENTITY = "iPhone Developer"; 371 | INFOPLIST_FILE = walktracker/Info.plist; 372 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 373 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 374 | PRODUCT_NAME = "$(TARGET_NAME)"; 375 | }; 376 | name = Debug; 377 | }; 378 | 92C338CC1A5FF18200DA1532 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 382 | CODE_SIGN_IDENTITY = "iPhone Developer"; 383 | INFOPLIST_FILE = walktracker/Info.plist; 384 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | }; 388 | name = Release; 389 | }; 390 | 92C338CE1A5FF18200DA1532 /* Debug */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | BUNDLE_LOADER = "$(TEST_HOST)"; 394 | FRAMEWORK_SEARCH_PATHS = ( 395 | "$(SDKROOT)/Developer/Library/Frameworks", 396 | "$(inherited)", 397 | ); 398 | GCC_PREPROCESSOR_DEFINITIONS = ( 399 | "DEBUG=1", 400 | "$(inherited)", 401 | ); 402 | INFOPLIST_FILE = walktrackerTests/Info.plist; 403 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 404 | PRODUCT_NAME = "$(TARGET_NAME)"; 405 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/walktracker.app/walktracker"; 406 | }; 407 | name = Debug; 408 | }; 409 | 92C338CF1A5FF18200DA1532 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | BUNDLE_LOADER = "$(TEST_HOST)"; 413 | FRAMEWORK_SEARCH_PATHS = ( 414 | "$(SDKROOT)/Developer/Library/Frameworks", 415 | "$(inherited)", 416 | ); 417 | INFOPLIST_FILE = walktrackerTests/Info.plist; 418 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/walktracker.app/walktracker"; 421 | }; 422 | name = Release; 423 | }; 424 | /* End XCBuildConfiguration section */ 425 | 426 | /* Begin XCConfigurationList section */ 427 | 92C338A41A5FF18200DA1532 /* Build configuration list for PBXProject "walktracker" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 92C338C81A5FF18200DA1532 /* Debug */, 431 | 92C338C91A5FF18200DA1532 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 92C338CA1A5FF18200DA1532 /* Build configuration list for PBXNativeTarget "walktracker" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 92C338CB1A5FF18200DA1532 /* Debug */, 440 | 92C338CC1A5FF18200DA1532 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | 92C338CD1A5FF18200DA1532 /* Build configuration list for PBXNativeTarget "walktrackerTests" */ = { 446 | isa = XCConfigurationList; 447 | buildConfigurations = ( 448 | 92C338CE1A5FF18200DA1532 /* Debug */, 449 | 92C338CF1A5FF18200DA1532 /* Release */, 450 | ); 451 | defaultConfigurationIsVisible = 0; 452 | defaultConfigurationName = Release; 453 | }; 454 | /* End XCConfigurationList section */ 455 | 456 | /* Begin XCVersionGroup section */ 457 | 923489B91A606EB3002C0B33 /* walktracker.xcdatamodeld */ = { 458 | isa = XCVersionGroup; 459 | children = ( 460 | 923489BA1A606EB3002C0B33 /* walktracker.xcdatamodel */, 461 | ); 462 | currentVersion = 923489BA1A606EB3002C0B33 /* walktracker.xcdatamodel */; 463 | path = walktracker.xcdatamodeld; 464 | sourceTree = ""; 465 | versionGroupType = wrapper.xcdatamodel; 466 | }; 467 | /* End XCVersionGroup section */ 468 | }; 469 | rootObject = 92C338A11A5FF18200DA1532 /* Project object */; 470 | } 471 | -------------------------------------------------------------------------------- /walktracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /walktracker/AnimatedStartButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatedStartButton.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/13/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import CoreGraphics 10 | import QuartzCore 11 | import UIKit 12 | 13 | class AnimatedStartButton : UIButton { 14 | 15 | // The horizontal disantce between the two lines in pause mode 16 | let pauseSpace: CGFloat = 10.0 17 | 18 | // This is due to the graphic being larger from the drop shadows 19 | let shadowPadding: CGFloat = 8.0 20 | 21 | let linePath: CGPath = { 22 | let path = CGPathCreateMutable() 23 | CGPathMoveToPoint(path, nil, 0, 0) 24 | CGPathAddLineToPoint(path, nil, 0, 12) 25 | 26 | return path 27 | }() 28 | 29 | let bottomTransform = CATransform3DRotate(CATransform3DMakeTranslation(0, 2, 0), CGFloat(M_PI/4), 0, 0, 1) 30 | let topTransform = CATransform3DRotate(CATransform3DMakeTranslation(-10, -2, 0), CGFloat(-M_PI/4), 0, 0, 1) 31 | 32 | override var selected: Bool { 33 | didSet { 34 | addTransforms() 35 | } 36 | } 37 | 38 | var top: CAShapeLayer! = CAShapeLayer() 39 | var bottom: CAShapeLayer! = CAShapeLayer() 40 | 41 | required init(coder aDecoder: NSCoder) { 42 | super.init(coder: aDecoder) 43 | self.setupPaths() 44 | } 45 | 46 | override init(frame: CGRect) { 47 | super.init(frame: frame) 48 | self.setupPaths() 49 | } 50 | 51 | func setupPaths() { 52 | let lineWidth: CGFloat = 2 53 | 54 | self.top.path = linePath 55 | self.bottom.path = linePath 56 | 57 | for layer in [ self.top, self.bottom ] { 58 | layer.fillColor = nil 59 | layer.strokeColor = UIColor.whiteColor().CGColor 60 | layer.lineWidth = lineWidth 61 | layer.lineCap = kCALineCapSquare 62 | layer.masksToBounds = true 63 | 64 | let strokingPath = CGPathCreateCopyByStrokingPath(layer.path, nil, lineWidth*2, kCGLineCapSquare, kCGLineJoinMiter, 0) 65 | layer.bounds = CGPathGetPathBoundingBox(strokingPath) 66 | layer.actions = [ 67 | "strokeStart": NSNull(), 68 | "strokeEnd": NSNull(), 69 | "transform": NSNull() 70 | ] 71 | 72 | self.layer.addSublayer(layer) 73 | } 74 | 75 | self.top.anchorPoint = CGPointMake(0.5, 0.0) 76 | self.top.position = CGPointMake(self.frame.size.width/2 + pauseSpace/2, (self.frame.size.height-shadowPadding)/2 - 12/2 ) 77 | self.top.transform = topTransform 78 | 79 | self.bottom.anchorPoint = CGPointMake(0.5, 1.0) 80 | self.bottom.position = CGPointMake(self.frame.size.width/2 - pauseSpace/2, self.top.position.y + 12 + shadowPadding/2) 81 | self.bottom.transform = bottomTransform 82 | } 83 | 84 | 85 | func addTransforms() { 86 | let bottomAnimation = CABasicAnimation(keyPath: "transform") 87 | bottomAnimation.duration = 0.4 88 | bottomAnimation.fillMode = kCAFillModeBackwards 89 | bottomAnimation.timingFunction = CAMediaTimingFunction(controlPoints: 0.5, -0.8, 0.5, 1.85) 90 | 91 | let topAnimation = bottomAnimation.copy() as! CABasicAnimation 92 | 93 | if (selected) { 94 | bottomAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity) 95 | topAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity) 96 | } 97 | else { 98 | bottomAnimation.toValue = NSValue(CATransform3D: bottomTransform) 99 | topAnimation.toValue = NSValue(CATransform3D: topTransform) 100 | } 101 | self.bottom.kv_applyAnimation(bottomAnimation) 102 | self.top.kv_applyAnimation(topAnimation) 103 | } 104 | 105 | } 106 | 107 | extension CALayer { 108 | func kv_applyAnimation(animation: CABasicAnimation) { 109 | let copy = animation.copy() as! CABasicAnimation 110 | 111 | if copy.fromValue == nil { 112 | copy.fromValue = self.presentationLayer().valueForKeyPath(copy.keyPath) 113 | } 114 | 115 | self.addAnimation(copy, forKey: copy.keyPath) 116 | self.setValue(copy.toValue, forKeyPath:copy.keyPath) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /walktracker/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/9/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | WalkStore.sharedInstance.saveContext() 31 | } 32 | 33 | func applicationWillEnterForeground(application: UIApplication) { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | func applicationDidBecomeActive(application: UIApplication) { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | func applicationWillTerminate(application: UIApplication) { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /walktracker/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /walktracker/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 | 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 | 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 | -------------------------------------------------------------------------------- /walktracker/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /walktracker/Images.xcassets/add_button.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "add_button.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /walktracker/Images.xcassets/add_button.imageset/add_button.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinvanderlugt/Swift-Walk-Tracker/825d5f56111c27b18b704fbf78633a4206ce9cd1/walktracker/Images.xcassets/add_button.imageset/add_button.pdf -------------------------------------------------------------------------------- /walktracker/Images.xcassets/add_button_no_shadow.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "add_button_no_shadow.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /walktracker/Images.xcassets/add_button_no_shadow.imageset/add_button_no_shadow.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinvanderlugt/Swift-Walk-Tracker/825d5f56111c27b18b704fbf78633a4206ce9cd1/walktracker/Images.xcassets/add_button_no_shadow.imageset/add_button_no_shadow.pdf -------------------------------------------------------------------------------- /walktracker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleDisplayName 10 | Walk Tracker 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | com.alpinepipeline.$(PRODUCT_NAME:rfc1034identifier) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1 27 | LSRequiresIPhoneOS 28 | 29 | NSLocationAlwaysUsageDescription 30 | Your location will only be tracked when you start a route 31 | NSLocationWhenInUseUsageDescription 32 | Location is needed to track your routes 33 | UIBackgroundModes 34 | 35 | location 36 | 37 | UILaunchStoryboardName 38 | LaunchScreen 39 | UIMainStoryboardFile 40 | Main 41 | UIRequiredDeviceCapabilities 42 | 43 | armv7 44 | 45 | UIStatusBarStyle 46 | UIStatusBarStyleLightContent 47 | UIStatusBarTintParameters 48 | 49 | UINavigationBar 50 | 51 | Style 52 | UIBarStyleDefault 53 | Translucent 54 | 55 | 56 | 57 | UISupportedInterfaceOrientations 58 | 59 | UIInterfaceOrientationPortrait 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | UISupportedInterfaceOrientations~ipad 64 | 65 | UIInterfaceOrientationPortrait 66 | UIInterfaceOrientationPortraitUpsideDown 67 | UIInterfaceOrientationLandscapeLeft 68 | UIInterfaceOrientationLandscapeRight 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /walktracker/MapViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MapViewController.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/9/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MapKit 11 | import CoreLocation 12 | 13 | class MapViewController: UIViewController, CLLocationManagerDelegate, UIToolbarDelegate, MKMapViewDelegate { 14 | var locationManager: CLLocationManager! 15 | 16 | let walkStore: WalkStore = WalkStore.sharedInstance 17 | 18 | var isTracking: Bool = false 19 | 20 | @IBOutlet weak var mapView: MKMapView! 21 | 22 | override func viewDidLoad() { 23 | super.viewDidLoad() 24 | // Do any additional setup after loading the view, typically from a nib. 25 | 26 | locationManager = CLLocationManager() 27 | locationManager.delegate = self 28 | locationManager.activityType = .Fitness 29 | locationManager.desiredAccuracy = kCLLocationAccuracyBest 30 | 31 | locationManager.requestAlwaysAuthorization() 32 | } 33 | 34 | override func viewWillAppear(animated: Bool) { 35 | super.viewWillAppear(animated) 36 | 37 | self.updateDisplay() 38 | } 39 | 40 | @IBAction func trashPressed(sender: UIBarButtonItem) { 41 | let alert = UIAlertController(title: "Delete Walk", 42 | message: "Are you sure you want to trash your current route?", 43 | preferredStyle: UIAlertControllerStyle.Alert) 44 | 45 | let cancelAction = UIAlertAction(title: "Cancel", 46 | style: UIAlertActionStyle.Default, 47 | handler: nil) 48 | 49 | let deleteAction = UIAlertAction(title: "Delete", 50 | style: UIAlertActionStyle.Destructive) 51 | { (action) in 52 | self.mapView.removeOverlays(self.mapView.overlays) 53 | self.walkStore.stopWalk() 54 | } 55 | 56 | alert.addAction(cancelAction) 57 | alert.addAction(deleteAction) 58 | self.presentViewController(alert, 59 | animated: true, completion: nil) 60 | } 61 | 62 | @IBAction func walkPressed(sender: UIButton) { 63 | sender.selected = !sender.selected 64 | if isTracking { 65 | locationManager.stopUpdatingLocation() 66 | } else { 67 | locationManager.startUpdatingLocation() 68 | walkStore.startWalk() 69 | } 70 | 71 | isTracking = !isTracking 72 | mapView.showsUserLocation = isTracking 73 | updateDisplay() 74 | } 75 | 76 | func updateDisplay() { 77 | if let walk = walkStore.currentWalk { 78 | if let region = self.mapRegion(walk) { 79 | mapView.setRegion(region, animated: true) 80 | } 81 | } 82 | 83 | mapView.removeOverlays(mapView.overlays) 84 | mapView.addOverlay(polyLine()) 85 | } 86 | 87 | func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { 88 | if let walk = walkStore.currentWalk { 89 | for location in locations { 90 | if let newLocation = location as? CLLocation { 91 | if newLocation.horizontalAccuracy > 0 { 92 | // Only set the location on and region on the first try 93 | // This may change in the future 94 | if walk.locations.count <= 0 { 95 | mapView.setCenterCoordinate(newLocation.coordinate, animated: true) 96 | 97 | let region = MKCoordinateRegionMakeWithDistance(newLocation.coordinate, 1000, 1000) 98 | mapView.setRegion(region, animated: true) 99 | } 100 | let locations = walk.locations as Array 101 | if let oldLocation = locations.last as CLLocation? { 102 | let delta: Double = newLocation.distanceFromLocation(oldLocation) 103 | walk.addDistance(delta) 104 | } 105 | 106 | walk.addNewLocation(newLocation) 107 | } 108 | } 109 | } 110 | updateDisplay() 111 | } 112 | } 113 | 114 | func polyLine() -> MKPolyline { 115 | if let walk = walkStore.currentWalk { 116 | var coordinates = walk.locations.map({ (location: CLLocation) -> 117 | CLLocationCoordinate2D in 118 | return location.coordinate 119 | }) 120 | 121 | return MKPolyline(coordinates: &coordinates, count: walk.locations.count) 122 | } 123 | return MKPolyline() 124 | } 125 | 126 | // This feels like it could definitely live somewhere else 127 | // I am not sure yet where this function lives 128 | func mapRegion(walk: Walk) -> MKCoordinateRegion? { 129 | if let startLocation = walk.locations.first { 130 | var minLatitude = startLocation.coordinate.latitude 131 | var maxLatitude = startLocation.coordinate.latitude 132 | 133 | var minLongitude = startLocation.coordinate.longitude 134 | var maxLongitude = startLocation.coordinate.longitude 135 | 136 | for location in walk.locations { 137 | if location.coordinate.latitude < minLatitude { 138 | minLatitude = location.coordinate.latitude 139 | } 140 | if location.coordinate.latitude > maxLatitude { 141 | maxLatitude = location.coordinate.latitude 142 | } 143 | 144 | if location.coordinate.longitude < minLongitude { 145 | minLongitude = location.coordinate.longitude 146 | } 147 | if location.coordinate.latitude > maxLongitude { 148 | maxLongitude = location.coordinate.longitude 149 | } 150 | } 151 | 152 | let center = CLLocationCoordinate2D(latitude: (minLatitude + maxLatitude)/2.0, 153 | longitude: (minLongitude + maxLongitude)/2.0) 154 | 155 | // 10% padding need more padding vertically because of the toolbar 156 | let span = MKCoordinateSpan(latitudeDelta: (maxLatitude - minLatitude)*1.3, 157 | longitudeDelta: (maxLongitude - minLongitude)*1.1) 158 | 159 | return MKCoordinateRegion(center: center, span: span) 160 | } 161 | return nil 162 | } 163 | 164 | func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! { 165 | if let polyLine = overlay as? MKPolyline { 166 | let renderer = MKPolylineRenderer(polyline: polyLine) 167 | renderer.strokeColor = UIColor(hue:0.88, saturation:0.46, brightness:0.73, alpha:0.75) 168 | renderer.lineWidth = 6 169 | return renderer 170 | } 171 | return nil 172 | } 173 | 174 | override func didReceiveMemoryWarning() { 175 | super.didReceiveMemoryWarning() 176 | // Dispose of any resources that can be recreated. 177 | } 178 | 179 | 180 | func positionForBar(bar: UIBarPositioning) -> UIBarPosition { 181 | return UIBarPosition.TopAttached 182 | } 183 | 184 | @IBAction func unwindToMapsView(segue:UIStoryboardSegue) { 185 | dismissViewControllerAnimated(true, completion: nil) 186 | } 187 | } 188 | 189 | -------------------------------------------------------------------------------- /walktracker/Walk.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Walk.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/9/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreData 11 | import CoreLocation 12 | 13 | class Walk: NSManagedObject { 14 | 15 | @NSManaged var distance: NSNumber 16 | @NSManaged var startTimestamp: NSDate 17 | @NSManaged var endTimestamp: NSDate 18 | @NSManaged var locations: Array 19 | 20 | var duration: NSTimeInterval { 21 | get { 22 | return endTimestamp.timeIntervalSinceDate(startTimestamp) 23 | } 24 | } 25 | 26 | func addDistance(distance: Double) { 27 | self.distance = NSNumber(double: (self.distance.doubleValue + distance)) 28 | } 29 | 30 | func addNewLocation(location: CLLocation) { 31 | locations.append(location) 32 | } 33 | 34 | override func awakeFromInsert() { 35 | super.awakeFromInsert() 36 | 37 | locations = [CLLocation]() 38 | startTimestamp = NSDate() 39 | distance = 0.0 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /walktracker/WalkStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WalkStore.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/10/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreData 11 | import CoreLocation 12 | 13 | private let _WalkStoreSharedInstance = WalkStore() 14 | @objc(Walk) 15 | 16 | class WalkStore: NSObject { 17 | 18 | // Singleton instance - Trying this for dealing with core data 19 | class var sharedInstance: WalkStore { 20 | return _WalkStoreSharedInstance 21 | } 22 | 23 | var currentWalk: Walk? 24 | 25 | lazy var allWalks: [Walk] = { 26 | let fetchRequest = NSFetchRequest(entityName: "Walk") 27 | let sortDescriptor = NSSortDescriptor(key: "startTimestamp", ascending: true) 28 | fetchRequest.sortDescriptors = [sortDescriptor] 29 | 30 | if let fetchResults = self.managedObjectContext!.executeFetchRequest(fetchRequest, error: nil) as? [Walk] { 31 | return fetchResults 32 | } 33 | return [Walk]() 34 | }() 35 | 36 | func startWalk() { 37 | if (currentWalk == nil) { 38 | currentWalk = NSEntityDescription.insertNewObjectForEntityForName("Walk", inManagedObjectContext: self.managedObjectContext!) as? Walk 39 | allWalks.append(currentWalk!) 40 | } 41 | } 42 | 43 | func stopWalk() { 44 | if currentWalk != nil { 45 | currentWalk?.endTimestamp = NSDate() 46 | saveContext() 47 | } 48 | 49 | currentWalk = nil 50 | } 51 | 52 | func indexOfCurrentWalk() -> Int? { 53 | if currentWalk != nil { 54 | return find(allWalks, currentWalk!) 55 | } 56 | return nil 57 | } 58 | 59 | // MARK: - Core Data stack 60 | 61 | lazy var applicationDocumentsDirectory: NSURL = { 62 | // The directory the application uses to store the Core Data store file. This code uses a directory named "com.alpinepipeline.test" in the application's documents Application Support directory. 63 | let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) 64 | return urls[urls.count-1] as! NSURL 65 | }() 66 | 67 | lazy var managedObjectModel: NSManagedObjectModel = { 68 | // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model. 69 | let modelURL = NSBundle.mainBundle().URLForResource("walktracker", withExtension: "momd")! 70 | return NSManagedObjectModel(contentsOfURL: modelURL)! 71 | }() 72 | 73 | lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = { 74 | // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail. 75 | // Create the coordinator and store 76 | var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) 77 | let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("walktracker.sqlite") 78 | var error: NSError? = nil 79 | var failureReason = "There was an error creating or loading the application's saved data." 80 | if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil { 81 | coordinator = nil 82 | // Report any error we got. 83 | let dict = NSMutableDictionary() 84 | dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" 85 | dict[NSLocalizedFailureReasonErrorKey] = failureReason 86 | dict[NSUnderlyingErrorKey] = error 87 | error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict as [NSObject : AnyObject]) 88 | // Replace this with code to handle the error appropriately. 89 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 90 | NSLog("Unresolved error \(error), \(error!.userInfo)") 91 | abort() 92 | } 93 | 94 | return coordinator 95 | }() 96 | 97 | lazy var managedObjectContext: NSManagedObjectContext? = { 98 | // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail. 99 | let coordinator = self.persistentStoreCoordinator 100 | if coordinator == nil { 101 | return nil 102 | } 103 | var managedObjectContext = NSManagedObjectContext() 104 | managedObjectContext.persistentStoreCoordinator = coordinator 105 | return managedObjectContext 106 | }() 107 | 108 | // MARK: - Core Data Saving support 109 | 110 | func saveContext () { 111 | if let moc = self.managedObjectContext { 112 | var error: NSError? = nil 113 | if moc.hasChanges && !moc.save(&error) { 114 | // Replace this implementation with code to handle the error appropriately. 115 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 116 | NSLog("Unresolved error \(error), \(error!.userInfo)") 117 | abort() 118 | } 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /walktracker/WalksViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WalksViewController.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/23/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Foundation 11 | 12 | class WalksViewController: UIViewController, UIToolbarDelegate, UITableViewDataSource, UITableViewDelegate { 13 | 14 | @IBOutlet weak var tableView: UITableView! 15 | @IBOutlet weak var toolbar: UIToolbar! 16 | 17 | let dateFormatter = NSDateFormatter() 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height 23 | 24 | self.tableView.contentInset = UIEdgeInsetsMake(toolbar.frame.size.height + statusBarHeight,0,0,0); 25 | 26 | dateFormatter.dateStyle = .LongStyle 27 | dateFormatter.timeStyle = .ShortStyle 28 | } 29 | 30 | override func viewWillAppear(animated: Bool) { 31 | super.viewWillAppear(animated) 32 | 33 | self.tableView.reloadData() 34 | self.setSelectedRow() 35 | } 36 | 37 | func setSelectedRow() { 38 | if let selectedWalkRow = WalkStore.sharedInstance.indexOfCurrentWalk() { 39 | self.tableView.selectRowAtIndexPath(NSIndexPath(forRow: selectedWalkRow, inSection: 0), 40 | animated: true, scrollPosition: UITableViewScrollPosition.Middle) 41 | } 42 | } 43 | 44 | func positionForBar(bar: UIBarPositioning) -> UIBarPosition { 45 | return UIBarPosition.TopAttached 46 | } 47 | 48 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 49 | var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell 50 | 51 | let allWalks = WalkStore.sharedInstance.allWalks 52 | let walk = allWalks[indexPath.row] 53 | cell.textLabel?.text = dateFormatter.stringFromDate(walk.startTimestamp) 54 | 55 | return cell 56 | } 57 | 58 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 59 | return WalkStore.sharedInstance.allWalks.count 60 | } 61 | 62 | func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 63 | let allWalks = WalkStore.sharedInstance.allWalks 64 | let walk = allWalks[indexPath.row] as Walk 65 | WalkStore.sharedInstance.currentWalk = walk 66 | self.dismissViewControllerAnimated(true, completion: nil) 67 | } 68 | } -------------------------------------------------------------------------------- /walktracker/walktracker.xcdatamodeld/walktracker.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /walktrackerTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.alpinepipeline.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /walktrackerTests/walktrackerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // walktrackerTests.swift 3 | // walktrackerTests 4 | // 5 | // Created by Kevin VanderLugt on 1/9/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class walktrackerTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------