enrecipes/app/components/modal/PromptDialog.vue

66 lines
1.6 KiB
Vue
Raw Permalink Normal View History

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