enrecipes/app/components/modal/PromptDialog.vue

66 lines
1.6 KiB
Vue
Raw Normal View History

2020-10-21 23:24:45 +05:30
<template>
2021-04-12 23:39:48 +05:30
<Page
@loaded="transparentPage"
backgroundColor="transparent"
:class="appTheme"
>
2021-04-01 16:25:35 +05:30
<GridLayout rows="auto, auto, auto" class="modal">
<Label class="title" :text="title | L" />
<StackLayout row="1" class="input">
2021-02-28 20:40:26 +05:30
<TextField
2021-04-01 16:25:35 +05:30
class="modalInput"
2021-02-28 20:40:26 +05:30
@loaded="focusField"
2021-04-01 16:25:35 +05:30
v-model="text"
@returnPress="$modal.close(text)"
2021-02-28 20:40:26 +05:30
/>
</StackLayout>
2021-04-01 16:25:35 +05:30
<GridLayout row="2" columns="*, auto, auto" class="actions">
<Button
2021-02-28 20:40:26 +05:30
col="1"
2021-04-01 16:25:35 +05:30
class="text sm"
2021-02-28 20:40:26 +05:30
:text="'cBtn' | L"
@tap="$modal.close(false)"
/>
2021-04-01 16:25:35 +05:30
<Button
2021-02-28 20:40:26 +05:30
col="2"
2021-04-01 16:25:35 +05:30
class="text sm"
:text="action | L"
@tap="$modal.close(text)"
2021-02-28 20:40:26 +05:30
/>
</GridLayout>
2021-04-01 16:25:35 +05:30
</GridLayout>
2021-02-28 20:40:26 +05:30
</Page>
2020-10-21 23:24:45 +05:30
</template>
<script>
2021-04-01 16:25:35 +05:30
import { Utils } from "@nativescript/core";
2021-02-28 20:40:26 +05:30
import { localize } from "@nativescript/localize";
import { mapState } from "vuex";
2020-10-21 23:24:45 +05:30
export default {
2021-04-01 16:25:35 +05:30
props: ["title", "hint", "placeholder", "action"],
2020-10-21 23:24:45 +05:30
data() {
return {
2021-04-01 16:25:35 +05:30
text: null,
2021-02-28 20:40:26 +05:30
};
2020-10-21 23:24:45 +05:30
},
computed: {
2021-04-01 16:25:35 +05:30
...mapState(["icon", "appTheme"]),
2020-10-23 00:06:50 +05:30
},
2020-11-02 17:06:53 +05:30
methods: {
2021-04-01 16:25:35 +05:30
focusField({ object }) {
let a = this.placeholder;
typeof a == "number"
? (object.keyboardType = "number")
: (object.autocapitalizationType = "words");
object.hint = this.hint;
object.focus();
setTimeout(() => Utils.ad.showSoftInput(object.android), 1);
2020-11-02 17:06:53 +05:30
},
},
2021-04-01 16:25:35 +05:30
created() {
let a = this.placeholder;
if (a) this.text = typeof a == "number" ? a : localize(a);
2020-11-10 23:58:48 +05:30
},
2021-02-28 20:40:26 +05:30
};
2020-10-21 23:24:45 +05:30
</script>