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

Refactor styling #536

Merged
merged 13 commits into from Aug 29, 2017
Merged

Refactor styling #536

merged 13 commits into from Aug 29, 2017

Conversation

frederoni
Copy link
Contributor

@frederoni frederoni commented Aug 25, 2017

Made a few changes here since trait collections are usually applied per property, not per style.
This also makes it a lot more convenient to style components that aren't explicitly exposed in the style.

A custom night style would look something like this:

class CustomNightStyle: DayStyle {
    
    required init() {
        super.init()
        mapStyleURL = URL(string: "mapbox://styles/mapbox/satellite-streets-v9")!
        styleType = .nightStyle
    }
    
    override func apply() {
        super.apply()
        ManeuverView.appearance().backgroundColor = #colorLiteral(red: 0.2974345386, green: 0.4338284135, blue: 0.9865127206, alpha: 1)
        RouteTableViewHeaderView.appearance().backgroundColor = #colorLiteral(red: 0.2974345386, green: 0.4338284135, blue: 0.9865127206, alpha: 1)
    }
}

@bsudekum 👀

@frederoni frederoni force-pushed the fred-extend-styling branch 2 times, most recently from 0afcd3b to 5e1d7fb Compare August 25, 2017 15:31
DistanceLabel.appearance().textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
DestinationLabel.appearance().textColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
TimeRemainingLabel.appearance().textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
ArrivalTimeLabel.appearance().textColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it, want to add a StyleType enum to this style and also add a custom dark theme? Would be cool to show custom night/day switching styles in the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 29b1269

@@ -162,10 +162,10 @@ class ViewController: UIViewController, MGLMapViewDelegate {

exampleMode = .default

let navigationViewController = NavigationViewController(for: route, locationManager: locationManager())
let navigationViewController = NavigationViewController(for: route, styles: [DefaultStyle()], locationManager: locationManager())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sort of a confusing case. It's sort of half the default case since we're not passing in the default dark style? Thoughts on reverting this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, this was just to force the light style while working on it.

@frederoni frederoni force-pushed the fred-extend-styling branch 2 times, most recently from f6d1846 to 1ca839e Compare August 25, 2017 16:34
@bsudekum
Copy link
Contributor

bsudekum commented Aug 25, 2017

This is looking good, however I'm getting the default dark style (during the day) in the demo app.

@frederoni
Copy link
Contributor Author

@bsudekum We should be good to ✅ here.

@@ -564,7 +210,7 @@ public class ProgressBar: UIView {

let bar = UIView()

dynamic var barColor: UIColor = #colorLiteral(red: 0.1411764771, green: 0.3960784376, blue: 0.5647059083, alpha: 1) {
dynamic public var barColor: UIColor = #colorLiteral(red: 0.1411764771, green: 0.3960784376, blue: 0.5647059083, alpha: 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs documentation.

@@ -23,7 +23,7 @@ extension UIFont {
}

// Adjusted for preferredContentSizeCategory (`adjustsFontForContentSizeCategory` is supported iOS >= 10.0)
var adjustedFont: UIFont {
public var adjustedFont: UIFont {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation needed.

Copy link
Contributor

@bsudekum bsudekum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, added few doc comments.

@frederoni frederoni merged commit 3affa25 into master Aug 29, 2017
@frederoni frederoni deleted the fred-extend-styling branch August 29, 2017 21:20
@1ec5 1ec5 added the backwards incompatible changes that break backwards compatibility of public API label Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible changes that break backwards compatibility of public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants