RedMadRobot / figma-export

Command line utility to export colors, typography, icons and images from Figma to Xcode / Android Studio project
MIT License
726 stars 114 forks source link

Support universal colors and assets #69

Closed JonLz closed 3 years ago

JonLz commented 3 years ago

Resolves #68

Let me know if there is any fix required for android. I'm not as familiar with how the color specifications work on that platform. I think it can now generate a dark colors file with less values than the light colors file. Is that an issue? For the time being, I've added in the same warning used in iOS. Similarly, I was not able to test illustration exports but let me know if you see any issues there.

subdan commented 3 years ago

Thanks for the PR! I will check it by the end of the week.

JonLz commented 3 years ago

Thank you for reviewing the PR. I've added your suggestions.

JonLz commented 3 years ago

Rebased from the latest master and updated the README conflicts.

JonLz commented 3 years ago

Thanks for your comments, I think the processing code is cleaner now. Please take a look at the latest commit. Thanks.

subdan commented 3 years ago

If I remove a dark illustration I get the following error: Error: ❌ Asset with name img_zero_error have different description. In dark theme «», in light theme «android»

Open AssetProcessor.swift file and find 4. descriptionMismatch string. When there is no dark variant of image dark is equal to nil and error occurs.

if let platform = asset.platform {
let dark = darkSet.first(where: { $0.name == asset.name })
if dark?.platform != platform { // <<<<<<—————— Bug here
    errors.all.append(...)
}

I've fixed this issue. You can copy the code below.

// 4. descriptionMismatch
lightSet.forEach { asset in
    if
        let platform = asset.platform,
        let dark = darkSet.first(where: { $0.name == asset.name }),
        dark.platform != platform {

        let error = AssetsValidatorError.descriptionMismatch(
            assetName: asset.name,
            light: platform.rawValue,
            dark: dark.platform?.rawValue ?? "")

        errors.all.append(error)
    }
}
subdan commented 3 years ago

@JonLz Thanks for the PR! Great job! I will publish a new version by the end of the week.