Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Hosted Weblate 2021-07-03 19:04:58 +02:00
commit 1a7179dde4
No known key found for this signature in database
GPG key ID: A3FAAA06E6569B4C
4 changed files with 369 additions and 221 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<Page @loaded="pgLoad" @unloaded="onPageUnload" actionBarHidden="true"> <Page @loaded="pageL" @unloaded="pageUL" actionBarHidden="true">
<GridLayout rows="*, auto, auto" columns="auto, *, auto"> <GridLayout rows="*, auto, auto" columns="auto, *, auto">
<DockLayout stretchLastChild="true" rowSpan="3" colSpan="3"> <DockLayout stretchLastChild="true" rowSpan="3" colSpan="3">
<RGridLayout <RGridLayout
@ -46,8 +46,8 @@
dock="bottom" dock="bottom"
width="100%" width="100%"
height="100%" height="100%"
@loaded="onScrollLoad" @loaded="scrollvL"
@scroll="svScroll($event)" @scroll="scrollvS($event)"
> >
<StackLayout> <StackLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
@ -71,7 +71,7 @@
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
<StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)"> <StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)">
<RLabel class="sub" :text="'prepT' | L" /> <RLabel class="sub" :text="'prepT' | L" />
<RLabel class="v" :text="formattedTime(recipe.prepTime)" /> <RLabel class="v" :text="niceTime(recipe.prepTime)" />
</StackLayout> </StackLayout>
<StackLayout <StackLayout
:col="hasTime(recipe.prepTime) ? 1 : 0" :col="hasTime(recipe.prepTime) ? 1 : 0"
@ -79,7 +79,7 @@
:hidden="!hasTime(recipe.cookTime)" :hidden="!hasTime(recipe.cookTime)"
> >
<RLabel class="title sub" :text="'cookT' | L" /> <RLabel class="title sub" :text="'cookT' | L" />
<RLabel class="v" :text="formattedTime(recipe.cookTime)" /> <RLabel class="v" :text="niceTime(recipe.cookTime)" />
</StackLayout> </StackLayout>
</RGridLayout> </RGridLayout>
<RGridLayout :rtl="RTL" rows="auto" columns="*, *"> <RGridLayout :rtl="RTL" rows="auto" columns="*, *">
@ -98,7 +98,7 @@
<RLabel class="v" :text="recipe.difficulty | L" /> <RLabel class="v" :text="recipe.difficulty | L" />
</StackLayout> </StackLayout>
</RGridLayout> </RGridLayout>
<StackLayout @loaded="onIngsLoad"> <StackLayout @loaded="ingCL">
<RLabel <RLabel
class="section t2 tb tw" class="section t2 tb tw"
:hidden="!recipe.ingredients.length" :hidden="!recipe.ingredients.length"
@ -124,7 +124,7 @@
/> />
</RStackLayout> </RStackLayout>
</StackLayout> </StackLayout>
<StackLayout @loaded="onInsLoad"> <StackLayout @loaded="insCL">
<RLabel <RLabel
:hidden="!recipe.instructions.length" :hidden="!recipe.instructions.length"
class="section t2 tb tw" class="section t2 tb tw"
@ -141,7 +141,7 @@
<Button <Button
:hidden="!item.type" :hidden="!item.type"
class="tb t3 ico si" class="tb t3 ico si"
:text="getInsPos(i)" :text="localeN(getInsPos[i])"
/> />
<RLabel <RLabel
class="v tw" class="v tw"
@ -151,7 +151,7 @@
</RStackLayout> </RStackLayout>
</StackLayout> </StackLayout>
<RLabel <RLabel
@loaded="onCmbLoad" @loaded="cmbCL"
:hidden="!recipe.combinations.length" :hidden="!recipe.combinations.length"
class="section t2 tb tw" class="section t2 tb tw"
:text="getTitleCount('cmbs', 'combinations')" :text="getTitleCount('cmbs', 'combinations')"
@ -165,16 +165,16 @@
@tap="viewCombination(combination)" @tap="viewCombination(combination)"
/> />
<RLabel <RLabel
@loaded="onNosTLoad" @loaded="notesCTL"
:hidden="!recipe.notes.length" :hidden="!recipe.notes.length"
class="section t2 tb tw" class="section t2 tb tw"
:text="getTitleCount('nos', 'notes')" :text="getTitleCount('nos', 'notes')"
/> />
<StackLayout @loaded="onNosLoad"> </StackLayout> <StackLayout @loaded="notesCL"> </StackLayout>
<Label <Label
padding="32 16 16" padding="32 16 16"
class="lh4 t5 sub tw" class="lh4 t5 sub tw"
:text="getDates().uc" :text="getDates.uc"
/> />
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
@ -187,7 +187,7 @@
</DockLayout> </DockLayout>
<GridLayout <GridLayout
row="1" row="1"
@loaded="sbload" @loaded="sidebarL"
class="appbar toolbar" class="appbar toolbar"
:col="RTL ? 0 : 2" :col="RTL ? 0 : 2"
rows="auto, auto, auto, auto" rows="auto, auto, auto, auto"
@ -216,7 +216,7 @@
:rtl="RTL" :rtl="RTL"
row="2" row="2"
colSpan="3" colSpan="3"
@loaded="abLoad" @loaded="appbarL"
class="appbar" class="appbar"
:hidden="toast" :hidden="toast"
columns="auto, *, auto, auto, auto, auto" columns="auto, *, auto, auto, auto, auto"
@ -261,7 +261,7 @@
<Toast <Toast
row="2" row="2"
colSpan="3" colSpan="3"
:onload="tbLoad" :onload="toastL"
:toast="toast" :toast="toast"
:action="hideBar" :action="hideBar"
/> />
@ -270,7 +270,7 @@
@tap="closePhoto" @tap="closePhoto"
backgroundColor="black" backgroundColor="black"
stretch="aspectFit" stretch="aspectFit"
@loaded="onImgViewLoad" @loaded="imgVLoad"
:src="recipe.image" :src="recipe.image"
class="imgV" class="imgV"
/> />
@ -352,7 +352,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["icon", "recipes", "RTL", "awakeV"]), ...mapState(["icon", "recipes", "RTL", "awakeV", "mSystem"]),
tempYieldQuantity() { tempYieldQuantity() {
return Math.abs(this.yieldMultiplier) > 0 return Math.abs(this.yieldMultiplier) > 0
? Math.abs(parseFloat(this.yieldMultiplier)) ? Math.abs(parseFloat(this.yieldMultiplier))
@ -382,10 +382,32 @@ export default {
getTags() { getTags() {
return this.recipe.tags.join(" · "); return this.recipe.tags.join(" · ");
}, },
getDates() {
let r = this.recipe;
let u = `${localize("Last updated")}: ${this.intlDate(r.lastModified)}`;
let c = `${localize("Created")}: ${this.intlDate(r.created)}`;
return {
u,
c,
uc: u + "\n" + c,
};
},
getInsPos() {
let a = 1;
let b = 1;
let ins = this.recipe.instructions;
return ins.reduce((acc, e) => {
if (!e.type) {
a = 1;
acc.push(b++);
} else acc.push(a++);
return acc;
}, []);
},
}, },
methods: { methods: {
...mapActions(["toggleState", "setR"]), ...mapActions(["toggleState", "setR"]),
pgLoad({ object }) { pageL({ 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)
@ -394,50 +416,56 @@ export default {
this.syncCombinations(); this.syncCombinations();
this.view = object.page.getViewById("printview"); this.view = object.page.getViewById("printview");
}, },
onPageUnload() { pageUL() {
utils.keepScreenOn(0); utils.keepScreenOn(0);
if (this.recipeTried) this.markTried(); if (this.recipeTried) this.markTried();
}, },
sbload({ object }) { sidebarL({ object }) {
this.sidebar = object; this.sidebar = object;
}, },
abLoad({ object }) { appbarL({ object }) {
this.appbar = object; this.appbar = object;
}, },
tbLoad({ object }) { toastL({ object }) {
this.toastbar = object; this.toastbar = object;
this.recipe.lastTried && this.showLastTried(); this.recipe.lastTried && this.showLastTried();
}, },
wvLoad({ object }) { ingCL({ object }) {
this.wv = object;
utils.updateLocale();
},
onIngsLoad({ object }) {
this.ingcon = object; this.ingcon = object;
}, },
onInsLoad({ object }) { insCL({ object }) {
this.inscon = object; this.inscon = object;
}, },
onCmbLoad({ object }) { cmbCL({ object }) {
this.cmbcon = object; this.cmbcon = object;
}, },
onNosTLoad({ object }) { notesCL({ object }) {
this.notesT = object;
},
onNosLoad({ object }) {
this.notescon = object; this.notescon = object;
this.createNotes(); this.createNotes();
}, },
onScrollLoad(args) { notesCTL({ object }) {
this.notesT = object;
},
// ScrollView
scrollvL(args) {
this.scrollview = args.object; this.scrollview = args.object;
}, },
onImgViewLoad({ object }) { scrollvS({ object, scrollY }) {
this.imgView = object; let swipeUp: boolean;
this.imgView.visibility = "collapsed"; let y = scrollY;
this.imgView.top = 24; if (y) {
this.imgView.left = this.RTL ? 16 : Screen.mainScreen.widthDIPs - 112; swipeUp = y > this.scrollPos;
this.scrollPos = Math.abs(y);
this.fixTitle(object, swipeUp);
if (!this.toast) {
let ab = this.appbar.translateY;
if (swipeUp && ab == 0) this.hideBars();
else if (!swipeUp && ab == 64) this.showBars();
}
}
}, },
fixTitle(object, swipeUp: boolean): void { fixTitle(object, swipeUp: boolean) {
let ingL = this.recipe.ingredients.length; let ingL = this.recipe.ingredients.length;
let insL = this.recipe.instructions.length; let insL = this.recipe.instructions.length;
let cmbL = this.recipe.combinations.length; let cmbL = this.recipe.combinations.length;
@ -475,39 +503,35 @@ export default {
setVisibleTitle(0); setVisibleTitle(0);
} }
}, },
svScroll({ object, scrollY }) {
let swipeUp: boolean; // AppBars
let y = scrollY;
if (y) {
swipeUp = y > this.scrollPos;
this.scrollPos = Math.abs(y);
this.fixTitle(object, swipeUp);
if (!this.toast) {
let ab = this.appbar.translateY;
if (swipeUp && ab == 0) this.hideBars();
else if (!swipeUp && ab == 64) this.showBars();
}
}
},
showBars() { showBars() {
this.animateBar(this.appbar, 1); this.animateBar(this.appbar, 1);
}, },
hideBar() {
clearInterval(barTimer);
this.animateBar(this.toastbar, 0).then(() => {
this.toast = null;
this.photoOpen
? (this.appbar.opacity = 1)
: this.animateBar(this.appbar, 1);
});
},
hideBars() { hideBars() {
this.showTools && this.toggleTools(); this.showTools && this.toggleTools();
this.animateBar(this.appbar, 0); this.animateBar(this.appbar, 0);
}, },
getInsPos(n) { showLastTried() {
let a = 1; this.animateBar(this.appbar, 0).then(() => {
let b = 1; this.toast = localize(
let ins = this.recipe.instructions; "triedInfo",
let group = ins.reduce((acc, e) => { this.niceDate(this.recipe.lastTried)
if (!e.type) { );
a = 1; this.animateBar(this.toastbar, 1, 1);
acc.push(b++); let a = 10;
} else acc.push(a++); clearInterval(barTimer);
return acc; barTimer = setInterval(() => a-- < 1 && this.hideBar(), 1000);
}, []); });
return this.localeN(group[n]);
}, },
// Helpers // Helpers
@ -533,13 +557,144 @@ export default {
return localize(title) + text; return localize(title) + text;
}, },
getIng(o) { getIng(o) {
return `${ let q = o.quantity;
this.roundedQuantity(o.quantity) return `${q ? this.scaleUnit(q, o.unit) : ""}${o.value}`;
? this.roundedQuantity(o.quantity) + " " },
: "" roundQ(q: number) {
}${this.roundedQuantity(o.quantity) ? localize(o.unit) + " " : ""}${ return Math.abs(
o.value Math.round(
}`; (q / this.recipe.yieldQuantity) * this.tempYieldQuantity * 100
) / 100
);
},
metric(q, u) {
switch (u) {
case "mg":
if (q / 1000 >= 1) {
q = q / 1000;
u = "g";
}
case "g":
if (q / 1000 >= 1) {
q = q / 1000;
u = "kg";
}
break;
case "ml":
if (q / 1000 >= 1) {
q = q / 1000;
u = "l";
}
break;
case "pinch":
if (q / 16 >= 1) {
q = q / 16;
u = "tsp";
}
case "tsp":
if (q / 3 >= 1) {
q = q / 3;
u = "tbsp";
}
case "tbsp":
if (q / 16 >= 1) {
q = q / 16;
u = "cup";
}
break;
case "cup":
if (q / 4.16 >= 1) {
q = q / 4.16;
u = "l";
}
break;
}
return { q, u };
},
imperial(q, u) {
switch (u) {
case "pinch":
if (q / 16 >= 1) {
q = q / 16;
u = "tsp";
}
case "tsp":
if (q / 3 >= 1) {
q = q / 3;
u = "tbsp";
} else if (q / 2 >= 1) {
q = q / 2;
u = "dsp";
}
case "dsp":
if (q / 1.5 >= 1) {
q = q / 1.5;
u = "tbsp";
}
case "tbsp":
if (q / 16 >= 1) {
q = q / 16;
u = "cup";
}
break;
case "fl oz":
if (q / 8 >= 1) {
q = q / 8;
u = "cup";
}
break;
case "cup":
if (q / 16 >= 1) {
q = q / 16;
u = "gal";
} else if (q / 4 >= 1) {
q = q / 4;
u = "qt";
} else if (q / 2 >= 1) {
q = q / 2;
u = "pt";
}
case "oz":
if (q / 16 >= 1) {
q = q / 16;
u = "lb";
}
case "pt":
if (q / 2 >= 1) {
q = q / 2;
u = "qt";
}
case "qt":
if (q / 4 >= 1) {
q = q / 4;
u = "gal";
}
}
return { q, u };
},
fraction(num) {
let arr = [0, 0.125, 0.25, 0.333, 0.375, 0.5, 0.666, 0.75, 0.875, 1];
let brr = [0, "⅛", "¼", "⅓", "⅜", "½", "⅔", "¾", "⅞", 1];
let dec = Math.trunc(num);
let n = Number((num - Math.floor(num)).toFixed(2));
let closest = arr.reduce((acc, e) =>
Math.abs(e - n) < Math.abs(acc - n) ? e : acc
);
let f = brr[arr.indexOf(closest)];
return f == 0 ? num : f == 1 ? dec + 1 : (dec ? dec + " " : "") + f;
},
scaleUnit(quantity, unit) {
quantity =
(quantity / this.recipe.yieldQuantity) * this.tempYieldQuantity;
let { q, u } =
this.mSystem == "mtrc"
? this.metric(quantity, unit)
: this.imperial(quantity, unit);
let rounded = Math.abs(Math.round(q * 100) / 100);
if (true) {
rounded = this.fraction(rounded);
}
return `${rounded} ${localize(u)} `;
}, },
changeYield() { changeYield() {
this.$showModal(Prompt, { this.$showModal(Prompt, {
@ -555,6 +710,14 @@ export default {
hasTime(time) { hasTime(time) {
return time != "00:00"; return time != "00:00";
}, },
niceTime(time) {
let t = time.split(":");
let h = parseInt(t[0]);
let m = parseInt(t[1]);
let hr = localize("hr");
let min = localize("min");
return h ? (m ? `${h} ${hr} ${m} ${min}` : `${h} ${hr}`) : `${m} ${min}`;
},
niceDate(lastTried) { niceDate(lastTried) {
let now = new Date().getTime(); let now = new Date().getTime();
let midnight = new Date().setHours(0, 0, 0, 0); let midnight = new Date().setHours(0, 0, 0, 0);
@ -574,43 +737,7 @@ export default {
(dayDiff > 365 && duration("ltAgo")) (dayDiff > 365 && duration("ltAgo"))
); );
}, },
showLastTried() { intlDate(date) {
this.animateBar(this.appbar, 0).then(() => {
this.toast = localize(
"triedInfo",
this.niceDate(this.recipe.lastTried)
);
this.animateBar(this.toastbar, 1, 1);
let a = 10;
clearInterval(barTimer);
barTimer = setInterval(() => a-- < 1 && this.hideBar(), 1000);
});
},
hideBar() {
clearInterval(barTimer);
this.animateBar(this.toastbar, 0).then(() => {
this.toast = null;
this.photoOpen
? (this.appbar.opacity = 1)
: this.animateBar(this.appbar, 1);
});
},
roundedQuantity(quantity: number) {
return Math.abs(
Math.round(
(quantity / this.recipe.yieldQuantity) * this.tempYieldQuantity * 100
) / 100
);
},
formattedTime(time) {
let t = time.split(":");
let h = parseInt(t[0]);
let m = parseInt(t[1]);
let hr = localize("hr");
let min = localize("min");
return h ? (m ? `${h} ${hr} ${m} ${min}` : `${h} ${hr}`) : `${m} ${min}`;
},
formattedDate(date) {
return new Intl.DateTimeFormat(null, { return new Intl.DateTimeFormat(null, {
year: "numeric", year: "numeric",
month: "long", month: "long",
@ -619,78 +746,6 @@ export default {
minute: "numeric", minute: "numeric",
}).format(new Date(date)); }).format(new Date(date));
}, },
getCombinationTitle(id) {
return this.recipes.filter((e) => e.id === id)[0].title;
},
syncCombinations() {
let combinationForOtherRecipes = this.recipes
.filter(
(e) =>
e.combinations.indexOf(this.currentRecipeID) >= 0 ||
this.recipe.combinations.includes(e.id)
)
.map((e) => e.id);
this.recipe.combinations = combinationForOtherRecipes;
// this.overwriteRecipeAction({
// id: this.currentRecipeID,
// recipe: this.recipe,
// });
},
touchIngredient({ object, action }, index) {
this.touchFade(object, action);
if (action == "up") this.checkChange(object, index);
},
checkChange(obj, index) {
this.checks[index] = !this.checks[index];
if (this.checks[index]) {
this.checked++;
obj.getChildAt(0).text = this.icon.check;
} else {
this.checked--;
obj.getChildAt(0).text = this.icon.uncheck;
}
},
clearChecks() {
this.checked = 0;
this.checks = [];
for (let i = 1; i < this.ingcon.getChildrenCount(); i++) {
this.ingcon.getChildAt(i).getChildAt(0).text = this.icon.uncheck;
}
},
touchInstruction({ object, action }) {
let hasDone = object.className.includes("done");
if (!hasDone) this.touchFade(object, action);
if (action == "up") this.stepDone(object);
},
stepDone(object) {
let a = object;
if (a.className.includes("done")) {
a.className = "check";
this.stepsDid--;
} else {
a.className = "check done";
this.stepsDid++;
}
},
clearSteps() {
this.stepsDid = 0;
for (let i = 1; i < this.inscon.getChildrenCount(); i++) {
this.inscon.getChildAt(i).className = "check";
}
},
getDates() {
let u = `${localize("Last updated")}: ${this.formattedDate(
this.recipe.lastModified
)}`;
let c = `${localize("Created")}: ${this.formattedDate(
this.recipe.created
)}`;
return {
u,
c,
uc: u + "\n" + c,
};
},
// NavigationHandlers // NavigationHandlers
hijackBackEvent() { hijackBackEvent() {
@ -719,6 +774,20 @@ export default {
animated: false, animated: false,
}); });
}, },
// Combinations
getCombinationTitle(id) {
return this.recipes.filter((e) => e.id === id)[0].title;
},
syncCombinations() {
this.recipe.combinations = this.recipes
.filter(
(e) =>
e.combinations.indexOf(this.currentRecipeID) >= 0 ||
this.recipe.combinations.includes(e.id)
)
.map((e) => e.id);
},
viewCombination(combination) { viewCombination(combination) {
this.hideBar(); this.hideBar();
this.scrollview.scrollToVerticalOffset(0, true); this.scrollview.scrollToVerticalOffset(0, true);
@ -793,9 +862,9 @@ export default {
if (r.tags.length) if (r.tags.length)
overview += `${localize("ts")}: ${r.tags.join(", ")}\n`; overview += `${localize("ts")}: ${r.tags.join(", ")}\n`;
if (r.prepTime != "00:00") if (r.prepTime != "00:00")
overview += `${localize("prepT")}: ${this.formattedTime(r.prepTime)}\n`; overview += `${localize("prepT")}: ${this.niceTime(r.prepTime)}\n`;
if (r.cookTime != "00:00") if (r.cookTime != "00:00")
overview += `${localize("cookT")}: ${this.formattedTime(r.cookTime)}\n`; overview += `${localize("cookT")}: ${this.niceTime(r.cookTime)}\n`;
overview += `${localize("yld")}: ${this.tempYieldQuantity} ${localize( overview += `${localize("yld")}: ${this.tempYieldQuantity} ${localize(
r.yieldUnit r.yieldUnit
)}\n${localize("Difficulty level")}: ${localize(r.difficulty)}\n`; )}\n${localize("Difficulty level")}: ${localize(r.difficulty)}\n`;
@ -807,19 +876,13 @@ export default {
if (e.type) { if (e.type) {
ingredients += `- ${ ingredients += `- ${
e.quantity e.quantity
? this.roundedQuantity(e.quantity) + ? this.roundQ(e.quantity) + " " + localize(e.unit) + " "
" " +
localize(e.unit) +
" "
: "" : ""
}${e.value}\n`; }${e.value}\n`;
} else { } else {
ingredients += `\n${ ingredients += `\n${
e.quantity e.quantity
? this.roundedQuantity(e.quantity) + ? this.roundQ(e.quantity) + " " + localize(e.unit) + " "
" " +
localize(e.unit) +
" "
: "" : ""
}${e.value}\n\n`; }${e.value}\n\n`;
} }
@ -863,7 +926,7 @@ export default {
utils.shareText(shareContent, localize("sru")); utils.shareText(shareContent, localize("sru"));
}, },
// DataHandlers // Toggles
toggle(key: string, setDate: number) { toggle(key: string, setDate: number) {
console.log(setDate); console.log(setDate);
if (setDate) { if (setDate) {
@ -891,6 +954,39 @@ export default {
}); });
} }
}, },
toggleCheck(obj, index) {
this.checks[index] = !this.checks[index];
if (this.checks[index]) {
this.checked++;
obj.getChildAt(0).text = this.icon.check;
} else {
this.checked--;
obj.getChildAt(0).text = this.icon.uncheck;
}
},
clearChecks() {
this.checked = 0;
this.checks = [];
for (let i = 1; i < this.ingcon.getChildrenCount(); i++) {
this.ingcon.getChildAt(i).getChildAt(0).text = this.icon.uncheck;
}
},
toggleStep(object) {
let a = object;
if (a.className.includes("done")) {
a.className = "check";
this.stepsDid--;
} else {
a.className = "check done";
this.stepsDid++;
}
},
clearSteps() {
this.stepsDid = 0;
for (let i = 1; i < this.inscon.getChildrenCount(); i++) {
this.inscon.getChildAt(i).className = "check";
}
},
// Notes // Notes
createNote(note) { createNote(note) {
@ -930,6 +1026,12 @@ export default {
}, },
// PhotoViewer // PhotoViewer
imgVLoad({ object }) {
this.imgView = object;
this.imgView.visibility = "collapsed";
this.imgView.top = 24;
this.imgView.left = this.RTL ? 16 : Screen.mainScreen.widthDIPs - 112;
},
viewPhoto() { viewPhoto() {
this.hideBars(); this.hideBars();
this.photoOpen = 1; this.photoOpen = 1;
@ -1015,6 +1117,10 @@ export default {
}, },
// Print // Print
wvLoad({ object }) {
this.wv = object;
utils.updateLocale(); // required to set local RTL and language in webview
},
prepareHTML() { prepareHTML() {
let r = this.recipe; let r = this.recipe;
const head = `<head><meta charset=UTF-8><meta content="IE=edge"http-equiv=X-UA-Compatible><meta content="width=device-width,initial-scale=1"name=viewport><title>EnRecipes - Recipe for Print</title><style>a,body,div,html,img,ol,p,span,ul{border:0;font-size:100%;font:inherit;margin:0;padding:0;vertical-align:baseline}@font-face{font-family:Inter-Medium;src:url(../app/fonts/Inter-Medium.otf)}@font-face{font-family:Inter-Bold;src:url(../app/fonts/Inter-Bold.otf)}body{font-family:Inter-Medium,sans-serif;line-height:1.5;max-width:45rem;padding:1.5rem}body>p{padding:.5rem 0}.attr>div>p:last-child,h1,h2,h3{font-family:Inter-Bold,sans-serif}#header{display:grid;grid-column-gap:2rem;grid-template-columns:1fr auto;margin-bottom:2.5rem;width:100%}img{border-radius:1rem;height:8rem;object-fit:cover;width:8rem}h1{font-size:2.25rem;line-height:1.25;margin:0;padding-bottom:1rem}svg{width:2rem;height:2rem;padding:0 .5rem 0 0}h2{margin:2rem 0 1rem}.attr{display:grid;grid-column-gap:2rem;grid-template-columns:1fr 1fr;margin-top:1rem}.attr>div>p:first-child{font-size:.9rem;opacity:.5}ol,ul{padding:0 1.5rem}li{padding:.5rem}a{color:inherit}.sub{font-size:.9rem;margin-top:2rem;opacity:.5}</style></head>`; const head = `<head><meta charset=UTF-8><meta content="IE=edge"http-equiv=X-UA-Compatible><meta content="width=device-width,initial-scale=1"name=viewport><title>EnRecipes - Recipe for Print</title><style>a,body,div,html,img,ol,p,span,ul{border:0;font-size:100%;font:inherit;margin:0;padding:0;vertical-align:baseline}@font-face{font-family:Inter-Medium;src:url(../app/fonts/Inter-Medium.otf)}@font-face{font-family:Inter-Bold;src:url(../app/fonts/Inter-Bold.otf)}body{font-family:Inter-Medium,sans-serif;line-height:1.5;max-width:45rem;padding:1.5rem}body>p{padding:.5rem 0}.attr>div>p:last-child,h1,h2,h3{font-family:Inter-Bold,sans-serif}#header{display:grid;grid-column-gap:2rem;grid-template-columns:1fr auto;margin-bottom:2.5rem;width:100%}img{border-radius:1rem;height:8rem;object-fit:cover;width:8rem}h1{font-size:2.25rem;line-height:1.25;margin:0;padding-bottom:1rem}svg{width:2rem;height:2rem;padding:0 .5rem 0 0}h2{margin:2rem 0 1rem}.attr{display:grid;grid-column-gap:2rem;grid-template-columns:1fr 1fr;margin-top:1rem}.attr>div>p:first-child{font-size:.9rem;opacity:.5}ol,ul{padding:0 1.5rem}li{padding:.5rem}a{color:inherit}.sub{font-size:.9rem;margin-top:2rem;opacity:.5}</style></head>`;
@ -1097,13 +1203,13 @@ export default {
this.hasTime(r.prepTime) || this.hasTime(r.cookTime) this.hasTime(r.prepTime) || this.hasTime(r.cookTime)
? `<div class=attr>${ ? `<div class=attr>${
this.hasTime(r.prepTime) this.hasTime(r.prepTime)
? `<div><p>${localize("prepT")}<p>${this.formattedTime( ? `<div><p>${localize("prepT")}<p>${this.niceTime(
r.prepTime r.prepTime
)}</div>` )}</div>`
: "" : ""
} ${ } ${
this.hasTime(r.cookTime) this.hasTime(r.cookTime)
? `<div><p>${localize("cookT")}<p>${this.formattedTime( ? `<div><p>${localize("cookT")}<p>${this.niceTime(
r.cookTime r.cookTime
)}</div>` )}</div>`
: "" : ""
@ -1129,9 +1235,9 @@ export default {
r.notes.length r.notes.length
? `<h2>${this.getTitleCount("nos", "notes", 1)}</h2>` ? `<h2>${this.getTitleCount("nos", "notes", 1)}</h2>`
: "" : ""
} ${getNotes()}<div class=sub><p>${this.getDates().u}<p>${ } ${getNotes()}<div class=sub><p>${this.getDates.u}</p><p>${
this.getDates().c this.getDates.c
}</div> }</p></div>
</body> </body>
</html>`; </html>`;
}, },
@ -1144,7 +1250,7 @@ export default {
); );
}, },
// Helpers // FeedBack
touchRate({ object, action }, r) { touchRate({ object, action }, r) {
this.touchFade(object, action); this.touchFade(object, action);
if (action == "up") this.rate(r); if (action == "up") this.rate(r);
@ -1154,6 +1260,15 @@ export default {
if (action == "up") this.changeYield(); if (action == "up") this.changeYield();
}, },
touchIngredient({ object, action }, index) {
this.touchFade(object, action);
if (action == "up") this.toggleCheck(object, index);
},
touchInstruction({ object, action }) {
let hasDone = object.className.includes("done");
if (!hasDone) this.touchFade(object, action);
if (action == "up") this.toggleStep(object);
},
}, },
created() { created() {
this.recipe = this.recipes.filter((e) => e.id === this.currentRecipeID)[0]; this.recipe = this.recipes.filter((e) => e.id === this.currentRecipeID)[0];

View file

@ -1,5 +1,5 @@
<template> <template>
<Page @loaded="pgLoad" actionBarHidden="true"> <Page @loaded="pageL" actionBarHidden="true">
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *"> <RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
<OptionsList title="intf" :items="items" /> <OptionsList title="intf" :items="items" />
<GridLayout row="1" class="appbar rtl" rows="*" columns="auto, *"> <GridLayout row="1" class="appbar rtl" rows="*" columns="auto, *">
@ -32,7 +32,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(["icon", "langs", "theme", "layout", "RTL"]), ...mapState(["icon", "langs", "theme", "layout", "RTL", "mSystem"]),
items() { items() {
return [ return [
{}, {},
@ -50,7 +50,7 @@ export default {
rtl: 0, rtl: 0,
title: "Theme", title: "Theme",
subTitle: localize(ApplicationSettings.getString("theme", "sysDef")), subTitle: localize(ApplicationSettings.getString("theme", "sysDef")),
action: this.selectThemes, action: this.setTheme,
}, },
{ {
type: "list", type: "list",
@ -60,15 +60,24 @@ export default {
subTitle: localize(this.layout), subTitle: localize(this.layout),
action: this.setLayoutMode, action: this.setLayoutMode,
}, },
{
type: "list",
icon: "layout",
rtl: 0,
title: "mSystem",
subTitle: localize(this.mSystem),
action: this.setMSystem,
},
{}, {},
]; ];
}, },
}, },
methods: { methods: {
...mapActions(["setT", "setL", "setRTL"]), ...mapActions(["setT", "setL", "setRTL", "setMS"]),
pgLoad({ object }) { pageL({ object }) {
object.bindingContext = new Observable(); object.bindingContext = new Observable();
}, },
// LanguageSelection // LanguageSelection
setAppLang() { setAppLang() {
let languages = this.langs.map((e) => e.title); let languages = this.langs.map((e) => e.title);
@ -96,8 +105,9 @@ export default {
} }
}); });
}, },
// ThemeSelection // ThemeSelection
selectThemes() { setTheme() {
this.$showModal(Action, { this.$showModal(Action, {
props: { props: {
title: "Theme", title: "Theme",
@ -116,6 +126,7 @@ export default {
} }
}); });
}, },
// LayoutMode // LayoutMode
setLayoutMode() { setLayoutMode() {
this.$showModal(Action, { this.$showModal(Action, {
@ -128,6 +139,19 @@ export default {
if (mode && this.layout !== mode) this.setL(mode.toLowerCase()); if (mode && this.layout !== mode) this.setL(mode.toLowerCase());
}); });
}, },
// MeasuringSystem
setMSystem() {
this.$showModal(Action, {
props: {
title: "mSystem",
list: ["mtrc", "imprl"],
selected: this.mSystem,
},
}).then((sys) => {
if (sys && this.mSystem !== sys) this.setMS(sys);
});
},
}, },
created() { created() {
this.applang = ApplicationSettings.getString("applang", "sysDef"); this.applang = ApplicationSettings.getString("applang", "sysDef");

View file

@ -409,8 +409,14 @@ export default new Vuex.Store({
planDel: getString('planDel', 'nvr'), // PlanDeletionCriteria planDel: getString('planDel', 'nvr'), // PlanDeletionCriteria
edgeS: getNumber('edgeS', 1), // EdgeSwipe edgeS: getNumber('edgeS', 1), // EdgeSwipe
awakeV: getNumber('awakeV', 1), // AwakeViewer awakeV: getNumber('awakeV', 1), // AwakeViewer
mSystem: getString('mSystem', 'mtrc'), //MeasuringSystem
}, },
mutations: { mutations: {
//SetMeasuringSystem
setMS(state, s) {
state.mSystem = s
setNumber('mSystem', s)
},
// ToggleKeepAwakeOnRecipeViewer // ToggleKeepAwakeOnRecipeViewer
toggleAwakeV(state) { toggleAwakeV(state) {
state.awakeV = +!state.awakeV state.awakeV = +!state.awakeV
@ -422,12 +428,12 @@ export default new Vuex.Store({
setNumber('edgeS', state.edgeS) setNumber('edgeS', state.edgeS)
}, },
// SetPlanDeletionCriteria // SetPlanDeletionCriteria
setPlanDel(state, s: string) { setPlanDel(state, s) {
state.planDel = s state.planDel = s
setString('planDel', s) setString('planDel', s)
}, },
// SetPlannerViewMode // SetPlannerViewMode
setPlannerV(state, s: string) { setPlannerV(state, s) {
state.plannerV = s state.plannerV = s
setString('plannerV', s) setString('plannerV', s)
}, },
@ -436,7 +442,7 @@ export default new Vuex.Store({
state.RTL = getNumber('RTL', 0) state.RTL = getNumber('RTL', 0)
}, },
// SetForegroundService // SetForegroundService
setFgS(state, n: number) { setFgS(state, n) {
state.FGS = n state.FGS = n
}, },
// AddTimerPreset // AddTimerPreset
@ -451,7 +457,7 @@ export default new Vuex.Store({
) )
}, },
// DeleteTimerPreset // DeleteTimerPreset
deleteTP(state, n: number) { deleteTP(state, n) {
let id = state.timerPs[n] let id = state.timerPs[n]
state.timerPs.splice(n, 1) state.timerPs.splice(n, 1)
db.execute(`DELETE FROM timerPresets WHERE id = ${id}`) db.execute(`DELETE FROM timerPresets WHERE id = ${id}`)
@ -508,21 +514,21 @@ export default new Vuex.Store({
state.activeTs.splice(i, 1, o) state.activeTs.splice(i, 1, o)
}, },
// RemoveActiveTimer // RemoveActiveTimer
removeAT(state, n: number) { removeAT(state, n) {
state.activeTs.splice(n, 1) state.activeTs.splice(n, 1)
}, },
// SetTimerDelay // SetTimerDelay
setTD(state, n: number) { setTD(state, n) {
state.timerD = n state.timerD = n
setNumber('timerD', n) setNumber('timerD', n)
}, },
// SetTimerSound // SetTimerSound
setTS(state, s: string) { setTS(state, s) {
state.timerS = s state.timerS = s
setString('timerS', JSON.stringify(s)) setString('timerS', JSON.stringify(s))
}, },
// SetTimerVibrate // SetTimerVibrate
setTV(state, n: number) { setTV(state, n) {
state.timerV = n state.timerV = n
setNumber('timerV', n) setNumber('timerV', n)
}, },
@ -531,12 +537,12 @@ export default new Vuex.Store({
for (const key in state.impSum) state.impSum[key] = 0 for (const key in state.impSum) state.impSum[key] = 0
}, },
// SetFirstDayMonday // SetFirstDayMonday
setFD(state, n: number) { setFD(state, n) {
state.startMon = n state.startMon = n
setNumber('startMon', n) setNumber('startMon', n)
}, },
// SetTheme // SetTheme
setT(state, s: string) { setT(state, s) {
switch (s) { switch (s) {
case 'sysDef': case 'sysDef':
state.theme = state.theme =
@ -557,12 +563,12 @@ export default new Vuex.Store({
state.selCuisine = state.selCategory = state.selTag = null state.selCuisine = state.selCategory = state.selTag = null
}, },
// SetLayout // SetLayout
setL(state, s: string) { setL(state, s) {
state.layout = s state.layout = s
setString('layout', s) setString('layout', s)
}, },
// SetSortType // SetSortType
setST(state, s: string) { setST(state, s) {
state.sortT = s state.sortT = s
}, },
// InitialiseRecipes // InitialiseRecipes
@ -1213,17 +1219,20 @@ export default new Vuex.Store({
} }
}) })
}, },
setCuisine(state, s: string) { setCuisine(state, s) {
state.selCuisine = s state.selCuisine = s
}, },
setCategory(state, s: string) { setCategory(state, s) {
state.selCategory = s state.selCategory = s
}, },
setTag(state, s: string) { setTag(state, s) {
state.selTag = s state.selTag = s
}, },
}, },
actions: { actions: {
setMS({ commit }, s: string) {
commit('setMS', s)
},
toggleAwakeV({ commit }) { toggleAwakeV({ commit }) {
commit('toggleAwakeV') commit('toggleAwakeV')
}, },

View file

@ -328,7 +328,7 @@
"sect": "Section %s", "sect": "Section %s",
"addSectBtn": "ADD SECTION", "addSectBtn": "ADD SECTION",
"sectRm": "Section removed", "sectRm": "Section removed",
"mSystem": "Measuring system", "mSystem": "Measurement system",
"mtrc": "Metric", "mtrc": "Metric",
"imprl": "Imperial" "imprl": "Imperial"
} }