Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2015 Tonic Design Co.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 12 additions & 0 deletions StyleKit.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Pod::Spec.new do |s|
s.name = "StyleKit"
s.version = "2.1.3"
s.license = { :type => "MIT", :file => "LICENSE" }
s.summary = "StyleKit is an iOS library that styles native controls with a CSS-like JSON format."
s.homepage = "https://github.com/dmgctrl/StyleKit"
s.author = "Tonic Design Co."
s.platform = :ios, "9.0"
s.source = { :git => "https://github.com/dmgctrl/StyleKit.git", :tag => "#{s.version}" }
s.source_files = "StyleKit/StyleKit/**/*.swift"
s.swift_version = "4.2"
end
28 changes: 15 additions & 13 deletions StyleKit/StyleKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Tonic Design";
TargetAttributes = {
29B64EFB1DC39E0100D460B1 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
29B64F031DC39E0100D460B1 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -319,12 +319,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -356,7 +358,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -372,12 +374,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -402,7 +406,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 4.2;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -421,6 +425,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = StyleKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
Expand All @@ -429,8 +434,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -451,15 +455,15 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = StyleKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.tonicdesign.StyleKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -482,8 +486,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.tonicdesign.StyleKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -502,8 +505,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.tonicdesign.StyleKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion StyleKit/StyleKit/ButtonStylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ extension UIButton {
}
}

func assignColors(_ colors: ColorStyle, forState state: UIControlState, resources:CommonResources) {
func assignColors(_ colors: ColorStyle, forState state: UIControl.State, resources:CommonResources) {
if let colorKey = colors.backgroundColor, let color = resources.colors[colorKey] {
self.setBackgroundImage(UIImage.imageWithColor(color), for: state)
}
Expand Down
30 changes: 15 additions & 15 deletions StyleKit/StyleKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -20,13 +15,27 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>2.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>Brandon_thin.otf</string>
<string>Brandon_med.otf</string>
<string>Brandon_light.otf</string>
<string>Brandon_light_it.otf</string>
<string>Brandon_blk.otf</string>
<string>Brandon_bld.otf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -41,14 +50,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIAppFonts</key>
<array>
<string>Brandon_thin.otf</string>
<string>Brandon_med.otf</string>
<string>Brandon_light.otf</string>
<string>Brandon_light_it.otf</string>
<string>Brandon_blk.otf</string>
<string>Brandon_bld.otf</string>
</array>
</dict>
</plist>
10 changes: 5 additions & 5 deletions StyleKit/StyleKit/LabelStylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ class LabelStyle: Stylist {
"Justified":.justified,
"Natural":.natural]

static func attributesForLabel(_ styles:AttributedTextStyle, textAlignment:NSTextAlignment) -> Dictionary<NSAttributedStringKey, AnyObject> {
static func attributesForLabel(_ styles:AttributedTextStyle, textAlignment:NSTextAlignment) -> Dictionary<NSAttributedString.Key, AnyObject> {


var attributes:[NSAttributedStringKey: AnyObject] = [:]
var attributes:[NSAttributedString.Key: AnyObject] = [:]

if let fontName = styles.fontStyle?.fontName, let fontSize = styles.fontStyle?.size {
attributes[NSAttributedStringKey.font] = UIFont(name: fontName, size: CGFloat(fontSize))
attributes[NSAttributedString.Key.font] = UIFont(name: fontName, size: CGFloat(fontSize))
}

if let tracking = styles.tracking, let fontSize = styles.fontStyle?.size {
let characterSpacing = fontSize * tracking / 1000
attributes[NSAttributedStringKey.kern] = characterSpacing as AnyObject?
attributes[NSAttributedString.Key.kern] = characterSpacing as AnyObject?
}

let style = NSMutableParagraphStyle()
Expand All @@ -48,7 +48,7 @@ class LabelStyle: Stylist {
if let lineSpace = styles.lineSpacing {
style.lineSpacing = lineSpace
}
attributes[NSAttributedStringKey.paragraphStyle] = style
attributes[NSAttributedString.Key.paragraphStyle] = style

return attributes
}
Expand Down
4 changes: 2 additions & 2 deletions StyleKit/StyleKit/ProgressViewStylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ProgressViewStyle : Stylist {

typealias Element = UIProgressView

var style: UIProgressViewStyle?
var style: UIProgressView.Style?
var progressTintColor: UIColor?
var trackTintColor: UIColor?
var progressImage: UIImage?
Expand All @@ -31,7 +31,7 @@ class ProgressViewStyle : Stylist {
}
switch property {
case .Style:
if let theValue = value as? Int, let viewStyle = UIProgressViewStyle(rawValue: theValue) {
if let theValue = value as? Int, let viewStyle = UIProgressView.Style(rawValue: theValue) {
style.style = viewStyle
}
case .ProgressTintColor:
Expand Down
8 changes: 4 additions & 4 deletions StyleKit/StyleKit/SegmentedControlStylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ extension UISegmentedControl {
case .FontStyle:
if let fontStyle = style.fontStyle {
let font = UIFont(name: fontStyle.fontName, size: CGFloat(fontStyle.size))
normalAttributes[NSAttributedStringKey.font] = font
selectedAttributes[NSAttributedStringKey.font] = font
normalAttributes[NSAttributedString.Key.font] = font
selectedAttributes[NSAttributedString.Key.font] = font
}
case .TintColor:
if let tintColor = style.tintColor {
Expand Down Expand Up @@ -115,12 +115,12 @@ extension UISegmentedControl {
}
}

func assignColors(_ colors: ColorStyle, forState state: UIControlState, resources:CommonResources) {
func assignColors(_ colors: ColorStyle, forState state: UIControl.State, resources:CommonResources) {
if let colorKey = colors.backgroundColor, let color = resources.colors[colorKey] {
self.setBackgroundImage(UIImage.imageWithColor(color), for: state, barMetrics: .default)
}
if let colorKey = colors.textColor, let color = resources.colors[colorKey] {
let attributes = [NSAttributedStringKey.foregroundColor: color]
let attributes = [NSAttributedString.Key.foregroundColor: color]
self.setTitleTextAttributes(attributes, for: state)
}
}
Expand Down
6 changes: 3 additions & 3 deletions StyleKit/StyleKit/StepperStylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class StepperStyle : Stylist {
case Disabled = "disabledState"
}

static func controlStateForAllowedState(_ state:AllowedStates) -> UIControlState {
static func controlStateForAllowedState(_ state:AllowedStates) -> UIControl.State {
switch state {
case .Disabled:
return UIControlState.disabled
return UIControl.State.disabled
case .Highlighted:
return UIControlState.highlighted
return UIControl.State.highlighted
case .Normal:
return .normal
}
Expand Down
6 changes: 3 additions & 3 deletions StyleKit/StyleKit/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ open class Style {
case invalidLabelStyle
}

open static let sharedInstance = Style()
public static let sharedInstance = Style()

fileprivate let fileName = "Style.json"
open static let styleSheetLocationKey = "SKStylesheetLocation" // Make sure to update docs if this changes
public static let styleSheetLocationKey = "SKStylesheetLocation" // Make sure to update docs if this changes

open var resources = CommonResources()

Expand Down Expand Up @@ -222,7 +222,7 @@ open class Style {
}
}

assert(false, "error serializing JSON: \(error)")
//assert(false, "error serializing JSON: \(error)")
}
}

Expand Down
6 changes: 3 additions & 3 deletions StyleKit/StyleKit/TextFieldStylist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TextFieldStyle : Stylist {
var borderWidth: Int?
var cornerRadius: Int?
var textAlignment: NSTextAlignment?
var borderStyle: UITextBorderStyle?
var borderStyle: UITextField.BorderStyle?
var backgroundColor: UIColor?

enum Properties: String {
Expand Down Expand Up @@ -84,10 +84,10 @@ class TextFieldStyle : Stylist {
return nil
}

static func mapBorderStyle(_ styleStr:String) -> UITextBorderStyle? {
static func mapBorderStyle(_ styleStr:String) -> UITextField.BorderStyle? {
let allowedValues = ["None","Line","Bezel","RoundedRect"]
if let index = allowedValues.index(of: styleStr) {
return UITextBorderStyle(rawValue: index)
return UITextField.BorderStyle(rawValue: index)
}
return nil
}
Expand Down
Loading