Skip to content

Commit

Permalink
Better support UIAppearance, improve rakefile (jjochen#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjochen authored Jan 4, 2018
1 parent 5c34d3c commit aa6edf2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 49 deletions.
37 changes: 12 additions & 25 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@

desc 'Initialize your working copy'
task :bootstrap do
unless system('which bundle')
error_message "Please install the bundler gem manually:\n" \
' $ [sudo] gem install bundler'
exit 1
end

check_executable('bundler')
install_gems
install_cocoapods
end
Expand Down Expand Up @@ -64,13 +59,8 @@ begin

desc 'Lint swift'
task :lint_swift do
unless system('which swiftlint')
error_message "Please install swiftlint manually:\n" \
' $ brew install swiftlint'
exit 1
end

title 'Linting swift'
check_executable('swiftlint')
sh "swiftlint"
end

Expand All @@ -85,13 +75,8 @@ begin

desc 'Format code'
task :format do
unless system('which swiftformat')
error_message "Please install swiftformat manually:\n" \
' $ brew install swiftformat'
exit 1
end

title 'Formating code'
check_executable('swiftformat')
sh "swiftformat Example/Tests Example/JJFloatingActionButton Sources"
end

Expand Down Expand Up @@ -137,14 +122,9 @@ begin

desc 'Record video booted simulator and convert to gif'
task :record_gif do
unless system('which ffmpeg')
error_message "Please install ffmpeg manually:\n" \
' $ brew install ffmpeg'
exit 1
end

title 'Recording video'

check_executable('ffmpeg')

mov_path='./Images/JJFloatingActionButton.mov'

trap('SIGINT') { puts }
Expand Down Expand Up @@ -213,6 +193,13 @@ def error_message(message)
$stderr.puts
end

def check_executable(executable)
unless system("which #{executable}")
error_message "Please install '#{executable}' manually."
exit 1
end
end

def check_parameter(parameter)
if parameter.nil? || parameter.empty?
error_message "parameter can't be empty."
Expand Down
4 changes: 2 additions & 2 deletions Sources/JJCircleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import UIKit

/// The color of the circle.
///
@objc @IBInspectable open var color: UIColor = JJStyles.defaultButtonColor {
@objc @IBInspectable open dynamic var color: UIColor = JJStyles.defaultButtonColor {
didSet {
updateHighlightedColorFallback()
setNeedsDisplay()
Expand All @@ -39,7 +39,7 @@ import UIKit

/// The color of the circle when highlighted. Default is `nil`.
///
@objc @IBInspectable open var highlightedColor: UIColor? {
@objc @IBInspectable open dynamic var highlightedColor: UIColor? {
didSet {
setNeedsDisplay()
}
Expand Down
44 changes: 22 additions & 22 deletions Sources/JJFloatingActionButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import UIKit
/// The background color of the floating action button.
/// Default is `UIColor(hue: 0.31, saturation: 0.37, brightness: 0.76, alpha: 1.00)`.
///
@objc @IBInspectable public var buttonColor: UIColor = JJStyles.defaultButtonColor {
@objc @IBInspectable public dynamic var buttonColor: UIColor = JJStyles.defaultButtonColor {
didSet {
circleView.color = buttonColor
}
Expand All @@ -71,7 +71,7 @@ import UIKit
/// The background color of the floating action button with highlighted state.
/// Default is `nil`.
///
@objc @IBInspectable public var highlightedButtonColor: UIColor? {
@objc @IBInspectable public dynamic var highlightedButtonColor: UIColor? {
didSet {
circleView.highlightedColor = highlightedButtonColor
}
Expand All @@ -80,12 +80,12 @@ import UIKit
/// The image displayed on the button by default.
/// When only one `JJActionItem` is added and `handleSingleActionDirectly` is enabled,
/// the image from the item is shown istead.
/// When an `openButtonImage` is given this is shwon when the button is opened.
/// When an `o penButtonImage` is given this is shwon when the button is opened.
/// Default is `nil`.
///
/// - SeeAlso: `openButtonImage`
///
@objc @IBInspectable public var defaultButtonImage: UIImage? {
@objc @IBInspectable public dynamic var defaultButtonImage: UIImage? {
didSet {
configureButtonImage()
}
Expand All @@ -99,7 +99,7 @@ import UIKit
///
/// - SeeAlso: `rotationAngle`
///
@objc @IBInspectable public var openButtonImage: UIImage? {
@objc @IBInspectable public dynamic var openButtonImage: UIImage? {
didSet {
configureButtonImage()
}
Expand All @@ -110,7 +110,7 @@ import UIKit
///
/// - Warning: Only template images are colored.
///
@objc @IBInspectable public var buttonImageColor: UIColor = .white {
@objc @IBInspectable public dynamic var buttonImageColor: UIColor = .white {
didSet {
imageView.tintColor = buttonImageColor
}
Expand All @@ -119,7 +119,7 @@ import UIKit
/// The shadow color of the floating action button.
/// Default is `UIColor.black`.
///
@objc @IBInspectable public var shadowColor: UIColor? = .black {
@objc @IBInspectable public dynamic var shadowColor: UIColor? = .black {
didSet {
circleView.layer.shadowColor = shadowColor?.cgColor
}
Expand All @@ -128,7 +128,7 @@ import UIKit
/// The shadow offset of the floating action button.
/// Default is `CGSize(width: 0, height: 1)`.
///
@objc @IBInspectable public var shadowOffset: CGSize = CGSize(width: 0, height: 1) {
@objc @IBInspectable public dynamic var shadowOffset: CGSize = CGSize(width: 0, height: 1) {
didSet {
circleView.layer.shadowOffset = shadowOffset
}
Expand All @@ -137,7 +137,7 @@ import UIKit
/// The shadow opacity of the floating action button.
/// Default is `0.4`.
///
@objc @IBInspectable public var shadowOpacity: Float = 0.4 {
@objc @IBInspectable public dynamic var shadowOpacity: Float = 0.4 {
didSet {
circleView.layer.shadowOpacity = shadowOpacity
}
Expand All @@ -146,7 +146,7 @@ import UIKit
/// The shadow radius of the floating action button.
/// Default is `2`.
///
@objc @IBInspectable public var shadowRadius: CGFloat = 2 {
@objc @IBInspectable public dynamic var shadowRadius: CGFloat = 2 {
didSet {
circleView.layer.shadowRadius = shadowRadius
}
Expand All @@ -157,7 +157,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc public var itemTitleFont: UIFont = .systemFont(ofSize: UIFont.systemFontSize) {
@objc public dynamic var itemTitleFont: UIFont = .systemFont(ofSize: UIFont.systemFontSize) {
didSet {
items.forEach { item in
item.titleLabel.font = itemTitleFont
Expand All @@ -170,7 +170,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemButtonColor: UIColor = .white {
@objc @IBInspectable public dynamic var itemButtonColor: UIColor = .white {
didSet {
items.forEach { item in
item.circleView.color = itemButtonColor
Expand All @@ -183,7 +183,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var highlightedItemButtonColor: UIColor? {
@objc @IBInspectable public dynamic var highlightedItemButtonColor: UIColor? {
didSet {
items.forEach { item in
item.circleView.highlightedColor = highlightedItemButtonColor
Expand All @@ -197,7 +197,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemImageColor: UIColor? {
@objc @IBInspectable public dynamic var itemImageColor: UIColor? {
didSet {
items.forEach { item in
item.imageView.tintColor = currentItemImageColor
Expand All @@ -210,7 +210,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemTitleColor: UIColor = .white {
@objc @IBInspectable public dynamic var itemTitleColor: UIColor = .white {
didSet {
items.forEach { item in
item.titleLabel.textColor = itemTitleColor
Expand All @@ -223,7 +223,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemShadowColor: UIColor = .black {
@objc @IBInspectable public dynamic var itemShadowColor: UIColor = .black {
didSet {
items.forEach { item in
item.layer.shadowColor = itemShadowColor.cgColor
Expand All @@ -236,7 +236,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemShadowOffset: CGSize = CGSize(width: 0, height: 1) {
@objc @IBInspectable public dynamic var itemShadowOffset: CGSize = CGSize(width: 0, height: 1) {
didSet {
items.forEach { item in
item.layer.shadowOffset = itemShadowOffset
Expand All @@ -249,7 +249,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemShadowOpacity: Float = 0.4 {
@objc @IBInspectable public dynamic var itemShadowOpacity: Float = 0.4 {
didSet {
items.forEach { item in
item.layer.shadowOpacity = itemShadowOpacity
Expand All @@ -262,7 +262,7 @@ import UIKit
///
/// - Remark: This can be changed for each action item.
///
@objc @IBInspectable public var itemShadowRadius: CGFloat = 2 {
@objc @IBInspectable public dynamic var itemShadowRadius: CGFloat = 2 {
didSet {
items.forEach { item in
item.layer.shadowRadius = itemShadowRadius
Expand All @@ -273,12 +273,12 @@ import UIKit
/// The size of an action item in relation to the floating action button.
/// Default is `0.75`.
///
@objc @IBInspectable public var itemSizeRatio: CGFloat = 0.75
@objc @IBInspectable public dynamic var itemSizeRatio: CGFloat = 0.75

/// The space between two action items in points.
/// Default is `12`.
///
@objc @IBInspectable public var interItemSpacing: CGFloat = 12
@objc @IBInspectable public dynamic var interItemSpacing: CGFloat = 12

/// The angle in radians the button should rotate when opening.
/// Default is `-CGFloat.pi / 4`.
Expand All @@ -287,7 +287,7 @@ import UIKit
///
/// - SeeAlso: `openButtonImage`
///
@objc @IBInspectable public var rotationAngle: CGFloat = -.pi / 4
@objc @IBInspectable public dynamic var rotationAngle: CGFloat = -.pi / 4

/// When enabled and only one action item is added, the floating action button will not open,
/// but the action from the action item will be executed direclty when the button is tapped.
Expand Down

0 comments on commit aa6edf2

Please sign in to comment.