cleaned code

This commit is contained in:
vishnuraghavb 2021-06-19 00:07:01 +05:30
parent dfbacb66a6
commit 58be4cec5c
22 changed files with 264 additions and 369 deletions

View file

@ -12,7 +12,7 @@
<Button col="1" class="ico" :text="icon.cog" @tap="navigateTo" /> <Button col="1" class="ico" :text="icon.cog" @tap="navigateTo" />
</RGridLayout> </RGridLayout>
<Timer <Timer
v-for="timer in activeTimers" v-for="timer in activeTs"
:key="timer.id + key" :key="timer.id + key"
:timer="timer" :timer="timer"
:formattedTime="formattedTime" :formattedTime="formattedTime"
@ -21,10 +21,10 @@
:timerAlert="timerAlert" :timerAlert="timerAlert"
:showToast="showToast" :showToast="showToast"
/> />
<StackLayout class="listSpace"> </StackLayout> <StackLayout class="ls"> </StackLayout>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
<GridLayout v-if="!activeTimers.length" rows="*, auto"> <GridLayout v-if="!activeTs.length" rows="*, auto">
<StackLayout row="1" class="empty"> <StackLayout row="1" class="empty">
<RLabel class="tb t3 tw" :text="'ccwt' | L" /> <RLabel class="tb t3 tw" :text="'ccwt' | L" />
<RLabel class="tw" :text="'plsAdd' | L" /> <RLabel class="tw" :text="'plsAdd' | L" />
@ -115,11 +115,11 @@ export default {
...mapState([ ...mapState([
"icon", "icon",
"recipes", "recipes",
"timerSound", "timerS",
"timerVibrate", "timerV",
"timerPresets", "timerPs",
"activeTimers", "activeTs",
"FGService", "FGS",
"RTL", "RTL",
]), ]),
hasBackStack() { hasBackStack() {
@ -127,18 +127,10 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions([ ...mapActions(["addAT", "removeAT", "clearATIs", "updateAT", "setFgS"]),
"addActiveTimer",
"removeActiveTimer",
"clearTimerInterval",
"addTimerPreset",
"updateActiveTimer",
"setFGService",
]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
if (this.activeTimers.filter((e: any) => e.done).length) if (this.activeTs.filter((e: any) => e.done).length) this.openReminder();
this.openReminder();
setNumber("isTimer", 1); setNumber("isTimer", 1);
}, },
abLoad({ object }) { abLoad({ object }) {
@ -188,8 +180,8 @@ export default {
// NOTIFICATION HANDLERS // NOTIFICATION HANDLERS
timerInfo() { timerInfo() {
let activeCount = this.activeTimers.length; let activeCount = this.activeTs.length;
let pausedCount = this.activeTimers.filter((e) => e.isPaused).length; let pausedCount = this.activeTs.filter((e) => e.isPaused).length;
let ongoingCount = activeCount - pausedCount; let ongoingCount = activeCount - pausedCount;
this.foregroundService(activeCount); this.foregroundService(activeCount);
function show() { function show() {
@ -204,13 +196,12 @@ export default {
title: localize("timer"), title: localize("timer"),
}); });
} }
if (this.FGService) if (this.FGS) setTimeout(() => this.activeTs.length && show(), 250);
setTimeout(() => this.activeTimers.length && show(), 250);
utils.wakeLock(ongoingCount); utils.wakeLock(ongoingCount);
}, },
timerAlert() { timerAlert() {
let title, description, bID; let title, description, bID;
let firedTimers = this.activeTimers.filter((e) => e.done); let firedTimers = this.activeTs.filter((e) => e.done);
let timer = firedTimers[0]; let timer = firedTimers[0];
if (firedTimers.length > 1) { if (firedTimers.length > 1) {
title = localize("texp", firedTimers.length); title = localize("texp", firedTimers.length);
@ -235,9 +226,9 @@ export default {
multi: firedTimers.length > 1, multi: firedTimers.length > 1,
nID: 7, nID: 7,
priority: 1, priority: 1,
sound: this.timerSound.uri, sound: this.timerS.uri,
title, title,
vibrate: this.timerVibrate, vibrate: this.timerV,
}); });
if (firedTimers.length == 1) { if (firedTimers.length == 1) {
Application.android.registerBroadcastReceiver(bID, (ctx, intent) => { Application.android.registerBroadcastReceiver(bID, (ctx, intent) => {
@ -255,7 +246,7 @@ export default {
} }
}, },
openReminder() { openReminder() {
this.clearTimerInterval(); this.clearATIs();
this.$showModal(TimerReminder, { this.$showModal(TimerReminder, {
fullscreen: true, fullscreen: true,
props: { props: {
@ -266,7 +257,7 @@ export default {
showToast: this.showToast, showToast: this.showToast,
}, },
}).then(() => { }).then(() => {
this.clearTimerInterval(); this.clearATIs();
this.key = Math.floor(Math.random() * 900) + 100; this.key = Math.floor(Math.random() * 900) + 100;
}); });
}, },
@ -276,16 +267,16 @@ export default {
ctx, ctx,
com.tns.ForegroundService.class com.tns.ForegroundService.class
); );
if (n && !this.FGService) { if (n && !this.FGS) {
parseInt(Device.sdkVersion) < 26 parseInt(Device.sdkVersion) < 26
? ctx.startService(intent) ? ctx.startService(intent)
: ctx.startForegroundService(intent); : ctx.startForegroundService(intent);
this.setFGService(1); this.setFgS(1);
setNumber("FGService", 1); setNumber("FGS", 1);
} else if (!this.activeTimers.length) { } else if (!this.activeTs.length) {
ctx.stopService(intent); ctx.stopService(intent);
this.setFGService(0); this.setFgS(0);
setNumber("FGService", 0); setNumber("FGS", 0);
} }
}, },
@ -294,14 +285,14 @@ export default {
this.$showModal(TimePickerHMS, { this.$showModal(TimePickerHMS, {
props: { props: {
title: "ntmr", title: "ntmr",
label: `${localize("tmr", this.activeTimers.length + 1)}`, label: `${localize("tmr", this.activeTs.length + 1)}`,
action: "strtBtn", action: "strtBtn",
showPreset: this.timerPresets.length, showPreset: this.timerPs.length,
}, },
}).then((res) => { }).then((res) => {
if (res) { if (res) {
if (res == "presets") { if (res == "presets") {
let list = this.timerPresets.map( let list = this.timerPs.map(
(e) => `${e.label} - ${this.formattedTime(e.time)}` (e) => `${e.label} - ${this.formattedTime(e.time)}`
); );
this.$showModal(Action, { this.$showModal(Action, {
@ -312,22 +303,22 @@ export default {
}).then((preset) => { }).then((preset) => {
if (preset) { if (preset) {
let timer = JSON.parse( let timer = JSON.parse(
JSON.stringify(this.timerPresets[list.indexOf(preset)]) JSON.stringify(this.timerPs[list.indexOf(preset)])
); );
timer.id = utils.getRandomID(1); timer.id = utils.getRandomID(1);
timer.recipeID = this.recipeID; timer.recipeID = this.recipeID;
timer.timerInt = timer.isPaused = 0; timer.timerInt = timer.isPaused = 0;
timer.preset = timer.mode = 1; timer.preset = timer.mode = 1;
this.addActiveTimer({ this.addAT({
timer, timer,
i: this.activeTimers.length, i: this.activeTs.length,
}); });
this.timerInfo(); this.timerInfo();
} }
}); });
} else { } else {
let mode = res.time != "00:00:00" ? 1 : 0; let mode = res.time != "00:00:00" ? 1 : 0;
this.addActiveTimer({ this.addAT({
timer: { timer: {
id: utils.getRandomID(1), id: utils.getRandomID(1),
label: res.label, label: res.label,
@ -339,7 +330,7 @@ export default {
done: 0, done: 0,
mode, mode,
}, },
i: this.activeTimers.length, i: this.activeTs.length,
}); });
this.timerInfo(); this.timerInfo();
} }
@ -347,11 +338,11 @@ export default {
}); });
}, },
removeTimer(id, noUndo) { removeTimer(id, noUndo) {
let i = this.activeTimers.findIndex((e) => e.id == id); let i = this.activeTs.findIndex((e) => e.id == id);
let temp = this.activeTimers[i]; let temp = this.activeTs[i];
clearInterval(temp.timerInt); clearInterval(temp.timerInt);
temp.timerInt = 0; temp.timerInt = 0;
this.removeActiveTimer(i); this.removeAT(i);
let secs = [getNumber(`${temp.id}c`, 0), getNumber(`${temp.id}d`, 0)]; let secs = [getNumber(`${temp.id}c`, 0), getNumber(`${temp.id}d`, 0)];
function removeSettings() { function removeSettings() {
remove(`${temp.id}c`); remove(`${temp.id}c`);
@ -363,7 +354,7 @@ export default {
.then(() => { .then(() => {
setNumber(`${temp.id}c`, secs[0]), setNumber(`${temp.id}c`, secs[0]),
setNumber(`${temp.id}d`, secs[1]), setNumber(`${temp.id}d`, secs[1]),
this.addActiveTimer({ this.addAT({
timer: temp, timer: temp,
i, i,
}); });
@ -377,7 +368,7 @@ export default {
togglePause(timer, n) { togglePause(timer, n) {
timer.isPaused = timer.isPaused =
typeof n === "number" ? n : (!timer.isPaused as boolean | 0); typeof n === "number" ? n : (!timer.isPaused as boolean | 0);
this.updateActiveTimer(timer); this.updateAT(timer);
n ? 0 : this.timerInfo(); n ? 0 : this.timerInfo();
}, },
showToast(data) { showToast(data) {
@ -453,7 +444,7 @@ export default {
// HELPERS // HELPERS
}, },
created() { created() {
this.clearTimerInterval(); this.clearATIs();
this.recipeID && this.addTimer(); this.recipeID && this.addTimer();
}, },
destroyed() { destroyed() {

View file

@ -391,7 +391,7 @@ export default {
modalOpen: 0, modalOpen: 0,
saving: 0, saving: 0,
cacheImagePath: null, cacheImagePath: null,
unSyncCombinations: [], unLinkCombs: [],
difficultyLevels: ["Easy", "Moderate", "Challenging"], difficultyLevels: ["Easy", "Moderate", "Challenging"],
appbar: null, appbar: null,
snackbar: null, snackbar: null,
@ -427,11 +427,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions([ ...mapActions(["addR", "addLI", "unLinkCs"]),
"addRecipeAction",
"addListItemAction",
"unSyncCombinationsAction",
]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
this.hijackBackEvent(); this.hijackBackEvent();
@ -491,7 +487,9 @@ export default {
knownFolders.temp().path, knownFolders.temp().path,
`${utils.getRandomID(0)}.jpg` `${utils.getRandomID(0)}.jpg`
); );
utils.copyPhotoToCache(uri, this.cacheImagePath).then((imgPath) => { utils
.copyPhotoToCache(uri.toString(), this.cacheImagePath)
.then((imgPath) => {
if (imgPath) { if (imgPath) {
ImageSource.fromFile(imgPath).then((image) => { ImageSource.fromFile(imgPath).then((image) => {
ImageCropper.prototype ImageCropper.prototype
@ -558,7 +556,7 @@ export default {
this.modalOpen = 0; this.modalOpen = 0;
if (item.length) { if (item.length) {
this.recipe.cuisine = item; this.recipe.cuisine = item;
this.addListItemAction({ this.addLI({
item, item,
listName: "cuisines", listName: "cuisines",
}); });
@ -572,7 +570,7 @@ export default {
if (focus) this.autoFocusField("category", 0); if (focus) this.autoFocusField("category", 0);
} else } else
this.cuisines.includes(this.recipe.cuisine) this.cuisines.includes(this.recipe.cuisine)
? mull ? null
: (this.recipe.cuisine = "Undefined"); : (this.recipe.cuisine = "Undefined");
} }
}); });
@ -597,7 +595,7 @@ export default {
this.modalOpen = 0; this.modalOpen = 0;
if (item.length) { if (item.length) {
this.recipe.category = item; this.recipe.category = item;
this.addListItemAction({ this.addLI({
item, item,
listName: "categories", listName: "categories",
}); });
@ -611,7 +609,7 @@ export default {
if (focus) this.autoFocusField("tags", 1); if (focus) this.autoFocusField("tags", 1);
} else } else
this.categories.includes(this.recipe.category) this.categories.includes(this.recipe.category)
? mull ? null
: (this.recipe.category = "Undefined"); : (this.recipe.category = "Undefined");
} }
}); });
@ -636,7 +634,7 @@ export default {
this.modalOpen = 0; this.modalOpen = 0;
if (item.length) { if (item.length) {
this.recipe.yieldUnit = item; this.recipe.yieldUnit = item;
this.addListItemAction({ this.addLI({
item, item,
listName: "yieldUnits", listName: "yieldUnits",
}); });
@ -650,7 +648,7 @@ export default {
if (focus) this.autoFocusField("difficultyLevel", 0); if (focus) this.autoFocusField("difficultyLevel", 0);
} else } else
this.yieldUnits.includes(this.recipe.yieldUnit) this.yieldUnits.includes(this.recipe.yieldUnit)
? mull ? null
: (this.recipe.yieldUnit = "Serving"); : (this.recipe.yieldUnit = "Serving");
} }
}); });
@ -670,7 +668,7 @@ export default {
if (focus) this.addIngredient(); if (focus) this.addIngredient();
} else } else
this.difficultyLevels.includes(this.recipe.difficulty) this.difficultyLevels.includes(this.recipe.difficulty)
? mull ? null
: (this.recipe.difficulty = "Easy"); : (this.recipe.difficulty = "Easy");
}); });
}, },
@ -694,7 +692,7 @@ export default {
this.modalOpen = 0; this.modalOpen = 0;
if (item.length) { if (item.length) {
this.recipe.ingredients[index].unit = item; this.recipe.ingredients[index].unit = item;
this.addListItemAction({ this.addLI({
item, item,
listName: "units", listName: "units",
}); });
@ -785,7 +783,7 @@ export default {
removeCombination(id) { removeCombination(id) {
let index = this.recipe.combinations.indexOf(id); let index = this.recipe.combinations.indexOf(id);
this.recipe.combinations.splice(index, 1); this.recipe.combinations.splice(index, 1);
this.unSyncCombinations.push(id); this.unLinkCombs.push(id);
this.showUndoBar("rmCmb").then((res) => this.showUndoBar("rmCmb").then((res) =>
this.recipe.combinations.splice(index, 0, id) this.recipe.combinations.splice(index, 0, id)
); );
@ -832,14 +830,14 @@ export default {
} else if (this.tempRecipe.image) { } else if (this.tempRecipe.image) {
getFileAccess().deleteFile(this.tempRecipe.image); getFileAccess().deleteFile(this.tempRecipe.image);
} }
this.unSyncCombinationsAction({ this.unLinkCs({
id: this.recipeID, id: this.recipeID,
combinations: this.unSyncCombinations, combs: this.unLinkCombs,
}); });
this.saveRecipe(); this.saveRecipe();
}, },
saveRecipe() { saveRecipe() {
this.addRecipeAction(this.recipe); this.addR(this.recipe);
this.saving = 0; this.saving = 0;
this.dupRecipe this.dupRecipe
? this.$navigateTo(EnRecipes, { ? this.$navigateTo(EnRecipes, {

View file

@ -111,7 +111,7 @@
</RStackLayout> </RStackLayout>
<RStackLayout :rtl="RTL" class="oh"> <RStackLayout :rtl="RTL" class="oh">
<Label class="ico s vc" :text="icon.star" /> <Label class="ico s vc" :text="icon.star" />
<Label class="attr" :text="getLocaleN(recipe.rating)" /> <Label class="attr" :text="localeN(recipe.rating)" />
<Label class="ico s vc" :text="icon.time" /> <Label class="ico s vc" :text="icon.time" />
<Label <Label
class="attr" class="attr"
@ -383,7 +383,7 @@
class="ico fab" class="ico fab"
:text="icon.plus" :text="icon.plus"
col="5" col="5"
@tap="addRecipe" @tap="addR"
/> />
<Button <Button
:hidden="!selectMode" :hidden="!selectMode"
@ -468,7 +468,7 @@ export default {
computed: { computed: {
...mapState([ ...mapState([
"icon", "icon",
"sortType", "sortT",
"recipes", "recipes",
"cuisines", "cuisines",
"categories", "categories",
@ -479,7 +479,7 @@ export default {
"selCuisine", "selCuisine",
"selCategory", "selCategory",
"selTag", "selTag",
"timerSound", "timerS",
"RTL", "RTL",
]), ]),
filteredRecipes() { filteredRecipes() {
@ -586,20 +586,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions([ ...mapActions(["setS", "setST", "deleteRs", "clearF"]),
"initListItems",
"initRecipes",
"initMealPlans",
"initTimerPresets",
"setShake",
"setFirstDay",
"setLayout",
"setSortType",
"deleteRecipes",
"clearFilter",
"setTheme",
"setTimerSound",
]),
setComp(comp) { setComp(comp) {
this.currentComp = comp; this.currentComp = comp;
}, },
@ -615,7 +602,7 @@ export default {
if (this.shake) { if (this.shake) {
if (utils.hasAccelerometer()) if (utils.hasAccelerometer())
startAccelerometerUpdates((data) => this.onSensorData(data)); startAccelerometerUpdates((data) => this.onSensorData(data));
else this.setShake(0); else this.setS(0);
} }
this.hijackBackEvent(); this.hijackBackEvent();
setTimeout(() => { setTimeout(() => {
@ -695,12 +682,12 @@ export default {
"Newest first", "Newest first",
"Oldest first", "Oldest first",
], ],
selected: this.sortType, selected: this.sortT,
}, },
}).then((action) => { }).then((action) => {
if (action && this.sortType !== action) { if (action && this.sortT !== action) {
this.setSortType(action); this.setST(action);
ApplicationSettings.setString("sortType", action); ApplicationSettings.setString("sortT", action);
this.updateSort(); this.updateSort();
} }
this.hijackBackEvent(); this.hijackBackEvent();
@ -782,7 +769,7 @@ export default {
}, },
}).then((action) => { }).then((action) => {
if (action) { if (action) {
this.deleteRecipes(this.selection); this.deleteRs(this.selection);
if (!this.filteredRecipes.length) this.goToHome(); if (!this.filteredRecipes.length) this.goToHome();
this.clearSelection(); this.clearSelection();
} }
@ -883,7 +870,7 @@ export default {
}).length; }).length;
break; break;
} }
return count && this.getLocaleN(count); return count && this.localeN(count);
}, },
centerLabel({ object }) { centerLabel({ object }) {
object.android.setGravity(17); object.android.setGravity(17);
@ -904,7 +891,6 @@ export default {
}, },
randomRecipeID() { randomRecipeID() {
// TODO: show only from selected filter
let min = 0; let min = 0;
let max = this.filteredRecipes.length - 1; let max = this.filteredRecipes.length - 1;
let randomIndex = Math.round(Math.random() * (max - min)); let randomIndex = Math.round(Math.random() * (max - min));
@ -952,7 +938,7 @@ export default {
} }
let dl1 = difficultyLevel(a.difficulty); let dl1 = difficultyLevel(a.difficulty);
let dl2 = difficultyLevel(b.difficulty); let dl2 = difficultyLevel(b.difficulty);
switch (this.sortType) { switch (this.sortT) {
case "random": case "random":
return 0.5 - Math.random(); return 0.5 - Math.random();
case "title": case "title":
@ -989,7 +975,7 @@ export default {
id == this.filteredRecipes[length - 2].id) id == this.filteredRecipes[length - 2].id)
? "lastItem" ? "lastItem"
: ""; : "";
let selection = this.selection.includes(id) ? "selected" : "unselected"; let selection = this.selection.includes(id) ? "select" : "deselect";
let classes = itemPos + " " + selection; let classes = itemPos + " " + selection;
return l2 ? classes + oddOrEven : classes; return l2 ? classes + oddOrEven : classes;
}, },
@ -1034,7 +1020,7 @@ export default {
goToHome() { goToHome() {
this.setComp("EnRecipes"); this.setComp("EnRecipes");
this.filterFavourites = this.filterTrylater = null; this.filterFavourites = this.filterTrylater = null;
this.clearFilter(); this.clearF();
}, },
navigateTo(to, title, page) { navigateTo(to, title, page) {
this.showTools && this.toggleTools(); this.showTools && this.toggleTools();
@ -1056,7 +1042,7 @@ export default {
this.setComp(title); this.setComp(title);
this.filterFavourites = to == "favourites"; this.filterFavourites = to == "favourites";
this.filterTrylater = to == "trylater"; this.filterTrylater = to == "trylater";
this.clearFilter(); this.clearF();
} }
}, },
stSwipe({ direction }) { stSwipe({ direction }) {
@ -1070,7 +1056,7 @@ export default {
this.setComp(comps[index - 1]); this.setComp(comps[index - 1]);
this.filterFavourites = comps[index - 1] == "favourites"; this.filterFavourites = comps[index - 1] == "favourites";
this.filterTrylater = comps[index - 1] == "trylater"; this.filterTrylater = comps[index - 1] == "trylater";
this.clearFilter(); this.clearF();
} }
break; break;
case 2: case 2:
@ -1084,7 +1070,7 @@ export default {
break; break;
} }
}, },
addRecipe() { addR() {
this.showTools && this.toggleTools(); this.showTools && this.toggleTools();
this.$navigateTo(EditRecipe, { this.$navigateTo(EditRecipe, {
props: { props: {

View file

@ -63,7 +63,7 @@
<v-template if="item.type == 1"> <v-template if="item.type == 1">
<Label <Label
class="type t3" class="type t3"
:class="{ tb: plannerView == 'd' }" :class="{ tb: plannerV == 'd' }"
:text="item.mealType | L" :text="item.mealType | L"
/> />
</v-template> </v-template>
@ -132,7 +132,7 @@
</RGridLayout> </RGridLayout>
</v-template> </v-template>
<v-template> <v-template>
<StackLayout class="listSpace"> </StackLayout> <StackLayout class="ls"> </StackLayout>
</v-template> </v-template>
</CollectionView> </CollectionView>
</StackLayout> </StackLayout>
@ -246,9 +246,9 @@ export default {
"recipes", "recipes",
"layout", "layout",
"mealPlans", "mealPlans",
"mondayFirst", "startMon",
"RTL", "RTL",
"plannerView", "plannerV",
]), ]),
todaysTime() { todaysTime() {
return new Date(this.year, this.month, this.date, 0).getTime(); return new Date(this.year, this.month, this.date, 0).getTime();
@ -269,12 +269,12 @@ export default {
calRows() { calRows() {
let h = (Screen.mainScreen.widthDIPs - 32) / 8; let h = (Screen.mainScreen.widthDIPs - 32) / 8;
if (h < 48) h = 48; if (h < 48) h = 48;
let pv = this.plannerView; let pv = this.plannerV;
return pv != "d" ? `${h}, `.repeat(pv == "wk" ? 1 : 6) + h : 0; return pv != "d" ? `${h}, `.repeat(pv == "wk" ? 1 : 6) + h : 0;
}, },
getDayNames() { getDayNames() {
let dNames = let dNames =
this.plannerView != "d" && this.plannerV != "d" &&
this.getCal.slice(0, 7).map((d) => { this.getCal.slice(0, 7).map((d) => {
let date = new Date(d.y, d.m, d.d); let date = new Date(d.y, d.m, d.d);
return new Intl.DateTimeFormat(null, { return new Intl.DateTimeFormat(null, {
@ -293,7 +293,7 @@ export default {
) { ) {
a.push({ a.push({
d: d.getDate(), d: d.getDate(),
ld: this.getLocaleN(d.getDate()), ld: this.localeN(d.getDate()),
m: d.getMonth(), m: d.getMonth(),
y: d.getFullYear(), y: d.getFullYear(),
}); });
@ -301,15 +301,15 @@ export default {
return a; return a;
}; };
let pv = this.plannerView; let pv = this.plannerV;
let date = new Date( let date = new Date(
this.year, this.year,
this.month, this.month,
pv == "mnth" ? 1 : this.date - this.mondayFirst pv == "mnth" ? 1 : this.date - this.startMon
); );
return pv != "d" return pv != "d"
? getDays( ? getDays(
date.setDate(date.getDate() - date.getDay() + this.mondayFirst), date.setDate(date.getDate() - date.getDay() + this.startMon),
date.setDate(date.getDate() + (pv == "mnth" ? 41 : 6)) date.setDate(date.getDate() + (pv == "mnth" ? 41 : 6))
) )
: []; : [];
@ -332,7 +332,7 @@ export default {
return /minimal/.test(this.layout); return /minimal/.test(this.layout);
}, },
mpItems() { mpItems() {
let pv = this.plannerView; let pv = this.plannerV;
let days = let days =
pv == "wk" pv == "wk"
? this.getCal.slice(0, 7) ? this.getCal.slice(0, 7)
@ -387,7 +387,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["addMealPlanAction", "deleteMealPlanAction"]), ...mapActions(["addMP", "deleteMP"]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
this.showBar(); this.showBar();
@ -439,7 +439,7 @@ export default {
getYield(id) { getYield(id) {
let mp = this.mealPlans.filter((e) => e.id == id)[0]; let mp = this.mealPlans.filter((e) => e.id == id)[0];
let r = this.recipes.filter((e) => e.id === mp.recipeID)[0]; let r = this.recipes.filter((e) => e.id === mp.recipeID)[0];
return r ? `${this.getLocaleN(mp.quantity)} ${localize(r.yieldUnit)}` : 0; return r ? `${this.localeN(mp.quantity)} ${localize(r.yieldUnit)}` : 0;
}, },
// NavigationHandlers // NavigationHandlers
@ -476,7 +476,7 @@ export default {
// Calendar // Calendar
navigate(dir) { navigate(dir) {
if (this.RTL) dir = !dir; if (this.RTL) dir = !dir;
let pv = this.plannerView; let pv = this.plannerV;
let date = new Date(this.year, this.month, this.date); let date = new Date(this.year, this.month, this.date);
let sd = let sd =
pv == "mnth" pv == "mnth"
@ -557,7 +557,7 @@ export default {
// DataHandlers // DataHandlers
newMealPlan({ plan, index, inDB }) { newMealPlan({ plan, index, inDB }) {
this.addMealPlanAction({ this.addMP({
plan, plan,
index, index,
inDB, inDB,
@ -655,7 +655,7 @@ export default {
deleteTempFromDB() { deleteTempFromDB() {
if (this.temp) { if (this.temp) {
let { plan, index } = this.temp; let { plan, index } = this.temp;
this.deleteMealPlanAction({ id: plan.id, index, inDB: 1 }); this.deleteMP({ id: plan.id, index, inDB: 1 });
this.temp = 0; this.temp = 0;
} }
}, },
@ -664,11 +664,11 @@ export default {
let index = this.mealPlans.findIndex((e) => e.id == id); let index = this.mealPlans.findIndex((e) => e.id == id);
let plan = this.mealPlans.filter((e) => e.id == id)[0]; let plan = this.mealPlans.filter((e) => e.id == id)[0];
this.temp = { plan, index }; this.temp = { plan, index };
this.deleteMealPlanAction({ id, index }); this.deleteMP({ id, index });
this.showUndoBar(plan.note ? "rmN" : "recRm") this.showUndoBar(plan.note ? "rmN" : "recRm")
.then(() => this.newMealPlan({ plan, index })) .then(() => this.newMealPlan({ plan, index }))
.catch(() => { .catch(() => {
this.deleteMealPlanAction({ id, index, inDB: 1 }); this.deleteMP({ id, index, inDB: 1 });
}); });
}, },
showUndoBar(message) { showUndoBar(message) {
@ -750,7 +750,7 @@ export default {
options.year = "numeric"; options.year = "numeric";
options.month = "long"; options.month = "long";
} }
if (this.plannerView == "d") { if (this.plannerV == "d") {
options.weekday = "long"; options.weekday = "long";
options.day = "numeric"; options.day = "numeric";
options.month = "short"; options.month = "short";

View file

@ -51,60 +51,57 @@
> >
<StackLayout> <StackLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout class="attribute"> <StackLayout class="attrT">
<RLabel class="sub" :text="'cui' | L" /> <RLabel class="sub" :text="'cui' | L" />
<RLabel class="value" :text="recipe.cuisine | L" /> <RLabel class="v" :text="recipe.cuisine | L" />
</StackLayout> </StackLayout>
<StackLayout class="attribute" col="1"> <StackLayout class="attrT" col="1">
<RLabel class="sub" :text="'cat' | L" /> <RLabel class="sub" :text="'cat' | L" />
<RLabel class="value" :text="recipe.category | L" /> <RLabel class="v" :text="recipe.category | L" />
</StackLayout> </StackLayout>
</RGridLayout> </RGridLayout>
<StackLayout <StackLayout
:hidden="!recipe.tags.length" :hidden="!recipe.tags.length"
class="attribute hal" class="attrT hal"
:class="{ r: RTL }" :class="{ r: RTL }"
> >
<RLabel class="sub" :text="'ts' | L" /> <RLabel class="sub" :text="'ts' | L" />
<RLabel class="value" :text="getTags(recipe.tags)" /> <RLabel class="v" :text="getTags(recipe.tags)" />
</StackLayout> </StackLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout <StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)">
class="attribute"
:hidden="!hasTime(recipe.prepTime)"
>
<RLabel class="sub" :text="'prepT' | L" /> <RLabel class="sub" :text="'prepT' | L" />
<RLabel <RLabel
class="value" class="v"
:text="formattedTime(recipe.prepTime)" :text="formattedTime(recipe.prepTime)"
/> />
</StackLayout> </StackLayout>
<StackLayout <StackLayout
:col="hasTime(recipe.prepTime) ? 1 : 0" :col="hasTime(recipe.prepTime) ? 1 : 0"
class="attribute" class="attrT"
:hidden="!hasTime(recipe.cookTime)" :hidden="!hasTime(recipe.cookTime)"
> >
<RLabel class="title sub" :text="'cookT' | L" /> <RLabel class="title sub" :text="'cookT' | L" />
<RLabel <RLabel
class="value" class="v"
:text="formattedTime(recipe.cookTime)" :text="formattedTime(recipe.cookTime)"
/> />
</StackLayout> </StackLayout>
</RGridLayout> </RGridLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout class="attribute"> <StackLayout class="attrT">
<RLabel class="title sub" :text="'yld' | L" /> <RLabel class="title sub" :text="'yld' | L" />
<RLabel <RLabel
@touch="touchYield" @touch="touchYield"
class="value accent" class="v accent"
:text="`${tempYieldQuantity} ${$options.filters.L( :text="`${tempYieldQuantity} ${$options.filters.L(
recipe.yieldUnit recipe.yieldUnit
)}`" )}`"
/> />
</StackLayout> </StackLayout>
<StackLayout class="attribute" col="1"> <StackLayout class="attrT" col="1">
<RLabel class="title sub" :text="'Difficulty level' | L" /> <RLabel class="title sub" :text="'Difficulty level' | L" />
<RLabel class="value" :text="recipe.difficulty | L" /> <RLabel class="v" :text="recipe.difficulty | L" />
</StackLayout> </StackLayout>
</RGridLayout> </RGridLayout>
<StackLayout @loaded="onIngsLoad"> <StackLayout @loaded="onIngsLoad">
@ -139,7 +136,7 @@
:key="index + 'ins'" :key="index + 'ins'"
class="check" class="check"
> >
<Button class="tb t3 ico si" :text="getLocaleN(index + 1)" /> <Button class="tb t3 ico si" :text="localeN(index + 1)" />
<RLabel class="v tw" :text="instruction" /> <RLabel class="v tw" :text="instruction" />
</RStackLayout> </RStackLayout>
</StackLayout> </StackLayout>
@ -152,7 +149,7 @@
<Button <Button
v-for="(combination, index) in recipe.combinations" v-for="(combination, index) in recipe.combinations"
:key="index + 'comb'" :key="index + 'comb'"
class="comb tw hal lh4 fb" class="note tw hal lh4 fb"
:class="{ r: RTL }" :class="{ r: RTL }"
:text="getCombinationTitle(combination)" :text="getCombinationTitle(combination)"
@tap="viewCombination(combination)" @tap="viewCombination(combination)"
@ -264,7 +261,7 @@
stretch="aspectFit" stretch="aspectFit"
@loaded="onImgViewLoad" @loaded="onImgViewLoad"
:src="recipe.image" :src="recipe.image"
class="imgViewer" class="imgV"
/> />
</AbsoluteLayout> </AbsoluteLayout>
<WebView @loaded="wvLoad" hidden /> <WebView @loaded="wvLoad" hidden />
@ -343,7 +340,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["icon", "recipes", "RTL", "awakeViewer"]), ...mapState(["icon", "recipes", "RTL", "awakeV"]),
tempYieldQuantity() { tempYieldQuantity() {
return Math.abs(this.yieldMultiplier) > 0 return Math.abs(this.yieldMultiplier) > 0
? Math.abs(parseFloat(this.yieldMultiplier)) ? Math.abs(parseFloat(this.yieldMultiplier))
@ -372,13 +369,13 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["toggleStateAction", "setRatingAction", "toggleCartAction"]), ...mapActions(["toggleState", "setR"]),
pgLoad({ object }) { pgLoad({ object }) {
this.busyDup = this.busyEdit = this.photoOpen = 0; this.busyDup = this.busyEdit = this.photoOpen = 0;
object.bindingContext = new Observable(); object.bindingContext = new Observable();
if (this.yieldMultiplier == this.recipe.yieldQuantity) if (this.yieldMultiplier == this.recipe.yieldQuantity)
this.yieldMultiplier = this.recipe.yieldQuantity; this.yieldMultiplier = this.recipe.yieldQuantity;
if (this.awakeViewer) utils.keepScreenOn(1); if (this.awakeV) utils.keepScreenOn(1);
this.syncCombinations(); this.syncCombinations();
this.view = object.page.getViewById("printview"); this.view = object.page.getViewById("printview");
}, },
@ -504,8 +501,8 @@ export default {
s = this.stepsDid; s = this.stepsDid;
break; break;
} }
c = this.getLocaleN(c); c = this.localeN(c);
s = s && this.getLocaleN(s); s = s && this.localeN(s);
let text = s ? ` (${s}/${c})` : ` (${c})`; let text = s ? ` (${s}/${c})` : ` (${c})`;
return localize(title) + text; return localize(title) + text;
}, },
@ -572,48 +569,6 @@ export default {
: this.animateBar(this.appbar, 1); : this.animateBar(this.appbar, 1);
}); });
}, },
// getMeasure(value: number, unit: string) {
// let vm = this;
// function roundedQ(val: number) {
// return Math.abs(
// Math.round(
// (val / vm.recipe.yieldQuantity) * vm.tempYieldQuantity * 100
// ) / 100
// );
// }
// if (value) {
// let rounded = Math.abs(
// Math.round(
// (value / this.recipe.yieldQuantity) * this.tempYieldQuantity * 100
// ) / 100
// );
// let lUnit = localize(unit);
// switch (unit) {
// //IMPERIAL
// case "g":
// return rounded < 1000
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 1000)} ${localize("kg")} `;
// case "ml":
// return rounded < 1000
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 1000)} ${localize("l")} `;
// //METRIC
// case "tsp":
// return rounded < 3
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 3)} ${localize("tbsp")} `;
// case "in":
// return rounded < 12
// ? `${rounded} ${lUnit} `
// : `${roundedQ(rounded / 12)} ${localize("ft")} `;
// default:
// return `${rounded} ${lUnit} `;
// }
// } else return "";
// },
roundedQuantity(quantity: number) { roundedQuantity(quantity: number) {
return Math.abs( return Math.abs(
Math.round( Math.round(
@ -830,7 +785,7 @@ export default {
// DataHandlers // DataHandlers
toggle(key: string, setDate: boolean) { toggle(key: string, setDate: boolean) {
this.toggleStateAction({ this.toggleState({
id: this.currentRecipeID, id: this.currentRecipeID,
key, key,
setDate, setDate,
@ -844,22 +799,14 @@ export default {
setRating(r) { setRating(r) {
if (r !== this.recipe.rating || r === 1) { if (r !== this.recipe.rating || r === 1) {
if (this.recipe.rating == 1 && r == 1) r = 0; if (this.recipe.rating == 1 && r == 1) r = 0;
this.setRatingAction({ this.setR({
id: this.currentRecipeID, id: this.currentRecipeID,
rating: r, r,
}); });
} }
}, },
// ShoppingList // ShoppingList
toggleCart() {
if (!this.recipe.inBag) {
} else {
}
this.toggleCartAction({
id: this.currentRecipeID,
});
},
// Notes // Notes
createNote(note) { createNote(note) {

View file

@ -80,10 +80,10 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["sortType", "icon", "theme", "RTL"]), ...mapState(["icon", "theme", "RTL"]),
}, },
methods: { methods: {
...mapActions(["removeListItemAction", "deleteTimerPreset"]), ...mapActions(["removeLI", "deleteTP"]),
localized(item: string): string { localized(item: string): string {
return this.title !== "lang" ? localize(item) : item; return this.title !== "lang" ? localize(item) : item;
}, },
@ -114,22 +114,22 @@ export default {
let vm = this; let vm = this;
let index = this.newList.findIndex((e) => e === item); let index = this.newList.findIndex((e) => e === item);
let localizedItem = `"${localize(item)}"`; let localizedItem = `"${localize(item)}"`;
function removeListItem(listName: string, desc: string): void { function removeLI(listName: string, desc: string): void {
vm.removeConfirmation(`${localize(desc, localizedItem)}`).then( vm.removeConfirmation(`${localize(desc, localizedItem)}`).then(
(action: boolean) => { (action: boolean) => {
if (action) if (action)
vm.removeListItemAction({ vm.removeLI({
item, item,
listName, listName,
}); });
} }
); );
} }
function deleteTimerPreset(): void { function deleteTP(): void {
vm.deletionConfirmation(`${localize("delPrst", `"${item}"`)}`).then( vm.deletionConfirmation(`${localize("delPrst", `"${item}"`)}`).then(
(action: boolean) => { (action: boolean) => {
if (action) { if (action) {
vm.deleteTimerPreset(index); vm.deleteTP(index);
vm.newList.splice(index, 1); vm.newList.splice(index, 1);
} }
} }
@ -137,19 +137,19 @@ export default {
} }
switch (this.title) { switch (this.title) {
case "cui": case "cui":
removeListItem("cuisines", "rmCuiInfo"); removeLI("cuisines", "rmCuiInfo");
break; break;
case "cat": case "cat":
removeListItem("categories", "rmCatInfo"); removeLI("categories", "rmCatInfo");
break; break;
case "yieldU": case "yieldU":
removeListItem("yieldUnits", "rmYUInfo"); removeLI("yieldUnits", "rmYUInfo");
break; break;
case "Unit": case "Unit":
removeListItem("units", "rmUInfo"); removeLI("units", "rmUInfo");
break; break;
case "prsts": case "prsts":
deleteTimerPreset(); deleteTP();
break; break;
} }
}, },

View file

@ -1,15 +1,11 @@
<template> <template>
<Page <Page @loaded="mLoad" backgroundColor="transparent" :class="theme">
@loaded="mLoad"
backgroundColor="transparent"
:class="theme"
>
<GridLayout rows="auto, auto, auto" class="modal"> <GridLayout rows="auto, auto, auto" class="modal">
<RLabel class="title" :text="title | L" /> <RLabel class="title" :text="title | L" />
<Label <Label
row="1" row="1"
v-if="description" v-if="description"
class="description tw" class="desc input tw lh4"
:text="description" :text="description"
/> />
<RGridLayout :rtl="RTL" row="2" columns="*, auto, auto" class="actions"> <RGridLayout :rtl="RTL" row="2" columns="*, auto, auto" class="actions">

View file

@ -173,7 +173,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["setCuisine", "setCategory", "setTag", "clearFilter"]), ...mapActions(["setCuisine", "setCategory", "setTag"]),
pgLoad(args) { pgLoad(args) {
this.mLoad(args); this.mLoad(args);
this.localCuisine = this.selCuisine; this.localCuisine = this.selCuisine;

View file

@ -57,7 +57,7 @@
col="3" col="3"
class="text tb st fb" class="text tb st fb"
:text="action | L" :text="action | L"
@tap="sendRespose" @tap="respond"
/> />
</RGridLayout> </RGridLayout>
</GridLayout> </GridLayout>
@ -122,7 +122,7 @@ export default {
object.focus(); object.focus();
setTimeout(() => Utils.ad.showSoftInput(object.android), 100); setTimeout(() => Utils.ad.showSoftInput(object.android), 100);
}, },
sendRespose() { respond() {
this.$modal.close({ this.$modal.close({
label: this.setLabel ? this.setLabel : this.label, label: this.setLabel ? this.setLabel : this.label,
time: this.selectedTime, time: this.selectedTime,

View file

@ -21,7 +21,7 @@
:timerAlert="timerAlert" :timerAlert="timerAlert"
:showToast="showToast" :showToast="showToast"
/> />
<StackLayout class="listSpace"> </StackLayout> <StackLayout class="ls"> </StackLayout>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
<GridLayout col="1" row="1" class="appbar"> <GridLayout col="1" row="1" class="appbar">
@ -42,10 +42,9 @@
import { Application, Screen, Device, Color, Utils } from "@nativescript/core"; import { Application, Screen, Device, Color, Utils } from "@nativescript/core";
import Timer from "../sub/Timer.vue"; import Timer from "../sub/Timer.vue";
import * as utils from "~/shared/utils"; import * as utils from "~/shared/utils";
import { mapState, mapActions } from "vuex"; import { mapState } from "vuex";
const windowMgr = android.view.WindowManager; const windowMgr = android.view.WindowManager;
const View = android.view.View as any;
const ViewGroup = android.view.ViewGroup;
export default { export default {
components: { Timer }, components: { Timer },
props: [ props: [
@ -56,12 +55,12 @@ export default {
"showToast", "showToast",
], ],
computed: { computed: {
...mapState(["icon", "theme", "activeTimers"]), ...mapState(["icon", "theme", "activeTs"]),
screenWidth() { screenWidth() {
return Screen.mainScreen.widthDIPs; return Screen.mainScreen.widthDIPs;
}, },
timers() { timers() {
let timers = this.activeTimers.filter((e) => e.done); let timers = this.activeTs.filter((e) => e.done);
if (!timers.length) { if (!timers.length) {
this.$modal.close(1); this.$modal.close(1);
this.isScreenLocked && this.turnOffScreen(); this.isScreenLocked && this.turnOffScreen();
@ -81,7 +80,6 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["clearTimerInterval"]),
pgLoad({ object }) { pgLoad({ object }) {
let dialog = object._dialogFragment.getDialog(); let dialog = object._dialogFragment.getDialog();
let dialogWindow = dialog.getWindow(); let dialogWindow = dialog.getWindow();

View file

@ -6,16 +6,16 @@
<Label class="pTitle tw tb" :text="'About' | L" /> <Label class="pTitle tw tb" :text="'About' | L" />
</v-template> </v-template>
<v-template if="$index == 1"> <v-template if="$index == 1">
<StackLayout class="app-info"> <StackLayout class="appInfo">
<Image class="icon" src="res://logo" stretch="none" /> <Image class="logo" src="res://logo" stretch="none" />
<Label class="name tb tc" :text="'EnRecipes' | L" /> <Label class="name tb tc" :text="'EnRecipes' | L" />
<Label :text="getVersion" class="version tb tc" /> <Label :text="getVersion" class="tb tc" />
<Label class="info tc tw" :text="'appInfo' | L" /> <Label class="info tc tw lh4" :text="'appInfo' | L" />
</StackLayout> </StackLayout>
</v-template> </v-template>
<v-template if="$index == 8"> <v-template if="$index == 8">
<StackLayout class="listSpace"> </StackLayout> <StackLayout class="ls"> </StackLayout>
</v-template> </v-template>
<v-template> <v-template>
<RGridLayout <RGridLayout
@ -105,13 +105,9 @@ export default {
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
// HELPERS
openURL(url) {
Utils.openUrl(url);
},
touch({ object, action }, url) { touch({ object, action }, url) {
this.touchFade(object, action); this.touchFade(object, action);
if (action == "up") this.openURL(url); if (action == "up") Utils.openUrl(url);
}, },
}, },
}; };

View file

@ -77,7 +77,6 @@ export default {
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
// HELPERS
navigateTo(view) { navigateTo(view) {
this.$navigateTo(view, { this.$navigateTo(view, {
animated: false, animated: false,

View file

@ -33,7 +33,7 @@ import * as utils from "~/shared/utils";
export default { export default {
components: { OptionsList }, components: { OptionsList },
computed: { computed: {
...mapState(["icon", "timerDelay", "timerSound", "timerVibrate", "RTL"]), ...mapState(["icon", "timerD", "timerS", "timerV", "RTL"]),
items() { items() {
let options = [ let options = [
{ {
@ -41,7 +41,7 @@ export default {
icon: "sound", icon: "sound",
rtl: 0, rtl: 0,
title: "tmrSnd", title: "tmrSnd",
subTitle: this.timerSound.title, subTitle: this.timerS.title,
action: this.showSoundsList, action: this.showSoundsList,
}, },
{ {
@ -49,7 +49,7 @@ export default {
icon: "vibrate", icon: "vibrate",
rtl: 0, rtl: 0,
title: "tmrvbrt", title: "tmrvbrt",
checked: !!this.timerVibrate, checked: !!this.timerV,
action: this.toggleTimerVibrate, action: this.toggleTimerVibrate,
}, },
]; ];
@ -72,9 +72,8 @@ export default {
rtl: 0, rtl: 0,
title: "dlyDur", title: "dlyDur",
subTitle: subTitle:
this.delayList[ this.delayList[this.delayList.findIndex((e) => e.n == this.timerD)]
this.delayList.findIndex((e) => e.n == this.timerDelay) .l,
].l,
action: this.showDelayList, action: this.showDelayList,
}, },
...list, ...list,
@ -87,14 +86,14 @@ export default {
...Array.from(Array(6), (_, x) => (x + 1) * 5), ...Array.from(Array(6), (_, x) => (x + 1) * 5),
].map((e) => { ].map((e) => {
return { return {
l: `${this.getLocaleN(e)} ${localize(e > 1 ? "minutes" : "minute")}`, l: `${this.localeN(e)} ${localize(e > 1 ? "minutes" : "minute")}`,
n: e, n: e,
}; };
}); });
}, },
}, },
methods: { methods: {
...mapActions(["setTimerDelay", "setTimerSound", "setTimerVibrate"]), ...mapActions(["setTD", "setTS", "setTV"]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
ApplicationSettings.setNumber("isTimer", 2); ApplicationSettings.setNumber("isTimer", 2);
@ -104,12 +103,12 @@ export default {
props: { props: {
title: "dlyDur", title: "dlyDur",
list: this.delayList.map((e) => e.l), list: this.delayList.map((e) => e.l),
selected: this.delayList.findIndex((e) => e.n == this.timerDelay), selected: this.delayList.findIndex((e) => e.n == this.timerD),
}, },
}).then( }).then(
(res) => (res) =>
res && res &&
this.setTimerDelay( this.setTD(
this.delayList[this.delayList.findIndex((e) => e.l == res)].n this.delayList[this.delayList.findIndex((e) => e.l == res)].n
) )
); );
@ -121,18 +120,18 @@ export default {
title: "tmrSnd", title: "tmrSnd",
list: getTones.tones.map((e) => e.title), list: getTones.tones.map((e) => e.title),
selected: getTones.tones.findIndex( selected: getTones.tones.findIndex(
(e) => e.title == this.timerSound.title (e) => e.title == this.timerS.title
), ),
}, },
}).then( }).then(
(tone) => (tone) =>
tone && tone &&
tone !== this.timerSound.title && tone !== this.timerS.title &&
this.setTimerSound(getTones.tones.filter((e) => e.title === tone)[0]) this.setTS(getTones.tones.filter((e) => e.title === tone)[0])
); );
}, },
toggleTimerVibrate() { toggleTimerVibrate() {
this.setTimerVibrate(!this.timerVibrate | 0); this.setTV(!this.timerV | 0);
}, },
openNotificationChannelSettings() { openNotificationChannelSettings() {
const ctx = Application.android.context; const ctx = Application.android.context;
@ -147,8 +146,6 @@ export default {
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(intent); ctx.startActivity(intent);
}, },
// HELPERS
channelExists() { channelExists() {
if (Device.sdkVersion * 1 >= 26) { if (Device.sdkVersion * 1 >= 26) {
const ctx = Utils.ad.getApplicationContext(); const ctx = Utils.ad.getApplicationContext();

View file

@ -75,7 +75,7 @@ export default {
"yieldUnits", "yieldUnits",
"units", "units",
"mealPlans", "mealPlans",
"importSummary", "impSum",
"RTL", "RTL",
]), ]),
items() { items() {
@ -108,14 +108,14 @@ export default {
}, },
methods: { methods: {
...mapActions([ ...mapActions([
"importListItems", "importLIs",
"importRecipesFromJSON", "importRsJSON",
"importRecipesFromDB", "importRsDB",
"importMealPlansFromJSON", "importMPsJSON",
"importMealPlansFromDB", "importMPsDB",
"importTimerPresets", "importTPs",
"unlinkBrokenImages", "unLinkBIs",
"clearImportSummary", "clearIS",
]), ]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
@ -144,10 +144,8 @@ export default {
android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION | android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION |
android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION; android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
utils.getBackupFolder().then((uri) => { utils.getBackupFolder().then((uri) => {
console.log(uri.toString());
if (uri != null) { if (uri != null) {
// ReleaseExistingPermissions // ReleaseExistingPermissions
if (this.backupFolder && this.backupFolder != uri.toString()) if (this.backupFolder && this.backupFolder != uri.toString())
ContentResolver.releasePersistableUriPermission( ContentResolver.releasePersistableUriPermission(
new android.net.Uri.parse(this.backupFolder), new android.net.Uri.parse(this.backupFolder),
@ -256,7 +254,7 @@ export default {
function importImages() { function importImages() {
const timer = setInterval(() => { const timer = setInterval(() => {
if (!vm.progress) clearInterval(timer); if (!vm.progress) clearInterval(timer);
if (vm.progress && vm.importSummary.found) { if (vm.progress && vm.impSum.found) {
Folder.exists(images) Folder.exists(images)
? vm.importImages(uri) ? vm.importImages(uri)
: vm.showImportSummary(); : vm.showImportSummary();
@ -270,8 +268,6 @@ export default {
importImages(); importImages();
} else if (File.exists(recipes)) { } else if (File.exists(recipes)) {
// IMPORT FROM JSON FILES // IMPORT FROM JSON FILES
console.log("import from json");
this.isFileDataValid([ this.isFileDataValid([
{ {
path: recipes, path: recipes,
@ -309,7 +305,6 @@ export default {
} else this.failedImport(localize("buInc")); } else this.failedImport(localize("buInc"));
}, },
isFileDataValid(file) { isFileDataValid(file) {
console.log("isFileDataValid");
const files = file.filter((e) => File.exists(e.path)); const files = file.filter((e) => File.exists(e.path));
if (files.length) { if (files.length) {
let isValid = files.map(() => 0); let isValid = files.map(() => 0);
@ -362,7 +357,7 @@ export default {
// Import recipes // Import recipes
db.select("SELECT * FROM recipes").then((res) => { db.select("SELECT * FROM recipes").then((res) => {
this.importRecipesFromDB(res); this.importRsDB(res);
}); });
// Import listitems // Import listitems
@ -370,7 +365,7 @@ export default {
`SELECT cuisines, categories, yieldUnits, units FROM lists` `SELECT cuisines, categories, yieldUnits, units FROM lists`
).then((res) => ).then((res) =>
Object.keys(res[0]).forEach((listName) => Object.keys(res[0]).forEach((listName) =>
this.importListItems({ this.importLIs({
data: JSON.parse(res[0][listName]), data: JSON.parse(res[0][listName]),
listName, listName,
}) })
@ -379,46 +374,45 @@ export default {
// Import mealPlans // Import mealPlans
db.select(`SELECT * FROM mealPlans`).then((res) => db.select(`SELECT * FROM mealPlans`).then((res) =>
this.importMealPlansFromDB(res) this.importMPsDB(res)
); );
// Import timerPresets // Import timerPs
db.select(`SELECT * FROM timerPresets`).then((res) => db.select(`SELECT * FROM timerPresets`).then((res) =>
this.importTimerPresets(res) this.importTPs(res)
); );
}, },
importData(data, db) { importData(data, db) {
console.log("importing");
switch (db) { switch (db) {
case "recipes": case "recipes":
this.importRecipesFromJSON(data); this.importRsJSON(data);
break; break;
case "userCuisines": case "userCuisines":
this.importListItems({ this.importLIs({
data, data,
listName: "cuisines", listName: "cuisines",
}); });
break; break;
case "userCategories": case "userCategories":
this.importListItems({ this.importLIs({
data, data,
listName: "categories", listName: "categories",
}); });
break; break;
case "userYieldUnits": case "userYieldUnits":
this.importListItems({ this.importLIs({
data, data,
listName: "yieldUnits", listName: "yieldUnits",
}); });
break; break;
case "userUnits": case "userUnits":
this.importListItems({ this.importLIs({
data, data,
listName: "units", listName: "units",
}); });
break; break;
case "mealPlans": case "mealPlans":
this.importMealPlansFromJSON(data); this.importMPsJSON(data);
break; break;
} }
}, },
@ -437,14 +431,14 @@ export default {
}); });
}); });
this.showImportSummary(); this.showImportSummary();
this.unlinkBrokenImages(); this.unLinkBIs();
} }
}); });
}, },
showImportSummary() { showImportSummary() {
this.progress = null; this.progress = null;
this.releaseBackEvent(); this.releaseBackEvent();
let { found, imported, updated } = this.importSummary; let { found, imported, updated } = this.impSum;
let exists = Math.abs(found - imported - updated) + updated; let exists = Math.abs(found - imported - updated) + updated;
let importedNote = `\n${localize("recI")} ${imported}`; let importedNote = `\n${localize("recI")} ${imported}`;
let existsNote = `\n${localize("recE")} ${exists}`; let existsNote = `\n${localize("recE")} ${exists}`;
@ -457,7 +451,7 @@ export default {
)}\n${importedNote}${existsNote}${updatedNote}`, )}\n${importedNote}${existsNote}${updatedNote}`,
okButtonText: "OK", okButtonText: "OK",
}, },
}).then(() => this.clearImportSummary()); }).then(() => this.clearIS());
}, },
// NAVIGATION HANDLERS // NAVIGATION HANDLERS

View file

@ -32,7 +32,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["icon", "language", "theme", "layout", "RTL"]), ...mapState(["icon", "langs", "theme", "layout", "RTL"]),
items() { items() {
return [ return [
{}, {},
@ -65,13 +65,13 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["setTheme", "setLayout", "setRTL"]), ...mapActions(["setT", "setL", "setRTL"]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
// LANGUAGE SELECTION // LanguageSelection
setAppLang() { setAppLang() {
let languages = this.language.map((e) => e.title); let languages = this.langs.map((e) => e.title);
this.$showModal(Action, { this.$showModal(Action, {
props: { props: {
title: "lang", title: "lang",
@ -84,8 +84,7 @@ export default {
"appLocale", "appLocale",
"none" "none"
).split("-"); ).split("-");
let locale = this.language.filter((e) => e.title === action)[0] let locale = this.langs.filter((e) => e.title === action)[0].locale;
.locale;
if (currentLocale !== locale) { if (currentLocale !== locale) {
this.applang = action; this.applang = action;
ApplicationSettings.setString("applang", action); ApplicationSettings.setString("applang", action);
@ -97,7 +96,7 @@ export default {
} }
}); });
}, },
// THEME SELECTION // ThemeSelection
selectThemes() { selectThemes() {
this.$showModal(Action, { this.$showModal(Action, {
props: { props: {
@ -112,12 +111,12 @@ export default {
? 1 ? 1
: this.theme != action) : this.theme != action)
) { ) {
this.setTheme(action); this.setT(action);
Frame.reloadPage(); Frame.reloadPage();
} }
}); });
}, },
// LAYOUT MODE // LayoutMode
setLayoutMode() { setLayoutMode() {
this.$showModal(Action, { this.$showModal(Action, {
props: { props: {
@ -126,7 +125,7 @@ export default {
selected: this.layout, selected: this.layout,
}, },
}).then((mode) => { }).then((mode) => {
if (mode && this.layout !== mode) this.setLayout(mode.toLowerCase()); if (mode && this.layout !== mode) this.setL(mode.toLowerCase());
}); });
}, },
}, },

View file

@ -26,7 +26,7 @@ import { localize } from "@nativescript/localize";
export default { export default {
components: { OptionsList }, components: { OptionsList },
computed: { computed: {
...mapState(["icon", "mondayFirst", "RTL", "plannerView", "planDeletion"]), ...mapState(["icon", "startMon", "RTL", "plannerV", "planDel"]),
items() { items() {
return [ return [
{}, {},
@ -34,21 +34,21 @@ export default {
type: "list", type: "list",
icon: "calv", icon: "calv",
title: "calVM", title: "calVM",
subTitle: localize(this.plannerView), subTitle: localize(this.plannerV),
action: this.selectPlannerView, action: this.selectPlannerView,
}, },
{ {
type: "switch", type: "switch",
icon: "week", icon: "week",
title: "swm", title: "swm",
checked: !!this.mondayFirst, checked: !!this.startMon,
action: this.toggleFirstDay, action: this.toggleFirstDay,
}, },
{ {
type: "list", type: "list",
icon: "mpd", icon: "mpd",
title: "admp", title: "admp",
subTitle: localize(this.planDeletion), subTitle: localize(this.planDel),
action: this.selectDeletionTime, action: this.selectDeletionTime,
}, },
{}, {},
@ -56,22 +56,22 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["setFirstDay", "setPlannerView", "setPlanDeletion"]), ...mapActions(["setFD", "setPlannerV", "setPlanDel"]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
toggleFirstDay() { toggleFirstDay() {
this.setFirstDay(!this.mondayFirst | 0); this.setFD(!this.startMon | 0);
}, },
selectPlannerView() { selectPlannerView() {
this.$showModal(Action, { this.$showModal(Action, {
props: { props: {
title: "calVM", title: "calVM",
list: ["d", "wk", "mnth"], list: ["d", "wk", "mnth"],
selected: this.plannerView, selected: this.plannerV,
}, },
}).then((res) => { }).then((res) => {
if (res && this.plannerView != res) this.setPlannerView(res); if (res && this.plannerV != res) this.setPlannerV(res);
}); });
}, },
selectDeletionTime() { selectDeletionTime() {
@ -79,10 +79,10 @@ export default {
props: { props: {
title: "admp", title: "admp",
list: ["otaw", "otam", "otay", "nvr"], list: ["otaw", "otam", "otay", "nvr"],
selected: this.planDeletion, selected: this.planDel,
}, },
}).then((res) => { }).then((res) => {
if (res && this.planDeletion != res) this.setPlanDeletion(res); if (res && this.planDel != res) this.setPlanDel(res);
}); });
}, },
}, },

View file

@ -42,7 +42,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["icon", "shake", "RTL", "edgeSwipe", "awakeViewer"]), ...mapState(["icon", "shake", "RTL", "edgeS", "awakeV"]),
items() { items() {
return [ return [
{}, {},
@ -59,7 +59,7 @@ export default {
icon: "awake", icon: "awake",
title: "ksavr", title: "ksavr",
subTitle: localize("ksavrInfo"), subTitle: localize("ksavrInfo"),
checked: !!this.awakeViewer, checked: !!this.awakeV,
action: this.toggleAwake, action: this.toggleAwake,
}, },
{ {
@ -67,7 +67,7 @@ export default {
icon: "edge", icon: "edge",
title: "esgb", title: "esgb",
subTitle: localize("esgbInfo"), subTitle: localize("esgbInfo"),
checked: !!this.edgeSwipe, checked: !!this.edgeS,
action: this.toggleSwipe, action: this.toggleSwipe,
}, },
{}, {},
@ -75,7 +75,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["setShake", "toggleEdgeSwipe", "toggleAwakeViewer"]), ...mapActions(["setS", "toggleEdgeS", "toggleAwakeV"]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
@ -90,13 +90,13 @@ export default {
let checked = this.shake; let checked = this.shake;
if (checked && !utils.hasAccelerometer()) if (checked && !utils.hasAccelerometer())
this.showToast(localize("noAccSensor")); this.showToast(localize("noAccSensor"));
else this.setShake(+!checked); else this.setS(+!checked);
}, },
toggleSwipe() { toggleSwipe() {
this.toggleEdgeSwipe(+!this.edgeSwipe); this.toggleEdgeS(+!this.edgeS);
}, },
toggleAwake() { toggleAwake() {
this.toggleAwakeViewer(+!this.awakeViewer); this.toggleAwakeV(+!this.awakeV);
}, },
showToast(data) { showToast(data) {

View file

@ -1,7 +1,7 @@
<template> <template>
<Page @loaded="pgLoad" actionBarHidden="true"> <Page @loaded="pgLoad" actionBarHidden="true">
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *"> <RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
<OptionsList title="rest" :items="items" :action="resetListItems" /> <OptionsList title="rest" :items="items" :action="reset" />
<GridLayout <GridLayout
:hidden="toast" :hidden="toast"
row="1" row="1"
@ -83,7 +83,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(["resetListItemsAction"]), ...mapActions(["resetLIs"]),
pgLoad({ object }) { pgLoad({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
@ -93,9 +93,8 @@ export default {
tbLoad({ object }) { tbLoad({ object }) {
this.toastbar = object; this.toastbar = object;
}, },
// RESET reset(list) {
resetListItems(listName) { this.resetLIs(list);
this.resetListItemsAction(listName);
this.showToast(); this.showToast();
}, },
showToast() { showToast() {

View file

@ -52,13 +52,13 @@
</v-template> </v-template>
<v-template if="item.type == 'info'"> <v-template if="item.type == 'info'">
<Label <Label
class="group-info sub tw" class="groupInfo sub tw lh4"
:class="{ r: RTL }" :class="{ r: RTL }"
:text="item.title | L" :text="item.title | L"
/> />
</v-template> </v-template>
<v-template> <v-template>
<StackLayout class="listSpace"> </StackLayout> <StackLayout class="ls"> </StackLayout>
</v-template> </v-template>
</ListView> </ListView>
</template> </template>

View file

@ -82,7 +82,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["icon", "recipes", "timerDelay", "timerPresets", "RTL"]), ...mapState(["icon", "recipes", "timerD", "timerPs", "RTL"]),
getRecipeTitle() { getRecipeTitle() {
let { recipeID } = this.timer; let { recipeID } = this.timer;
if (recipeID) { if (recipeID) {
@ -137,12 +137,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions([ ...mapActions(["addTP", "sortATs"]),
"removeActiveTimer",
"addTimerPreset",
"deleteTimerPreset",
"sortActiveTimers",
]),
pLoaded({ object }) { pLoaded({ object }) {
this.pBar = object.android; this.pBar = object.android;
this.pBar.setRotation( this.pBar.setRotation(
@ -165,7 +160,7 @@ export default {
} else if (res) { } else if (res) {
let timer = this.timer; let timer = this.timer;
timer.recipeID = res; timer.recipeID = res;
this.sortActiveTimers(); this.sortATs();
} }
}); });
}, },
@ -211,7 +206,7 @@ export default {
this.timer.isPaused ? this.resetInterval() : this.initTimer(); this.timer.isPaused ? this.resetInterval() : this.initTimer();
}, },
addPreset() { addPreset() {
let exist = this.timerPresets.some((e) => e.id == this.timer.id); let exist = this.timerPs.some((e) => e.id == this.timer.id);
this.timer.preset = 1; this.timer.preset = 1;
if (this.countUp) { if (this.countUp) {
this.timer.time = new Date(this.count * 1000) this.timer.time = new Date(this.count * 1000)
@ -221,14 +216,14 @@ export default {
let timer = JSON.parse(JSON.stringify(this.timer)); let timer = JSON.parse(JSON.stringify(this.timer));
let { recipeID, timerInt, isPaused, preset, done, mode, ...presetTimer } = let { recipeID, timerInt, isPaused, preset, done, mode, ...presetTimer } =
timer; timer;
this.addTimerPreset(presetTimer); this.addTP(presetTimer);
exist ? this.showToast("prstTU") : this.showToast("aTPrst"); exist ? this.showToast("prstTU") : this.showToast("aTPrst");
}, },
addDelay() { addDelay() {
this.timer.done = 0; this.timer.done = 0;
let td = this.timerDelay; let td = this.timerD;
let delayDur = let delayDur =
this.getLocaleN(td) + " " + localize(td > 1 ? "minutes" : "minute"); this.localeN(td) + " " + localize(td > 1 ? "minutes" : "minute");
this.showToast(localize("wDBy", this.timer.label, delayDur)); this.showToast(localize("wDBy", this.timer.label, delayDur));
let delay = td * 60; let delay = td * 60;
if (this.done) this.delay = delay; if (this.done) this.delay = delay;

View file

@ -40,15 +40,15 @@ Vue.filter('L', localize)
const initFrame = () => { const initFrame = () => {
const s = store const s = store
// MainInit // MainInit
s.commit('setTheme', getString('theme', 'sysDef')) s.commit('setT', getString('theme', 'sysDef'))
s.commit('initRecipes') s.commit('initRs')
s.commit('initMealPlans') s.commit('initMPs')
s.commit('initListItems') s.commit('initLIs')
s.commit('initTimerPresets') s.commit('initTPs')
if (!Object.keys(s.state.timerSound).length) { if (!Object.keys(s.state.timerS).length) {
let hasTimerSound = getString('timerSound', null) let hasTimerSound = getString('timerS', null)
s.commit( s.commit(
'setTimerSound', 'setTS',
hasTimerSound ? JSON.parse(hasTimerSound) : utils.getTones().defaultTone hasTimerSound ? JSON.parse(hasTimerSound) : utils.getTones().defaultTone
) )
} }

View file

@ -1051,7 +1051,7 @@ export default new Vuex.Store({
// DeleteMealPlan // DeleteMealPlan
deleteMP( deleteMP(
state, state,
{ id, index, inDB }: { id: string; index: number; inDB: number } { id, index, inDB }: { id: string; index: number; inDB?: number }
) { ) {
if (inDB) { if (inDB) {
db.execute(`DELETE FROM mealPlans WHERE id = '${id}'`) db.execute(`DELETE FROM mealPlans WHERE id = '${id}'`)
@ -1074,9 +1074,9 @@ export default new Vuex.Store({
} }
}, },
// UnLinkCombinations // UnLinkCombinations
unLinkCs(state, { id, a }) { unLinkCs(state, { id, combs }) {
state.recipes.forEach((e, i) => { state.recipes.forEach((e, i) => {
if (a.includes(e.id)) { if (combs.includes(e.id)) {
state.recipes[i].combinations.splice(e.combinations.indexOf(id), 1) state.recipes[i].combinations.splice(e.combinations.indexOf(id), 1)
db.execute( db.execute(
`UPDATE recipes SET combinations = '${JSON.stringify( `UPDATE recipes SET combinations = '${JSON.stringify(
@ -1092,10 +1092,10 @@ export default new Vuex.Store({
setNumber('shake', n) setNumber('shake', n)
}, },
// SetRating // SetRating
setR(state, { id, rating }) { setR(state, { id, r }) {
let i = state.recipes.findIndex((e) => e.id == id) let i = state.recipes.findIndex((e) => e.id == id)
state.recipes[i].rating = rating state.recipes[i].rating = r
db.execute(`UPDATE recipes SET rating = ${rating} WHERE id = '${id}'`) db.execute(`UPDATE recipes SET rating = ${r} WHERE id = '${id}'`)
}, },
// UnLinkBrokenImages // UnLinkBrokenImages
unLinkBIs(state) { unLinkBIs(state) {