inloop / Styles

Styling iOS apps made easy
MIT License
18 stars 2 forks source link

Allow typed access to style attributes #75

Open VilemKurz opened 6 years ago

VilemKurz commented 6 years ago

Let's say I have a standard style defined like this which is used in multiple scenes on multiple places.

static let defaultRegular12CoolGrey = TextStyle(
    .font(.defaultRegular12),
    .foregroundColor(.coolGrey)
)

One of those places is to style raw html from api. Here I need to inject styling html header, where I need separate color and separate font. Currently I have to type the attribute:

let color = TextStyle.defaultRegular12CoolGrey.attributes[.foregroundColor] as? UIColor

It is not Swifty that attributes[.attribute] returns Any. It should return exact type. So that we could write directly

let color = TextStyle.defaultRegular12CoolGrey.attributes[.foregroundColor] //color is optional UIColor