From bc3546c55b6753a08d20833fe10172e1a6f8ef28 Mon Sep 17 00:00:00 2001 From: Louis D'hauwe Date: Mon, 2 Apr 2018 16:53:09 +0200 Subject: [PATCH] Add example --- Example/Example.xcodeproj/project.pbxproj | 359 ++++++++++++++++++ Example/Example/AppDelegate.swift | 46 +++ .../AppIcon.appiconset/Contents.json | 98 +++++ Example/Example/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ Example/Example/Base.lproj/Main.storyboard | 206 ++++++++++ Example/Example/Info.plist | 45 +++ Example/Example/ViewController.swift | 84 ++++ HueKit.xcodeproj/project.pbxproj | 2 + HueKit.xcworkspace/contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + 11 files changed, 889 insertions(+) create mode 100644 Example/Example.xcodeproj/project.pbxproj create mode 100644 Example/Example/AppDelegate.swift create mode 100644 Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Example/Example/Assets.xcassets/Contents.json create mode 100644 Example/Example/Base.lproj/LaunchScreen.storyboard create mode 100644 Example/Example/Base.lproj/Main.storyboard create mode 100644 Example/Example/Info.plist create mode 100644 Example/Example/ViewController.swift create mode 100644 HueKit.xcworkspace/contents.xcworkspacedata create mode 100644 HueKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..48b1703 --- /dev/null +++ b/Example/Example.xcodeproj/project.pbxproj @@ -0,0 +1,359 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + BEB7754C207267E400201EBB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB7754B207267E400201EBB /* AppDelegate.swift */; }; + BEB7754E207267E400201EBB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB7754D207267E400201EBB /* ViewController.swift */; }; + BEB77551207267E400201EBB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEB7754F207267E400201EBB /* Main.storyboard */; }; + BEB77553207267E500201EBB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BEB77552207267E500201EBB /* Assets.xcassets */; }; + BEB77556207267E500201EBB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEB77554207267E500201EBB /* LaunchScreen.storyboard */; }; + BEB7755E207267F800201EBB /* HueKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEB7755D207267F800201EBB /* HueKit.framework */; }; + BEB7755F207267F800201EBB /* HueKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BEB7755D207267F800201EBB /* HueKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + BEB77560207267F800201EBB /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + BEB7755F207267F800201EBB /* HueKit.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + BEB77548207267E400201EBB /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEB7754B207267E400201EBB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + BEB7754D207267E400201EBB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + BEB77550207267E400201EBB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + BEB77552207267E500201EBB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + BEB77555207267E500201EBB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + BEB77557207267E500201EBB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BEB7755D207267F800201EBB /* HueKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = HueKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BEB77545207267E400201EBB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BEB7755E207267F800201EBB /* HueKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BEB7753F207267E400201EBB = { + isa = PBXGroup; + children = ( + BEB7755D207267F800201EBB /* HueKit.framework */, + BEB7754A207267E400201EBB /* Example */, + BEB77549207267E400201EBB /* Products */, + ); + sourceTree = ""; + }; + BEB77549207267E400201EBB /* Products */ = { + isa = PBXGroup; + children = ( + BEB77548207267E400201EBB /* Example.app */, + ); + name = Products; + sourceTree = ""; + }; + BEB7754A207267E400201EBB /* Example */ = { + isa = PBXGroup; + children = ( + BEB7754B207267E400201EBB /* AppDelegate.swift */, + BEB7754D207267E400201EBB /* ViewController.swift */, + BEB7754F207267E400201EBB /* Main.storyboard */, + BEB77552207267E500201EBB /* Assets.xcassets */, + BEB77554207267E500201EBB /* LaunchScreen.storyboard */, + BEB77557207267E500201EBB /* Info.plist */, + ); + path = Example; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BEB77547207267E400201EBB /* Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = BEB7755A207267E500201EBB /* Build configuration list for PBXNativeTarget "Example" */; + buildPhases = ( + BEB77544207267E400201EBB /* Sources */, + BEB77545207267E400201EBB /* Frameworks */, + BEB77546207267E400201EBB /* Resources */, + BEB77560207267F800201EBB /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Example; + productName = Example; + productReference = BEB77548207267E400201EBB /* Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BEB77540207267E400201EBB /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0930; + LastUpgradeCheck = 0930; + ORGANIZATIONNAME = "Silver Fox"; + TargetAttributes = { + BEB77547207267E400201EBB = { + CreatedOnToolsVersion = 9.3; + }; + }; + }; + buildConfigurationList = BEB77543207267E400201EBB /* Build configuration list for PBXProject "Example" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BEB7753F207267E400201EBB; + productRefGroup = BEB77549207267E400201EBB /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BEB77547207267E400201EBB /* Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BEB77546207267E400201EBB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BEB77556207267E500201EBB /* LaunchScreen.storyboard in Resources */, + BEB77553207267E500201EBB /* Assets.xcassets in Resources */, + BEB77551207267E400201EBB /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + BEB77544207267E400201EBB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BEB7754E207267E400201EBB /* ViewController.swift in Sources */, + BEB7754C207267E400201EBB /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + BEB7754F207267E400201EBB /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BEB77550207267E400201EBB /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + BEB77554207267E500201EBB /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BEB77555207267E500201EBB /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + BEB77558207267E500201EBB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + BEB77559207267E500201EBB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + BEB7755B207267E500201EBB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6G5LMQ72D8; + INFOPLIST_FILE = Example/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.Example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + BEB7755C207267E500201EBB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6G5LMQ72D8; + INFOPLIST_FILE = Example/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = be.silverfox.Example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BEB77543207267E400201EBB /* Build configuration list for PBXProject "Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BEB77558207267E500201EBB /* Debug */, + BEB77559207267E500201EBB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BEB7755A207267E500201EBB /* Build configuration list for PBXNativeTarget "Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BEB7755B207267E500201EBB /* Debug */, + BEB7755C207267E500201EBB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = BEB77540207267E400201EBB /* Project object */; +} diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift new file mode 100644 index 0000000..ff4ef88 --- /dev/null +++ b/Example/Example/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Example +// +// Created by Louis D'hauwe on 02/04/2018. +// Copyright © 2018 Silver Fox. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // 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. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // 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. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/Contents.json b/Example/Example/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Example/Example/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Base.lproj/LaunchScreen.storyboard b/Example/Example/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f83f6fd --- /dev/null +++ b/Example/Example/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..1287475 --- /dev/null +++ b/Example/Example/Base.lproj/Main.storyboard @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Info.plist b/Example/Example/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/Example/Example/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift new file mode 100644 index 0000000..7b7d35d --- /dev/null +++ b/Example/Example/ViewController.swift @@ -0,0 +1,84 @@ +// +// ViewController.swift +// Example +// +// Created by Louis D'hauwe on 02/04/2018. +// Copyright © 2018 Silver Fox. All rights reserved. +// + +import UIKit +import HueKit + +class ViewController: UIViewController { + + @IBOutlet weak var colorSquarePicker: ColorSquarePicker! + @IBOutlet weak var colorIndicatorView: ColorIndicatorView! + + @IBOutlet weak var rLabel: UILabel! + @IBOutlet weak var gLabel: UILabel! + @IBOutlet weak var bLabel: UILabel! + + @IBOutlet weak var hLabel: UILabel! + @IBOutlet weak var sLabel: UILabel! + @IBOutlet weak var vLabel: UILabel! + + @IBOutlet weak var hexLabel: UILabel! + + override func viewDidLoad() { + super.viewDidLoad() + + didChangeColor(colorSquarePicker.color) + + } + + @IBAction func colorBarPickerValueChanged(_ sender: ColorBarPicker) { + + colorSquarePicker.hue = sender.hue + didChangeColor(colorSquarePicker.color) + + } + + @IBAction func colorSquarePickerValueChanged(_ sender: ColorSquarePicker) { + + didChangeColor(sender.color) + + } + + func didChangeColor(_ color: UIColor) { + + guard let rgbValue = color.rgbValue else { + return + } + + guard let hsvValue = color.hsvValue else { + return + } + + rLabel.text = String(format: "R: %.f", rgbValue.r * 255) + gLabel.text = String(format: "G: %.f", rgbValue.g * 255) + bLabel.text = String(format: "B: %.f", rgbValue.b * 255) + + hLabel.text = String(format: "H: %.f°", hsvValue.h * 360) + sLabel.text = String(format: "S: %.f%%", hsvValue.s * 100) + vLabel.text = String(format: "V: %.f%%", hsvValue.v * 100) + + hexLabel.text = color.hexString + colorIndicatorView.color = color + + } + +} + +extension UIColor { + + public var hexString: String { + var r: CGFloat = 0 + var g: CGFloat = 0 + var b: CGFloat = 0 + var a: CGFloat = 0 + self.getRed(&r, green: &g, blue: &b, alpha: &a) + + return String(format: "#%02X%02X%02X", Int(r * 255), Int(g * 255), Int(b * 255)) + } + +} diff --git a/HueKit.xcodeproj/project.pbxproj b/HueKit.xcodeproj/project.pbxproj index d204a16..cd62ee4 100644 --- a/HueKit.xcodeproj/project.pbxproj +++ b/HueKit.xcodeproj/project.pbxproj @@ -150,6 +150,7 @@ BE5C1E0E1F3266B600B0080C /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0930; LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Silver Fox"; TargetAttributes = { @@ -167,6 +168,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = BE5C1E0D1F3266B600B0080C; productRefGroup = BE5C1E181F3266B600B0080C /* Products */; diff --git a/HueKit.xcworkspace/contents.xcworkspacedata b/HueKit.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..e6d851b --- /dev/null +++ b/HueKit.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/HueKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/HueKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/HueKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +