Skip to content

assetAccentColor doesn't search for AccentColor in my module's bundle #431

@dfabulich

Description

@dfabulich

skip-ui/README.md

Lines 2575 to 2579 in 2f7c8e2

#### Accent Color
In addition to programmatically using SwiftUI's `.tint` modifier, iOS allows you to set your application's accent color via the `AccentColor` resource in your app's `Assets` asset catalog. In a Skip app, you can find `Assets` in the `Darwin` folder.
Skip also supports these mechanisms, but your generated Android app can't access the `Darwin` folder contents. To define an accent color resource for your Android app, create a color set called `AccentColor` in the `Sources/<YourAppModule>/Resources/Module` asset catalog. See the section on Named Colors below for additional details.

Accent Color

In addition to programmatically using SwiftUI's .tint modifier, iOS allows you to set your application's accent color via the AccentColor resource in your app's Assets asset catalog. In a Skip app, you can find Assets in the Darwin folder.

Skip also supports these mechanisms, but your generated Android app can't access the Darwin folder contents. To define an accent color resource for your Android app, create a color set called AccentColor in the Sources/<YourAppModule>/Resources/Module asset catalog. See the section on Named Colors below for additional details.

Sounds great, but there's just one problem:

#if SKIP
@Composable static func assetAccentColor(colorScheme: ColorScheme) -> androidx.compose.ui.graphics.Color? {
let name = "AccentColor"
let colorInfo = rememberCachedAsset(namedColorCache, AssetKey(name: name, bundle: Bundle.main)) { _ in
assetColorInfo(name: name, bundle: Bundle.main)
}
return colorInfo?.colorImpl(colorScheme: colorScheme)
}

We're not searching my module's bundle. We're searching Bundle.main, the bundle that isn't transpiled.

This code can find an accent color if you manually install one in your main bundle, but if you follow the documented instructions to put an AccentColor in your module bundle, this code will never find it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions