RxTheme
Theme management based on Rx
Install / Use
/learn @RxSwiftCommunity/RxThemeREADME
RxTheme
Manual
Define theme service
import RxTheme
protocol Theme {
var backgroundColor: UIColor { get }
var textColor: UIColor { get }
}
struct LightTheme: Theme {
let backgroundColor = .white
let textColor = .black
}
struct DarkTheme: Theme {
let backgroundColor = .black
let textColor = .white
}
enum ThemeType: ThemeProvider {
case light, dark
var associatedObject: Theme {
switch self {
case .light:
return LightTheme()
case .dark:
return DarkTheme()
}
}
}
let themeService = 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.
Installation
SPM
- File > Swift Packages > Add Package Dependency
- Add https://github.com/RxSwiftCommunity/RxTheme
Cocoapods
pod 'RxTheme', '~> 6.0'
Carthage
github "RxSwiftCommunity/RxTheme" ~> 6.0.0
Author
duan, wddwyss@gmail.com
License
RxTheme is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
