Git Product home page Git Product logo

thememanager's Introduction

ThemeManager

ThemeManager is a most lightweight, powerful, convenient and easiest way to manage your app themes, and also support change text(e.g. language) or other configurations dynamically too.

Installing ThemeManager

ThemeManager supports CocoaPods and Carthage. ThemeManager is written in Swift.

Github Repo

You can pull the ThemeManager Github Repo and include the ThemeManager.xcodeproj to build a dynamic or static library.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate ThemeManager into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'WYZThemeManager'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate ThemeManager into your Xcode project using Carthage, specify it in your Cartfile:

github "azone/ThemeManager" "master"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but ThemeManager does support its use on supported platforms.

Once you have your Swift package set up, adding ThemeManager as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/azone/ThemeManager.git", from: "0.3.0")
]

Demo

Usage

1. implement your self theme, language or other configuration (may be class, struct or anything you want) which must be conform Theme protocol.

Example:

import ThemeManager

struct MyTheme: Theme {
   var backgroundColor = UIColor.gray
   var mainColor = UIColor.orange

   var titleFont = UIFont.preferredFont(forTextStyle: .headline)
   var subtitleFont = UIFont.preferredFont(forTextStyle: .subheadline)
   var textColor = UIColor.red

   var buttonTitleColor = UIColor.orange
   var buttonTitleHighlightcolor = UIColor.red
   
   var title = "Default Theme"
}

2. Declare ThemeManager instance variable with your default theme in the global scope.

Example:

let themeManager = ThemeManager(MyTheme())

3. Put any theme, language or configuration related setups in setUp method

Example

themeManager.setup(view) { (view, theme) in
    view.backgroundColor = theme.backgroundColor
}

themeManager.setup(navigationItem) { (item, theme) in
    item.title = theme.title
}

themeManager.setup(navigationController?.navigationBar) { (bar, theme) in
    bar.tintColor = theme.mainColor
    bar.barTintColor = theme.backgroundColor
}

4. Change another theme, language or configuration with your theme instance:

themeManager.apply(otherTheme)

License

ThemeManager is released under the MIT license. See LICENSE for details.

thememanager's People

Contributors

azone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

thememanager's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.