enrecipes/app/components/sub/OptionsList.vue

87 lines
2.3 KiB
Vue
Raw Normal View History

2021-05-25 14:32:53 +00:00
<template>
2021-06-15 11:04:42 +00:00
<ListView colSpan="2" rowSpan="2" class="options" for="item in items">
2021-05-25 14:32:53 +00:00
<v-template if="$index == 0">
2021-06-18 12:52:03 +00:00
<Label class="pTitle tw tb" :text="title | L" />
2021-05-25 14:32:53 +00:00
</v-template>
<v-template if="item.type == 'switch'">
2021-06-15 11:04:42 +00:00
<RGridLayout
:rtl="RTL"
2021-05-25 14:32:53 +00:00
columns="auto, *, auto"
class="option"
@touch="touch($event, item.data, item.action)"
>
2021-06-18 12:52:03 +00:00
<Label class="ico vc rtl" :text="icon[item.icon]" />
2021-06-15 11:04:42 +00:00
<StackLayout col="1" class="info">
<RLabel :text="item.title | L" class="tw" />
<RLabel
v-if="item.subTitle"
:text="item.subTitle | L"
class="sub tw"
/>
2021-05-25 14:32:53 +00:00
</StackLayout>
<Switch
2021-06-15 11:04:42 +00:00
@loaded="swLoad"
2021-05-25 14:32:53 +00:00
isUserInteractionEnabled="false"
:color="item.checked ? '#ff5200' : '#adb5bd'"
col="2"
:checked="item.checked"
/>
2021-06-15 11:04:42 +00:00
</RGridLayout>
2021-05-25 14:32:53 +00:00
</v-template>
<v-template if="item.type == 'list'">
2021-06-15 11:04:42 +00:00
<RGridLayout
:rtl="RTL"
2021-05-25 14:32:53 +00:00
columns="auto, *"
class="option"
@touch="touch($event, item.data, item.action)"
>
2021-06-18 12:52:03 +00:00
<Label
class="ico vc"
:class="{ rtl: item.rtl }"
:text="icon[item.icon]"
/>
2021-06-15 11:04:42 +00:00
<StackLayout col="1" class="info">
<RLabel :text="item.title | L" class="tw" />
<RLabel
:hidden="!item.subTitle"
:text="item.subTitle"
class="sub tw"
/>
2021-05-25 14:32:53 +00:00
</StackLayout>
2021-06-15 11:04:42 +00:00
</RGridLayout>
2021-05-25 14:32:53 +00:00
</v-template>
<v-template if="item.type == 'info'">
2021-06-15 11:04:42 +00:00
<Label
2021-06-18 18:37:01 +00:00
class="groupInfo sub tw lh4"
2021-06-15 11:04:42 +00:00
:class="{ r: RTL }"
:text="item.title | L"
/>
2021-05-25 14:32:53 +00:00
</v-template>
<v-template>
2021-06-18 18:37:01 +00:00
<StackLayout class="ls"> </StackLayout>
2021-05-25 14:32:53 +00:00
</v-template>
</ListView>
</template>
<script>
import { mapState } from "vuex";
2021-06-15 11:04:42 +00:00
import * as utils from "~/shared/utils";
2021-05-25 14:32:53 +00:00
export default {
props: ["title", "items", "action"],
computed: {
2021-06-15 11:04:42 +00:00
...mapState(["icon", "RTL"]),
2021-05-25 14:32:53 +00:00
},
methods: {
2021-06-15 11:04:42 +00:00
swLoad({ object }) {
object.android.setRotation(
this.RTL && utils.sysRTL() ? 0 : this.RTL || utils.sysRTL() ? 180 : 0
);
},
2021-05-25 14:32:53 +00:00
touch({ object, action }, data, localAction) {
2021-06-18 12:52:03 +00:00
this.touchFade(object, action);
2021-05-25 14:32:53 +00:00
if (action == "up") localAction ? localAction(data) : this.action(data);
},
},
};
</script>