You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import RxTheme
protocolTheme{varbackgroundColor:UIColor{get}vartextColor:UIColor{get}}structLightTheme:Theme{letbackgroundColor=.white
lettextColor=.black
}structDarkTheme:Theme{letbackgroundColor=.black
lettextColor=.white
}enumThemeType:ThemeProvider{case light, dark
varassociatedObject:Theme{switchself{case.light:returnLightTheme()case.dark:returnDarkTheme()}}}letthemeService=ThemeType.service(initial:.light)
Apply theme to UI
// Bind stream to a single attribute
// RxTheme would automatically manage the lifecycle of the binded stream
view.theme.backgroundColor = themeService.attribute{ $0.backgroundColor }
Switch themes
themeService.switch(.dark)
// When this is triggered by some signal, you can use:
someSignal.bind(to: themeService.switcher)
Other APIs
// Current theme type
themeService.type
// Theme type stream
themeService.typeStream
Examples
You can run the example project, clone the repo, run pod install from the Example directory first, and open up the workspace file.