If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Create a theme class to hold colors/images/fonts

RESOLVED DUPLICATE of bug 1148469

Status

()

Firefox for iOS
General
RESOLVED DUPLICATE of bug 1148469
3 years ago
3 years ago

People

(Reporter: bnicholson, Assigned: nalexander)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
Our theming is quickly becoming messy as we have fonts, colors, and images scattered throughout the app. This becomes especially ugly when introducing things like https://github.com/mozilla/firefox-ios/pull/97.

We should consider creating a themes class to contain these resources. One approach is loosely outlined on Stack Overflow: http://stackoverflow.com/questions/13547860/best-practices-of-theming-skinning-an-ios-app

Comment 1

3 years ago
Hey Brian,

I haven't contributed to the project but have been following from afar and I might be able to make a suggestion. One thing I've done in the past is wrap any stylings on fonts/images/etc inside their own extensions on the framework classes that describe how the font is used - like extension methods named tabHeader, detailText, etc. The extension method can then delegate/proxy to a theme controller that has knowledge of the various themes available to the app. These themes can be stored in a plist file or some other format and be parsed into the controller. At runtime, when the user toggles different modes, the theme controller updates it's current theme and the associated proxied extension methods have the new theme.

Another benefit of this approach is that it cleans up a lot of styling you need to do on your views in your view controllers and keeps the code DRY but not repeating the same fonts/colors/etc across the app. I haven't done this in Swift yet - only in ObjC - but I can't imagine it being that much different.

Hope that helps a bit!
(In reply to Brian Nicholson (:bnicholson) from comment #0)
> We should consider creating a themes class to contain these resources. One
> approach is loosely outlined on Stack Overflow:
> http://stackoverflow.com/questions/13547860/best-practices-of-theming-
> skinning-an-ios-app

Note that those answers are from before Apple introduced extensive theming support in UIKit. We should take advantage of that where possible I think.

Check out http://nshipster.com/uiappearance/ for a quick intro to UIAppearance
(Reporter)

Updated

3 years ago
Blocks: 1135178
(Assignee)

Updated

3 years ago
Assignee: nobody → nalexander
Status: NEW → ASSIGNED
I did something like this in bug 1148469. We need to pull out more, but I've been waiting to see what's duplicated to figure out what to pull out... Closing this though.
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1148469
You need to log in before you can comment on or make changes to this bug.