Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a single style leads to undefined behavior if incorrect time of day #989

Closed
ericrwolfe opened this issue Jan 9, 2018 · 1 comment · Fixed by #990
Closed

Setting a single style leads to undefined behavior if incorrect time of day #989

ericrwolfe opened this issue Jan 9, 2018 · 1 comment · Fixed by #990

Comments

@ericrwolfe
Copy link
Contributor

I'm getting a situation where I'm building a style switcher and caching each style as a property to load later. When passing them into the NavigationViewController.init() method, sometimes the style loads, and sometimes it displays like so:

simulator screen shot - iphone x - 2018-01-08 at 17 18 35

class ListViewController: UITableViewController {

    let styleA = StyleA()
    let styleB = StyleB()
    let styleC = StyleC()

   ...
}

Loading navigation from ListViewController like so:

let viewController = NavigationViewController(for: route, styles: [self.styleA])

Each style is a subclass of DayStyle, and implements the init() and apply() methods:

class StyleBase: DayStyle {
    required init() {
        super.init()
        statusBarStyle = .lightContent
    }
    
    override func apply() {
        super.apply()
        Button.appearance().textColor = #colorLiteral(red: 0.9842069745, green: 0.9843751788, blue: 0.9841964841, alpha: 1)
    }
}

cc @frederoni

@ericrwolfe ericrwolfe changed the title Styles not loading properly Setting a single style leads to undefined behavior if incorrect time of day Jan 9, 2018
@ericrwolfe
Copy link
Contributor Author

Looks like this is a bug related to the time of day. Given that it's now night time locally, setting styleType = .night fixed the problem.

We should not check the time of day if only a single style is passed in.

cc @frederoni @bsudekum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant