Coder Social home page Coder Social logo

Initial theme apply? about gestalt HOT 3 CLOSED

regexident avatar regexident commented on June 15, 2024
Initial theme apply?

from gestalt.

Comments (3)

regexident avatar regexident commented on June 15, 2024 1

The README mentions it:

// In `AppDelegate.application(_:didFinishLaunchingWithOptions:)`
// assign a default theme (or user's choice from user defaults):
ThemeManager.default.theme = Theme.light

But you're right, it could β€”and shouldβ€” be much clearer! πŸ™ˆ

I just pushed the first beta for v2.0.0 a couple of days ago and haven't gotten to improving the README yet. I'll make sure to improve the README!

If you have any further questions or things that might be made clearer, lemme know and I'll make sure to include them in the documentation improvements.

from gestalt.

regexident avatar regexident commented on June 15, 2024

self.observe(theme: \MyTheme.view) will ensure that self.apply(theme: \MyTheme.view) is executed immediately (if a theme has been chosen at that point).

To choose a theme you assign a value to ThemeManager.default.theme early during your app's launch (e.g. in AppDelegate's func application(_:didFinishLaunchingWithOptions:)):

(Gestalt includes a GestaltDemo target which should give you an idea of how Gestalt works.)

πŸ‘‰πŸ» GestaltDemo/AppDelegate.swift

With v2.x all you should have to do is run self.observe(theme: \MyTheme.view) once in an object's lifetime. The ThemeManager then makes sure that self.apply(theme: \MyTheme.view) is executed on every theme-observing object once its theme is changed.

from gestalt.

mario-deluna avatar mario-deluna commented on June 15, 2024

The GestaltDemo is really helpful thanks, I think what god me confused is this part in the Readme:

class ViewController: UIViewController {
    @IBOutlet var label: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
	self.observe(theme: \Theme.view)
    }
}

This way apply is not being called initially, if the view controller is being loaded after a the theme has been set.

from gestalt.

Related Issues (13)

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.