enrecipes/app/components/Settings.vue

107 lines
2.6 KiB
Vue
Raw Normal View History

2020-09-15 16:40:16 +05:30
<template>
2021-04-01 16:25:35 +05:30
<Page @loaded="onPageLoad" actionBarHidden="true">
<GridLayout rows="*, auto" columns="auto, *">
<ListView
colSpan="2"
rowSpan="2"
class="options-list"
for="item in items"
>
<v-template if="$index == 0">
<Label class="pageTitle" :text="'Settings' | L" />
</v-template>
2021-04-12 23:39:48 +05:30
<v-template if="$index == 6">
2021-04-01 16:25:35 +05:30
<StackLayout class="listSpace"> </StackLayout>
</v-template>
2021-03-21 22:32:04 +05:30
<v-template>
<GridLayout
columns="auto, *"
2021-04-01 16:25:35 +05:30
class="option"
@touch="touch($event, item.view)"
2021-03-21 22:32:04 +05:30
>
2021-02-28 20:40:26 +05:30
<Label
2021-03-21 22:32:04 +05:30
verticalAlignment="center"
2021-04-01 16:25:35 +05:30
class="ico"
2021-03-21 22:32:04 +05:30
:text="icon[item.icon]"
2021-02-28 20:40:26 +05:30
/>
2021-03-21 22:32:04 +05:30
<Label verticalAlignment="center" col="1" :text="item.title | L" />
</GridLayout>
</v-template>
</ListView>
2021-04-01 16:25:35 +05:30
<GridLayout row="1" class="appbar" rows="*" columns="auto, *">
2021-04-12 23:39:48 +05:30
<Button class="ico" :text="icon.back" @tap="$navigateBack()" />
2021-04-01 16:25:35 +05:30
</GridLayout>
2021-03-21 22:32:04 +05:30
</GridLayout>
2021-02-28 20:40:26 +05:30
</Page>
2020-09-15 16:40:16 +05:30
</template>
<script>
2021-03-21 22:32:04 +05:30
import { Observable } from "@nativescript/core";
2021-02-28 20:40:26 +05:30
import { mapState, mapActions } from "vuex";
2021-03-21 22:32:04 +05:30
import Interface from "./Settings/Interface.vue";
import Options from "./Settings/Options.vue";
import Database from "./Settings/Database.vue";
import Reset from "./Settings/Reset.vue";
import About from "./Settings/About.vue";
2020-09-15 16:40:16 +05:30
export default {
data() {
return {
2021-03-21 22:32:04 +05:30
items: [
2021-04-01 16:25:35 +05:30
{},
2021-03-21 22:32:04 +05:30
{
2021-04-12 23:39:48 +05:30
icon: "interface",
2021-03-21 22:32:04 +05:30
title: "intf",
view: Interface,
},
{
2021-04-12 23:39:48 +05:30
icon: "opts",
2021-03-21 22:32:04 +05:30
title: "opts",
view: Options,
},
{
2021-04-12 23:39:48 +05:30
icon: "db",
2021-03-21 22:32:04 +05:30
title: "db",
view: Database,
},
{
icon: "reset",
title: "rest",
view: Reset,
},
{
icon: "info",
title: "About",
view: About,
},
2021-04-01 16:25:35 +05:30
{},
2021-03-21 22:32:04 +05:30
],
2021-02-28 20:40:26 +05:30
};
2020-09-15 16:40:16 +05:30
},
2020-10-15 01:02:32 +05:30
computed: {
2021-03-21 22:32:04 +05:30
...mapState(["icon"]),
2020-10-15 01:02:32 +05:30
},
2020-09-15 16:40:16 +05:30
methods: {
2021-04-01 16:25:35 +05:30
...mapActions(["setComponent"]),
2021-02-28 20:40:26 +05:30
onPageLoad(args) {
const page = args.object;
page.bindingContext = new Observable();
2021-04-01 16:25:35 +05:30
this.setComponent("Settings");
2020-09-15 16:40:16 +05:30
},
2021-03-21 22:32:04 +05:30
// HELPERS
navigateTo(view) {
2021-04-01 16:25:35 +05:30
this.$navigateTo(view, {
transition: {
name: "slide",
duration: 200,
curve: "easeOut",
},
});
},
touch({ object, action }, view) {
object.className = action.match(/down|move/) ? "option fade" : "option";
if (action == "up") this.navigateTo(view);
2021-02-28 20:40:26 +05:30
},
2020-09-15 16:40:16 +05:30
},
2021-02-28 20:40:26 +05:30
};
2020-09-15 16:40:16 +05:30
</script>