Skip to content

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-pavlychko committed Mar 7, 2018
1 parent 0fd22c5 commit dab3a22
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 40 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# SwiftyAppearance Change Log

## [Version 1.1.0](https://github.com/victor-pavlychko/SwiftyAppearance/releases/tag/1.1.0)
*Released on 2017-05-??.*
*Released on 2018-03-07.*

- moved `UIView.refreshSubviewAppearance` to `UIWindow` where it belongs and renamed to `refreshAppearance`
- renamed `UIApplication.refreshApplicationAppearance` to `refreshAppearance`
= added `AppearanceView` for application theming
- added `AppearanceStyle` for application theming
- cleaned up the API in favor of default parameters

## [Version 1.0.2](https://github.com/victor-pavlychko/SwiftyAppearance/releases/tag/1.0.2)
*Released on 2016-11-27.*
Expand Down
37 changes: 16 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,27 @@ provide proxy object to configure its properties.

### Free Functions

* `func appearance(for traits: UITraitCollection, _ block: () -> Void)` — adds traits from the collection to the scope
* `func appearance(in containerType: UIAppearanceContainer.Type, _ block: () -> Void)` — adds nested container to the scope
* `func appearance(inChain containerTypes: [UIAppearanceContainer.Type], _ block: () -> Void)` — adds chain of nested containers to the scope
* `func appearance(inAny containerTypes: [UIAppearanceContainer.Type], _ block: () -> Void)` — defines a set of nested scopes for each provided container
* `func appearance(for traitCollection: UITraitCollection? = nil, in containerTypes: [UIAppearanceContainer.Type] = [], _ block: () -> Void)` — adds traits and containers from the collection to the scope
* `func appearance(for traitCollection: UITraitCollection? = nil, inAny containerTypes: [UIAppearanceContainer.Type], _ block: () -> Void)` — adds traits and defines a set of nested scopes for each provided container

### UIAppearanceContainer Extensions
### UIAppearance and UIAppearanceContainer Extensions

* `static func appearance(_ block: () -> Void)` — adds nested container to the scope, this is equivalent to one of free functions
* `static func UIAppearanceContainer.appearance(style: AppearanceStyle = nil, for traitCollection: UITraitCollection? = nil, _ block: () -> Void)` — adds nested container to the scope optionally specifying style
* `static func UIAppearance.appearance(style: AppearanceStyle = nil, for traitCollection: UITraitCollection? = nil, _ block: (_ proxy: Self) -> Void)` — adds traits from the collection to the scope, provides appearance proxy for class with an optional style class, then adds current class as a container
if applicable

### UIAppearance Extensions
### UIWindow and UIApplication Extensions

This group of functions first extends scopes similar to what free functions do, then provides appearance proxy for `Self` class and finally defines
new scope adding `Self` as a container when applicable.
* `func UIWindow.refreshAppearance(animated: Bool)` — refreshes appearance for the window
* `func UIApplication.refreshAppearance(animated: Bool)` — refreshes appearance for all windows in the application

* `static func appearance(_ block: (_ proxy: Self) -> Void)` — provides appearance proxy for class, then adds current class as a container
if applicable
* `static func appearance(for traits: UITraitCollection, _ block: (_ proxy: Self) -> Void)` — adds traits from the collection to the scope,
provides appearance proxy for class, then adds current class as a container if applicable
* `static func appearance(in containerType: UIAppearanceContainer.Type, _ block: (_ proxy: Self) -> Void)` — adds nested container to the scope,
provides appearance proxy for class, then adds current class as a container if applicable
* `static func appearance(inChain containerTypes: [UIAppearanceContainer.Type], _ block: (_ proxy: Self) -> Void)` — adds chain of nested
containers to the scope, provides appearance proxy for class, then adds current class as a container if applicable
* `static func appearance(inAny containerTypes: [UIAppearanceContainer.Type], _ block: (_ proxy: Self) -> Void)` — defines a set of nested scopes
for each provided container, provides appearance proxy for class, then adds current class as a container if applicable

## Installation
### UIView and UIViewController Extensions

* `@IBInspectable public var appearanceStyleName: String` — inspectable property to set appearance style from Interface Builder
* `var appearanceStyle: AppearanceStyle` — appearance style accessor
* `func setAppearanceStyle(_ style: AppearanceStyle, animated: Bool)` — sets appearance style optionally animating the update

## Installation

### CocoaPods

Expand Down
2 changes: 1 addition & 1 deletion SwiftyAppearance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@
57296DC41EB8B4CD004E434C /* AppearanceStyleExtensions.swift */,
571E483D204EA18E001D9FD9 /* AppearanceStyleHelpers.swift */,
57FED3801D8F3B48008DB72E /* UIAppearanceExtensions.swift */,
57296DC61EB8F327004E434C /* UIWindowExtensions.swift */,
573B0E0D1F0A9BFF008609B1 /* UIApplicationExtensions.swift */,
57296DC61EB8F327004E434C /* UIWindowExtensions.swift */,
57FED3751D8F3A9F008DB72E /* Info.plist */,
);
path = SwiftyAppearance;
Expand Down
23 changes: 15 additions & 8 deletions SwiftyAppearance/UIAppearanceExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import UIKit

/// Nested appearance scope for specified trait collection
/// Nested appearance scope for specified trait collection and container types
///
/// - Parameters:
/// - traits: trait collection
/// - traitCollection: trait collection
/// - containerTypes: list of container types
/// - block: appearance code block
public func appearance(for traitCollection: UITraitCollection? = nil, in containerTypes: [UIAppearanceContainer.Type] = [], _ block: () -> Void) {
AppearanceScope.main.push(traitCollection: traitCollection)
Expand All @@ -20,10 +21,11 @@ public func appearance(for traitCollection: UITraitCollection? = nil, in contain
AppearanceScope.main.pop(count: 2)
}

/// Nested appearance scope for any of specified containers
/// Nested appearance scope for specified trait collection any of specified containers
///
/// - Parameters:
/// - containerTypes: list of containers
/// - traitCollection: trait collection
/// - containerTypes: list of container types
/// - block: appearance code block
public func appearance(for traitCollection: UITraitCollection? = nil, inAny containerTypes: [UIAppearanceContainer.Type], _ block: () -> Void) {
AppearanceScope.main.push(traitCollection: traitCollection)
Expand All @@ -37,9 +39,12 @@ public func appearance(for traitCollection: UITraitCollection? = nil, inAny cont

public extension UIAppearanceContainer {

/// Nested appearance scope for `Self` container
/// Nested appearance scope for `Self` container and trait collection
///
/// - Parameter block: appearance code block for current container
/// - Parameter
/// - style: appearance style for this container
/// - traitCollection: trait collection
/// - block: appearance code block for current container
public static func appearance(style: AppearanceStyle = nil, for traitCollection: UITraitCollection? = nil, _ block: () -> Void) {
let cls = styleClass(self, styleName: style.name)
AppearanceScope.main.push(traitCollection: traitCollection)
Expand All @@ -55,7 +60,8 @@ public extension UIAppearance {
/// nested appearance scope for `Self` container with specified trait collection
///
/// - Parameters:
/// - traits: trait collections
/// - style: appearance style for current class
/// - traitCollection: trait collections
/// - block: appearance code block for current container
/// - proxy: appearance proxy to configure
public static func appearance(style: AppearanceStyle = nil, for traitCollection: UITraitCollection? = nil, _ block: (_ proxy: Self) -> Void) {
Expand All @@ -80,7 +86,8 @@ public extension UIAppearance where Self: UIAppearanceContainer {
/// nested appearance scope for `Self` container with specified trait collection
///
/// - Parameters:
/// - traits: trait collections
/// - style: appearance style for current class
/// - traitCollection: trait collections
/// - block: appearance code block for current container
/// - proxy: appearance proxy to configure
public static func appearance(style: AppearanceStyle = nil, for traitCollection: UITraitCollection? = nil, _ block: (_ proxy: Self) -> Void) {
Expand Down
6 changes: 2 additions & 4 deletions SwiftyAppearance/UIApplicationExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import UIKit

public extension NSNotification.Name {

/// <#Description#>
public static let SwiftyAppearanceWillRefreshApplication = NSNotification.Name(rawValue: "SwiftyAppearanceWillRefreshApplicationNotification")

/// <#Description#>
public static let SwiftyAppearanceDidRefreshApplication = NSNotification.Name(rawValue: "SwiftyAppearanceDidRefreshApplicationNotification")
}

Expand All @@ -25,9 +23,9 @@ public extension UIApplication {
}
}

/// <#Description#>
/// Refreshes appearance for all windows in the application
///
/// - Parameter animated: <#animated description#>
/// - Parameter animated: if the refresh should be animated
public func refreshAppearance(animated: Bool) {
NotificationCenter.default.post(name: .SwiftyAppearanceWillRefreshApplication, object: self)
UIView.animate(withDuration: animated ? 0.25 : 0, animations: {
Expand Down
6 changes: 2 additions & 4 deletions SwiftyAppearance/UIWindowExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import UIKit

public extension NSNotification.Name {

/// <#Description#>
public static let SwiftyAppearanceWillRefreshWindow = NSNotification.Name(rawValue: "SwiftyAppearanceWillRefreshWindowNotification")

/// <#Description#>
public static let SwiftyAppearanceDidRefreshWindow = NSNotification.Name(rawValue: "SwiftyAppearanceDidRefreshWindowNotification")
}

Expand All @@ -29,9 +27,9 @@ public extension UIWindow {
addConstraints(constraints)
}

/// <#Description#>
/// Refreshes appearance for the window
///
/// - Parameter animated: <#animated description#>
/// - Parameter animated: if the refresh should be animated
public func refreshAppearance(animated: Bool) {
NotificationCenter.default.post(name: .SwiftyAppearanceWillRefreshWindow, object: self)
UIView.animate(withDuration: animated ? 0.25 : 0, animations: {
Expand Down

0 comments on commit dab3a22

Please sign in to comment.