|
@@ -18,27 +18,15 @@ const { locale } = useI18n();
|
|
|
|
|
|
|
|
const $q = useQuasar();
|
|
const $q = useQuasar();
|
|
|
|
|
|
|
|
-const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
|
|
|
- ? "dark"
|
|
|
|
|
- : "light";
|
|
|
|
|
-
|
|
|
|
|
-const updateStatusBar = async (isDark) => {
|
|
|
|
|
|
|
+const updateStatusBar = async () => {
|
|
|
if (!Capacitor.isNativePlatform()) return;
|
|
if (!Capacitor.isNativePlatform()) return;
|
|
|
|
|
|
|
|
await StatusBar.show();
|
|
await StatusBar.show();
|
|
|
await StatusBar.setStyle({
|
|
await StatusBar.setStyle({
|
|
|
- style: isDark ? Style.Dark : Style.Light,
|
|
|
|
|
|
|
+ style: Style.Light,
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-watch(
|
|
|
|
|
- () => $q.dark.isActive,
|
|
|
|
|
- async (value) => {
|
|
|
|
|
- await Preferences.set({ key: "theme", value: value ? "dark" : "light" });
|
|
|
|
|
- await updateStatusBar(value);
|
|
|
|
|
- },
|
|
|
|
|
-);
|
|
|
|
|
-
|
|
|
|
|
watch(
|
|
watch(
|
|
|
() => locale.value,
|
|
() => locale.value,
|
|
|
async (value) => {
|
|
async (value) => {
|
|
@@ -47,16 +35,12 @@ watch(
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
onBeforeMount(async () => {
|
|
onBeforeMount(async () => {
|
|
|
- const { value: themePref } = await Preferences.get({ key: "theme" });
|
|
|
|
|
- const theme = themePref || systemTheme;
|
|
|
|
|
- const isDark = theme === "dark";
|
|
|
|
|
-
|
|
|
|
|
- $q.dark.set(isDark);
|
|
|
|
|
- await updateStatusBar(isDark);
|
|
|
|
|
|
|
+ $q.dark.set(false);
|
|
|
|
|
+ await updateStatusBar();
|
|
|
|
|
|
|
|
const { value: localePref } = await Preferences.get({ key: "locale" });
|
|
const { value: localePref } = await Preferences.get({ key: "locale" });
|
|
|
const userLocale = localePref || window.navigator.language;
|
|
const userLocale = localePref || window.navigator.language;
|
|
|
|
|
|
|
|
- console.log(theme, userLocale);
|
|
|
|
|
|
|
+ console.log(userLocale);
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|