Polish Live Activity branding and add EAS build config.
Use brand mark and wordmark images in the time clock Live Activity, migrate file copies to the modern expo-file-system File API, and add eas.json for TestFlight production builds. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { Asset } from "expo-asset";
|
||||
import { File } from "expo-file-system";
|
||||
import { widgetsDirectory } from "expo-widgets";
|
||||
import { Platform } from "react-native";
|
||||
|
||||
const MARK_FILE = "beenvoice-live-mark.png";
|
||||
const LOGO_FILE = "beenvoice-live-logo.png";
|
||||
|
||||
let cachedUris: { markUri: string; logoUri: string } | null = null;
|
||||
let copyPromise: Promise<{ markUri: string; logoUri: string } | null> | null = null;
|
||||
|
||||
async function copyBrandFile(fromUri: string, toUri: string) {
|
||||
await new File(fromUri).copy(new File(toUri), { overwrite: true });
|
||||
}
|
||||
|
||||
/** Copy brand PNGs into the app-group folder so the widget extension can read them. */
|
||||
export async function ensureWidgetBrandAssets(): Promise<{
|
||||
markUri: string;
|
||||
logoUri: string;
|
||||
} | null> {
|
||||
if (cachedUris) return cachedUris;
|
||||
if (copyPromise) return copyPromise;
|
||||
|
||||
copyPromise = (async () => {
|
||||
if (Platform.OS !== "ios" || !widgetsDirectory) return null;
|
||||
|
||||
const base = widgetsDirectory.endsWith("/") ? widgetsDirectory : `${widgetsDirectory}/`;
|
||||
const markUri = `${base}${MARK_FILE}`;
|
||||
const logoUri = `${base}${LOGO_FILE}`;
|
||||
|
||||
const markAsset = Asset.fromModule(require("@/assets/images/icon.png"));
|
||||
const logoAsset = Asset.fromModule(require("@/assets/images/beenvoice-logo-dark.png"));
|
||||
await Promise.all([markAsset.downloadAsync(), logoAsset.downloadAsync()]);
|
||||
|
||||
if (!markAsset.localUri || !logoAsset.localUri) return null;
|
||||
|
||||
await Promise.all([
|
||||
copyBrandFile(markAsset.localUri, markUri),
|
||||
copyBrandFile(logoAsset.localUri, logoUri),
|
||||
]);
|
||||
|
||||
cachedUris = { markUri, logoUri };
|
||||
return cachedUris;
|
||||
})();
|
||||
|
||||
try {
|
||||
return await copyPromise;
|
||||
} finally {
|
||||
copyPromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
export function getWidgetBrandAssetUris() {
|
||||
return cachedUris;
|
||||
}
|
||||
Reference in New Issue
Block a user