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
Size: 501
Language: Swift
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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()])
eService.bind([
({ $0.textColor }, [label.rx.textColor]),
({ $0.backgroundColor }, [view.rx.backgroundColor])
isposed(by: disposeBag)
eService.set(index: 0)
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
}
}
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.
To run the example project, clone the repo, and run pod install
from the Example directory first.
RxTheme is available through CocoaPods. To install it, simply add the following line to your Podfile:
'RxTheme'
duan, wddwyss@gmail.com
RxTheme is available under the MIT license. See the LICENSE file for more info.