From 047670356783eb3a3e898ee9d6e955cdca2a48d1 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 7 May 2023 21:06:30 -0700 Subject: [PATCH] nx: set theme color Signed-off-by: Varun Patil --- src/App.vue | 6 ++++++ src/native.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/App.vue b/src/App.vue index 90f2e9b6..451d4ec1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -226,6 +226,12 @@ export default defineComponent({ root.style.setProperty('--color-primary-select-light', `${colorPrimary}40`); root.style.setProperty('--plyr-color-main', colorPrimary); + // Set theme color for native part + nativex.setThemeColor?.( + getComputedStyle(document.body).getPropertyValue('--color-main-background'), + document.body.hasAttribute('data-theme-dark') + ); + // Register sidebar metadata tab globalThis.OCA?.Files?.Sidebar?.registerTab( new globalThis.OCA.Files.Sidebar.Tab({ diff --git a/src/native.ts b/src/native.ts index 8ebdf803..19ca26e2 100644 --- a/src/native.ts +++ b/src/native.ts @@ -10,6 +10,7 @@ type NativePromise = (call: string, arg: T) => void; */ export type NativeX = { isNative: () => boolean; + setThemeColor: (color: string, isDark: boolean) => void; getLocalDays: NativePromise; getLocalByDayId: NativePromise; getJpeg: NativePromise; @@ -80,6 +81,11 @@ globalThis.nativexr = (call: string, resolve?: string, reject?: string) => { */ export const has = () => !!nativex; +/** + * Change the theme color of the app. + */ +export const setThemeColor: typeof nativex.setThemeColor = nativex?.setThemeColor.bind(nativex); + /** * Gets the local days array. *