All Projects → onmyway133 → Easytheme

onmyway133 / Easytheme

Licence: other
👕👚 Theme management in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Easytheme

Ssf2fcitx
Automagically convert your favorite sogou-pinyin skin to fcitx skin
Stars: ✭ 104 (-51.85%)
Mutual labels:  skin
Creature webgl
2D Skeletal Animation WebGL Runtimes for Creature ( PixiJS, PhaserJS, ThreeJS, BabylonJS, Cocos Creator )
Stars: ✭ 140 (-35.19%)
Mutual labels:  skin
Thememanager
ThemeManager is a lightweight library for application to switching themes. support more attributes and theme extensions. more easy and convenient to use.
Stars: ✭ 165 (-23.61%)
Mutual labels:  skin
Sbplayerclient
支持全格式的mac版视频播放器
Stars: ✭ 110 (-49.07%)
Mutual labels:  skin
Dmusic
DMusic Player for Android - An online music player based on Component + MVP Base + MVP Customization + greenDAO + OkHttp3 + Retrofit + RxJava2; supports local and network music playback; can play Baidu music, Netease cloud music; support online music list , radio, MV, music online, download, local and online lyrics; Lyrics, music cache; self-built song list, song management, collection, sorting, sorting, skinning, sleep timing, mode switching, more settings, etc. 基于 Component + MVP Base + MVP Customization + greenDAO + OkHttp3 + Retrofit + RxJava2 的在线音乐播放器; 支持本地及网络音乐播放; 可播放百度音乐,网易云音乐; 支持在线音乐榜单, 电台, MV, 音乐在线播放,下载, 本地及在线歌词; 歌词, 音乐缓存; 自建歌单, 歌曲管理, 收藏, 排序, 分类, 换肤, 睡眠定时, 模式切换, 更多设置等
Stars: ✭ 121 (-43.98%)
Mutual labels:  skin
Minimal Gltf Loader
A minimal, engine-agnostic JavaScript glTF Loader.
Stars: ✭ 148 (-31.48%)
Mutual labels:  skin
Fluent Metro
A modern, highly customizable Start menu for Open-Shell.
Stars: ✭ 80 (-62.96%)
Mutual labels:  skin
Swifttheme
🎨 Powerful theme/skin manager for iOS 9+ 主题/换肤, 暗色模式
Stars: ✭ 2,259 (+945.83%)
Mutual labels:  skin
Weewx Belchertown
A clean and modern weewx skin with real time streaming updates, forecast data and interactive charts. View it in action at BelchertownWeather.com
Stars: ✭ 131 (-39.35%)
Mutual labels:  skin
Substance
A modern and high-performant Swing look-and-feel library
Stars: ✭ 163 (-24.54%)
Mutual labels:  skin
Metro For Discord
Make your Discord client look like a UWP app.
Stars: ✭ 109 (-49.54%)
Mutual labels:  skin
Cp sssss
Naive screen-space subsurface scattering solution for Unity 5.
Stars: ✭ 119 (-44.91%)
Mutual labels:  skin
Solo Skins
🎨 Solo 博客系统的官方皮肤。
Stars: ✭ 150 (-30.56%)
Mutual labels:  skin
Minecraft Avatar
PHP script (using GD) to generate avatar or skin from a Minecraft username
Stars: ✭ 104 (-51.85%)
Mutual labels:  skin
Qui
【此项目作者为刘典武,不是我自己的原创项目,望周知。也请大家不要骚扰刘典武。】一个用Qt开发的用来生成QSS文件的小程序,附简单Demo,主程序本身也可以看作一个很好的Demo。
Stars: ✭ 168 (-22.22%)
Mutual labels:  skin
Hubot Minecraft Skin
Hubot's very own Minecraft skin
Stars: ✭ 85 (-60.65%)
Mutual labels:  skin
Chameleon
Android Change Skin, Android Night Mode, 安卓换肤,安卓夜间模式
Stars: ✭ 141 (-34.72%)
Mutual labels:  skin
Arctic admin
Responsive Theme for ActiveAdmin
Stars: ✭ 201 (-6.94%)
Mutual labels:  skin
Creature ue4
Unreal Engine 4 Runtimes for Creature, the 2D Skeletal + Mesh Animation Tool
Stars: ✭ 174 (-19.44%)
Mutual labels:  skin
Etl unicorn
数据可视化, 数据挖掘, 数据处理 ETL
Stars: ✭ 156 (-27.78%)
Mutual labels:  skin

Themes

CI Status Version Carthage Compatible License Platform Swift

Story

Ever want to support Night mode? Or skin the app differently depending on the seasons? Or toggle features according to paid status? Well, those are actually reactions to app events.

Many other frameworks encourage you to use hard coded values, like label.xyz_textColors = [.red, .blue], textField.xyz_fonts = [font1, font2], .... This also makes it very hard to change because the usage of index, you need to remember that the 1st index is this theme, the 2nd index is that theme, ... Also, xyz_textColors is like trying to replicate the entire UIKit APIs, which updates often 😱

Themes is here to help. Usually, you have a finite number of colors and fonts in an app. You can have many more but that is not encourage and has design smells. When you have a theme, changing happens in one place.

Features

  • [x] Universal support for iOS, macOS, tvOS, watchOS
  • [x] Complete control over themes
  • [X] Update existing views
  • [x] Protocol oriented
  • [x] Extensible

Usage

Step 1: Create a theme

Declare your theme by conforming to Theme, which is just a marker protocol. You can declare whatever you like, including nested objects, all depending on your need. You can also create as many themes as you like

struct MyTheme: Theme {
  let topImage: UIImage
  let cellColor: UIColor
  let backgroundColor: UIColor
  let name: String
  let titleFont: UIFont
  let subtitleFont: UIFont
}

Then create some themes based on your templates

let dayTheme = MyTheme(topImage: UIImage(named: "day"), cellColor: .white)
let nightTheme = MyTheme(topImage: UIImage(named: "night"), cellColor: .black)

The beauty of this is that you can init your theme from json, which can be fetched from backend 🚀

let json = [
  "primary_color": "#21ABE9",
  "font_name": "Chewy"
]
let unicornTheme = MyTheme(json)

Step 2: Register your current theme

When app launches, you need to declare 1 theme as the current, it can be loaded from cache

ThemeManager.shared.currentTheme = dayTheme

Step 3: React to theme change

You can do this wherever you like. It is set using the current theme, and whenever theme changes

// ViewController.swift
override func viewDidLoad() {
  super.viewDidLoad()

  use(MyTheme.self) {
    $0.title = $1.name
    $0.tableView.backgroundColor = $1.backgroundColor
    $0.navigationController?.navigationBar.setBackgroundImage($1.topImage, for: .default)
    $0.tableView.rowHeight = $1.name == "Unicorn" ? 180 : 120
    $0.tableView.reloadData()
  }
}

// Cell.swift
override func awakeFromNib() {
  super.awakeFromNib()

  imageView.layer.cornerRadius = 5
  imageView.layer.masksToBounds = true

  use(MyTheme.self) {
    $0.titleLabel.font = $1.titleFont
    $0.subtitleLabel.font = $1.subtitleFont
    $0.container.backgroundColor = $1.cellColor
  }
}

Step 4: Change the theme

Change the current theme is as easy as assigning a new theme. All happens in real time and very fast

ThemeManager.shared.currentTheme = nightTheme

Installation

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

pod 'Themes'

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

github "onmyway133/Themes"

Themes can also be installed manually. Just download and drop Sources folders in your project.

Author

Khoa Pham, [email protected]

Contributing

We would love you to contribute to Themes, check the CONTRIBUTING file for more info.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].