├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── StyleKit.podspec ├── StyleKit.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── StyleKit.xcscheme ├── StyleKit.xcworkspace └── contents.xcworkspacedata ├── StyleKit ├── FileLoader.swift ├── Helpers │ ├── ColorHelper.swift │ ├── ControlStateHelper.swift │ └── FontHelper.swift ├── Info.plist ├── StyleKit.h ├── StyleKit.swift ├── StyleParsable.swift ├── StyleParser.swift ├── Stylist.swift └── Utilities │ ├── ColorExtensions.swift │ ├── SKLogger.swift │ ├── SKTryCatch.h │ ├── SKTryCatch.m │ ├── StringExtensions.swift │ ├── UIAppearance+Swift.h │ └── UIAppearance+Swift.m ├── StyleKitDemo ├── StyleKitDemo.xcodeproj │ └── project.pbxproj └── StyleKitDemo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── CustomViews │ ├── SKButton.swift │ ├── SKLabel.swift │ ├── SKNavigationBar.swift │ ├── SKTextField.swift │ └── SKView.swift │ ├── Info.plist │ ├── Style │ ├── StyleParser.swift │ └── style.json │ └── ViewController.swift └── StyleKitTests ├── HelperTests.swift ├── Info.plist ├── JSONLoadTests.swift ├── Style ├── fail-style.json ├── style.json └── success-style.json ├── StyleKitTestsHost ├── AppDelegate.swift └── Info.plist ├── StyleTests.swift └── UI Extensions ├── SKButton.swift ├── SKLabel.swift └── SKView.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | 67 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | xcode_project: StyleKit.xcodeproj 4 | xcode_scheme: StyleKit 5 | osx_image: xcode9.1 6 | xcode_sdk: macosx10.13 7 | 8 | script: 9 | - xcodebuild clean build test -project StyleKit.xcodeproj -scheme StyleKit -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.1' 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 146BC 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 | ![alt text](https://i.imgur.com/IqDIU4q.png "StyleKit - A powerful & easy to use styling framework written in Swift") 2 | 3 | [![Build Status](https://travis-ci.org/146BC/StyleKit.svg?branch=develop)](https://travis-ci.org/146BC/StyleKit) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | 5 | StyleKit is a microframework that enables you to style your applications using a simple JSON file. Behind the scenes, StyleKit uses [UIAppearance](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAppearance_Protocol/) and some selector magic to apply the styles. You can also customize the parser for greater flexibility. 6 | 7 | 8 | ### How does it work? 9 | 10 | #### Create a JSON file in the following format 11 | 12 | ```js 13 | { 14 | "@headingFont": "HelveticaNeue-Bold:30.0", 15 | "UILabel": { 16 | "font": "@headingFont", 17 | "backgroundColor": "#000FFF" 18 | }, 19 | "StyleKitDemo.SKView": { 20 | "StyleKitDemo.SKLabel": { 21 | "font": "HelveticaNeue-Bold:20.0", 22 | "backgroundColor": "#FFF000", 23 | "color": "#fff" 24 | }, 25 | "StyleKitDemo.SKButton": { 26 | "font": "HelveticaNeue-Light:20.0", 27 | "titleColor:normal": "#FFFFFF", 28 | "titleColor:highlighted": "#000000" 29 | } 30 | }, 31 | "StyleKitDemo.SKNavigationBar": { 32 | "titleTextAttributes": { 33 | "NSColor": "#000FFF", 34 | "NSFont": "@headingFont" 35 | } 36 | }, 37 | "StyleKitDemo.SKTextField": { 38 | "font": "HelveticaNeue-Light:20.0", 39 | "textColor": "#000FFF" 40 | } 41 | } 42 | ``` 43 | #### Load JSON file 44 | 45 | *AppDelegate.swift* 46 | 47 | ```swift 48 | func application(_ application: UIApplication, 49 | didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 50 | 51 | if let styleFile = Bundle.main.url(forResource: "style", withExtension: "json") { 52 | StyleKit(fileUrl: styleFile)?.apply() 53 | } 54 | 55 | return true 56 | } 57 | ``` 58 | 59 | On application launch the JSON file will be loaded and the styles applied. 60 | 61 | 62 | ### The JSON file structure 63 | 64 | Each object inside the JSON file should contain the name of the UIView as a key and the object inside should either contain the properties/functions that need to be set/called or another UIView, this will give you the ability to apply styles on views when contained in other views, an example of this would be the following. 65 | 66 | ```js 67 | { 68 | "UIButton": { 69 | "font": "HelveticaNeue-Bold:20.0" 70 | }, 71 | "MyApp.LoginView": { 72 | "UIButton": { 73 | "font": "HelveticaNeue-Light:25.0" 74 | } 75 | } 76 | } 77 | ``` 78 | 79 | This would apply HelveticaNeue-Bold with size 20 to all the UIButtons except the ones contained inside the LoginView class in your app. 80 | 81 | Custom classes must be namespaced by the name of the module they are contained in. e.g. `StyleKitDemo.SKTextField` 82 | 83 | ### Aliases 84 | 85 | ```js 86 | { 87 | "@mainFont": "HelveticaNeue-Bold:20.0", 88 | "@primaryColor": "#000FFF", 89 | "UIButton": { 90 | "font": "@mainFont" 91 | }, 92 | "MyApp.LoginView": { 93 | "UIButton": { 94 | "font": "HelveticaNeue-Light:25.0", 95 | "titleColor:normal": "@primaryColor" 96 | } 97 | } 98 | } 99 | ``` 100 | 101 | ### Bring Your Own Parser 102 | 103 | StyleKit's initialiser supports passing a custom parser which should conform to the `StyleParsable` protocol. 104 | 105 | *Default Parser* 106 | 107 | ```swift 108 | class StyleParser: StyleParsable { 109 | 110 | func getStyle(forName name: String, value: AnyObject) -> AnyObject { 111 | if let value = value as? String { 112 | if let font = FontHelper.parseFont(value) { 113 | return font 114 | } else if let color = ColorHelper.parseColor(value) { 115 | return color 116 | } 117 | } 118 | return value 119 | } 120 | } 121 | ``` 122 | 123 | *AppDelegate.swift* 124 | 125 | ```swift 126 | func application(_ application: UIApplication, 127 | didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 128 | 129 | if let styleFile = Bundle.main.url(forResource: "style", withExtension: "json") { 130 | StyleKit(fileUrl: styleFile, styleParser: StyleParser())?.apply() 131 | } 132 | 133 | return true 134 | } 135 | ``` 136 | 137 | ### Logging 138 | 139 | By default, StyleKit will log any errors to the console. To customise the level of logging, you can pass a logLevel parameter as follows: 140 | 141 | ```swift 142 | StyleKit(fileUrl: styleFile, logLevel: .debug)?.apply() 143 | ``` 144 | 145 | The levels of logging are: 146 | 147 | * ```.debug``` 148 | * ```.error``` (This is the default log level) 149 | * ```.severe``` 150 | * ```.none``` 151 | 152 | 153 | ### How to install? 154 | 155 | #### Carthage 156 | 157 | ##### Swift 3 158 | 159 | ```ogdl 160 | github "146BC/StyleKit" ~> 0.6 161 | ``` 162 | ##### Swift 4 163 | 164 | ```ogdl 165 | github "146BC/StyleKit" ~> 0.7 166 | ``` 167 | 168 | #### CocoaPods 169 | 170 | Add the 146BC Source 171 | 172 | ```ruby 173 | source 'https://github.com/146BC/Specs.git' 174 | source 'https://github.com/CocoaPods/Specs.git' 175 | ``` 176 | 177 | ##### Swift 3 178 | 179 | ```ruby 180 | pod 'StyleKit', '~> 0.6' 181 | ``` 182 | 183 | ##### Swift 4 184 | 185 | ```ruby 186 | pod 'StyleKit', '~> 0.7' 187 | ``` -------------------------------------------------------------------------------- /StyleKit.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "StyleKit" 4 | s.version = "0.5.0" 5 | s.summary = "A powerful & easy to use styling framework written in Swift." 6 | 7 | s.description = "StyleKit is a microframework that enables you to style your applications using a simple JSON file. Behind the scenes, StyleKit uses UIAppearance and some selector magic to apply the styles. You can also customize the parser for greater flexibility." 8 | 9 | s.homepage = "https://github.com/146BC/StyleKit" 10 | s.license = { :type => "MIT", :file => "LICENSE" } 11 | s.author = { "Bernard Gatt" => "bernard@blinkrocket.com" } 12 | s.platform = :ios, "8.0" 13 | 14 | s.source = { :git => "https://github.com/146BC/StyleKit.git", :tag => "#{s.version}" } 15 | 16 | s.source_files = "StyleKit/*.{swift,h,m}", "StyleKit/**/*.{swift,h,m}" 17 | 18 | end -------------------------------------------------------------------------------- /StyleKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 059932DC1D59E0DF0085E522 /* SKTryCatch.m in Sources */ = {isa = PBXBuildFile; fileRef = 059932DB1D59E0DF0085E522 /* SKTryCatch.m */; }; 11 | 059932DD1D59E1950085E522 /* SKTryCatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 059932D81D59E09D0085E522 /* SKTryCatch.h */; settings = {ATTRIBUTES = (Public, ); }; }; 12 | 992723731D5B36D700B74CDD /* UIAppearance+Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 992723711D5B36D700B74CDD /* UIAppearance+Swift.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | 992723741D5B36D700B74CDD /* UIAppearance+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 992723721D5B36D700B74CDD /* UIAppearance+Swift.m */; }; 14 | 996775991D5A2E8E005DA08A /* StyleParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 996775981D5A2E8E005DA08A /* StyleParsable.swift */; }; 15 | 9967759D1D5A3607005DA08A /* FontHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9967759C1D5A3607005DA08A /* FontHelper.swift */; }; 16 | 9967759F1D5A3691005DA08A /* ColorHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9967759E1D5A3691005DA08A /* ColorHelper.swift */; }; 17 | 996775A11D5A38E8005DA08A /* ControlStateHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 996775A01D5A38E8005DA08A /* ControlStateHelper.swift */; }; 18 | A100097F1DB02AF300C761CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A100097E1DB02AF300C761CC /* AppDelegate.swift */; }; 19 | A10009961DB02D9D00C761CC /* SKLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10009931DB02D9D00C761CC /* SKLabel.swift */; }; 20 | A10009971DB02D9D00C761CC /* SKView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10009941DB02D9D00C761CC /* SKView.swift */; }; 21 | A10009981DB02D9D00C761CC /* SKButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10009951DB02D9D00C761CC /* SKButton.swift */; }; 22 | A10009A01DB0313200C761CC /* style.json in Resources */ = {isa = PBXBuildFile; fileRef = A10009911DB02D8D00C761CC /* style.json */; }; 23 | A104CE3F1D57E9D200626F2A /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE3E1D57E9D200626F2A /* StringExtensions.swift */; }; 24 | A104CE431D580D6A00626F2A /* ColorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE421D580D6A00626F2A /* ColorExtensions.swift */; }; 25 | A10FD69E1D53FA2600341EDD /* StyleKit.h in Headers */ = {isa = PBXBuildFile; fileRef = A10FD69D1D53FA2600341EDD /* StyleKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26 | A10FD6A51D53FA2600341EDD /* StyleKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A10FD69A1D53FA2600341EDD /* StyleKit.framework */; }; 27 | A10FD6AA1D53FA2600341EDD /* JSONLoadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10FD6A91D53FA2600341EDD /* JSONLoadTests.swift */; }; 28 | A10FD6BF1D55357400341EDD /* FileLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10FD6BE1D55357400341EDD /* FileLoader.swift */; }; 29 | A10FD6C61D556A1F00341EDD /* StyleKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10FD6C51D556A1F00341EDD /* StyleKit.swift */; }; 30 | A10FD6C81D556A9C00341EDD /* Stylist.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10FD6C71D556A9C00341EDD /* Stylist.swift */; }; 31 | A155AE911D5A9A8700C1BC28 /* HelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A155AE901D5A9A8700C1BC28 /* HelperTests.swift */; }; 32 | A1C5156B1D5A7DC00016BF1E /* success-style.json in Resources */ = {isa = PBXBuildFile; fileRef = A1C5156A1D5A7DC00016BF1E /* success-style.json */; }; 33 | A1C5156D1D5A7DE20016BF1E /* fail-style.json in Resources */ = {isa = PBXBuildFile; fileRef = A1C5156C1D5A7DE20016BF1E /* fail-style.json */; }; 34 | A1C5E1291DAAF1BB0026464A /* StyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C5E1281DAAF1BB0026464A /* StyleTests.swift */; }; 35 | A1D8B1221D57C28A00355807 /* StyleParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1D8B1211D57C28A00355807 /* StyleParser.swift */; }; 36 | A1E4676E1D59494C003B1AB2 /* SKLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1E4676D1D59494C003B1AB2 /* SKLogger.swift */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXContainerItemProxy section */ 40 | A100098E1DB02B1A00C761CC /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = A10FD6911D53FA2600341EDD /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = A100097B1DB02AF300C761CC; 45 | remoteInfo = StyleKitTestsApp; 46 | }; 47 | A10FD6A61D53FA2600341EDD /* PBXContainerItemProxy */ = { 48 | isa = PBXContainerItemProxy; 49 | containerPortal = A10FD6911D53FA2600341EDD /* Project object */; 50 | proxyType = 1; 51 | remoteGlobalIDString = A10FD6991D53FA2600341EDD; 52 | remoteInfo = StyleKit; 53 | }; 54 | /* End PBXContainerItemProxy section */ 55 | 56 | /* Begin PBXFileReference section */ 57 | 059932D81D59E09D0085E522 /* SKTryCatch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SKTryCatch.h; sourceTree = ""; }; 58 | 059932DB1D59E0DF0085E522 /* SKTryCatch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKTryCatch.m; sourceTree = ""; }; 59 | 992723711D5B36D700B74CDD /* UIAppearance+Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAppearance+Swift.h"; sourceTree = ""; }; 60 | 992723721D5B36D700B74CDD /* UIAppearance+Swift.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAppearance+Swift.m"; sourceTree = ""; }; 61 | 996775981D5A2E8E005DA08A /* StyleParsable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyleParsable.swift; sourceTree = ""; }; 62 | 9967759C1D5A3607005DA08A /* FontHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontHelper.swift; sourceTree = ""; }; 63 | 9967759E1D5A3691005DA08A /* ColorHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorHelper.swift; sourceTree = ""; }; 64 | 996775A01D5A38E8005DA08A /* ControlStateHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlStateHelper.swift; sourceTree = ""; }; 65 | A100097C1DB02AF300C761CC /* StyleKitTestsHost.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StyleKitTestsHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | A100097E1DB02AF300C761CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 67 | A100098A1DB02AF300C761CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | A10009911DB02D8D00C761CC /* style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = style.json; path = Style/style.json; sourceTree = ""; }; 69 | A10009931DB02D9D00C761CC /* SKLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SKLabel.swift; sourceTree = ""; }; 70 | A10009941DB02D9D00C761CC /* SKView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SKView.swift; sourceTree = ""; }; 71 | A10009951DB02D9D00C761CC /* SKButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SKButton.swift; sourceTree = ""; }; 72 | A104CE3E1D57E9D200626F2A /* StringExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = ""; }; 73 | A104CE421D580D6A00626F2A /* ColorExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorExtensions.swift; sourceTree = ""; }; 74 | A10FD69A1D53FA2600341EDD /* StyleKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StyleKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 75 | A10FD69D1D53FA2600341EDD /* StyleKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StyleKit.h; sourceTree = ""; }; 76 | A10FD69F1D53FA2600341EDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 77 | A10FD6A41D53FA2600341EDD /* StyleKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StyleKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 78 | A10FD6A91D53FA2600341EDD /* JSONLoadTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONLoadTests.swift; sourceTree = ""; }; 79 | A10FD6AB1D53FA2600341EDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 80 | A10FD6BE1D55357400341EDD /* FileLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileLoader.swift; sourceTree = ""; }; 81 | A10FD6C51D556A1F00341EDD /* StyleKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyleKit.swift; sourceTree = ""; }; 82 | A10FD6C71D556A9C00341EDD /* Stylist.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stylist.swift; sourceTree = ""; }; 83 | A155AE901D5A9A8700C1BC28 /* HelperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HelperTests.swift; sourceTree = ""; }; 84 | A1C5156A1D5A7DC00016BF1E /* success-style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "success-style.json"; path = "Style/success-style.json"; sourceTree = ""; }; 85 | A1C5156C1D5A7DE20016BF1E /* fail-style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "fail-style.json"; path = "Style/fail-style.json"; sourceTree = ""; }; 86 | A1C5E1281DAAF1BB0026464A /* StyleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyleTests.swift; sourceTree = ""; }; 87 | A1D8B1211D57C28A00355807 /* StyleParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyleParser.swift; sourceTree = ""; }; 88 | A1E4676D1D59494C003B1AB2 /* SKLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SKLogger.swift; sourceTree = ""; }; 89 | /* End PBXFileReference section */ 90 | 91 | /* Begin PBXFrameworksBuildPhase section */ 92 | A10009791DB02AF300C761CC /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | A10FD6961D53FA2600341EDD /* Frameworks */ = { 100 | isa = PBXFrameworksBuildPhase; 101 | buildActionMask = 2147483647; 102 | files = ( 103 | ); 104 | runOnlyForDeploymentPostprocessing = 0; 105 | }; 106 | A10FD6A11D53FA2600341EDD /* Frameworks */ = { 107 | isa = PBXFrameworksBuildPhase; 108 | buildActionMask = 2147483647; 109 | files = ( 110 | A10FD6A51D53FA2600341EDD /* StyleKit.framework in Frameworks */, 111 | ); 112 | runOnlyForDeploymentPostprocessing = 0; 113 | }; 114 | /* End PBXFrameworksBuildPhase section */ 115 | 116 | /* Begin PBXGroup section */ 117 | A100097D1DB02AF300C761CC /* StyleKitTestsHost */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | A100097E1DB02AF300C761CC /* AppDelegate.swift */, 121 | A100098A1DB02AF300C761CC /* Info.plist */, 122 | ); 123 | path = StyleKitTestsHost; 124 | sourceTree = ""; 125 | }; 126 | A10FD6901D53FA2600341EDD = { 127 | isa = PBXGroup; 128 | children = ( 129 | A10FD69B1D53FA2600341EDD /* Products */, 130 | A10FD69C1D53FA2600341EDD /* StyleKit */, 131 | A10FD6A81D53FA2600341EDD /* StyleKitTests */, 132 | ); 133 | sourceTree = ""; 134 | }; 135 | A10FD69B1D53FA2600341EDD /* Products */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | A10FD69A1D53FA2600341EDD /* StyleKit.framework */, 139 | A10FD6A41D53FA2600341EDD /* StyleKitTests.xctest */, 140 | A100097C1DB02AF300C761CC /* StyleKitTestsHost.app */, 141 | ); 142 | name = Products; 143 | sourceTree = ""; 144 | }; 145 | A10FD69C1D53FA2600341EDD /* StyleKit */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | A10FD6C01D55376600341EDD /* Helpers */, 149 | A1D8B11C1D57BD8900355807 /* Utilities */, 150 | A10FD6BE1D55357400341EDD /* FileLoader.swift */, 151 | A10FD6C51D556A1F00341EDD /* StyleKit.swift */, 152 | 996775981D5A2E8E005DA08A /* StyleParsable.swift */, 153 | A1D8B1211D57C28A00355807 /* StyleParser.swift */, 154 | A10FD6C71D556A9C00341EDD /* Stylist.swift */, 155 | A10FD69D1D53FA2600341EDD /* StyleKit.h */, 156 | A10FD69F1D53FA2600341EDD /* Info.plist */, 157 | ); 158 | path = StyleKit; 159 | sourceTree = ""; 160 | }; 161 | A10FD6A81D53FA2600341EDD /* StyleKitTests */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | A100097D1DB02AF300C761CC /* StyleKitTestsHost */, 165 | A1C5E1231DA91B7C0026464A /* UI Extensions */, 166 | A1C515691D5A7D2B0016BF1E /* Style */, 167 | A1C5E1281DAAF1BB0026464A /* StyleTests.swift */, 168 | A10FD6A91D53FA2600341EDD /* JSONLoadTests.swift */, 169 | A155AE901D5A9A8700C1BC28 /* HelperTests.swift */, 170 | A10FD6AB1D53FA2600341EDD /* Info.plist */, 171 | ); 172 | path = StyleKitTests; 173 | sourceTree = ""; 174 | }; 175 | A10FD6C01D55376600341EDD /* Helpers */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 9967759E1D5A3691005DA08A /* ColorHelper.swift */, 179 | 996775A01D5A38E8005DA08A /* ControlStateHelper.swift */, 180 | 9967759C1D5A3607005DA08A /* FontHelper.swift */, 181 | ); 182 | path = Helpers; 183 | sourceTree = ""; 184 | }; 185 | A1C515691D5A7D2B0016BF1E /* Style */ = { 186 | isa = PBXGroup; 187 | children = ( 188 | A1C5156A1D5A7DC00016BF1E /* success-style.json */, 189 | A1C5156C1D5A7DE20016BF1E /* fail-style.json */, 190 | A10009911DB02D8D00C761CC /* style.json */, 191 | ); 192 | name = Style; 193 | sourceTree = ""; 194 | }; 195 | A1C5E1231DA91B7C0026464A /* UI Extensions */ = { 196 | isa = PBXGroup; 197 | children = ( 198 | A10009931DB02D9D00C761CC /* SKLabel.swift */, 199 | A10009941DB02D9D00C761CC /* SKView.swift */, 200 | A10009951DB02D9D00C761CC /* SKButton.swift */, 201 | ); 202 | path = "UI Extensions"; 203 | sourceTree = ""; 204 | }; 205 | A1D8B11C1D57BD8900355807 /* Utilities */ = { 206 | isa = PBXGroup; 207 | children = ( 208 | 992723711D5B36D700B74CDD /* UIAppearance+Swift.h */, 209 | 992723721D5B36D700B74CDD /* UIAppearance+Swift.m */, 210 | A104CE421D580D6A00626F2A /* ColorExtensions.swift */, 211 | A1E4676D1D59494C003B1AB2 /* SKLogger.swift */, 212 | A104CE3E1D57E9D200626F2A /* StringExtensions.swift */, 213 | 059932D81D59E09D0085E522 /* SKTryCatch.h */, 214 | 059932DB1D59E0DF0085E522 /* SKTryCatch.m */, 215 | ); 216 | path = Utilities; 217 | sourceTree = ""; 218 | }; 219 | /* End PBXGroup section */ 220 | 221 | /* Begin PBXHeadersBuildPhase section */ 222 | A10FD6971D53FA2600341EDD /* Headers */ = { 223 | isa = PBXHeadersBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 059932DD1D59E1950085E522 /* SKTryCatch.h in Headers */, 227 | 992723731D5B36D700B74CDD /* UIAppearance+Swift.h in Headers */, 228 | A10FD69E1D53FA2600341EDD /* StyleKit.h in Headers */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXHeadersBuildPhase section */ 233 | 234 | /* Begin PBXNativeTarget section */ 235 | A100097B1DB02AF300C761CC /* StyleKitTestsHost */ = { 236 | isa = PBXNativeTarget; 237 | buildConfigurationList = A100098D1DB02AF300C761CC /* Build configuration list for PBXNativeTarget "StyleKitTestsHost" */; 238 | buildPhases = ( 239 | A10009781DB02AF300C761CC /* Sources */, 240 | A10009791DB02AF300C761CC /* Frameworks */, 241 | A100097A1DB02AF300C761CC /* Resources */, 242 | ); 243 | buildRules = ( 244 | ); 245 | dependencies = ( 246 | ); 247 | name = StyleKitTestsHost; 248 | productName = StyleKitTestsApp; 249 | productReference = A100097C1DB02AF300C761CC /* StyleKitTestsHost.app */; 250 | productType = "com.apple.product-type.application"; 251 | }; 252 | A10FD6991D53FA2600341EDD /* StyleKit */ = { 253 | isa = PBXNativeTarget; 254 | buildConfigurationList = A10FD6AE1D53FA2600341EDD /* Build configuration list for PBXNativeTarget "StyleKit" */; 255 | buildPhases = ( 256 | A10FD6951D53FA2600341EDD /* Sources */, 257 | A10FD6961D53FA2600341EDD /* Frameworks */, 258 | A10FD6971D53FA2600341EDD /* Headers */, 259 | A10FD6981D53FA2600341EDD /* Resources */, 260 | ); 261 | buildRules = ( 262 | ); 263 | dependencies = ( 264 | ); 265 | name = StyleKit; 266 | productName = StyleKit; 267 | productReference = A10FD69A1D53FA2600341EDD /* StyleKit.framework */; 268 | productType = "com.apple.product-type.framework"; 269 | }; 270 | A10FD6A31D53FA2600341EDD /* StyleKitTests */ = { 271 | isa = PBXNativeTarget; 272 | buildConfigurationList = A10FD6B11D53FA2600341EDD /* Build configuration list for PBXNativeTarget "StyleKitTests" */; 273 | buildPhases = ( 274 | A10FD6A01D53FA2600341EDD /* Sources */, 275 | A10FD6A11D53FA2600341EDD /* Frameworks */, 276 | A10FD6A21D53FA2600341EDD /* Resources */, 277 | ); 278 | buildRules = ( 279 | ); 280 | dependencies = ( 281 | A10FD6A71D53FA2600341EDD /* PBXTargetDependency */, 282 | A100098F1DB02B1A00C761CC /* PBXTargetDependency */, 283 | ); 284 | name = StyleKitTests; 285 | productName = StyleKitTests; 286 | productReference = A10FD6A41D53FA2600341EDD /* StyleKitTests.xctest */; 287 | productType = "com.apple.product-type.bundle.unit-test"; 288 | }; 289 | /* End PBXNativeTarget section */ 290 | 291 | /* Begin PBXProject section */ 292 | A10FD6911D53FA2600341EDD /* Project object */ = { 293 | isa = PBXProject; 294 | attributes = { 295 | LastSwiftUpdateCheck = 0800; 296 | LastUpgradeCheck = 0910; 297 | ORGANIZATIONNAME = "Bernard Gatt"; 298 | TargetAttributes = { 299 | A100097B1DB02AF300C761CC = { 300 | CreatedOnToolsVersion = 8.0; 301 | LastSwiftMigration = 0910; 302 | ProvisioningStyle = Automatic; 303 | }; 304 | A10FD6991D53FA2600341EDD = { 305 | CreatedOnToolsVersion = 7.3.1; 306 | LastSwiftMigration = 0910; 307 | }; 308 | A10FD6A31D53FA2600341EDD = { 309 | CreatedOnToolsVersion = 7.3.1; 310 | LastSwiftMigration = 0910; 311 | TestTargetID = A100097B1DB02AF300C761CC; 312 | }; 313 | }; 314 | }; 315 | buildConfigurationList = A10FD6941D53FA2600341EDD /* Build configuration list for PBXProject "StyleKit" */; 316 | compatibilityVersion = "Xcode 3.2"; 317 | developmentRegion = English; 318 | hasScannedForEncodings = 0; 319 | knownRegions = ( 320 | en, 321 | Base, 322 | ); 323 | mainGroup = A10FD6901D53FA2600341EDD; 324 | productRefGroup = A10FD69B1D53FA2600341EDD /* Products */; 325 | projectDirPath = ""; 326 | projectRoot = ""; 327 | targets = ( 328 | A10FD6991D53FA2600341EDD /* StyleKit */, 329 | A10FD6A31D53FA2600341EDD /* StyleKitTests */, 330 | A100097B1DB02AF300C761CC /* StyleKitTestsHost */, 331 | ); 332 | }; 333 | /* End PBXProject section */ 334 | 335 | /* Begin PBXResourcesBuildPhase section */ 336 | A100097A1DB02AF300C761CC /* Resources */ = { 337 | isa = PBXResourcesBuildPhase; 338 | buildActionMask = 2147483647; 339 | files = ( 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | }; 343 | A10FD6981D53FA2600341EDD /* Resources */ = { 344 | isa = PBXResourcesBuildPhase; 345 | buildActionMask = 2147483647; 346 | files = ( 347 | ); 348 | runOnlyForDeploymentPostprocessing = 0; 349 | }; 350 | A10FD6A21D53FA2600341EDD /* Resources */ = { 351 | isa = PBXResourcesBuildPhase; 352 | buildActionMask = 2147483647; 353 | files = ( 354 | A10009A01DB0313200C761CC /* style.json in Resources */, 355 | A1C5156B1D5A7DC00016BF1E /* success-style.json in Resources */, 356 | A1C5156D1D5A7DE20016BF1E /* fail-style.json in Resources */, 357 | ); 358 | runOnlyForDeploymentPostprocessing = 0; 359 | }; 360 | /* End PBXResourcesBuildPhase section */ 361 | 362 | /* Begin PBXSourcesBuildPhase section */ 363 | A10009781DB02AF300C761CC /* Sources */ = { 364 | isa = PBXSourcesBuildPhase; 365 | buildActionMask = 2147483647; 366 | files = ( 367 | A100097F1DB02AF300C761CC /* AppDelegate.swift in Sources */, 368 | ); 369 | runOnlyForDeploymentPostprocessing = 0; 370 | }; 371 | A10FD6951D53FA2600341EDD /* Sources */ = { 372 | isa = PBXSourcesBuildPhase; 373 | buildActionMask = 2147483647; 374 | files = ( 375 | 996775991D5A2E8E005DA08A /* StyleParsable.swift in Sources */, 376 | 996775A11D5A38E8005DA08A /* ControlStateHelper.swift in Sources */, 377 | A104CE3F1D57E9D200626F2A /* StringExtensions.swift in Sources */, 378 | A1E4676E1D59494C003B1AB2 /* SKLogger.swift in Sources */, 379 | A10FD6BF1D55357400341EDD /* FileLoader.swift in Sources */, 380 | 059932DC1D59E0DF0085E522 /* SKTryCatch.m in Sources */, 381 | A10FD6C81D556A9C00341EDD /* Stylist.swift in Sources */, 382 | A104CE431D580D6A00626F2A /* ColorExtensions.swift in Sources */, 383 | 9967759F1D5A3691005DA08A /* ColorHelper.swift in Sources */, 384 | 992723741D5B36D700B74CDD /* UIAppearance+Swift.m in Sources */, 385 | A1D8B1221D57C28A00355807 /* StyleParser.swift in Sources */, 386 | 9967759D1D5A3607005DA08A /* FontHelper.swift in Sources */, 387 | A10FD6C61D556A1F00341EDD /* StyleKit.swift in Sources */, 388 | ); 389 | runOnlyForDeploymentPostprocessing = 0; 390 | }; 391 | A10FD6A01D53FA2600341EDD /* Sources */ = { 392 | isa = PBXSourcesBuildPhase; 393 | buildActionMask = 2147483647; 394 | files = ( 395 | A10009971DB02D9D00C761CC /* SKView.swift in Sources */, 396 | A10009981DB02D9D00C761CC /* SKButton.swift in Sources */, 397 | A10FD6AA1D53FA2600341EDD /* JSONLoadTests.swift in Sources */, 398 | A1C5E1291DAAF1BB0026464A /* StyleTests.swift in Sources */, 399 | A10009961DB02D9D00C761CC /* SKLabel.swift in Sources */, 400 | A155AE911D5A9A8700C1BC28 /* HelperTests.swift in Sources */, 401 | ); 402 | runOnlyForDeploymentPostprocessing = 0; 403 | }; 404 | /* End PBXSourcesBuildPhase section */ 405 | 406 | /* Begin PBXTargetDependency section */ 407 | A100098F1DB02B1A00C761CC /* PBXTargetDependency */ = { 408 | isa = PBXTargetDependency; 409 | target = A100097B1DB02AF300C761CC /* StyleKitTestsHost */; 410 | targetProxy = A100098E1DB02B1A00C761CC /* PBXContainerItemProxy */; 411 | }; 412 | A10FD6A71D53FA2600341EDD /* PBXTargetDependency */ = { 413 | isa = PBXTargetDependency; 414 | target = A10FD6991D53FA2600341EDD /* StyleKit */; 415 | targetProxy = A10FD6A61D53FA2600341EDD /* PBXContainerItemProxy */; 416 | }; 417 | /* End PBXTargetDependency section */ 418 | 419 | /* Begin XCBuildConfiguration section */ 420 | A100098B1DB02AF300C761CC /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 424 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 425 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 426 | INFOPLIST_FILE = "$(SRCROOT)/StyleKitTests/StyleKitTestsHost/Info.plist"; 427 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 429 | PRODUCT_BUNDLE_IDENTIFIER = OneFourSixBC.StyleKitTestsHost; 430 | PRODUCT_NAME = "$(TARGET_NAME)"; 431 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 432 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 433 | SWIFT_VERSION = 4.0; 434 | }; 435 | name = Debug; 436 | }; 437 | A100098C1DB02AF300C761CC /* Release */ = { 438 | isa = XCBuildConfiguration; 439 | buildSettings = { 440 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 441 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 442 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 443 | INFOPLIST_FILE = "$(SRCROOT)/StyleKitTests/StyleKitTestsHost/Info.plist"; 444 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 446 | PRODUCT_BUNDLE_IDENTIFIER = OneFourSixBC.StyleKitTestsHost; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 449 | SWIFT_VERSION = 4.0; 450 | }; 451 | name = Release; 452 | }; 453 | A10FD6AC1D53FA2600341EDD /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ALWAYS_SEARCH_USER_PATHS = NO; 457 | CLANG_ANALYZER_NONNULL = YES; 458 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 459 | CLANG_CXX_LIBRARY = "libc++"; 460 | CLANG_ENABLE_MODULES = YES; 461 | CLANG_ENABLE_OBJC_ARC = YES; 462 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 463 | CLANG_WARN_BOOL_CONVERSION = YES; 464 | CLANG_WARN_COMMA = YES; 465 | CLANG_WARN_CONSTANT_CONVERSION = YES; 466 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 467 | CLANG_WARN_EMPTY_BODY = YES; 468 | CLANG_WARN_ENUM_CONVERSION = YES; 469 | CLANG_WARN_INFINITE_RECURSION = YES; 470 | CLANG_WARN_INT_CONVERSION = YES; 471 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 472 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 473 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 474 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 475 | CLANG_WARN_STRICT_PROTOTYPES = YES; 476 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 477 | CLANG_WARN_UNREACHABLE_CODE = YES; 478 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 479 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 480 | COPY_PHASE_STRIP = NO; 481 | CURRENT_PROJECT_VERSION = 1; 482 | DEBUG_INFORMATION_FORMAT = dwarf; 483 | ENABLE_STRICT_OBJC_MSGSEND = YES; 484 | ENABLE_TESTABILITY = YES; 485 | GCC_C_LANGUAGE_STANDARD = gnu99; 486 | GCC_DYNAMIC_NO_PIC = NO; 487 | GCC_NO_COMMON_BLOCKS = YES; 488 | GCC_OPTIMIZATION_LEVEL = 0; 489 | GCC_PREPROCESSOR_DEFINITIONS = ( 490 | "DEBUG=1", 491 | "$(inherited)", 492 | ); 493 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 494 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 495 | GCC_WARN_UNDECLARED_SELECTOR = YES; 496 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 497 | GCC_WARN_UNUSED_FUNCTION = YES; 498 | GCC_WARN_UNUSED_VARIABLE = YES; 499 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 500 | MTL_ENABLE_DEBUG_INFO = YES; 501 | ONLY_ACTIVE_ARCH = YES; 502 | OTHER_SWIFT_FLAGS = "-D DEBUG"; 503 | SDKROOT = iphoneos; 504 | SWIFT_OBJC_BRIDGING_HEADER = ""; 505 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 506 | SWIFT_VERSION = 3.0; 507 | TARGETED_DEVICE_FAMILY = "1,2"; 508 | VERSIONING_SYSTEM = "apple-generic"; 509 | VERSION_INFO_PREFIX = ""; 510 | }; 511 | name = Debug; 512 | }; 513 | A10FD6AD1D53FA2600341EDD /* Release */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ALWAYS_SEARCH_USER_PATHS = NO; 517 | CLANG_ANALYZER_NONNULL = YES; 518 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 519 | CLANG_CXX_LIBRARY = "libc++"; 520 | CLANG_ENABLE_MODULES = YES; 521 | CLANG_ENABLE_OBJC_ARC = YES; 522 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 523 | CLANG_WARN_BOOL_CONVERSION = YES; 524 | CLANG_WARN_COMMA = YES; 525 | CLANG_WARN_CONSTANT_CONVERSION = YES; 526 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 527 | CLANG_WARN_EMPTY_BODY = YES; 528 | CLANG_WARN_ENUM_CONVERSION = YES; 529 | CLANG_WARN_INFINITE_RECURSION = YES; 530 | CLANG_WARN_INT_CONVERSION = YES; 531 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 532 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 533 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 534 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 535 | CLANG_WARN_STRICT_PROTOTYPES = YES; 536 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 537 | CLANG_WARN_UNREACHABLE_CODE = YES; 538 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 539 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 540 | COPY_PHASE_STRIP = NO; 541 | CURRENT_PROJECT_VERSION = 1; 542 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 543 | ENABLE_NS_ASSERTIONS = NO; 544 | ENABLE_STRICT_OBJC_MSGSEND = YES; 545 | GCC_C_LANGUAGE_STANDARD = gnu99; 546 | GCC_NO_COMMON_BLOCKS = YES; 547 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 548 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 549 | GCC_WARN_UNDECLARED_SELECTOR = YES; 550 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 551 | GCC_WARN_UNUSED_FUNCTION = YES; 552 | GCC_WARN_UNUSED_VARIABLE = YES; 553 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 554 | MTL_ENABLE_DEBUG_INFO = NO; 555 | SDKROOT = iphoneos; 556 | SWIFT_OBJC_BRIDGING_HEADER = ""; 557 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 558 | SWIFT_VERSION = 3.0; 559 | TARGETED_DEVICE_FAMILY = "1,2"; 560 | VALIDATE_PRODUCT = YES; 561 | VERSIONING_SYSTEM = "apple-generic"; 562 | VERSION_INFO_PREFIX = ""; 563 | }; 564 | name = Release; 565 | }; 566 | A10FD6AF1D53FA2600341EDD /* Debug */ = { 567 | isa = XCBuildConfiguration; 568 | buildSettings = { 569 | ALWAYS_SEARCH_USER_PATHS = NO; 570 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; 571 | CLANG_ENABLE_MODULES = YES; 572 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 573 | DEFINES_MODULE = YES; 574 | DYLIB_COMPATIBILITY_VERSION = 1; 575 | DYLIB_CURRENT_VERSION = 1; 576 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 577 | INFOPLIST_FILE = StyleKit/Info.plist; 578 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 579 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 580 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 581 | OTHER_SWIFT_FLAGS = ""; 582 | PRODUCT_BUNDLE_IDENTIFIER = OneFourSixBC.StyleKit; 583 | PRODUCT_NAME = "$(TARGET_NAME)"; 584 | SKIP_INSTALL = YES; 585 | SWIFT_OBJC_BRIDGING_HEADER = ""; 586 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 587 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 588 | SWIFT_VERSION = 4.0; 589 | }; 590 | name = Debug; 591 | }; 592 | A10FD6B01D53FA2600341EDD /* Release */ = { 593 | isa = XCBuildConfiguration; 594 | buildSettings = { 595 | ALWAYS_SEARCH_USER_PATHS = NO; 596 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; 597 | CLANG_ENABLE_MODULES = YES; 598 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 599 | DEFINES_MODULE = YES; 600 | DYLIB_COMPATIBILITY_VERSION = 1; 601 | DYLIB_CURRENT_VERSION = 1; 602 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 603 | INFOPLIST_FILE = StyleKit/Info.plist; 604 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 605 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 606 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 607 | PRODUCT_BUNDLE_IDENTIFIER = OneFourSixBC.StyleKit; 608 | PRODUCT_NAME = "$(TARGET_NAME)"; 609 | SKIP_INSTALL = YES; 610 | SWIFT_OBJC_BRIDGING_HEADER = ""; 611 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 612 | SWIFT_VERSION = 4.0; 613 | }; 614 | name = Release; 615 | }; 616 | A10FD6B21D53FA2600341EDD /* Debug */ = { 617 | isa = XCBuildConfiguration; 618 | buildSettings = { 619 | DEVELOPMENT_TEAM = ""; 620 | INFOPLIST_FILE = StyleKitTests/Info.plist; 621 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 622 | PRODUCT_BUNDLE_IDENTIFIER = BernardGatt.StyleKitTests; 623 | PRODUCT_NAME = "$(TARGET_NAME)"; 624 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 625 | SWIFT_VERSION = 4.0; 626 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StyleKitTestsHost.app/StyleKitTestsHost"; 627 | }; 628 | name = Debug; 629 | }; 630 | A10FD6B31D53FA2600341EDD /* Release */ = { 631 | isa = XCBuildConfiguration; 632 | buildSettings = { 633 | DEVELOPMENT_TEAM = ""; 634 | INFOPLIST_FILE = StyleKitTests/Info.plist; 635 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 636 | PRODUCT_BUNDLE_IDENTIFIER = BernardGatt.StyleKitTests; 637 | PRODUCT_NAME = "$(TARGET_NAME)"; 638 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 639 | SWIFT_VERSION = 4.0; 640 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/StyleKitTestsHost.app/StyleKitTestsHost"; 641 | }; 642 | name = Release; 643 | }; 644 | /* End XCBuildConfiguration section */ 645 | 646 | /* Begin XCConfigurationList section */ 647 | A100098D1DB02AF300C761CC /* Build configuration list for PBXNativeTarget "StyleKitTestsHost" */ = { 648 | isa = XCConfigurationList; 649 | buildConfigurations = ( 650 | A100098B1DB02AF300C761CC /* Debug */, 651 | A100098C1DB02AF300C761CC /* Release */, 652 | ); 653 | defaultConfigurationIsVisible = 0; 654 | defaultConfigurationName = Release; 655 | }; 656 | A10FD6941D53FA2600341EDD /* Build configuration list for PBXProject "StyleKit" */ = { 657 | isa = XCConfigurationList; 658 | buildConfigurations = ( 659 | A10FD6AC1D53FA2600341EDD /* Debug */, 660 | A10FD6AD1D53FA2600341EDD /* Release */, 661 | ); 662 | defaultConfigurationIsVisible = 0; 663 | defaultConfigurationName = Release; 664 | }; 665 | A10FD6AE1D53FA2600341EDD /* Build configuration list for PBXNativeTarget "StyleKit" */ = { 666 | isa = XCConfigurationList; 667 | buildConfigurations = ( 668 | A10FD6AF1D53FA2600341EDD /* Debug */, 669 | A10FD6B01D53FA2600341EDD /* Release */, 670 | ); 671 | defaultConfigurationIsVisible = 0; 672 | defaultConfigurationName = Release; 673 | }; 674 | A10FD6B11D53FA2600341EDD /* Build configuration list for PBXNativeTarget "StyleKitTests" */ = { 675 | isa = XCConfigurationList; 676 | buildConfigurations = ( 677 | A10FD6B21D53FA2600341EDD /* Debug */, 678 | A10FD6B31D53FA2600341EDD /* Release */, 679 | ); 680 | defaultConfigurationIsVisible = 0; 681 | defaultConfigurationName = Release; 682 | }; 683 | /* End XCConfigurationList section */ 684 | }; 685 | rootObject = A10FD6911D53FA2600341EDD /* Project object */; 686 | } 687 | -------------------------------------------------------------------------------- /StyleKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /StyleKit.xcodeproj/xcshareddata/xcschemes/StyleKit.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 66 | 67 | 73 | 74 | 75 | 76 | 77 | 78 | 84 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /StyleKit.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /StyleKit/FileLoader.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class FileLoader { 4 | 5 | private let jsonFile: URL 6 | 7 | init(fileUrl: URL) { 8 | self.jsonFile = fileUrl 9 | } 10 | 11 | func load() -> [String:AnyObject]? { 12 | if let data = try? Data(contentsOf: jsonFile) { 13 | do { 14 | let contents = try JSONSerialization.jsonObject(with: data, options: .allowFragments) 15 | if let dictionary = contents as? [String: AnyObject] { 16 | return dictionary 17 | } 18 | } catch { 19 | SKLogger.severe("Issue parsing StyleKit JSON file: \(self.jsonFile)" ) 20 | } 21 | } 22 | return nil 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /StyleKit/Helpers/ColorHelper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct ColorHelper { 4 | 5 | public static func parseColor(_ color: String) -> UIColor? { 6 | 7 | do { 8 | let colorRegex = try NSRegularExpression(pattern: "^#[0-9a-f]{8}|#[0-9a-f]{6}|#[0-9a-f]{3}$", options: .caseInsensitive) 9 | let validColor = colorRegex.firstMatch(in: color, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, color.count)) != nil 10 | if validColor { 11 | return UIColor(hexString: color) 12 | } else { 13 | return nil 14 | } 15 | } catch { 16 | return nil 17 | } 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /StyleKit/Helpers/ControlStateHelper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct ControlStateHelper { 4 | 5 | static func parseControlState(_ state: String) -> UInt { 6 | 7 | switch state { 8 | case "normal": return UIControlState().rawValue 9 | case "highlighted": return UIControlState.highlighted.rawValue 10 | case "disabled": return UIControlState.disabled.rawValue 11 | case "selected": return UIControlState.selected.rawValue 12 | case "focused": 13 | if #available(iOS 9.0, *) { return UIControlState.focused.rawValue } 14 | else { return UIControlState.highlighted.rawValue } 15 | case "application": return UIControlState.application.rawValue 16 | case "reserved": return UIControlState.reserved.rawValue 17 | default: return UIControlState().rawValue 18 | } 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /StyleKit/Helpers/FontHelper.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct FontHelper { 4 | 5 | public static func parseFont(_ font: String) -> UIFont? { 6 | 7 | let fontString = font.components(separatedBy: ":") 8 | if let size = NumberFormatter().number(from: fontString.last!) as? CGFloat { 9 | if fontString.count == 2 { 10 | if let font = UIFont(name: fontString.first!, size: size) { 11 | return font 12 | } else { 13 | SKLogger.error("Font \(font) not found, using system font.") 14 | return UIFont.systemFont(ofSize: size) 15 | } 16 | } else { 17 | return nil 18 | } 19 | } else { 20 | return nil 21 | } 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /StyleKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.7.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /StyleKit/StyleKit.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "SKTryCatch.h" 3 | #import "UIAppearance+Swift.h" 4 | 5 | //! Project version number for StyleKit. 6 | FOUNDATION_EXPORT double StyleKitVersionNumber; 7 | 8 | //! Project version string for StyleKit. 9 | FOUNDATION_EXPORT const unsigned char StyleKitVersionString[]; 10 | 11 | // In this header, you should import all the public headers of your framework using statements like #import 12 | -------------------------------------------------------------------------------- /StyleKit/StyleKit.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class StyleKit { 4 | 5 | let stylist: Stylist 6 | 7 | public init?(fileUrl: URL, styleParser: StyleParsable? = nil, logLevel: SKLogLevel = .error) { 8 | let log = SKLogger.defaultInstance() 9 | log.setup(logLevel, 10 | showLogIdentifier: false, 11 | showFunctionName: true, 12 | showThreadName: true, 13 | showSKLogLevel: true, 14 | showFileNames: true, 15 | showLineNumbers: true, 16 | showDate: false) 17 | 18 | let fileLoader = FileLoader.init(fileUrl: fileUrl) 19 | if let data = fileLoader.load() { 20 | self.stylist = Stylist.init(data: data, styleParser: styleParser) 21 | } else { 22 | return nil 23 | } 24 | } 25 | 26 | public func apply() { 27 | self.stylist.apply() 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /StyleKit/StyleParsable.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public protocol StyleParsable { 4 | 5 | func getStyle(forName name: String, value: AnyObject) -> AnyObject 6 | 7 | } -------------------------------------------------------------------------------- /StyleKit/StyleParser.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class StyleParser: StyleParsable { 4 | 5 | func getStyle(forName name: String, value: AnyObject) -> AnyObject { 6 | 7 | if let value = value as? String { 8 | if let font = FontHelper.parseFont(value) { 9 | return font 10 | } else if let color = ColorHelper.parseColor(value) { 11 | return color 12 | } 13 | } 14 | return value 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /StyleKit/Stylist.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class Stylist { 4 | 5 | typealias Style = [String:AnyObject] 6 | typealias setValueForControlState = @convention(c) (AnyObject, Selector, AnyObject, UInt) -> Void 7 | 8 | let data: Style 9 | let aliases: Style 10 | let styleParser: StyleParsable 11 | var currentComponent: AnyClass? 12 | var viewStack = [UIAppearanceContainer.Type]() 13 | 14 | init(data: Style, styleParser: StyleParsable?) { 15 | self.styleParser = styleParser ?? StyleParser() 16 | 17 | var tmpAlias = Style() 18 | var tmpData = Style() 19 | 20 | for (key, value) in data { 21 | if key.hasPrefix("@") { 22 | tmpAlias[key] = value 23 | } else { 24 | tmpData[key] = value 25 | } 26 | } 27 | 28 | self.data = tmpData 29 | self.aliases = tmpAlias 30 | } 31 | 32 | func apply() { 33 | SKTryCatch.try( { 34 | self.validateAndApply(self.data) 35 | }, catch: { exception in 36 | SKLogger.severe("There was an error while applying styles: \(exception.debugDescription)") 37 | }, finallyBlock: nil) 38 | } 39 | 40 | private func validateAndApply(_ data: Style) { 41 | 42 | for (key, value) in data { 43 | if let value = value as? Style , NSClassFromString(key) != nil { 44 | if selectCurrentComponent(key), let appearanceContainer = self.currentComponent! as? UIAppearanceContainer.Type { 45 | viewStack.append(appearanceContainer) 46 | } 47 | validateAndApply(value) 48 | _ = viewStack.popLast() 49 | if viewStack.count > 0 { 50 | self.currentComponent = viewStack.last 51 | } 52 | } 53 | else { 54 | SKTryCatch.try( { 55 | if let currentComponent = self.currentComponent { 56 | self.applyStyle(key, object: value, currentComponent: currentComponent) 57 | } else { 58 | SKLogger.error("Style \(value) not applied on \(key) for \(self.currentComponent.debugDescription)") 59 | } 60 | }, catch: { exception in 61 | SKLogger.error("Style \(value) not applied on \(key) for \(self.currentComponent.debugDescription) Error \(exception.debugDescription)") 62 | }, finallyBlock: nil) 63 | } 64 | } 65 | } 66 | 67 | private func selectCurrentComponent(_ name: String) -> Bool { 68 | 69 | SKLogger.debug("Switching to: \(name)") 70 | 71 | guard let currentComponent = NSClassFromString(name) else { 72 | SKLogger.debug("Component \(name) cannot be selected") 73 | return false 74 | } 75 | self.currentComponent = currentComponent 76 | return true 77 | } 78 | 79 | private func applyStyle(_ name: String, object: AnyObject, currentComponent: AnyClass) { 80 | 81 | var selectorName = name 82 | let nameState = name.components(separatedBy: ":") 83 | var state: AnyObject? 84 | if nameState.count == 2 { 85 | selectorName = "\(nameState.first!):forState" 86 | state = ControlStateHelper.parseControlState(nameState.last!) as AnyObject? 87 | } else { 88 | state = nil 89 | } 90 | 91 | SKLogger.debug("Applying: \(selectorName) on level \(self.viewStack.count)") 92 | if let styles = object as? Stylist.Style { 93 | var stylesToApply = Stylist.Style() 94 | for (style, value) in styles { 95 | stylesToApply[style] = styleParser.getStyle(forName: name, value: self.getValue(value)) 96 | } 97 | callAppearanceSelector(selectorName, valueOne: stylesToApply as AnyObject?, valueTwo: state) 98 | } else { 99 | let value = styleParser.getStyle(forName: name, value: self.getValue(object)) 100 | callAppearanceSelector(selectorName, valueOne: value, valueTwo: state) 101 | } 102 | } 103 | 104 | /** 105 | Checks if the value is an alias, and if it is resolves to the correct value. 106 | Otherwise, it will return the passed value. 107 | 108 | - Parameter value: The alias name or actual value 109 | */ 110 | private func getValue(_ value: AnyObject) -> AnyObject { 111 | 112 | guard let stringValue = value as? String, stringValue.hasPrefix("@") else { 113 | return value 114 | } 115 | 116 | if let aliasValue = aliases[stringValue] { 117 | return aliasValue 118 | } else { 119 | SKLogger.error("Value declared is using Alias \(value) which has not been defined") 120 | 121 | return value 122 | } 123 | } 124 | 125 | private func callAppearanceSelector(_ selector: String, valueOne: AnyObject?, valueTwo: AnyObject?) { 126 | 127 | let modifiedSelector = "set\(selector.capitalizeFirstLetter()):" 128 | 129 | var viewStack = self.viewStack 130 | _ = viewStack.popLast() 131 | 132 | let isViewStackRelevant = viewStack.count > 0 133 | viewStack = viewStack.reversed() 134 | 135 | if valueOne == nil && valueTwo == nil { 136 | if isViewStackRelevant { 137 | if #available(iOS 9.0, *) { 138 | _ = (self.currentComponent!.appearance(whenContainedInInstancesOf: viewStack) as! NSObject).perform(Selector(modifiedSelector)) 139 | } else { 140 | _ = (self.currentComponent!.styleKitAppearanceWhenContained(within: viewStack) as! NSObject).perform(Selector(modifiedSelector)) 141 | } 142 | } else { 143 | _ = (self.currentComponent!.appearance() as! NSObject).perform(Selector(modifiedSelector)) 144 | } 145 | } else if valueOne != nil && valueTwo != nil { 146 | if isViewStackRelevant { 147 | if #available(iOS 9.0, *) { 148 | let methodSignature = (self.currentComponent!.appearance(whenContainedInInstancesOf: viewStack) as! NSObject).method(for: Selector(modifiedSelector)) 149 | let callback = unsafeBitCast(methodSignature, to: setValueForControlState.self) 150 | callback(self.currentComponent!.appearance(whenContainedInInstancesOf: viewStack), Selector(modifiedSelector), valueOne!, valueTwo as! UInt) 151 | } else { 152 | let methodSignature = (self.currentComponent!.styleKitAppearanceWhenContained(within: viewStack) as! NSObject).method(for: Selector(modifiedSelector)) 153 | let callback = unsafeBitCast(methodSignature, to: setValueForControlState.self) 154 | callback(self.currentComponent!.styleKitAppearanceWhenContained(within: viewStack), Selector(modifiedSelector), valueOne!, valueTwo as! UInt) 155 | } 156 | } else { 157 | let methodSignature = (self.currentComponent!.appearance() as! NSObject).method(for: Selector(modifiedSelector)) 158 | let callback = unsafeBitCast(methodSignature, to: setValueForControlState.self) 159 | callback(self.currentComponent!.appearance(), Selector(modifiedSelector), valueOne!, valueTwo as! UInt) 160 | } 161 | } else if valueOne != nil { 162 | if isViewStackRelevant { 163 | if #available(iOS 9.0, *) { 164 | _ = (self.currentComponent!.appearance(whenContainedInInstancesOf: viewStack) as! NSObject).perform(Selector(modifiedSelector), with: valueOne!) 165 | } else { 166 | _ = self.currentComponent!.styleKitAppearanceWhenContained(within: viewStack).perform(Selector(modifiedSelector), with: valueOne!) 167 | } 168 | } else { 169 | _ = (self.currentComponent!.appearance() as! NSObject).perform(Selector(modifiedSelector), with: valueOne!) 170 | } 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /StyleKit/Utilities/ColorExtensions.swift: -------------------------------------------------------------------------------- 1 | extension UIColor { 2 | 3 | convenience init(hexString: String) { 4 | let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) 5 | var int = UInt32() 6 | Scanner(string: hex).scanHexInt32(&int) 7 | let a, r, g, b: UInt32 8 | switch hex.count { 9 | case 3: // RGB (12-bit) 10 | (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) 11 | case 6: // RGB (24-bit) 12 | (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) 13 | case 8: // ARGB (32-bit) 14 | (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) 15 | default: 16 | (a, r, g, b) = (1, 1, 1, 0) 17 | } 18 | 19 | self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255) 20 | } 21 | 22 | func getNSForegroundColorAttribute() -> [String:UIColor] { 23 | return [NSAttributedStringKey.foregroundColor.rawValue:self] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /StyleKit/Utilities/SKLogger.swift: -------------------------------------------------------------------------------- 1 | // Inspired by XCGLogger: https://github.com/DaveWoodCom/XCGLogger 2 | // 3 | // Created by Dave Wood on 2014-06-06. 4 | // Copyright (c) 2014 Dave Wood, Cerebral Gardens. 5 | // Some rights reserved: https://github.com/DaveWoodCom/XCGLogger/blob/master/LICENSE.txt 6 | // 7 | 8 | import Foundation 9 | #if os(OSX) 10 | import AppKit 11 | #elseif os(iOS) || os(tvOS) || os(watchOS) 12 | import UIKit 13 | #endif 14 | 15 | /// Log Level 16 | public enum SKLogLevel: Int, Comparable, CustomStringConvertible { 17 | case debug 18 | case error 19 | case severe 20 | case none 21 | 22 | public var description: String { 23 | switch self { 24 | case .debug: 25 | return "Debug" 26 | case .error: 27 | return "Error" 28 | case .severe: 29 | return "Severe" 30 | case .none: 31 | return "None" 32 | } 33 | } 34 | } 35 | 36 | // Implement Comparable for SKLogLevel 37 | public func < (lhs:SKLogLevel, rhs:SKLogLevel) -> Bool { 38 | return lhs.rawValue < rhs.rawValue 39 | } 40 | 41 | 42 | // MARK: - SKLogDetails 43 | // - Data structure to hold all info about a log message, passed to log destination classes 44 | internal struct SKLogDetails { 45 | var logLevel: SKLogLevel 46 | var date: Date 47 | var logMessage: String 48 | var functionName: String 49 | var fileName: String 50 | var lineNumber: Int 51 | 52 | init(logLevel: SKLogLevel, date: Date, logMessage: String, functionName: StaticString, fileName: StaticString, lineNumber: Int) { 53 | self.logLevel = logLevel 54 | self.date = date 55 | self.logMessage = logMessage 56 | self.functionName = String(describing: functionName) 57 | self.fileName = String(describing: fileName) 58 | self.lineNumber = lineNumber 59 | } 60 | } 61 | 62 | // MARK: - SKConsoleLogDestination 63 | // - A standard log destination that outputs log details to the console 64 | internal class SKConsoleLogDestination: CustomDebugStringConvertible { 65 | // MARK: - Properties 66 | var owner: SKLogger 67 | var outputSKLogLevel: SKLogLevel = .debug 68 | 69 | var showFunctionName: Bool = true 70 | var showThreadName: Bool = false 71 | var showFileName: Bool = true 72 | var showLineNumber: Bool = true 73 | var showSKLogLevel: Bool = true 74 | var showDate: Bool = true 75 | 76 | var logQueue: DispatchQueue? = nil 77 | 78 | // MARK: - CustomDebugStringConvertible 79 | var debugDescription: String { 80 | get { 81 | return "\(extractClassName(self)): - SKLogLevel: \(outputSKLogLevel) showFunctionName: \(showFunctionName) showThreadName: \(showThreadName) showSKLogLevel: \(showSKLogLevel) showFileName: \(showFileName) showLineNumber: \(showLineNumber) showDate: \(showDate)" 82 | } 83 | } 84 | 85 | // MARK: - Life Cycle 86 | init(owner: SKLogger) { 87 | self.owner = owner 88 | } 89 | 90 | // MARK: - Methods to Process Log Details 91 | func processLogDetails(_ logDetails: SKLogDetails) { 92 | var extendedDetails: String = "" 93 | 94 | if showDate { 95 | var formattedDate: String = logDetails.date.description 96 | if let dateFormatter = owner.dateFormatter { 97 | formattedDate = dateFormatter.string(from: logDetails.date) 98 | } 99 | 100 | // extendedDetails += "\(formattedDate) " // Note: Leaks in Swift versions prior to Swift 3 101 | extendedDetails += formattedDate + " " 102 | } 103 | 104 | if showSKLogLevel { 105 | extendedDetails += "[\(logDetails.logLevel)] " 106 | } 107 | 108 | if showThreadName { 109 | if Thread.isMainThread { 110 | extendedDetails += "[main] " 111 | } 112 | else { 113 | 114 | if let threadName = Thread.current.name , !threadName.isEmpty { 115 | extendedDetails += "[" + threadName + "] " 116 | } 117 | else if let label = logQueue?.label, let queueName = String(validatingUTF8: label) , !queueName.isEmpty { 118 | extendedDetails += "[" + queueName + "] " 119 | } 120 | else { 121 | extendedDetails += "[" + String(format: "%p", Thread.current) + "] " 122 | } 123 | } 124 | } 125 | 126 | if showFileName { 127 | extendedDetails += "[" + (logDetails.fileName as NSString).lastPathComponent + (showLineNumber ? ":" + String(logDetails.lineNumber) : "") + "] " 128 | } 129 | else if showLineNumber { 130 | extendedDetails += "[" + String(logDetails.lineNumber) + "] " 131 | } 132 | 133 | if showFunctionName { 134 | // extendedDetails += "\(logDetails.functionName) " // Note: Leaks in Swift versions prior to Swift 3 135 | extendedDetails += logDetails.functionName + " " 136 | } 137 | 138 | // output(logDetails, text: "\(extendedDetails)> \(logDetails.logMessage)") // Note: Leaks in Swift versions prior to Swift 3 139 | output(logDetails, text: extendedDetails + "> " + logDetails.logMessage) 140 | } 141 | 142 | func processInternalLogDetails(_ logDetails: SKLogDetails) { 143 | var extendedDetails: String = "" 144 | 145 | if showDate { 146 | var formattedDate: String = logDetails.date.description 147 | if let dateFormatter = owner.dateFormatter { 148 | formattedDate = dateFormatter.string(from: logDetails.date) 149 | } 150 | 151 | // extendedDetails += "\(formattedDate) " // Note: Leaks in Swift versions prior to Swift 3 152 | extendedDetails += formattedDate + " " 153 | } 154 | 155 | if showSKLogLevel { 156 | extendedDetails += "[\(logDetails.logLevel)] " 157 | } 158 | 159 | // output(logDetails, text: "\(extendedDetails)> \(logDetails.logMessage)") // Note: Leaks in Swift versions prior to Swift 3 160 | output(logDetails, text: extendedDetails + "> " + logDetails.logMessage) 161 | } 162 | 163 | // MARK: - Misc methods 164 | func isEnabledForSKLogLevel (_ logLevel: SKLogLevel) -> Bool { 165 | return logLevel >= self.outputSKLogLevel 166 | } 167 | 168 | // MARK: - Output 169 | func output(_ logDetails: SKLogDetails, text: String) { 170 | let outputClosure = { 171 | print(text) 172 | } 173 | 174 | if let logQueue = logQueue { 175 | logQueue.async(execute: outputClosure) 176 | } 177 | else { 178 | outputClosure() 179 | } 180 | } 181 | } 182 | 183 | // MARK: - SKLogger 184 | // - The main logging class 185 | internal class SKLogger: CustomDebugStringConvertible { 186 | // MARK: - Constants 187 | struct Constants { 188 | static let logQueueIdentifier = "OneFourSixBC.StyleKit.xcglogger.queue" 189 | } 190 | 191 | // MARK: - Properties (Options) 192 | var outputSKLogLevel: SKLogLevel = .debug { 193 | didSet { 194 | logDestination.outputSKLogLevel = outputSKLogLevel 195 | } 196 | } 197 | 198 | // MARK: - Properties 199 | class var logQueue: DispatchQueue { 200 | struct Statics { 201 | static var logQueue = DispatchQueue(label: SKLogger.Constants.logQueueIdentifier, attributes: []) 202 | } 203 | 204 | return Statics.logQueue 205 | } 206 | 207 | fileprivate var _dateFormatter: DateFormatter? = nil 208 | var dateFormatter: DateFormatter? { 209 | get { 210 | if _dateFormatter != nil { 211 | return _dateFormatter 212 | } 213 | 214 | let defaultDateFormatter = DateFormatter() 215 | defaultDateFormatter.locale = Locale.current 216 | defaultDateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" 217 | _dateFormatter = defaultDateFormatter 218 | 219 | return _dateFormatter 220 | } 221 | set { 222 | _dateFormatter = newValue 223 | } 224 | } 225 | 226 | lazy var logDestination: SKConsoleLogDestination = SKConsoleLogDestination(owner: self) 227 | 228 | // MARK: - Default instance 229 | class func defaultInstance() -> SKLogger { 230 | struct Statics { 231 | static let instance: SKLogger = SKLogger() 232 | } 233 | 234 | return Statics.instance 235 | } 236 | 237 | // MARK: - Setup methods 238 | class func setup(_ logLevel: SKLogLevel = .debug, showLogIdentifier: Bool = false, showFunctionName: Bool = true, showThreadName: Bool = false, showSKLogLevel: Bool = true, showFileNames: Bool = true, showLineNumbers: Bool = true, showDate: Bool = true) { 239 | defaultInstance().setup(logLevel, showLogIdentifier: showLogIdentifier, showFunctionName: showFunctionName, showThreadName: showThreadName, showSKLogLevel: showSKLogLevel, showFileNames: showFileNames, showLineNumbers: showLineNumbers, showDate: showDate) 240 | } 241 | 242 | func setup(_ logLevel: SKLogLevel = .debug, showLogIdentifier: Bool = false, showFunctionName: Bool = true, showThreadName: Bool = false, showSKLogLevel: Bool = true, showFileNames: Bool = true, showLineNumbers: Bool = true, showDate: Bool = true) { 243 | outputSKLogLevel = logLevel; 244 | 245 | logDestination.showFunctionName = showFunctionName 246 | logDestination.showThreadName = showThreadName 247 | logDestination.showSKLogLevel = showSKLogLevel 248 | logDestination.showFileName = showFileNames 249 | logDestination.showLineNumber = showLineNumbers 250 | logDestination.showDate = showDate 251 | logDestination.outputSKLogLevel = logLevel 252 | } 253 | 254 | // MARK: - Logging methods 255 | class func logln( _ closure: @autoclosure @escaping () -> String?, logLevel: SKLogLevel = .debug, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line) { 256 | self.defaultInstance().logln(logLevel, functionName: functionName, fileName: fileName, lineNumber: lineNumber, closure: closure) 257 | } 258 | 259 | class func logln(_ logLevel: SKLogLevel = .debug, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line, closure: () -> String?) { 260 | self.defaultInstance().logln(logLevel, functionName: functionName, fileName: fileName, lineNumber: lineNumber, closure: closure) 261 | } 262 | 263 | func logln( _ closure: @autoclosure @escaping () -> String?, logLevel: SKLogLevel = .debug, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line) { 264 | self.logln(logLevel, functionName: functionName, fileName: fileName, lineNumber: lineNumber, closure: closure) 265 | } 266 | 267 | func logln(_ logLevel: SKLogLevel = .debug, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line, closure: () -> String?) { 268 | var logDetails: SKLogDetails! 269 | 270 | guard logDestination.isEnabledForSKLogLevel(logLevel) else { 271 | return 272 | } 273 | 274 | if logDetails == nil { 275 | guard let logMessage = closure() else { 276 | return 277 | } 278 | 279 | logDetails = SKLogDetails(logLevel: logLevel, date: Date(), logMessage: logMessage, functionName: functionName, fileName: fileName, lineNumber: lineNumber) 280 | } 281 | 282 | logDestination.processLogDetails(logDetails) 283 | 284 | } 285 | 286 | class func exec(_ logLevel: SKLogLevel = .debug, closure: () -> () = {}) { 287 | self.defaultInstance().exec(logLevel, closure: closure) 288 | } 289 | 290 | func exec(_ logLevel: SKLogLevel = .debug, closure: () -> () = {}) { 291 | guard isEnabledForSKLogLevel(logLevel) else { 292 | return 293 | } 294 | closure() 295 | } 296 | 297 | // MARK: * Debug 298 | class func debug( _ closure: @autoclosure @escaping () -> String?, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line) { 299 | self.defaultInstance().logln(.debug, functionName: functionName, fileName: fileName, lineNumber: lineNumber, closure: closure) 300 | } 301 | 302 | 303 | // MARK: * Error 304 | class func error( _ closure: @autoclosure @escaping () -> String?, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line) { 305 | self.defaultInstance().logln(.error, functionName: functionName, fileName: fileName, lineNumber: lineNumber, closure: closure) 306 | } 307 | 308 | // MARK: * Severe 309 | class func severe( _ closure: @autoclosure @escaping () -> String?, functionName: StaticString = #function, fileName: StaticString = #file, lineNumber: Int = #line) { 310 | self.defaultInstance().logln(.severe, functionName: functionName, fileName: fileName, lineNumber: lineNumber, closure: closure) 311 | } 312 | 313 | // MARK: * Debug 314 | class func debugExec(_ closure: () -> () = {}) { 315 | self.defaultInstance().exec(SKLogLevel.debug, closure: closure) 316 | } 317 | 318 | // MARK: * Error 319 | class func errorExec(_ closure: () -> () = {}) { 320 | self.defaultInstance().exec(SKLogLevel.error, closure: closure) 321 | } 322 | 323 | // MARK: * Severe 324 | class func severeExec(_ closure: () -> () = {}) { 325 | self.defaultInstance().exec(SKLogLevel.severe, closure: closure) 326 | } 327 | 328 | // MARK: - Misc methods 329 | func isEnabledForSKLogLevel (_ logLevel: SKLogLevel) -> Bool { 330 | return logLevel >= self.outputSKLogLevel 331 | } 332 | 333 | // MARK: - Private methods 334 | fileprivate func _logln(_ logMessage: String, logLevel: SKLogLevel = .debug) { 335 | 336 | var logDetails: SKLogDetails? = nil 337 | if (logDestination.isEnabledForSKLogLevel(logLevel)) { 338 | if logDetails == nil { 339 | logDetails = SKLogDetails(logLevel: logLevel, date: Date(), logMessage: logMessage, functionName: "", fileName: "", lineNumber: 0) 340 | } 341 | 342 | logDestination.processInternalLogDetails(logDetails!) 343 | } 344 | } 345 | 346 | 347 | // MARK: - DebugPrintable 348 | var debugDescription: String { 349 | get { 350 | var description: String = "\(extractClassName(self)): - logDestination: \r" 351 | description += "\t \(logDestination.debugDescription)\r" 352 | return description 353 | } 354 | } 355 | } 356 | 357 | func extractClassName(_ someObject: Any) -> String { 358 | return (someObject is Any.Type) ? "\(someObject)" : "\(type(of: (someObject) as AnyObject))" 359 | } 360 | -------------------------------------------------------------------------------- /StyleKit/Utilities/SKTryCatch.h: -------------------------------------------------------------------------------- 1 | #ifndef SwiftTryCatch_h 2 | #define SwiftTryCatch_h 3 | 4 | @interface SKTryCatch : NSObject 5 | 6 | /** 7 | Provides try catch functionality for swift by wrapping around Objective-C 8 | */ 9 | + (void)tryBlock:(void(^)(void))tryBlock catchBlock:(void(^)(NSException*exception))catchBlock finallyBlock:(void(^)(void))finallyBlock; 10 | + (void)throwString:(NSString*)s; 11 | + (void)throwException:(NSException*)e; 12 | @end 13 | 14 | #endif /* SwiftTryCatch_h */ 15 | -------------------------------------------------------------------------------- /StyleKit/Utilities/SKTryCatch.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "SKTryCatch.h" 3 | 4 | @implementation SKTryCatch 5 | 6 | /** 7 | Provides try catch functionality for swift by wrapping around Objective-C 8 | */ 9 | + (void)tryBlock:(void(^)(void))tryBlock catchBlock:(void(^)(NSException*exception))catchBlock finallyBlock:(void(^)(void))finallyBlock { 10 | @try { 11 | tryBlock ? tryBlock() : nil; 12 | } 13 | 14 | @catch (NSException *exception) { 15 | catchBlock ? catchBlock(exception) : nil; 16 | } 17 | @finally { 18 | finallyBlock ? finallyBlock() : nil; 19 | } 20 | } 21 | 22 | + (void)throwString:(NSString*)s 23 | { 24 | @throw [NSException exceptionWithName:s reason:s userInfo:nil]; 25 | } 26 | 27 | + (void)throwException:(NSException*)e 28 | { 29 | @throw e; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /StyleKit/Utilities/StringExtensions.swift: -------------------------------------------------------------------------------- 1 | extension String { 2 | func capitalizeFirstLetter() -> String { 3 | let first = String(prefix(1)).capitalized 4 | let other = String(dropFirst()) 5 | return first + other 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /StyleKit/Utilities/UIAppearance+Swift.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface UIView (UIAppearance_Swift) 5 | /// @param containers An array of Class 6 | + (instancetype)styleKitAppearanceWhenContainedWithin: (NSArray *)containers; 7 | @end -------------------------------------------------------------------------------- /StyleKit/Utilities/UIAppearance+Swift.m: -------------------------------------------------------------------------------- 1 | #import "UIAppearance+Swift.h" 2 | 3 | @implementation UIView (UIAppearance_Swift) 4 | 5 | + (instancetype)styleKitAppearanceWhenContainedWithin: (NSArray *)containers 6 | { 7 | //Refer to: http://stackoverflow.com/a/28765193 8 | 9 | NSUInteger count = containers.count; 10 | NSAssert(count <= 10, @"Nested style levels greater than 10 is only supported from iOS 9+"); 11 | 12 | return [self appearanceWhenContainedIn: 13 | count > 0 ? containers[0] : nil, 14 | count > 1 ? containers[1] : nil, 15 | count > 2 ? containers[2] : nil, 16 | count > 3 ? containers[3] : nil, 17 | count > 4 ? containers[4] : nil, 18 | count > 5 ? containers[5] : nil, 19 | count > 6 ? containers[6] : nil, 20 | count > 7 ? containers[7] : nil, 21 | count > 8 ? containers[8] : nil, 22 | count > 9 ? containers[9] : nil, 23 | nil]; 24 | } 25 | @end -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 059932E91D5B248F0085E522 /* StyleKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 059932E71D5B244C0085E522 /* StyleKit.framework */; }; 11 | 059932EA1D5B248F0085E522 /* StyleKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 059932E71D5B244C0085E522 /* StyleKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | A104CE041D57DCD500626F2A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE031D57DCD500626F2A /* AppDelegate.swift */; }; 13 | A104CE061D57DCD500626F2A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE051D57DCD500626F2A /* ViewController.swift */; }; 14 | A104CE091D57DCD500626F2A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A104CE071D57DCD500626F2A /* Main.storyboard */; }; 15 | A104CE0B1D57DCD500626F2A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A104CE0A1D57DCD500626F2A /* Assets.xcassets */; }; 16 | A104CE0E1D57DCD500626F2A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A104CE0C1D57DCD500626F2A /* LaunchScreen.storyboard */; }; 17 | A104CE171D57DD3300626F2A /* style.json in Resources */ = {isa = PBXBuildFile; fileRef = A104CE161D57DD3300626F2A /* style.json */; }; 18 | A104CE1A1D57E1D700626F2A /* SKView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE191D57E1D700626F2A /* SKView.swift */; }; 19 | A104CE1C1D57E22000626F2A /* SKButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE1B1D57E22000626F2A /* SKButton.swift */; }; 20 | A104CE1E1D57E23C00626F2A /* SKLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE1D1D57E23C00626F2A /* SKLabel.swift */; }; 21 | A104CE201D57E25E00626F2A /* SKTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE1F1D57E25E00626F2A /* SKTextField.swift */; }; 22 | A104CE411D57FEDB00626F2A /* SKNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104CE401D57FEDB00626F2A /* SKNavigationBar.swift */; }; 23 | A1C515681D5A72CF0016BF1E /* StyleParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C515671D5A72CF0016BF1E /* StyleParser.swift */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXCopyFilesBuildPhase section */ 27 | 059932EB1D5B248F0085E522 /* Embed Frameworks */ = { 28 | isa = PBXCopyFilesBuildPhase; 29 | buildActionMask = 2147483647; 30 | dstPath = ""; 31 | dstSubfolderSpec = 10; 32 | files = ( 33 | 059932EA1D5B248F0085E522 /* StyleKit.framework in Embed Frameworks */, 34 | ); 35 | name = "Embed Frameworks"; 36 | runOnlyForDeploymentPostprocessing = 0; 37 | }; 38 | /* End PBXCopyFilesBuildPhase section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 059932E71D5B244C0085E522 /* StyleKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = StyleKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | A104CE001D57DCD500626F2A /* StyleKitDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StyleKitDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | A104CE031D57DCD500626F2A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 44 | A104CE051D57DCD500626F2A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 45 | A104CE081D57DCD500626F2A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | A104CE0A1D57DCD500626F2A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | A104CE0D1D57DCD500626F2A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | A104CE0F1D57DCD500626F2A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | A104CE161D57DD3300626F2A /* style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = style.json; path = Style/style.json; sourceTree = ""; }; 50 | A104CE191D57E1D700626F2A /* SKView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SKView.swift; path = CustomViews/SKView.swift; sourceTree = ""; }; 51 | A104CE1B1D57E22000626F2A /* SKButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SKButton.swift; path = CustomViews/SKButton.swift; sourceTree = ""; }; 52 | A104CE1D1D57E23C00626F2A /* SKLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SKLabel.swift; path = CustomViews/SKLabel.swift; sourceTree = ""; }; 53 | A104CE1F1D57E25E00626F2A /* SKTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SKTextField.swift; path = CustomViews/SKTextField.swift; sourceTree = ""; }; 54 | A104CE401D57FEDB00626F2A /* SKNavigationBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SKNavigationBar.swift; path = CustomViews/SKNavigationBar.swift; sourceTree = ""; }; 55 | A1C515671D5A72CF0016BF1E /* StyleParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StyleParser.swift; path = Style/StyleParser.swift; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | A104CDFD1D57DCD500626F2A /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 059932E91D5B248F0085E522 /* StyleKit.framework in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | A104CDF71D57DCD500626F2A = { 71 | isa = PBXGroup; 72 | children = ( 73 | A104CE231D57E30A00626F2A /* Frameworks */, 74 | A104CE021D57DCD500626F2A /* StyleKitDemo */, 75 | A104CE011D57DCD500626F2A /* Products */, 76 | ); 77 | sourceTree = ""; 78 | }; 79 | A104CE011D57DCD500626F2A /* Products */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | A104CE001D57DCD500626F2A /* StyleKitDemo.app */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | A104CE021D57DCD500626F2A /* StyleKitDemo */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | A104CE181D57E1AB00626F2A /* CustomViews */, 91 | A104CE151D57DD0600626F2A /* Style */, 92 | A104CE031D57DCD500626F2A /* AppDelegate.swift */, 93 | A104CE051D57DCD500626F2A /* ViewController.swift */, 94 | A104CE071D57DCD500626F2A /* Main.storyboard */, 95 | A104CE0A1D57DCD500626F2A /* Assets.xcassets */, 96 | A104CE0C1D57DCD500626F2A /* LaunchScreen.storyboard */, 97 | A104CE0F1D57DCD500626F2A /* Info.plist */, 98 | ); 99 | path = StyleKitDemo; 100 | sourceTree = ""; 101 | }; 102 | A104CE151D57DD0600626F2A /* Style */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A104CE161D57DD3300626F2A /* style.json */, 106 | A1C515671D5A72CF0016BF1E /* StyleParser.swift */, 107 | ); 108 | name = Style; 109 | sourceTree = ""; 110 | }; 111 | A104CE181D57E1AB00626F2A /* CustomViews */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | A104CE191D57E1D700626F2A /* SKView.swift */, 115 | A104CE1B1D57E22000626F2A /* SKButton.swift */, 116 | A104CE1D1D57E23C00626F2A /* SKLabel.swift */, 117 | A104CE1F1D57E25E00626F2A /* SKTextField.swift */, 118 | A104CE401D57FEDB00626F2A /* SKNavigationBar.swift */, 119 | ); 120 | name = CustomViews; 121 | sourceTree = ""; 122 | }; 123 | A104CE231D57E30A00626F2A /* Frameworks */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 059932E71D5B244C0085E522 /* StyleKit.framework */, 127 | ); 128 | name = Frameworks; 129 | sourceTree = ""; 130 | }; 131 | /* End PBXGroup section */ 132 | 133 | /* Begin PBXNativeTarget section */ 134 | A104CDFF1D57DCD500626F2A /* StyleKitDemo */ = { 135 | isa = PBXNativeTarget; 136 | buildConfigurationList = A104CE121D57DCD500626F2A /* Build configuration list for PBXNativeTarget "StyleKitDemo" */; 137 | buildPhases = ( 138 | A104CDFC1D57DCD500626F2A /* Sources */, 139 | A104CDFD1D57DCD500626F2A /* Frameworks */, 140 | A104CDFE1D57DCD500626F2A /* Resources */, 141 | 059932EB1D5B248F0085E522 /* Embed Frameworks */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | ); 147 | name = StyleKitDemo; 148 | productName = StyleKitDemo; 149 | productReference = A104CE001D57DCD500626F2A /* StyleKitDemo.app */; 150 | productType = "com.apple.product-type.application"; 151 | }; 152 | /* End PBXNativeTarget section */ 153 | 154 | /* Begin PBXProject section */ 155 | A104CDF81D57DCD500626F2A /* Project object */ = { 156 | isa = PBXProject; 157 | attributes = { 158 | LastSwiftUpdateCheck = 0730; 159 | LastUpgradeCheck = 0910; 160 | ORGANIZATIONNAME = "Bernard Gatt"; 161 | TargetAttributes = { 162 | A104CDFF1D57DCD500626F2A = { 163 | CreatedOnToolsVersion = 7.3.1; 164 | LastSwiftMigration = 0910; 165 | }; 166 | }; 167 | }; 168 | buildConfigurationList = A104CDFB1D57DCD500626F2A /* Build configuration list for PBXProject "StyleKitDemo" */; 169 | compatibilityVersion = "Xcode 3.2"; 170 | developmentRegion = English; 171 | hasScannedForEncodings = 0; 172 | knownRegions = ( 173 | en, 174 | Base, 175 | ); 176 | mainGroup = A104CDF71D57DCD500626F2A; 177 | productRefGroup = A104CE011D57DCD500626F2A /* Products */; 178 | projectDirPath = ""; 179 | projectRoot = ""; 180 | targets = ( 181 | A104CDFF1D57DCD500626F2A /* StyleKitDemo */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXResourcesBuildPhase section */ 187 | A104CDFE1D57DCD500626F2A /* Resources */ = { 188 | isa = PBXResourcesBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | A104CE0E1D57DCD500626F2A /* LaunchScreen.storyboard in Resources */, 192 | A104CE0B1D57DCD500626F2A /* Assets.xcassets in Resources */, 193 | A104CE091D57DCD500626F2A /* Main.storyboard in Resources */, 194 | A104CE171D57DD3300626F2A /* style.json in Resources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXResourcesBuildPhase section */ 199 | 200 | /* Begin PBXSourcesBuildPhase section */ 201 | A104CDFC1D57DCD500626F2A /* Sources */ = { 202 | isa = PBXSourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | A104CE061D57DCD500626F2A /* ViewController.swift in Sources */, 206 | A104CE1A1D57E1D700626F2A /* SKView.swift in Sources */, 207 | A1C515681D5A72CF0016BF1E /* StyleParser.swift in Sources */, 208 | A104CE411D57FEDB00626F2A /* SKNavigationBar.swift in Sources */, 209 | A104CE041D57DCD500626F2A /* AppDelegate.swift in Sources */, 210 | A104CE1E1D57E23C00626F2A /* SKLabel.swift in Sources */, 211 | A104CE1C1D57E22000626F2A /* SKButton.swift in Sources */, 212 | A104CE201D57E25E00626F2A /* SKTextField.swift in Sources */, 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | /* End PBXSourcesBuildPhase section */ 217 | 218 | /* Begin PBXVariantGroup section */ 219 | A104CE071D57DCD500626F2A /* Main.storyboard */ = { 220 | isa = PBXVariantGroup; 221 | children = ( 222 | A104CE081D57DCD500626F2A /* Base */, 223 | ); 224 | name = Main.storyboard; 225 | sourceTree = ""; 226 | }; 227 | A104CE0C1D57DCD500626F2A /* LaunchScreen.storyboard */ = { 228 | isa = PBXVariantGroup; 229 | children = ( 230 | A104CE0D1D57DCD500626F2A /* Base */, 231 | ); 232 | name = LaunchScreen.storyboard; 233 | sourceTree = ""; 234 | }; 235 | /* End PBXVariantGroup section */ 236 | 237 | /* Begin XCBuildConfiguration section */ 238 | A104CE101D57DCD500626F2A /* Debug */ = { 239 | isa = XCBuildConfiguration; 240 | buildSettings = { 241 | ALWAYS_SEARCH_USER_PATHS = NO; 242 | CLANG_ANALYZER_NONNULL = YES; 243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 244 | CLANG_CXX_LIBRARY = "libc++"; 245 | CLANG_ENABLE_MODULES = YES; 246 | CLANG_ENABLE_OBJC_ARC = YES; 247 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 248 | CLANG_WARN_BOOL_CONVERSION = YES; 249 | CLANG_WARN_COMMA = YES; 250 | CLANG_WARN_CONSTANT_CONVERSION = YES; 251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INFINITE_RECURSION = YES; 255 | CLANG_WARN_INT_CONVERSION = YES; 256 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = 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_UNREACHABLE_CODE = YES; 263 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 264 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = dwarf; 267 | ENABLE_STRICT_OBJC_MSGSEND = YES; 268 | ENABLE_TESTABILITY = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_DYNAMIC_NO_PIC = NO; 271 | GCC_NO_COMMON_BLOCKS = YES; 272 | GCC_OPTIMIZATION_LEVEL = 0; 273 | GCC_PREPROCESSOR_DEFINITIONS = ( 274 | "DEBUG=1", 275 | "$(inherited)", 276 | ); 277 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 279 | GCC_WARN_UNDECLARED_SELECTOR = YES; 280 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 284 | MTL_ENABLE_DEBUG_INFO = YES; 285 | ONLY_ACTIVE_ARCH = YES; 286 | SDKROOT = iphoneos; 287 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 288 | SWIFT_VERSION = 3.0; 289 | TARGETED_DEVICE_FAMILY = "1,2"; 290 | }; 291 | name = Debug; 292 | }; 293 | A104CE111D57DCD500626F2A /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ALWAYS_SEARCH_USER_PATHS = NO; 297 | CLANG_ANALYZER_NONNULL = YES; 298 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 299 | CLANG_CXX_LIBRARY = "libc++"; 300 | CLANG_ENABLE_MODULES = YES; 301 | CLANG_ENABLE_OBJC_ARC = YES; 302 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 303 | CLANG_WARN_BOOL_CONVERSION = YES; 304 | CLANG_WARN_COMMA = YES; 305 | CLANG_WARN_CONSTANT_CONVERSION = YES; 306 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 307 | CLANG_WARN_EMPTY_BODY = YES; 308 | CLANG_WARN_ENUM_CONVERSION = YES; 309 | CLANG_WARN_INFINITE_RECURSION = YES; 310 | CLANG_WARN_INT_CONVERSION = YES; 311 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 312 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 313 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 314 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 315 | CLANG_WARN_STRICT_PROTOTYPES = YES; 316 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 317 | CLANG_WARN_UNREACHABLE_CODE = YES; 318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 319 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 320 | COPY_PHASE_STRIP = NO; 321 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 322 | ENABLE_NS_ASSERTIONS = NO; 323 | ENABLE_STRICT_OBJC_MSGSEND = YES; 324 | GCC_C_LANGUAGE_STANDARD = gnu99; 325 | GCC_NO_COMMON_BLOCKS = YES; 326 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 327 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 328 | GCC_WARN_UNDECLARED_SELECTOR = YES; 329 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 330 | GCC_WARN_UNUSED_FUNCTION = YES; 331 | GCC_WARN_UNUSED_VARIABLE = YES; 332 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 333 | MTL_ENABLE_DEBUG_INFO = NO; 334 | SDKROOT = iphoneos; 335 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 336 | SWIFT_VERSION = 3.0; 337 | TARGETED_DEVICE_FAMILY = "1,2"; 338 | VALIDATE_PRODUCT = YES; 339 | }; 340 | name = Release; 341 | }; 342 | A104CE131D57DCD500626F2A /* Debug */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 346 | INFOPLIST_FILE = StyleKitDemo/Info.plist; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 348 | PRODUCT_BUNDLE_IDENTIFIER = OneFourSixBC.StyleKitDemo; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 351 | SWIFT_VERSION = 4.0; 352 | }; 353 | name = Debug; 354 | }; 355 | A104CE141D57DCD500626F2A /* Release */ = { 356 | isa = XCBuildConfiguration; 357 | buildSettings = { 358 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 359 | INFOPLIST_FILE = StyleKitDemo/Info.plist; 360 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 361 | PRODUCT_BUNDLE_IDENTIFIER = OneFourSixBC.StyleKitDemo; 362 | PRODUCT_NAME = "$(TARGET_NAME)"; 363 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 364 | SWIFT_VERSION = 4.0; 365 | }; 366 | name = Release; 367 | }; 368 | /* End XCBuildConfiguration section */ 369 | 370 | /* Begin XCConfigurationList section */ 371 | A104CDFB1D57DCD500626F2A /* Build configuration list for PBXProject "StyleKitDemo" */ = { 372 | isa = XCConfigurationList; 373 | buildConfigurations = ( 374 | A104CE101D57DCD500626F2A /* Debug */, 375 | A104CE111D57DCD500626F2A /* Release */, 376 | ); 377 | defaultConfigurationIsVisible = 0; 378 | defaultConfigurationName = Release; 379 | }; 380 | A104CE121D57DCD500626F2A /* Build configuration list for PBXNativeTarget "StyleKitDemo" */ = { 381 | isa = XCConfigurationList; 382 | buildConfigurations = ( 383 | A104CE131D57DCD500626F2A /* Debug */, 384 | A104CE141D57DCD500626F2A /* Release */, 385 | ); 386 | defaultConfigurationIsVisible = 0; 387 | defaultConfigurationName = Release; 388 | }; 389 | /* End XCConfigurationList section */ 390 | }; 391 | rootObject = A104CDF81D57DCD500626F2A /* Project object */; 392 | } 393 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import StyleKit 3 | 4 | @UIApplicationMain 5 | class AppDelegate: UIResponder, UIApplicationDelegate { 6 | 7 | var window: UIWindow? 8 | 9 | func application(_ application: UIApplication, 10 | didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 11 | 12 | if let styleFile = Bundle.main.url(forResource: "style", withExtension: "json") { 13 | 14 | // Uses style parser within demo app 15 | //StyleKit(fileUrl: styleFile, styleParser: StyleParser())?.apply() 16 | 17 | // Uses default style parser 18 | StyleKit(fileUrl: styleFile, logLevel: .debug)?.apply() 19 | 20 | } 21 | 22 | 23 | return true 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/Assets.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 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/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 | 27 | 28 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 126 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 170 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/CustomViews/SKButton.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKButton: UIButton { 5 | 6 | private var backgroundColors: [UInt: UIColor] = [:] 7 | 8 | override var isSelected: Bool { 9 | didSet { 10 | updateBackgroundColorForState(state) 11 | } 12 | } 13 | 14 | override var isHighlighted: Bool { 15 | didSet { 16 | updateBackgroundColorForState(state) 17 | } 18 | } 19 | 20 | @objc 21 | func setTransparency(_ alpha: NSNumber) { 22 | self.alpha = CGFloat(alpha.floatValue) / 100.0 23 | } 24 | 25 | @objc 26 | func setBackgroundColor(_ color: UIColor, forState state: UIControlState) { 27 | backgroundColors[state.rawValue] = color 28 | 29 | if state == UIControlState() { 30 | updateBackgroundColorForState(state) 31 | } 32 | } 33 | 34 | private func updateBackgroundColorForState(_ state: UIControlState) { 35 | backgroundColor = backgroundColors[state.rawValue] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/CustomViews/SKLabel.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKLabel: UILabel { 5 | 6 | @objc dynamic var padding: [CGFloat] = [0,0,0,0] 7 | 8 | override func drawText(in rect: CGRect) { 9 | let insets = UIEdgeInsets.init(top: padding[0], left: padding[1], bottom: padding[2], right: padding[3]) 10 | super.drawText(in: UIEdgeInsetsInsetRect(rect, insets)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/CustomViews/SKNavigationBar.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKNavigationBar: UINavigationBar { 5 | 6 | } -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/CustomViews/SKTextField.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKTextField: UITextField { 5 | 6 | } -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/CustomViews/SKView.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKView: UIView { 5 | 6 | } -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/Style/StyleParser.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import StyleKit 3 | 4 | class StyleParser: StyleParsable { 5 | 6 | func getStyle(forName name: String, value: AnyObject) -> AnyObject { 7 | 8 | if let value = value as? String { 9 | if let font = FontHelper.parseFont(value) { 10 | return font 11 | } else if let color = ColorHelper.parseColor(value) { 12 | return color 13 | } 14 | } 15 | return value 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/Style/style.json: -------------------------------------------------------------------------------- 1 | { 2 | "@mainFont": "HelveticaNeue-Bold:20.0", 3 | "@secondaryFont": "HelveticaNeue-Medium:13.0", 4 | "@primaryColor": "#cd0073", 5 | "@secondaryColor": "#8000c6", 6 | "@transparencyValue": 90, 7 | "StyleKitDemo.SKNavigationBar": { 8 | "tintColor": "@secondaryColor", 9 | "titleTextAttributes": { 10 | "NSColor": "@primaryColor", 11 | "NSFont": "@mainFont" 12 | } 13 | }, 14 | "UITableView": { 15 | "UITableViewCell": { 16 | "UILabel": { 17 | "font": "@secondaryFont", 18 | "color": "#000" 19 | } 20 | } 21 | }, 22 | "UITableViewCell": { 23 | "UILabel": { 24 | "font": "@secondaryFont", 25 | "color": "#000" 26 | } 27 | }, 28 | "StyleKitDemo.SKButton": { 29 | "backgroundColor:normal": "@primaryColor", 30 | "backgroundColor:highlighted": "@secondaryColor", 31 | "titleColor:normal": "#fff", 32 | "titleColor:highlighted": "#fff", 33 | "font": "HelveticaNeue-Light:13.0", 34 | "transparency": "@transparencyValue" 35 | }, 36 | "UIButton": { 37 | "font": "@secondaryFont", 38 | "titleColor:normal": "#000", 39 | "titleColor:highlighted": "#555" 40 | }, 41 | "StyleKitDemo.SKLabel": { 42 | "font": "HelveticaNeue-Light:17.0", 43 | "color": "@primaryColor" 44 | }, 45 | "UILabel": { 46 | "font": "HelveticaNeue-Bold:15.0", 47 | "color": "#8000c6" 48 | }, 49 | "UIScrollView": { 50 | "UILabel": { 51 | "font": "HelveticaNeue-Light:15.0", 52 | "color": "#000" 53 | }, 54 | "StyleKitDemo.SKView": { 55 | "StyleKitDemo.SKLabel": { 56 | "font": "HelveticaNeue-Bold:15.0", 57 | "color": "@primaryColor", 58 | "padding": [0,30,0,0], 59 | "backgroundColor": "#eee" 60 | } 61 | } 62 | }, 63 | "UITextField": { 64 | "font": "HelveticaNeue-Light:15.0", 65 | "textColor": "#000", 66 | "UILabel": { 67 | "font": "HelveticaNeue-Medium:15.0", 68 | "color": "#000" 69 | } 70 | }, 71 | "StyleKitDemo.SKTextField": { 72 | "textColor": "@primaryColor", 73 | "UILabel": { 74 | "color": "@primaryColor" 75 | } 76 | }, 77 | "UISegmentedControl": { 78 | "tintColor": "@primaryColor", 79 | "titleTextAttributes:normal": { 80 | "NSColor": "#999", 81 | "NSFont": "HelveticaNeue-Light:15.0" 82 | }, 83 | "titleTextAttributes:selected": { 84 | "NSColor": "#000", 85 | "NSFont": "HelveticaNeue-Medium:15.0" 86 | } 87 | }, 88 | "UIActivityIndicatorView": { 89 | "color": "@primaryColor" 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /StyleKitDemo/StyleKitDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class ViewController: UIViewController { 4 | 5 | override func viewDidLoad() { 6 | super.viewDidLoad() 7 | } 8 | 9 | override func didReceiveMemoryWarning() { 10 | super.didReceiveMemoryWarning() 11 | } 12 | 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /StyleKitTests/HelperTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import StyleKit 3 | 4 | class HelperTests: XCTestCase { 5 | 6 | func testColorHelper() { 7 | 8 | guard let blackColor = ColorHelper.parseColor("#000000") else { 9 | XCTFail("ColorHelper should return UIColor") 10 | return 11 | } 12 | 13 | XCTAssert(blackColor.isEqual(UIColor(hexString:"#000000")), 14 | "Color returned from ColorHelper should be black") 15 | 16 | // Testing color helper with bad color parameter 17 | 18 | XCTAssertNil(ColorHelper.parseColor("000000"), 19 | "Color helper should return nil") 20 | 21 | } 22 | 23 | func testControlStateHelper() { 24 | 25 | XCTAssertEqual(ControlStateHelper.parseControlState("normal"), 26 | UIControlState.normal.rawValue) 27 | 28 | XCTAssertEqual(ControlStateHelper.parseControlState("disabled"), 29 | UIControlState.disabled.rawValue) 30 | 31 | XCTAssertEqual(ControlStateHelper.parseControlState("application"), 32 | UIControlState.application.rawValue) 33 | 34 | XCTAssertEqual(ControlStateHelper.parseControlState("focused"), 35 | UIControlState.focused.rawValue) 36 | 37 | XCTAssertEqual(ControlStateHelper.parseControlState("highlighted"), 38 | UIControlState.highlighted.rawValue) 39 | 40 | XCTAssertEqual(ControlStateHelper.parseControlState("reserved"), 41 | UIControlState.reserved.rawValue) 42 | 43 | XCTAssertEqual(ControlStateHelper.parseControlState("testfallback"), 44 | UIControlState.normal.rawValue) 45 | 46 | } 47 | 48 | func testFontHelper() { 49 | 50 | guard let helveticaBoldBig = FontHelper.parseFont("Helvetica-Bold:30") else { 51 | XCTFail("FontHelper should return UIFont") 52 | return 53 | } 54 | 55 | let helveticaFont = UIFont(name: "Helvetica-Bold", size: 30) 56 | 57 | XCTAssert(helveticaBoldBig.isEqual(helveticaFont), 58 | "Font returned should be Helvetica Bold size 30") 59 | 60 | // Testing font fallback with bad font parameter 61 | 62 | XCTAssertEqual(FontHelper.parseFont("unknown:30"), 63 | UIFont.systemFont(ofSize: 30), 64 | "Font helper should return system font with size 30") 65 | 66 | // Testing font helper with bad font:size parameter 67 | 68 | XCTAssertNil(FontHelper.parseFont("font!size"), 69 | "Font helper should return nil") 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /StyleKitTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 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 | -------------------------------------------------------------------------------- /StyleKitTests/JSONLoadTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import StyleKit 3 | 4 | class JSONLoadTests: XCTestCase { 5 | 6 | func testSuccessLoad() { 7 | 8 | guard let styleFile = Bundle(for: type(of: self)).url(forResource: "success-style", withExtension: "json") else { 9 | XCTFail("Unable to find success-style.json file") 10 | return 11 | } 12 | 13 | XCTAssertNotNil(StyleKit(fileUrl: styleFile), "success-style.json failed") 14 | 15 | } 16 | 17 | func testFailLoad() { 18 | 19 | guard let styleFile = Bundle(for: type(of: self)).url(forResource: "fail-style", withExtension: "json") else { 20 | XCTFail("Unable to find fail-style.json file") 21 | return 22 | } 23 | 24 | XCTAssertNil(StyleKit(fileUrl: styleFile), "fail-style.json succeeded") 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /StyleKitTests/Style/fail-style.json: -------------------------------------------------------------------------------- 1 | { 2 | "BadFormatJson" { 3 | } 4 | } -------------------------------------------------------------------------------- /StyleKitTests/Style/style.json: -------------------------------------------------------------------------------- 1 | { 2 | "@ButtonTitleColor": "#FAA", 3 | "@ButtonBackgroundColor": "#0F0", 4 | "@NestedLabelColor": "#999", 5 | "@UINavBarFont": "HelveticaNeue-Light:18.0", 6 | "UINavigationBar": { 7 | "tintColor": "#000", 8 | "titleTextAttributes": { 9 | "NSColor": "#FF000000", 10 | "NSFont": "@UINavBarFont" 11 | } 12 | }, 13 | "UILabel": { 14 | "font": "HelveticaNeue-Bold:15.0", 15 | "textColor": "#fff", 16 | "backgroundColor": "#eee" 17 | }, 18 | "StyleKitTests.SKLabel": { 19 | "font": "HelveticaNeue-Light:17.0", 20 | "color": "#000" 21 | }, 22 | "UIButton": { 23 | "font": "HelveticaNeue-Medium:13.0", 24 | "titleColor:normal": "@ButtonTitleColor", 25 | "titleColor:highlighted": "#fff" 26 | }, 27 | "StyleKitTests.SKButton": { 28 | "backgroundColor:normal": "@ButtonBackgroundColor", 29 | "backgroundColor:highlighted": "#fff", 30 | "titleColor:normal": "@ButtonTitleColor", 31 | "titleColor:highlighted": "#000", 32 | "font": "HelveticaNeue-Light:13.0", 33 | "transparency":70 34 | }, 35 | "StyleKitTests.SKView": { 36 | "backgroundColor": "#000" 37 | }, 38 | "UIScrollView": { 39 | "UILabel": { 40 | "font": "HelveticaNeue-Medium:20.0", 41 | "color": "@NestedLabelColor" 42 | }, 43 | "StyleKitTests.SKView": { 44 | "backgroundColor": "#888", 45 | "StyleKitTests.SKLabel": { 46 | "font": "HelveticaNeue-Light:40.0", 47 | "color": "#fff", 48 | "padding": [0,30,0,0] 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /StyleKitTests/Style/success-style.json: -------------------------------------------------------------------------------- 1 | { 2 | "UINavigationBar": { 3 | "UILabel": { 4 | "font": "HelveticaNeue-Bold:30.0", 5 | "backgroundColor": "#000FFF", 6 | } 7 | }, 8 | "UIButton": { 9 | "font": "HelveticaNeue-Light:20.0", 10 | "titleColor:normal":"#FFFFFF", 11 | "titleColor:highlighted":"#000000" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /StyleKitTests/StyleKitTestsHost/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | class AppDelegate: UIResponder, UIApplicationDelegate { 5 | 6 | var window: UIWindow? 7 | 8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 9 | 10 | self.window = UIWindow(frame: UIScreen.main.bounds) 11 | let viewController = UIViewController(nibName: nil, bundle: nil) 12 | self.window?.rootViewController = viewController 13 | self.window?.makeKeyAndVisible() 14 | 15 | return true 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /StyleKitTests/StyleKitTestsHost/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIcons 10 | 11 | CFBundleIcons~ipad 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /StyleKitTests/StyleTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import UIKit 3 | @testable import StyleKit 4 | 5 | class StyleTests: XCTestCase { 6 | 7 | let viewController = UIViewController() 8 | let skView = SKView() 9 | let skButton = SKButton() 10 | let skLabel = SKLabel() 11 | let label = UILabel() 12 | let navigationBar = UINavigationBar() 13 | let button = UIButton() 14 | 15 | let scrollView = UIScrollView() 16 | let nestedLabel = UILabel() 17 | let nestedSKView = SKView() 18 | let nestedSKLabel = SKLabel() 19 | 20 | var loaded = false 21 | 22 | func loadStyles() { 23 | if let styleFile = Bundle(for: type(of: self)).url(forResource: "style", withExtension: "json") { 24 | guard let styleKit = StyleKit(fileUrl: styleFile) else { 25 | XCTFail("Unable to load style.json file") 26 | return 27 | } 28 | styleKit.apply() 29 | loaded = true 30 | } else { 31 | XCTFail("Unable to find style.json file") 32 | } 33 | } 34 | 35 | override func setUp() { 36 | 37 | if !loaded { 38 | loadStyles() 39 | 40 | viewController.view.addSubview(skView) 41 | viewController.view.addSubview(skButton) 42 | viewController.view.addSubview(skLabel) 43 | viewController.view.addSubview(label) 44 | viewController.view.addSubview(navigationBar) 45 | viewController.view.addSubview(button) 46 | viewController.view.addSubview(scrollView) 47 | 48 | nestedSKView.addSubview(nestedSKLabel) 49 | scrollView.addSubview(nestedSKView) 50 | scrollView.addSubview(nestedLabel) 51 | 52 | UIApplication.shared.keyWindow?.rootViewController = viewController 53 | } 54 | 55 | } 56 | 57 | func testBasicComponents() { 58 | 59 | // UINavigationBar 60 | XCTAssertEqual(navigationBar.tintColor, UIColor(hexString: "#000")) 61 | 62 | if let navigationBarColor = navigationBar.titleTextAttributes?[.foregroundColor] as? UIColor { 63 | XCTAssertEqual(navigationBarColor, UIColor(hexString: "#FF000000")) 64 | } else { 65 | XCTFail("Color not found in navigation") 66 | } 67 | 68 | if let navigationBarFont = navigationBar.titleTextAttributes?[.font] as? UIFont { 69 | XCTAssertEqual(navigationBarFont.fontName, "HelveticaNeue-Light") 70 | XCTAssertEqual(navigationBarFont.pointSize, 18.0) 71 | } else { 72 | XCTFail("Font not found in navigation") 73 | } 74 | 75 | // UILabel 76 | XCTAssertEqual(label.font.fontName, "HelveticaNeue-Bold") 77 | XCTAssertEqual(label.font.pointSize, 15.0) 78 | XCTAssertEqual(label.textColor, UIColor(hexString: "#fff")) 79 | XCTAssertEqual(label.backgroundColor, UIColor(hexString: "#eee")) 80 | 81 | // UIButton 82 | XCTAssertEqual(button.titleLabel?.font.fontName, "HelveticaNeue-Medium") 83 | XCTAssertEqual(button.titleLabel?.font.pointSize, 13.0) 84 | XCTAssertEqual(button.titleColor(for: .normal), UIColor(hexString: "#FAA")) 85 | XCTAssertEqual(button.titleColor(for: .highlighted), UIColor(hexString: "#fff")) 86 | } 87 | 88 | func testExtendedComponents() { 89 | // SKButton 90 | XCTAssertEqual(skButton.titleLabel?.font.fontName, "HelveticaNeue-Light") 91 | XCTAssertEqual(skButton.titleLabel?.font.pointSize, 13.0) 92 | XCTAssertEqual(skButton.titleColor(for: .normal), UIColor(hexString: "#FAA")) 93 | XCTAssertEqual(skButton.titleColor(for: .highlighted), UIColor(hexString: "#000")) 94 | XCTAssertEqual(skButton.backgroundColor, UIColor(hexString: "#0F0")) 95 | XCTAssert(fabs(Float(skButton.alpha) - 0.7) < Float.ulpOfOne) 96 | 97 | // SKLabel 98 | XCTAssertEqual(skLabel.font.fontName, "HelveticaNeue-Light") 99 | XCTAssertEqual(skLabel.font.pointSize, 17.0) 100 | XCTAssertEqual(skLabel.textColor, UIColor(hexString: "#000")) 101 | 102 | // SKView 103 | XCTAssertEqual(skView.backgroundColor, UIColor(hexString: "#000")) 104 | } 105 | 106 | func testNestedComponents() { 107 | // Label inside Scroll View 108 | XCTAssertEqual(nestedLabel.font.fontName, "HelveticaNeue-Medium") 109 | XCTAssertEqual(nestedLabel.font.pointSize, 20.0) 110 | XCTAssertEqual(nestedLabel.textColor, UIColor(hexString: "#999")) 111 | 112 | // SKView inside Scroll View 113 | XCTAssertEqual(nestedSKView.backgroundColor, UIColor(hexString: "#888")) 114 | 115 | // SKLabel inside nested SKView 116 | XCTAssertEqual(nestedSKLabel.font.fontName, "HelveticaNeue-Light") 117 | XCTAssertEqual(nestedSKLabel.font.pointSize, 40.0) 118 | XCTAssertEqual(nestedSKLabel.textColor, UIColor(hexString: "#fff")) 119 | XCTAssertEqual(nestedSKLabel.padding, [0,30,0,0]) 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /StyleKitTests/UI Extensions/SKButton.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKButton: UIButton { 5 | 6 | private var backgroundColors: [UInt: UIColor] = [:] 7 | 8 | override var isSelected: Bool { 9 | didSet { 10 | updateBackgroundColorForState(state) 11 | } 12 | } 13 | 14 | override var isHighlighted: Bool { 15 | didSet { 16 | updateBackgroundColorForState(state) 17 | } 18 | } 19 | 20 | @objc 21 | func setTransparency(_ alpha: NSNumber) { 22 | self.alpha = CGFloat(alpha.floatValue) / 100.0 23 | } 24 | 25 | @objc 26 | func setBackgroundColor(_ color: UIColor, forState state: UIControlState) { 27 | backgroundColors[state.rawValue] = color 28 | 29 | if state == UIControlState() { 30 | updateBackgroundColorForState(state) 31 | } 32 | } 33 | 34 | private func updateBackgroundColorForState(_ state: UIControlState) { 35 | backgroundColor = backgroundColors[state.rawValue] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /StyleKitTests/UI Extensions/SKLabel.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKLabel: UILabel { 5 | 6 | @objc dynamic var padding: [CGFloat] = [0,0,0,0] 7 | 8 | override func drawText(in rect: CGRect) { 9 | let insets = UIEdgeInsets.init(top: padding[0], 10 | left: padding[1], 11 | bottom: padding[2], 12 | right: padding[3]) 13 | super.drawText(in: UIEdgeInsetsInsetRect(rect, insets)) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /StyleKitTests/UI Extensions/SKView.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | class SKView: UIView { 5 | 6 | } 7 | --------------------------------------------------------------------------------