enrecipes/app/components/modals/Prompt.vue

80 lines
2 KiB
Vue
Raw Normal View History

2020-10-21 23:24:45 +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" />
2021-04-01 16:25:35 +05:30
<StackLayout row="1" class="input">
2021-06-15 16:34:42 +05:30
<TextView
v-if="type == 'view'"
autocorrect="true"
autocapitalizationType="sentences"
class="modalInput"
@loaded="focusField"
v-model="text"
/>
2021-02-28 20:40:26 +05:30
<TextField
2021-06-15 16:34:42 +05:30
autocapitalizationType="sentences"
autocorrect="true"
v-else
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-06-15 16:34:42 +05:30
<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-04-01 16:25:35 +05:30
:text="action | L"
@tap="$modal.close(text)"
2021-02-28 20:40:26 +05:30
/>
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-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-06-15 16:34:42 +05:30
props: ["title", "type", "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-06-15 16:34:42 +05:30
...mapState(["icon", "theme", "RTL"]),
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 }) {
2021-06-15 16:34:42 +05:30
this.setGravity(object);
2021-04-01 16:25:35 +05:30
let a = this.placeholder;
typeof a == "number"
? (object.keyboardType = "number")
2021-06-15 16:34:42 +05:30
: this.type
? ""
2021-04-01 16:25:35 +05:30
: (object.autocapitalizationType = "words");
object.hint = this.hint;
object.focus();
2021-04-21 16:02:03 +05:30
setTimeout(() => Utils.ad.showSoftInput(object.android), 100);
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>