Skip to content
This repository has been archived by the owner. It is now read-only.
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

themeable

Themeable Build Status Carthage Swift License

Usage

Load your colors into Theme.shared using ThemeColors which conforms to Codeable, so you can load a JSON file from your Bundle (e.g. mytheme.json)

let myThemeColors = ThemeColors.load(bundle: "mytheme")

or any from any URL

let myThemeColors = ThemeColors.load(url: URL(string: "https://example.com/mytheme.json")!)

and apply the Theme using (if force is true it will also reload the current view=

Theme.shared.apply(force: true)

Example

Load your Theme mytheme.json at the start of the app.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Theme.shared.colors = ThemeColors.from(bundle: "mytheme")
    Theme.shared.apply(force: true)
    return true
}

Advanced

If your app is using Eureka you can enable support for it with Theme.shared.eureka = true

If you want to customize the colors (for example a user customizable global tint color) before applying the theme you can do so in

Theme.shared.customColor {
	// Load custom Colors, e.g.
	Theme.shared.tint = ... // Load user tint 
}

You can also add your custom apperance setters here

Theme.shared.customAppearances {
	// Load custom appearances, e.g.
	UIButton.appearance(whenContainedInInstancesOf [MyViewController.self]).backgroundColor = .green
}

Installation

Themeable is available through Carthage. To install just write into your Cartfile:

github "divadretlaw/Themeable"

License

See LICENSE