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

Programatic themes #59

Merged
merged 3 commits into from
Apr 20, 2020
Merged

Conversation

rivera-ernesto
Copy link
Contributor

With this changes it is now possible both to create Theme objects fully programmatically, or also adjust themes read from json files.

Sample fully programatic theme that handles iOS 13 dark mode:

var theme = Theme()
theme.body.attributes = [.font :  UIFont.inter(), .foregroundColor : UIColor.secondaryLabel]
theme.styles.append(Style(element: .h1, attributes: [.font : UIFont.inter(size: 24), .foregroundColor : UIColor.label]))
theme.styles.append(Style(element: .h2, attributes: [.font : UIFont.inter(size: 18), .foregroundColor : UIColor.label]))
theme.styles.append(Style(element: .h3, attributes: [.font : UIFont.inter(size: 16), .foregroundColor : UIColor.label]))
theme.styles.append(Style(element: .bold, attributes: [.font : UIFont.inter(weight: .bold)]))
theme.styles.append(Style(element: .italic, attributes: [.font : UIFont.inter(italic: true)]))
theme.styles.append(Style(element: .boldItalic, attributes: [.font : UIFont.inter(weight: .bold, italic: true)]))
theme.styles.append(Style(element: .code, attributes: [.font : UIFont(name: "CourierNewPSMT", size: 15)!, .foregroundColor : UIColor.label, .backgroundColor : UIColor.secondarySystemBackground]))
theme.styles.append(Style(element: .image, attributes: [.foregroundColor : UIColor.appTint]))
theme.styles.append(Style(element: .url, attributes: [.foregroundColor : UIColor.appTint]))

Copy link
Owner

@ruddfawcett ruddfawcett left a comment

Choose a reason for hiding this comment

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

Looks great — thanks again @rivera-ernesto. 🎉

@ruddfawcett ruddfawcett merged commit 11e260e into ruddfawcett:master Apr 20, 2020
@rivera-ernesto rivera-ernesto deleted the programatic_themes branch April 20, 2020 14:18
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 this pull request may close these issues.

None yet

2 participants