system default theme implemented

This commit is contained in:
vishnuraghavb 2021-04-24 01:20:32 +05:30
parent e077d04ce4
commit 1aeff3fafe
4 changed files with 26 additions and 9 deletions

View file

@ -1088,7 +1088,7 @@ export default {
}, },
}, },
created() { created() {
this.setTheme(ApplicationSettings.getString("appTheme", "Light")); this.setTheme(ApplicationSettings.getString("appTheme", "sysDef"));
this.setLayout(ApplicationSettings.getString("layout", "detailed")); this.setLayout(ApplicationSettings.getString("layout", "detailed"));
if (!this.recipes.length) this.initRecipes(); if (!this.recipes.length) this.initRecipes();
this.initListItems(); this.initListItems();

View file

@ -67,7 +67,9 @@ export default {
{ {
icon: "theme", icon: "theme",
title: "Theme", title: "Theme",
subTitle: localize(this.appTheme), subTitle: localize(
ApplicationSettings.getString("appTheme", "sysDef")
),
action: this.selectThemes, action: this.selectThemes,
}, },
{ {
@ -124,10 +126,15 @@ export default {
this.$showModal(ActionDialog, { this.$showModal(ActionDialog, {
props: { props: {
title: "Theme", title: "Theme",
list: ["Light", "Dark", "Black"], list: ["Light", "Dark", "Black", "sysDef", "sysDefB"],
}, },
}).then((action) => { }).then((action) => {
if (action && action !== "Cancel" && this.appTheme !== action) { if (
action &&
(ApplicationSettings.getString("appTheme") != this.appTheme
? true
: this.appTheme != action)
) {
this.setTheme(action); this.setTheme(action);
Frame.reloadPage(); Frame.reloadPage();
} }

View file

@ -15,8 +15,8 @@
android { android {
defaultConfig { defaultConfig {
versionCode 7 versionCode 8
versionName '1.3.2' versionName '1.3.3'
applicationId 'com.vishnuraghav.enrecipes' applicationId 'com.vishnuraghav.enrecipes'
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 30 targetSdkVersion 30

View file

@ -2,7 +2,7 @@ import Vue from 'nativescript-vue'
import Vuex from 'vuex' import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
import { CouchBase } from '@triniwiz/nativescript-couchbase' import { CouchBase } from '@triniwiz/nativescript-couchbase'
import { getFileAccess, File, ApplicationSettings, Device } from '@nativescript/core' import { getFileAccess, File, ApplicationSettings, Application } from '@nativescript/core'
const EnRecipesDB = new CouchBase('EnRecipes') const EnRecipesDB = new CouchBase('EnRecipes')
const userCuisinesDB = new CouchBase('userCuisines') const userCuisinesDB = new CouchBase('userCuisines')
const userCategoriesDB = new CouchBase('userCategories') const userCategoriesDB = new CouchBase('userCategories')
@ -300,7 +300,7 @@ export default new Vuex.Store({
selectedCuisine: null, selectedCuisine: null,
selectedCategory: null, selectedCategory: null,
selectedTag: null, selectedTag: null,
appTheme: 'Light', appTheme: 'sysDef',
mondayFirst: false, mondayFirst: false,
}, },
mutations: { mutations: {
@ -312,7 +312,17 @@ export default new Vuex.Store({
ApplicationSettings.setBoolean('mondayFirst', bool) ApplicationSettings.setBoolean('mondayFirst', bool)
}, },
setTheme(state, theme) { setTheme(state, theme) {
switch (theme) {
case 'sysDef':
state.appTheme = Application.systemAppearance() == 'dark' ? "Dark" : "Light"
break;
case 'sysDefB':
state.appTheme = Application.systemAppearance() == 'dark' ? "Black" : "Light"
break;
default:
state.appTheme = theme state.appTheme = theme
break;
}
ApplicationSettings.setString('appTheme', theme) ApplicationSettings.setString('appTheme', theme)
}, },
clearFilter(state) { clearFilter(state) {