├── ColorPicker.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── brandonbaars.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── ColorPicker ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── ColorPickerView.swift ├── ContentView.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json └── SceneDelegate.swift └── README.md /ColorPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8F2636D523CBE9C900F53AD7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F2636D423CBE9C900F53AD7 /* AppDelegate.swift */; }; 11 | 8F2636D723CBE9C900F53AD7 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F2636D623CBE9C900F53AD7 /* SceneDelegate.swift */; }; 12 | 8F2636D923CBE9C900F53AD7 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F2636D823CBE9C900F53AD7 /* ContentView.swift */; }; 13 | 8F2636DB23CBE9CB00F53AD7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F2636DA23CBE9CB00F53AD7 /* Assets.xcassets */; }; 14 | 8F2636DE23CBE9CB00F53AD7 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F2636DD23CBE9CB00F53AD7 /* Preview Assets.xcassets */; }; 15 | 8F2636E123CBE9CB00F53AD7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8F2636DF23CBE9CB00F53AD7 /* LaunchScreen.storyboard */; }; 16 | 8FC82BA323CC2B2700D9897E /* ColorPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FC82BA223CC2B2700D9897E /* ColorPickerView.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 8F2636D123CBE9C900F53AD7 /* ColorPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ColorPicker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 8F2636D423CBE9C900F53AD7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 8F2636D623CBE9C900F53AD7 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 23 | 8F2636D823CBE9C900F53AD7 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 24 | 8F2636DA23CBE9CB00F53AD7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 8F2636DD23CBE9CB00F53AD7 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 26 | 8F2636E023CBE9CB00F53AD7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | 8F2636E223CBE9CB00F53AD7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 8FC82BA223CC2B2700D9897E /* ColorPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPickerView.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 8F2636CE23CBE9C900F53AD7 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 8F2636C823CBE9C900F53AD7 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 8F2636D323CBE9C900F53AD7 /* ColorPicker */, 46 | 8F2636D223CBE9C900F53AD7 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 8F2636D223CBE9C900F53AD7 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 8F2636D123CBE9C900F53AD7 /* ColorPicker.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 8F2636D323CBE9C900F53AD7 /* ColorPicker */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 8F2636D423CBE9C900F53AD7 /* AppDelegate.swift */, 62 | 8F2636D623CBE9C900F53AD7 /* SceneDelegate.swift */, 63 | 8F2636D823CBE9C900F53AD7 /* ContentView.swift */, 64 | 8F2636DA23CBE9CB00F53AD7 /* Assets.xcassets */, 65 | 8F2636DF23CBE9CB00F53AD7 /* LaunchScreen.storyboard */, 66 | 8F2636E223CBE9CB00F53AD7 /* Info.plist */, 67 | 8F2636DC23CBE9CB00F53AD7 /* Preview Content */, 68 | 8FC82BA223CC2B2700D9897E /* ColorPickerView.swift */, 69 | ); 70 | path = ColorPicker; 71 | sourceTree = ""; 72 | }; 73 | 8F2636DC23CBE9CB00F53AD7 /* Preview Content */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 8F2636DD23CBE9CB00F53AD7 /* Preview Assets.xcassets */, 77 | ); 78 | path = "Preview Content"; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 8F2636D023CBE9C900F53AD7 /* ColorPicker */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 8F2636E523CBE9CB00F53AD7 /* Build configuration list for PBXNativeTarget "ColorPicker" */; 87 | buildPhases = ( 88 | 8F2636CD23CBE9C900F53AD7 /* Sources */, 89 | 8F2636CE23CBE9C900F53AD7 /* Frameworks */, 90 | 8F2636CF23CBE9C900F53AD7 /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = ColorPicker; 97 | productName = ColorPicker; 98 | productReference = 8F2636D123CBE9C900F53AD7 /* ColorPicker.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 8F2636C923CBE9C900F53AD7 /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastSwiftUpdateCheck = 1130; 108 | LastUpgradeCheck = 1130; 109 | ORGANIZATIONNAME = "Brandon Baars"; 110 | TargetAttributes = { 111 | 8F2636D023CBE9C900F53AD7 = { 112 | CreatedOnToolsVersion = 11.3; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 8F2636CC23CBE9C900F53AD7 /* Build configuration list for PBXProject "ColorPicker" */; 117 | compatibilityVersion = "Xcode 9.3"; 118 | developmentRegion = en; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 8F2636C823CBE9C900F53AD7; 125 | productRefGroup = 8F2636D223CBE9C900F53AD7 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 8F2636D023CBE9C900F53AD7 /* ColorPicker */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 8F2636CF23CBE9C900F53AD7 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 8F2636E123CBE9CB00F53AD7 /* LaunchScreen.storyboard in Resources */, 140 | 8F2636DE23CBE9CB00F53AD7 /* Preview Assets.xcassets in Resources */, 141 | 8F2636DB23CBE9CB00F53AD7 /* Assets.xcassets in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 8F2636CD23CBE9C900F53AD7 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 8FC82BA323CC2B2700D9897E /* ColorPickerView.swift in Sources */, 153 | 8F2636D523CBE9C900F53AD7 /* AppDelegate.swift in Sources */, 154 | 8F2636D723CBE9C900F53AD7 /* SceneDelegate.swift in Sources */, 155 | 8F2636D923CBE9C900F53AD7 /* ContentView.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin PBXVariantGroup section */ 162 | 8F2636DF23CBE9CB00F53AD7 /* LaunchScreen.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | 8F2636E023CBE9CB00F53AD7 /* Base */, 166 | ); 167 | name = LaunchScreen.storyboard; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXVariantGroup section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | 8F2636E323CBE9CB00F53AD7 /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_ANALYZER_NONNULL = YES; 178 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 179 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 180 | CLANG_CXX_LIBRARY = "libc++"; 181 | CLANG_ENABLE_MODULES = YES; 182 | CLANG_ENABLE_OBJC_ARC = YES; 183 | CLANG_ENABLE_OBJC_WEAK = YES; 184 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 185 | CLANG_WARN_BOOL_CONVERSION = YES; 186 | CLANG_WARN_COMMA = YES; 187 | CLANG_WARN_CONSTANT_CONVERSION = YES; 188 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 190 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 191 | CLANG_WARN_EMPTY_BODY = YES; 192 | CLANG_WARN_ENUM_CONVERSION = YES; 193 | CLANG_WARN_INFINITE_RECURSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 196 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 197 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 199 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 200 | CLANG_WARN_STRICT_PROTOTYPES = YES; 201 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 202 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu11; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 224 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 225 | MTL_FAST_MATH = YES; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = iphoneos; 228 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | }; 231 | name = Debug; 232 | }; 233 | 8F2636E423CBE9CB00F53AD7 /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_ANALYZER_NONNULL = YES; 238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_ENABLE_OBJC_WEAK = YES; 244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_COMMA = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 257 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 260 | CLANG_WARN_STRICT_PROTOTYPES = YES; 261 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 262 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 263 | CLANG_WARN_UNREACHABLE_CODE = YES; 264 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu11; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 13.2; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | MTL_FAST_MATH = YES; 280 | SDKROOT = iphoneos; 281 | SWIFT_COMPILATION_MODE = wholemodule; 282 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 283 | VALIDATE_PRODUCT = YES; 284 | }; 285 | name = Release; 286 | }; 287 | 8F2636E623CBE9CB00F53AD7 /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | CODE_SIGN_STYLE = Automatic; 292 | DEVELOPMENT_ASSET_PATHS = "\"ColorPicker/Preview Content\""; 293 | DEVELOPMENT_TEAM = 4TWWRT697R; 294 | ENABLE_PREVIEWS = YES; 295 | INFOPLIST_FILE = ColorPicker/Info.plist; 296 | LD_RUNPATH_SEARCH_PATHS = ( 297 | "$(inherited)", 298 | "@executable_path/Frameworks", 299 | ); 300 | PRODUCT_BUNDLE_IDENTIFIER = com.BB.ColorPicker; 301 | PRODUCT_NAME = "$(TARGET_NAME)"; 302 | SWIFT_VERSION = 5.0; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | }; 305 | name = Debug; 306 | }; 307 | 8F2636E723CBE9CB00F53AD7 /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 311 | CODE_SIGN_STYLE = Automatic; 312 | DEVELOPMENT_ASSET_PATHS = "\"ColorPicker/Preview Content\""; 313 | DEVELOPMENT_TEAM = 4TWWRT697R; 314 | ENABLE_PREVIEWS = YES; 315 | INFOPLIST_FILE = ColorPicker/Info.plist; 316 | LD_RUNPATH_SEARCH_PATHS = ( 317 | "$(inherited)", 318 | "@executable_path/Frameworks", 319 | ); 320 | PRODUCT_BUNDLE_IDENTIFIER = com.BB.ColorPicker; 321 | PRODUCT_NAME = "$(TARGET_NAME)"; 322 | SWIFT_VERSION = 5.0; 323 | TARGETED_DEVICE_FAMILY = "1,2"; 324 | }; 325 | name = Release; 326 | }; 327 | /* End XCBuildConfiguration section */ 328 | 329 | /* Begin XCConfigurationList section */ 330 | 8F2636CC23CBE9C900F53AD7 /* Build configuration list for PBXProject "ColorPicker" */ = { 331 | isa = XCConfigurationList; 332 | buildConfigurations = ( 333 | 8F2636E323CBE9CB00F53AD7 /* Debug */, 334 | 8F2636E423CBE9CB00F53AD7 /* Release */, 335 | ); 336 | defaultConfigurationIsVisible = 0; 337 | defaultConfigurationName = Release; 338 | }; 339 | 8F2636E523CBE9CB00F53AD7 /* Build configuration list for PBXNativeTarget "ColorPicker" */ = { 340 | isa = XCConfigurationList; 341 | buildConfigurations = ( 342 | 8F2636E623CBE9CB00F53AD7 /* Debug */, 343 | 8F2636E723CBE9CB00F53AD7 /* Release */, 344 | ); 345 | defaultConfigurationIsVisible = 0; 346 | defaultConfigurationName = Release; 347 | }; 348 | /* End XCConfigurationList section */ 349 | }; 350 | rootObject = 8F2636C923CBE9C900F53AD7 /* Project object */; 351 | } 352 | -------------------------------------------------------------------------------- /ColorPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ColorPicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ColorPicker.xcodeproj/xcuserdata/brandonbaars.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ColorPicker.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ColorPicker/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ColorPicker 4 | // 5 | // Created by Brandon Baars on 1/12/20. 6 | // Copyright © 2020 Brandon Baars. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /ColorPicker/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ColorPicker/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ColorPicker/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /ColorPicker/ColorPickerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerView.swift 3 | // ColorPicker 4 | // 5 | // Created by Brandon Baars on 1/12/20. 6 | // Copyright © 2020 Brandon Baars. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ColorPickerView: View { 12 | @Binding var chosenColor: Color 13 | 14 | // 1 15 | @State private var isDragging: Bool = false 16 | @State private var startLocation: CGFloat = .zero 17 | @State private var dragOffset: CGSize = .zero 18 | 19 | init(chosenColor: Binding) { 20 | self._chosenColor = chosenColor 21 | } 22 | 23 | private var colors: [Color] = { 24 | let hueValues = Array(0...359) 25 | return hueValues.map { 26 | Color(UIColor(hue: CGFloat($0) / 359.0 , 27 | saturation: 1.0, 28 | brightness: 1.0, 29 | alpha: 1.0)) 30 | } 31 | }() 32 | 33 | // 2 34 | private var circleWidth: CGFloat { 35 | isDragging ? 35 : 15 36 | } 37 | 38 | private var linearGradientHeight: CGFloat = 200 39 | 40 | /// Get the current color based on our current translation within the view 41 | private var currentColor: Color { 42 | Color(UIColor.init(hue: self.normalizeGesture() / linearGradientHeight, saturation: 1.0, brightness: 1.0, alpha: 1.0)) 43 | } 44 | 45 | /// Normalize our gesture to be between 0 and 200, where 200 is the height. 46 | /// At 0, the users finger is on top and at 200 the users finger is at the bottom 47 | private func normalizeGesture() -> CGFloat { 48 | let offset = startLocation + dragOffset.height // Using our starting point, see how far we've dragged +- from there 49 | let maxY = max(0, offset) // We want to always be greater than 0, even if their finger goes outside our view 50 | let minY = min(maxY, linearGradientHeight) // We want to always max at 200 even if the finger is outside the view. 51 | 52 | return minY 53 | } 54 | 55 | var body: some View { 56 | // 3 57 | ZStack(alignment: .top) { 58 | LinearGradient(gradient: Gradient(colors: colors), 59 | startPoint: .top, 60 | endPoint: .bottom) 61 | .frame(width: 10, height: linearGradientHeight) 62 | .cornerRadius(5) 63 | .shadow(radius: 8) 64 | .overlay( 65 | RoundedRectangle(cornerRadius: 5).stroke(Color.white, lineWidth: 2.0) 66 | ) 67 | .gesture( 68 | DragGesture() 69 | .onChanged({ (value) in 70 | self.dragOffset = value.translation 71 | self.startLocation = value.startLocation.y 72 | self.chosenColor = self.currentColor 73 | self.isDragging = true // 4 74 | }) 75 | // 5 76 | .onEnded({ (_) in 77 | self.isDragging = false 78 | }) 79 | ) 80 | 81 | // 6 82 | Circle() 83 | .foregroundColor(self.currentColor) 84 | .frame(width: self.circleWidth, height: self.circleWidth, alignment: .center) 85 | .shadow(radius: 5) 86 | .overlay( 87 | RoundedRectangle(cornerRadius: self.circleWidth / 2.0).stroke(Color.white, lineWidth: 2.0) 88 | ) 89 | .offset(x: self.isDragging ? -self.circleWidth : 0.0, y: self.normalizeGesture() - self.circleWidth / 2) 90 | .animation(Animation.spring().speed(2)) 91 | } 92 | } 93 | } 94 | 95 | struct ColorPickerView_Previews: PreviewProvider { 96 | static var previews: some View { 97 | ColorPickerView(chosenColor: Binding.constant(Color.white)) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /ColorPicker/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // ColorPicker 4 | // 5 | // Created by Brandon Baars on 1/12/20. 6 | // Copyright © 2020 Brandon Baars. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentView: View { 12 | @State var currentColor: Color = .clear 13 | 14 | var body: some View { 15 | ZStack(alignment: .topTrailing) { 16 | 17 | currentColor 18 | 19 | // 3 20 | ColorPickerView(chosenColor: $currentColor) 21 | .frame(width: 50, height: 200) 22 | .offset(x: 0, y: 75) 23 | }.edgesIgnoringSafeArea(.all) // fill past all edges on iPhoneX 24 | } 25 | } 26 | 27 | struct ContentView_Previews: PreviewProvider { 28 | static var previews: some View { 29 | ContentView() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ColorPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ColorPicker/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ColorPicker/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // ColorPicker 4 | // 5 | // Created by Brandon Baars on 1/12/20. 6 | // Copyright © 2020 Brandon Baars. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 | 22 | // Create the SwiftUI view that provides the window contents. 23 | let contentView = ContentView() 24 | 25 | // Use a UIHostingController as window root view controller. 26 | if let windowScene = scene as? UIWindowScene { 27 | let window = UIWindow(windowScene: windowScene) 28 | window.rootViewController = UIHostingController(rootView: contentView) 29 | self.window = window 30 | window.makeKeyAndVisible() 31 | } 32 | } 33 | 34 | func sceneDidDisconnect(_ scene: UIScene) { 35 | // Called as the scene is being released by the system. 36 | // This occurs shortly after the scene enters the background, or when its session is discarded. 37 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 | } 40 | 41 | func sceneDidBecomeActive(_ scene: UIScene) { 42 | // Called when the scene has moved from an inactive state to an active state. 43 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 | } 45 | 46 | func sceneWillResignActive(_ scene: UIScene) { 47 | // Called when the scene will move from an active state to an inactive state. 48 | // This may occur due to temporary interruptions (ex. an incoming phone call). 49 | } 50 | 51 | func sceneWillEnterForeground(_ scene: UIScene) { 52 | // Called as the scene transitions from the background to the foreground. 53 | // Use this method to undo the changes made on entering the background. 54 | } 55 | 56 | func sceneDidEnterBackground(_ scene: UIScene) { 57 | // Called as the scene transitions from the foreground to the background. 58 | // Use this method to save data, release shared resources, and store enough scene-specific state information 59 | // to restore the scene back to its current state. 60 | } 61 | 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftUI-Gradient-ColorPicker 2 | Create a gradient color picker like Snapchats 3 | 4 | ![](https://media.giphy.com/media/KbeKt4m4svGeTvEEWB/giphy.gif) 5 | --------------------------------------------------------------------------------