2021-05-25 14:32:53 +00:00
|
|
|
<template>
|
2021-06-15 11:04:42 +00:00
|
|
|
<Page @loaded="pgLoad" actionBarHidden="true">
|
|
|
|
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
|
2021-05-25 14:32:53 +00:00
|
|
|
<OptionsList title="Settings" :items="items" />
|
2021-06-15 11:04:42 +00:00
|
|
|
<GridLayout row="1" class="appbar rtl" rows="*" columns="auto, *">
|
2021-05-25 14:32:53 +00:00
|
|
|
<Button class="ico" :text="icon.back" @tap="$navigateBack()" />
|
|
|
|
</GridLayout>
|
2021-06-18 12:52:03 +00:00
|
|
|
<Label rowSpan="2" class="edge hal rtl" @swipe="swipeBack" />
|
|
|
|
<Label
|
|
|
|
rowSpan="2"
|
|
|
|
colSpan="2"
|
|
|
|
class="edge har rtl f"
|
|
|
|
@swipe="swipeBack"
|
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RGridLayout>
|
2021-05-25 14:32:53 +00:00
|
|
|
</Page>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-06-15 11:04:42 +00:00
|
|
|
import {
|
|
|
|
Observable,
|
|
|
|
Device,
|
|
|
|
Application,
|
|
|
|
ApplicationSettings,
|
|
|
|
Utils,
|
|
|
|
} from "@nativescript/core";
|
2021-05-25 14:32:53 +00:00
|
|
|
import { mapState, mapActions } from "vuex";
|
|
|
|
import { localize } from "@nativescript/localize";
|
|
|
|
import OptionsList from "../sub/OptionsList";
|
|
|
|
import Action from "../modals/Action";
|
|
|
|
import * as utils from "~/shared/utils";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: { OptionsList },
|
|
|
|
computed: {
|
2021-06-15 11:04:42 +00:00
|
|
|
...mapState(["icon", "timerDelay", "timerSound", "timerVibrate", "RTL"]),
|
2021-05-25 14:32:53 +00:00
|
|
|
items() {
|
|
|
|
let options = [
|
|
|
|
{
|
|
|
|
type: "list",
|
|
|
|
icon: "sound",
|
2021-06-15 11:04:42 +00:00
|
|
|
rtl: 0,
|
2021-05-25 14:32:53 +00:00
|
|
|
title: "tmrSnd",
|
|
|
|
subTitle: this.timerSound.title,
|
|
|
|
action: this.showSoundsList,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "switch",
|
|
|
|
icon: "vibrate",
|
2021-06-15 11:04:42 +00:00
|
|
|
rtl: 0,
|
2021-05-25 14:32:53 +00:00
|
|
|
title: "tmrvbrt",
|
2021-06-15 11:04:42 +00:00
|
|
|
checked: !!this.timerVibrate,
|
2021-05-25 14:32:53 +00:00
|
|
|
action: this.toggleTimerVibrate,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
let openSettings = [
|
|
|
|
{
|
|
|
|
type: "list",
|
|
|
|
icon: "sound",
|
2021-06-15 11:04:42 +00:00
|
|
|
rtl: 0,
|
2021-05-25 14:32:53 +00:00
|
|
|
title: "notifSetg",
|
|
|
|
subTitle: null,
|
|
|
|
action: this.openNotificationChannelSettings,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
let list = this.channelExists() ? openSettings : options;
|
|
|
|
return [
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
type: "list",
|
|
|
|
icon: "delay",
|
2021-06-15 11:04:42 +00:00
|
|
|
rtl: 0,
|
2021-05-25 14:32:53 +00:00
|
|
|
title: "dlyDur",
|
2021-06-15 11:04:42 +00:00
|
|
|
subTitle:
|
|
|
|
this.delayList[
|
|
|
|
this.delayList.findIndex((e) => e.n == this.timerDelay)
|
|
|
|
].l,
|
2021-05-25 14:32:53 +00:00
|
|
|
action: this.showDelayList,
|
|
|
|
},
|
|
|
|
...list,
|
|
|
|
{},
|
|
|
|
];
|
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
delayList() {
|
|
|
|
return [
|
|
|
|
...Array.from(Array(4), (_, x) => x + 1),
|
|
|
|
...Array.from(Array(6), (_, x) => (x + 1) * 5),
|
|
|
|
].map((e) => {
|
|
|
|
return {
|
|
|
|
l: `${this.getLocaleN(e)} ${localize(e > 1 ? "minutes" : "minute")}`,
|
|
|
|
n: e,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
2021-05-25 14:32:53 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2021-06-15 11:04:42 +00:00
|
|
|
...mapActions(["setTimerDelay", "setTimerSound", "setTimerVibrate"]),
|
|
|
|
pgLoad({ object }) {
|
2021-05-25 14:32:53 +00:00
|
|
|
object.bindingContext = new Observable();
|
2021-06-15 11:04:42 +00:00
|
|
|
ApplicationSettings.setNumber("isTimer", 2);
|
2021-05-25 14:32:53 +00:00
|
|
|
},
|
|
|
|
showDelayList() {
|
|
|
|
this.$showModal(Action, {
|
|
|
|
props: {
|
|
|
|
title: "dlyDur",
|
2021-06-15 11:04:42 +00:00
|
|
|
list: this.delayList.map((e) => e.l),
|
|
|
|
selected: this.delayList.findIndex((e) => e.n == this.timerDelay),
|
2021-05-25 14:32:53 +00:00
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
}).then(
|
|
|
|
(res) =>
|
|
|
|
res &&
|
|
|
|
this.setTimerDelay(
|
|
|
|
this.delayList[this.delayList.findIndex((e) => e.l == res)].n
|
|
|
|
)
|
|
|
|
);
|
2021-05-25 14:32:53 +00:00
|
|
|
},
|
|
|
|
showSoundsList() {
|
|
|
|
let getTones = utils.getTones();
|
|
|
|
this.$showModal(Action, {
|
|
|
|
props: {
|
|
|
|
title: "tmrSnd",
|
|
|
|
list: getTones.tones.map((e) => e.title),
|
2021-06-18 12:52:03 +00:00
|
|
|
selected: getTones.tones.findIndex(
|
|
|
|
(e) => e.title == this.timerSound.title
|
|
|
|
),
|
2021-05-25 14:32:53 +00:00
|
|
|
},
|
|
|
|
}).then(
|
|
|
|
(tone) =>
|
|
|
|
tone &&
|
|
|
|
tone !== this.timerSound.title &&
|
|
|
|
this.setTimerSound(getTones.tones.filter((e) => e.title === tone)[0])
|
|
|
|
);
|
|
|
|
},
|
|
|
|
toggleTimerVibrate() {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.setTimerVibrate(!this.timerVibrate | 0);
|
2021-05-25 14:32:53 +00:00
|
|
|
},
|
|
|
|
openNotificationChannelSettings() {
|
|
|
|
const ctx = Application.android.context;
|
|
|
|
const Settings = android.provider.Settings;
|
|
|
|
const Intent = android.content.Intent;
|
|
|
|
let intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
|
|
|
|
intent.putExtra(
|
|
|
|
Settings.EXTRA_APP_PACKAGE,
|
|
|
|
Application.android.packageName
|
|
|
|
);
|
|
|
|
intent.putExtra(Settings.EXTRA_CHANNEL_ID, "cta");
|
|
|
|
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
ctx.startActivity(intent);
|
|
|
|
},
|
|
|
|
|
|
|
|
// HELPERS
|
|
|
|
channelExists() {
|
|
|
|
if (Device.sdkVersion * 1 >= 26) {
|
|
|
|
const ctx = Utils.ad.getApplicationContext();
|
|
|
|
const NotifySrv = ctx.getSystemService(
|
|
|
|
android.content.Context.NOTIFICATION_SERVICE
|
|
|
|
);
|
|
|
|
return NotifySrv.getNotificationChannel("cta");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|