RxSwiftCommunity/RxTheme

Name: RxTheme

Owner: RxSwift Community

Description: Theme management based on Rx

Created: 2018-03-04 09:05:30.0

Updated: 2018-05-24 19:39:10.0

Pushed: 2018-04-17 11:50:07.0

Homepage:

Size: 501

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

RxTheme

Build Status Version License Platform

Manual
Define theme service
ocol Theme {
var backgroundColor: UIColor { get }
var textColor: UIColor { get }


ct LightTheme: Theme {
let backgroundColor = UIColor.white
let textColor = UIColor.black


ct DarkTheme: Theme {
let backgroundColor = UIColor.black
let textColor = UIColor.white


themeService = ThemeService<Theme>(themes: [LightTheme(), DarkTheme()])
Apply theme to UI
eService.bind([
({ $0.textColor }, [label.rx.textColor]),
({ $0.backgroundColor }, [view.rx.backgroundColor])
isposed(by: disposeBag)
Switch themes
eService.set(index: 0)
Binder presets
UIApplication UIView UIButton UILabel UITextField UIImageView UIProgressView UIPageControl UISlider UIToolbar UISwitch UITableView UINavigationBar UITabBar UITextView UIActivityIndicatorView UIBarButtonItem CALayer
Extend binders in your codebase

Because RxTheme uses Binder<T> from RxCocoa, any Binder defined in RxCocoa could be used here.

This also makes the lib super easy to extend in your codebase, here is an example

nsion Reactive where Base: UIView {
var borderColor: Binder<UIColor?> {
    return Binder(self.base) { view, color in
        view.layer.borderColor = color?.cgColor
    }
}

Extend binders in the lib

Open codegen/exts.yml, add class, attributes and supported os.

plication:
trs:
statusBarStyle: UIStatusBarStyle
: [iOS]

then run codegen script

ake sure you have python3 and pipenv installed
penv install
penv run python -m codegen

If you think it's commonly used, please send us a PR.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

RxTheme is available through CocoaPods. To install it, simply add the following line to your Podfile:

'RxTheme'
Author

duan, wddwyss@gmail.com

License

RxTheme is available under the MIT license. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.