enrecipes/app/components/modals/TimePickerHM.vue

96 lines
2.3 KiB
Vue
Raw Normal View History

2020-11-02 17:06:53 +05:30
<template>
2021-04-12 23:39:48 +05:30
<Page
2021-06-18 18:22:03 +05:30
@loaded="mLoad"
2021-04-12 23:39:48 +05:30
backgroundColor="transparent"
2021-06-15 16:34:42 +05:30
:class="theme"
2021-04-12 23:39:48 +05:30
>
2021-04-01 16:25:35 +05:30
<GridLayout rows="auto, auto, auto" class="modal">
2021-06-15 16:34:42 +05:30
<RLabel class="title" :text="title | L" />
<RStackLayout
:rtl="RTL"
2021-04-01 16:25:35 +05:30
row="1"
2021-02-28 20:40:26 +05:30
orientation="horizontal"
horizontalAlignment="center"
>
<ListPicker
2021-04-12 23:39:48 +05:30
@loaded="onLPLoad"
2021-02-28 20:40:26 +05:30
:items="hrsList"
:selectedIndex="hrIndex"
@selectedIndexChange="setHrs"
></ListPicker>
<ListPicker
2021-04-12 23:39:48 +05:30
@loaded="onLPLoad"
2021-02-28 20:40:26 +05:30
:items="minsList"
:selectedIndex="minIndex"
@selectedIndexChange="setMins"
></ListPicker>
2021-06-15 16:34:42 +05:30
</RStackLayout>
<RGridLayout :rtl="RTL" row="2" columns="*, auto, auto" class="actions">
2021-04-01 16:25:35 +05:30
<Button
2021-02-28 20:40:26 +05:30
col="1"
2021-06-18 18:22:03 +05:30
class="text tb st fb"
2021-02-28 20:40:26 +05:30
:text="'cBtn' | L"
2021-06-15 16:34:42 +05:30
@tap="$modal.close(0)"
2021-02-28 20:40:26 +05:30
/>
2021-04-01 16:25:35 +05:30
<Button
2021-02-28 20:40:26 +05:30
col="2"
2021-06-18 18:22:03 +05:30
class="text tb st fb"
2021-06-15 16:34:42 +05:30
:text="'SET' | L"
2021-02-28 20:40:26 +05:30
@tap="$modal.close(selectedTime)"
/>
2021-06-15 16:34:42 +05:30
</RGridLayout>
2021-04-01 16:25:35 +05:30
</GridLayout>
2021-02-28 20:40:26 +05:30
</Page>
2020-11-02 17:06:53 +05:30
</template>
<script>
2021-02-28 20:40:26 +05:30
import { mapState } from "vuex";
import { localize } from "@nativescript/localize";
2020-11-02 17:06:53 +05:30
export default {
2021-06-15 16:34:42 +05:30
props: ["title", "selectedHr", "selectedMin"],
2020-11-02 17:06:53 +05:30
data() {
return {
hrs: [],
mins: [],
2020-11-02 17:06:53 +05:30
selectedHrs: "00",
selectedMins: "00",
2021-02-28 20:40:26 +05:30
};
2020-11-02 17:06:53 +05:30
},
computed: {
2021-06-15 16:34:42 +05:30
...mapState(["icon", "theme", "RTL"]),
hrsList() {
2021-02-28 20:40:26 +05:30
let h = [...Array(24).keys()];
this.hrs = h;
return h.map((e) => `${e} ${localize("hr")}`);
},
minsList() {
2021-05-22 14:26:31 +05:30
let m = [...Array(60).keys()];
2021-02-28 20:40:26 +05:30
this.mins = m;
return m.map((e) => `${e} ${localize("min")}`);
},
2020-11-02 17:06:53 +05:30
hrIndex() {
2021-02-28 20:40:26 +05:30
return this.hrs.indexOf(parseInt(this.selectedHr));
2020-11-02 17:06:53 +05:30
},
minIndex() {
2021-02-28 20:40:26 +05:30
return this.mins.indexOf(parseInt(this.selectedMin));
2020-11-02 17:06:53 +05:30
},
selectedTime() {
2021-02-28 20:40:26 +05:30
return this.selectedHrs + ":" + this.selectedMins;
2020-11-02 17:06:53 +05:30
},
},
methods: {
2021-04-12 23:39:48 +05:30
onLPLoad({ object }) {
object.android.setWrapSelectorWheel(true);
2021-03-10 21:29:50 +05:30
},
2021-02-28 20:40:26 +05:30
setHrs(args) {
let hr = "0" + this.hrs[args.object.selectedIndex];
this.selectedHrs = hr.slice(-2);
2020-11-02 17:06:53 +05:30
},
2021-02-28 20:40:26 +05:30
setMins(args) {
let min = "0" + this.mins[args.object.selectedIndex];
this.selectedMins = min.slice(-2);
2020-11-02 17:06:53 +05:30
},
},
2021-02-28 20:40:26 +05:30
};
2020-11-02 17:06:53 +05:30
</script>