enrecipes/app/components/settings/Interface.vue

161 lines
4.2 KiB
Vue
Raw Normal View History

2021-03-21 22:32:04 +05:30
<template>
<Page @loaded="pageL" actionBarHidden="true">
2021-06-15 16:34:42 +05:30
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
2021-05-25 20:02:53 +05:30
<OptionsList title="intf" :items="items" />
2021-06-15 16:34:42 +05:30
<GridLayout row="1" class="appbar rtl" rows="*" columns="auto, *">
2021-06-28 17:08:21 +05:30
<Button class="ico" :text="icon.back" @tap="$navigateBack()" />
2021-04-01 16:25:35 +05:30
</GridLayout>
2021-06-18 18:22:03 +05:30
<Label rowSpan="2" class="edge hal rtl" @swipe="swipeBack" />
<Label
rowSpan="2"
colSpan="2"
class="edge har rtl f"
@swipe="swipeBack"
/>
2021-06-08 17:13:54 +05:30
</RGridLayout>
2021-03-21 22:32:04 +05:30
</Page>
</template>
<script>
2021-06-15 16:34:42 +05:30
import { ApplicationSettings, Observable, Frame } from "@nativescript/core";
2021-05-25 20:02:53 +05:30
import Action from "../modals/Action";
import OptionsList from "../sub/OptionsList";
2021-03-21 22:32:04 +05:30
import { mapState, mapActions } from "vuex";
2021-04-12 23:39:48 +05:30
import * as utils from "~/shared/utils";
2021-06-15 16:34:42 +05:30
import { localize } from "@nativescript/localize";
2021-03-21 22:32:04 +05:30
export default {
2021-05-25 20:02:53 +05:30
components: { OptionsList },
2021-03-21 22:32:04 +05:30
data() {
return {
2021-06-08 17:13:54 +05:30
applang: 0,
2021-03-21 22:32:04 +05:30
};
},
computed: {
...mapState(["icon", "langs", "theme", "layout", "RTL", "mSystem"]),
2021-03-21 22:32:04 +05:30
items() {
return [
2021-04-01 16:25:35 +05:30
{},
2021-03-21 22:32:04 +05:30
{
2021-05-25 20:02:53 +05:30
type: "list",
2021-03-21 22:32:04 +05:30
icon: "lang",
2021-06-15 16:34:42 +05:30
rtl: 0,
2021-03-21 22:32:04 +05:30
title: "lang",
2021-06-15 16:34:42 +05:30
subTitle: localize(this.applang),
2021-06-08 17:13:54 +05:30
action: this.setAppLang,
2021-03-21 22:32:04 +05:30
},
{
2021-05-25 20:02:53 +05:30
type: "list",
2021-03-21 22:32:04 +05:30
icon: "theme",
2021-06-15 16:34:42 +05:30
rtl: 0,
2021-03-21 22:32:04 +05:30
title: "Theme",
2021-06-18 18:22:03 +05:30
subTitle: localize(ApplicationSettings.getString("theme", "sysDef")),
action: this.setTheme,
2021-03-21 22:32:04 +05:30
},
{
2021-05-25 20:02:53 +05:30
type: "list",
2021-04-12 23:39:48 +05:30
icon: "layout",
2021-06-15 16:34:42 +05:30
rtl: 1,
2021-03-21 22:32:04 +05:30
title: "listVM",
2021-06-15 16:34:42 +05:30
subTitle: localize(this.layout),
2021-03-21 22:32:04 +05:30
action: this.setLayoutMode,
},
{
type: "list",
icon: "layout",
rtl: 0,
title: "mSystem",
subTitle: localize(this.mSystem),
action: this.setMSystem,
},
2021-04-01 16:25:35 +05:30
{},
2021-03-21 22:32:04 +05:30
];
},
},
methods: {
...mapActions(["setT", "setL", "setRTL", "setMS"]),
pageL({ object }) {
2021-05-25 20:02:53 +05:30
object.bindingContext = new Observable();
2021-03-21 22:32:04 +05:30
},
2021-06-19 00:07:01 +05:30
// LanguageSelection
2021-06-08 17:13:54 +05:30
setAppLang() {
2021-06-19 00:07:01 +05:30
let languages = this.langs.map((e) => e.title);
2021-05-25 20:02:53 +05:30
this.$showModal(Action, {
2021-03-21 22:32:04 +05:30
props: {
title: "lang",
list: [...languages],
2021-06-18 18:22:03 +05:30
selected: this.applang,
2021-03-21 22:32:04 +05:30
},
}).then((action) => {
2021-06-08 17:13:54 +05:30
if (action && this.applang !== action) {
let currentLocale = ApplicationSettings.getString(
"appLocale",
"none"
).split("-");
2021-06-19 00:07:01 +05:30
let locale = this.langs.filter((e) => e.title === action)[0].locale;
2021-03-21 22:32:04 +05:30
if (currentLocale !== locale) {
2021-06-08 17:13:54 +05:30
this.applang = action;
ApplicationSettings.setString("applang", action);
ApplicationSettings.setString("appLocale", locale);
utils.updateLocale();
this.setRTL();
2021-06-15 16:34:42 +05:30
Frame.reloadPage();
2021-03-21 22:32:04 +05:30
}
}
});
},
2021-06-19 00:07:01 +05:30
// ThemeSelection
setTheme() {
2021-05-25 20:02:53 +05:30
this.$showModal(Action, {
2021-03-21 22:32:04 +05:30
props: {
title: "Theme",
2021-04-24 01:20:32 +05:30
list: ["Light", "Dark", "Black", "sysDef", "sysDefB"],
2021-06-18 18:22:03 +05:30
selected: ApplicationSettings.getString("theme", "sysDef"),
2021-03-21 22:32:04 +05:30
},
}).then((action) => {
2021-04-24 01:20:32 +05:30
if (
action &&
2021-06-15 16:34:42 +05:30
(ApplicationSettings.getString("theme") != this.theme
2021-06-08 17:13:54 +05:30
? 1
2021-06-15 16:34:42 +05:30
: this.theme != action)
2021-04-24 01:20:32 +05:30
) {
2021-06-19 00:07:01 +05:30
this.setT(action);
2021-04-01 16:25:35 +05:30
Frame.reloadPage();
2021-03-21 22:32:04 +05:30
}
});
},
2021-06-19 00:07:01 +05:30
// LayoutMode
2021-03-21 22:32:04 +05:30
setLayoutMode() {
2021-05-25 20:02:53 +05:30
this.$showModal(Action, {
2021-03-21 22:32:04 +05:30
props: {
2021-04-16 00:17:06 +05:30
title: "listVM",
2021-04-12 23:39:48 +05:30
list: ["detailed", "grid", "photogrid", "simple", "minimal"],
2021-06-18 18:22:03 +05:30
selected: this.layout,
2021-03-21 22:32:04 +05:30
},
2021-06-18 18:22:03 +05:30
}).then((mode) => {
2021-06-19 00:07:01 +05:30
if (mode && this.layout !== mode) this.setL(mode.toLowerCase());
2021-03-21 22:32:04 +05:30
});
},
// MeasuringSystem
setMSystem() {
this.$showModal(Action, {
props: {
title: "mSystem",
list: ["mtrc", "imprl"],
selected: this.mSystem,
},
}).then((sys) => {
if (sys && this.mSystem !== sys) this.setMS(sys);
});
},
2021-03-21 22:32:04 +05:30
},
2021-05-25 20:02:53 +05:30
created() {
2021-06-08 17:13:54 +05:30
this.applang = ApplicationSettings.getString("applang", "sysDef");
2021-03-21 22:32:04 +05:30
},
};
</script>