Skip to content

Drive Color generation from UIColor generation #3

@leopic-sc

Description

@leopic-sc

Is your feature request related to a problem? Please describe.
Most mature iOS applications use either fully or partially UIKit for their user interfaces. This means that a purely SwiftUI driven exporter is a nice addition, but has reduced day-to-day value.

Describe the solution you'd like
Ideally an entire UIKit driven exporter would be provided by Supernova, but Colors can be a starting point.

Additional context
It's important to keep in mind that SwiftUI Colors have an initializer that can take a UIKit UIColor.

Reusing the existing template to generate a UIColor:

import UIKit

extension UIColor {
    static let Token = UIColor.TokenColor()
    
    struct TokenColor {
        // Light mode
        let lightModeSurface = UIColor(red: 255 / 255, green: 255 / 255, blue: 255 / 255, alpha: 1)
    }
}

Once the color is declared as a UIColor, we can just reference it in SwiftUI:

import SwiftUI

extension Color {
    static let Token = Color.TokenColor()

    struct TokenColor {
        // Light mode
        let lightModeSurface = Color(UIColor.Token.lightModeSurface)
}

This would mean that each color would be generated for both Frameworks but still driven from the same token.

The downside of this approach would be newer SwiftUI only applications would have UIKit generated code that wouldn't be used.

NOTE: keep in mind that UIColors can be used to create Colors, but not the other way around.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions