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

Drive Color generation from UIColor generation #3

Open
leopic-sc opened this issue Mar 9, 2022 · 1 comment
Open

Drive Color generation from UIColor generation #3

leopic-sc opened this issue Mar 9, 2022 · 1 comment
Assignees

Comments

@leopic-sc
Copy link

leopic-sc commented Mar 9, 2022

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.

@Ydus
Copy link
Contributor

Ydus commented Mar 9, 2022

Hi @leopic-sc 🙂

Thanks for bringing this up! We can definitely update the exporter to generate UIKit colors as well. Could you write down some examples of how you'd like to see the other tokens exported in UIKit? That would help a lot!

Ydus added a commit that referenced this issue Mar 29, 2022
…from UIColors, separated SwiftUI and UIKit into folders
@Ydus Ydus self-assigned this Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants