SkillAgentSearch skills...

ThemePark

Theme library for iOS

Install / Use

/learn @eonist/ThemePark
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ThemePark

mit platform Lang SPM SwiftLint Sindre codebeat badge Swift

<img width="222" alt="img" src="https://rawgit.com/stylekit/img/master/ThemeLib.gif">

What is it

Theme library for iOS & Mac

How does it work

  • Watches for changes 💥
  • Live theme updates while the app is running 👌
  • Traverses the entire UIView hierarchy with one call 🤯
  • Animated transitions 🎬
  • Small foot-print 🗜
  • Store styles in json or struct

How do I get it

  • SPM "github.com/eonist/ThemePark" branch: "master"
  • Manual Open .xcodeproj

Topology:

.
├── assets.bundle         # .json theme files
├── theme                 # Customize your theme structure
├── ThemePark             # iOS app code
├── ThemePark-example     # macOS app code
└── src                   # Core-src
     ├── common           # Util-Extensions
     └── core             # Core code
           ├── decode     # Decode JSON to Color and Font
           ├── util       # Apply theme to components
           └── themeable  # Components that are themeable

Examples:

Change theme live / dynamically in the app

@IBAction private func onSwitchChange(_ sender: UISwitch) {
      CustomTheme.currentType = sender.isOn ? CustomTheme.ThemeType.dark.rawValue : CustomTheme.ThemeType.light.rawValue
      CustomTheme.theme = CustomTheme.getTheme(theme: CustomTheme.currentType)
      ThemeUtil.transition(self)
    }
}

Add theme in controller

class Main: UITableViewController {
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        ThemeUtil.apply(self)
    }
}

Hot load theme / see your theme changes be applied live

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
   // Set the customTheme, before components ask Theme for styling
   CustomTheme.setTheme(themeType: CustomTheme.ThemeType.light.rawValue) // set init theme
   // Watches for changes, super useful for testing styling by just changing the json doc
   FileWatcher(Bundle.main.resourcePath!+"/assets.bundle/dark.json") {
      Swift.print("the file was modified")
      if let controller = UIApplication.shared.topMostViewController() {
         CustomTheme.theme = CustomTheme.getTheme(theme: CustomTheme.currentType)//update the theme
         ThemeUtil.apply(controller)
      }
   }.start()
   return true
}

Todo:

View on GitHub
GitHub Stars17
CategoryDevelopment
Updated4y ago
Forks0

Languages

Swift

Security Score

60/100

Audited on Jan 23, 2022

No findings