2020-10-14 19:32:32 +00:00
|
|
|
<template>
|
2021-07-03 16:27:14 +00:00
|
|
|
<Page @loaded="pageL" @unloaded="pageUL" actionBarHidden="true">
|
2021-06-15 11:04:42 +00:00
|
|
|
<GridLayout rows="*, auto, auto" columns="auto, *, auto">
|
|
|
|
<DockLayout stretchLastChild="true" rowSpan="3" colSpan="3">
|
|
|
|
<RGridLayout
|
|
|
|
:rtl="RTL"
|
2021-04-01 10:55:35 +00:00
|
|
|
dock="top"
|
|
|
|
rows="auto,auto"
|
|
|
|
columns="*, auto"
|
2021-04-12 18:09:48 +00:00
|
|
|
paddingBottom="24"
|
2021-04-01 10:55:35 +00:00
|
|
|
>
|
|
|
|
<StackLayout>
|
2021-06-18 12:52:03 +00:00
|
|
|
<RLabel
|
|
|
|
class="pTitle tw tb"
|
|
|
|
paddingBottom="8"
|
|
|
|
:text="recipe.title"
|
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
<StackLayout
|
|
|
|
:class="{ f: RTL }"
|
|
|
|
margin="0 12"
|
|
|
|
orientation="horizontal"
|
|
|
|
>
|
2021-04-01 10:55:35 +00:00
|
|
|
<Button
|
|
|
|
class="ico rate"
|
|
|
|
:class="{ rated: recipe.rating >= n }"
|
|
|
|
v-for="n in 5"
|
|
|
|
:key="n"
|
|
|
|
:text="recipe.rating < n ? icon.star : icon.starred"
|
2021-06-18 12:52:03 +00:00
|
|
|
@touch="touchRate($event, n)"
|
2021-04-01 10:55:35 +00:00
|
|
|
/>
|
|
|
|
</StackLayout>
|
|
|
|
</StackLayout>
|
|
|
|
<Image
|
|
|
|
col="1"
|
2021-05-22 08:56:31 +00:00
|
|
|
v-if="recipe.image"
|
|
|
|
:src="recipe.image"
|
2021-04-01 10:55:35 +00:00
|
|
|
stretch="aspectFit"
|
|
|
|
class="photo"
|
|
|
|
decodeWidth="96"
|
|
|
|
decodeHeight="96"
|
2021-04-12 18:09:48 +00:00
|
|
|
@tap="viewPhoto"
|
2021-02-28 15:10:26 +00:00
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RGridLayout>
|
2021-04-14 09:27:40 +00:00
|
|
|
<AbsoluteLayout dock="bottom">
|
|
|
|
<ScrollView
|
2021-04-21 10:31:49 +00:00
|
|
|
dock="bottom"
|
2021-04-14 09:27:40 +00:00
|
|
|
width="100%"
|
|
|
|
height="100%"
|
2021-07-03 16:27:14 +00:00
|
|
|
@loaded="scrollvL"
|
|
|
|
@scroll="scrollvS($event)"
|
2021-04-14 09:27:40 +00:00
|
|
|
>
|
|
|
|
<StackLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RGridLayout :rtl="RTL" rows="auto" columns="*, *">
|
2021-06-18 18:37:01 +00:00
|
|
|
<StackLayout class="attrT">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel class="sub" :text="'cui' | L" />
|
2021-06-18 18:37:01 +00:00
|
|
|
<RLabel class="v" :text="recipe.cuisine | L" />
|
2021-04-14 09:27:40 +00:00
|
|
|
</StackLayout>
|
2021-06-18 18:37:01 +00:00
|
|
|
<StackLayout class="attrT" col="1">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel class="sub" :text="'cat' | L" />
|
2021-06-18 18:37:01 +00:00
|
|
|
<RLabel class="v" :text="recipe.category | L" />
|
2021-04-14 09:27:40 +00:00
|
|
|
</StackLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RGridLayout>
|
|
|
|
<StackLayout
|
|
|
|
:hidden="!recipe.tags.length"
|
2021-06-18 18:37:01 +00:00
|
|
|
class="attrT hal"
|
2021-06-15 11:04:42 +00:00
|
|
|
:class="{ r: RTL }"
|
|
|
|
>
|
|
|
|
<RLabel class="sub" :text="'ts' | L" />
|
2021-06-29 15:01:03 +00:00
|
|
|
<RLabel class="v" :text="getTags" />
|
2021-02-28 15:10:26 +00:00
|
|
|
</StackLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RGridLayout :rtl="RTL" rows="auto" columns="*, *">
|
2021-06-18 18:37:01 +00:00
|
|
|
<StackLayout class="attrT" :hidden="!hasTime(recipe.prepTime)">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel class="sub" :text="'prepT' | L" />
|
2021-07-03 16:27:14 +00:00
|
|
|
<RLabel class="v" :text="niceTime(recipe.prepTime)" />
|
2021-04-14 09:27:40 +00:00
|
|
|
</StackLayout>
|
|
|
|
<StackLayout
|
|
|
|
:col="hasTime(recipe.prepTime) ? 1 : 0"
|
2021-06-18 18:37:01 +00:00
|
|
|
class="attrT"
|
2021-04-14 09:27:40 +00:00
|
|
|
:hidden="!hasTime(recipe.cookTime)"
|
|
|
|
>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel class="title sub" :text="'cookT' | L" />
|
2021-07-03 16:27:14 +00:00
|
|
|
<RLabel class="v" :text="niceTime(recipe.cookTime)" />
|
2021-04-14 09:27:40 +00:00
|
|
|
</StackLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RGridLayout>
|
|
|
|
<RGridLayout :rtl="RTL" rows="auto" columns="*, *">
|
2021-06-18 18:37:01 +00:00
|
|
|
<StackLayout class="attrT">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel class="title sub" :text="'yld' | L" />
|
|
|
|
<RLabel
|
2021-04-14 09:27:40 +00:00
|
|
|
@touch="touchYield"
|
2021-06-18 18:37:01 +00:00
|
|
|
class="v accent"
|
2021-04-14 09:27:40 +00:00
|
|
|
:text="`${tempYieldQuantity} ${$options.filters.L(
|
2021-05-22 08:56:31 +00:00
|
|
|
recipe.yieldUnit
|
2021-04-14 09:27:40 +00:00
|
|
|
)}`"
|
|
|
|
/>
|
|
|
|
</StackLayout>
|
2021-06-18 18:37:01 +00:00
|
|
|
<StackLayout class="attrT" col="1">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel class="title sub" :text="'Difficulty level' | L" />
|
2021-06-18 18:37:01 +00:00
|
|
|
<RLabel class="v" :text="recipe.difficulty | L" />
|
2021-04-14 09:27:40 +00:00
|
|
|
</StackLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RGridLayout>
|
2021-07-03 16:27:14 +00:00
|
|
|
<StackLayout @loaded="ingCL">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel
|
2021-06-18 12:52:03 +00:00
|
|
|
class="section t2 tb tw"
|
2021-04-14 09:27:40 +00:00
|
|
|
:hidden="!recipe.ingredients.length"
|
|
|
|
:text="getTitleCount('ings', 'ingredients')"
|
2021-04-12 18:09:48 +00:00
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RStackLayout
|
|
|
|
:rtl="RTL"
|
2021-04-14 09:27:40 +00:00
|
|
|
orientation="horizontal"
|
2021-06-28 11:38:21 +00:00
|
|
|
v-for="(item, i) in recipe.ingredients"
|
|
|
|
:key="item.key"
|
2021-06-18 12:52:03 +00:00
|
|
|
class="check"
|
2021-06-28 11:38:21 +00:00
|
|
|
@touch="item.type && touchIngredient($event, i)"
|
2021-04-14 09:27:40 +00:00
|
|
|
>
|
2021-06-28 11:38:21 +00:00
|
|
|
<Button
|
|
|
|
:hidden="!item.type"
|
|
|
|
class="ico si"
|
|
|
|
:text="icon.uncheck"
|
|
|
|
/>
|
|
|
|
<RLabel
|
|
|
|
class="v tw"
|
|
|
|
:class="{ 'tb t t3': !item.type }"
|
2021-06-29 15:01:03 +00:00
|
|
|
:text="getIng(item)"
|
2021-06-28 11:38:21 +00:00
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RStackLayout>
|
2021-04-12 18:09:48 +00:00
|
|
|
</StackLayout>
|
2021-07-03 16:27:14 +00:00
|
|
|
<StackLayout @loaded="insCL">
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel
|
2021-04-14 09:27:40 +00:00
|
|
|
:hidden="!recipe.instructions.length"
|
2021-06-18 12:52:03 +00:00
|
|
|
class="section t2 tb tw"
|
2021-04-14 09:27:40 +00:00
|
|
|
:text="getTitleCount('inss', 'instructions')"
|
2021-04-12 18:09:48 +00:00
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RStackLayout
|
|
|
|
:rtl="RTL"
|
2021-04-14 09:27:40 +00:00
|
|
|
orientation="horizontal"
|
2021-06-28 11:38:21 +00:00
|
|
|
@touch="item.type && touchInstruction($event)"
|
|
|
|
v-for="(item, i) in recipe.instructions"
|
|
|
|
:key="item.key"
|
2021-06-18 12:52:03 +00:00
|
|
|
class="check"
|
2021-04-14 09:27:40 +00:00
|
|
|
>
|
2021-06-28 11:38:21 +00:00
|
|
|
<Button
|
|
|
|
:hidden="!item.type"
|
|
|
|
class="tb t3 ico si"
|
2021-07-03 16:27:14 +00:00
|
|
|
:text="localeN(getInsPos[i])"
|
2021-06-28 11:38:21 +00:00
|
|
|
/>
|
|
|
|
<RLabel
|
|
|
|
class="v tw"
|
|
|
|
:class="{ 'tb t t3': !item.type }"
|
|
|
|
:text="item.value"
|
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RStackLayout>
|
2021-04-14 09:27:40 +00:00
|
|
|
</StackLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel
|
2021-07-03 16:27:14 +00:00
|
|
|
@loaded="cmbCL"
|
2021-04-14 09:27:40 +00:00
|
|
|
:hidden="!recipe.combinations.length"
|
2021-06-18 12:52:03 +00:00
|
|
|
class="section t2 tb tw"
|
2021-04-14 09:27:40 +00:00
|
|
|
:text="getTitleCount('cmbs', 'combinations')"
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
v-for="(combination, index) in recipe.combinations"
|
|
|
|
:key="index + 'comb'"
|
2021-06-18 18:37:01 +00:00
|
|
|
class="note tw hal lh4 fb"
|
2021-06-18 12:52:03 +00:00
|
|
|
:class="{ r: RTL }"
|
2021-04-14 09:27:40 +00:00
|
|
|
:text="getCombinationTitle(combination)"
|
|
|
|
@tap="viewCombination(combination)"
|
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel
|
2021-07-03 16:27:14 +00:00
|
|
|
@loaded="notesCTL"
|
2021-04-14 09:27:40 +00:00
|
|
|
:hidden="!recipe.notes.length"
|
2021-06-18 12:52:03 +00:00
|
|
|
class="section t2 tb tw"
|
2021-04-14 09:27:40 +00:00
|
|
|
:text="getTitleCount('nos', 'notes')"
|
|
|
|
/>
|
2021-07-03 16:27:14 +00:00
|
|
|
<StackLayout @loaded="notesCL"> </StackLayout>
|
2021-06-18 12:52:03 +00:00
|
|
|
<Label
|
|
|
|
padding="32 16 16"
|
|
|
|
class="lh4 t5 sub tw"
|
2021-07-03 16:27:14 +00:00
|
|
|
:text="getDates.uc"
|
2021-06-18 12:52:03 +00:00
|
|
|
/>
|
2021-04-12 18:09:48 +00:00
|
|
|
</StackLayout>
|
2021-04-14 09:27:40 +00:00
|
|
|
</ScrollView>
|
2021-06-15 11:04:42 +00:00
|
|
|
<RLabel
|
2021-06-18 12:52:03 +00:00
|
|
|
class="t2 tb tw sticky"
|
2021-04-21 10:31:49 +00:00
|
|
|
:hidden="!stickyTitle"
|
|
|
|
:text="stickyTitle"
|
2021-04-14 09:27:40 +00:00
|
|
|
/>
|
|
|
|
</AbsoluteLayout>
|
2021-04-01 10:55:35 +00:00
|
|
|
</DockLayout>
|
|
|
|
<GridLayout
|
|
|
|
row="1"
|
2021-07-03 16:27:14 +00:00
|
|
|
@loaded="sidebarL"
|
2021-06-20 17:54:47 +00:00
|
|
|
class="appbar toolbar"
|
2021-06-15 11:04:42 +00:00
|
|
|
:col="RTL ? 0 : 2"
|
2021-06-20 17:54:47 +00:00
|
|
|
rows="auto, auto, auto, auto"
|
|
|
|
:visibility="showTools ? 'visible' : 'hidden'"
|
2021-04-01 10:55:35 +00:00
|
|
|
>
|
2021-06-15 11:04:42 +00:00
|
|
|
<Button class="ico" :text="icon.timer" @tap="openCookingTimer" />
|
2021-04-12 18:09:48 +00:00
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
row="1"
|
|
|
|
:hidden="busyDup"
|
2021-04-12 18:09:48 +00:00
|
|
|
class="ico"
|
2021-06-15 11:04:42 +00:00
|
|
|
:class="{ f: RTL }"
|
|
|
|
:text="icon.dup"
|
|
|
|
@tap="duplicateRecipe"
|
2021-04-12 18:09:48 +00:00
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
<ActivityIndicator row="1" :hidden="!busyDup" :busy="busyDup" />
|
2021-04-01 10:55:35 +00:00
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
:hidden="!hasPrinterSupport"
|
|
|
|
row="2"
|
2021-05-22 08:56:31 +00:00
|
|
|
class="ico"
|
2021-06-15 11:04:42 +00:00
|
|
|
:text="icon.print"
|
|
|
|
@tap="printView"
|
2021-05-22 08:56:31 +00:00
|
|
|
/>
|
2021-06-20 17:54:47 +00:00
|
|
|
<Button row="3" class="ico" :text="icon.share" @tap="shareHandler" />
|
2021-06-15 11:04:42 +00:00
|
|
|
</GridLayout>
|
|
|
|
<RGridLayout
|
|
|
|
:rtl="RTL"
|
|
|
|
row="2"
|
|
|
|
colSpan="3"
|
2021-07-03 16:27:14 +00:00
|
|
|
@loaded="appbarL"
|
2021-06-15 11:04:42 +00:00
|
|
|
class="appbar"
|
|
|
|
:hidden="toast"
|
|
|
|
columns="auto, *, auto, auto, auto, auto"
|
|
|
|
@touch="() => null"
|
|
|
|
>
|
2021-06-28 11:38:21 +00:00
|
|
|
<Button class="ico rtl" :text="icon.back" @tap="$navigateBack()" />
|
2021-05-22 08:56:31 +00:00
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
col="2"
|
2021-04-01 10:55:35 +00:00
|
|
|
v-if="!filterTrylater"
|
|
|
|
class="ico"
|
|
|
|
:text="recipe.tried ? icon.try : icon.tried"
|
2021-04-12 18:09:48 +00:00
|
|
|
@tap="toggle('tried')"
|
2021-04-01 10:55:35 +00:00
|
|
|
/>
|
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
col="2"
|
2021-04-01 10:55:35 +00:00
|
|
|
v-else
|
|
|
|
class="ico"
|
2021-06-29 15:01:03 +00:00
|
|
|
:text="recipeTried ? icon.try : icon.done"
|
2021-06-15 11:04:42 +00:00
|
|
|
@tap="toggle('tried', 1)"
|
2021-04-01 10:55:35 +00:00
|
|
|
/>
|
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
col="3"
|
2021-04-01 10:55:35 +00:00
|
|
|
class="ico"
|
2021-05-22 08:56:31 +00:00
|
|
|
:text="recipe.favorite ? icon.faved : icon.fav"
|
|
|
|
@tap="toggle('favorite')"
|
2021-04-01 10:55:35 +00:00
|
|
|
/>
|
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
col="4"
|
|
|
|
:hidden="busyEdit"
|
2021-04-01 10:55:35 +00:00
|
|
|
class="ico"
|
|
|
|
:text="icon.edit"
|
|
|
|
@tap="editRecipe"
|
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
<ActivityIndicator col="4" :hidden="!busyEdit" :busy="busyEdit" />
|
2021-04-01 10:55:35 +00:00
|
|
|
<Button
|
2021-06-15 11:04:42 +00:00
|
|
|
col="5"
|
2021-06-28 11:38:21 +00:00
|
|
|
class="ico"
|
2021-06-20 17:54:47 +00:00
|
|
|
:text="showTools ? icon.less : icon.more"
|
|
|
|
@tap="toggleTools"
|
2021-04-01 10:55:35 +00:00
|
|
|
/>
|
2021-06-15 11:04:42 +00:00
|
|
|
</RGridLayout>
|
|
|
|
<Toast
|
|
|
|
row="2"
|
|
|
|
colSpan="3"
|
2021-07-03 16:27:14 +00:00
|
|
|
:onload="toastL"
|
2021-06-15 11:04:42 +00:00
|
|
|
:toast="toast"
|
|
|
|
:action="hideBar"
|
|
|
|
/>
|
|
|
|
<AbsoluteLayout rowSpan="3" colSpan="3">
|
2021-04-21 10:31:49 +00:00
|
|
|
<Image
|
2021-06-15 11:04:42 +00:00
|
|
|
@tap="closePhoto"
|
2021-04-21 10:31:49 +00:00
|
|
|
backgroundColor="black"
|
|
|
|
stretch="aspectFit"
|
2021-07-03 16:27:14 +00:00
|
|
|
@loaded="imgVLoad"
|
2021-05-22 08:56:31 +00:00
|
|
|
:src="recipe.image"
|
2021-06-18 18:37:01 +00:00
|
|
|
class="imgV"
|
2021-04-21 10:31:49 +00:00
|
|
|
/>
|
2021-04-12 18:09:48 +00:00
|
|
|
</AbsoluteLayout>
|
2021-06-15 11:04:42 +00:00
|
|
|
<WebView @loaded="wvLoad" hidden />
|
2021-06-18 12:52:03 +00:00
|
|
|
<Label
|
|
|
|
rowSpan="3"
|
|
|
|
colSpan="3"
|
|
|
|
class="edge hal"
|
|
|
|
:class="{ 'f r': RTL }"
|
|
|
|
@swipe="swipeBack"
|
|
|
|
/>
|
|
|
|
<Label
|
|
|
|
rowSpan="3"
|
|
|
|
colSpan="3"
|
|
|
|
class="edge har rtl f"
|
|
|
|
@swipe="swipeBack"
|
|
|
|
/>
|
2021-04-01 10:55:35 +00:00
|
|
|
</GridLayout>
|
2021-02-28 15:10:26 +00:00
|
|
|
</Page>
|
2020-10-14 19:32:32 +00:00
|
|
|
</template>
|
|
|
|
|
2021-04-21 10:31:49 +00:00
|
|
|
<script lang="ts">
|
2020-11-02 11:36:53 +00:00
|
|
|
import {
|
2020-12-02 10:37:45 +00:00
|
|
|
Application,
|
2021-04-12 18:09:48 +00:00
|
|
|
AndroidApplication,
|
2020-11-10 18:28:48 +00:00
|
|
|
ImageSource,
|
|
|
|
Utils,
|
2020-12-02 09:46:25 +00:00
|
|
|
Span,
|
|
|
|
FormattedString,
|
2020-12-29 10:35:19 +00:00
|
|
|
Observable,
|
2021-04-01 10:55:35 +00:00
|
|
|
Screen,
|
2021-04-12 18:09:48 +00:00
|
|
|
CoreTypes,
|
2021-06-15 11:04:42 +00:00
|
|
|
WebView,
|
2021-02-28 15:10:26 +00:00
|
|
|
} from "@nativescript/core";
|
2021-06-15 11:04:42 +00:00
|
|
|
import { RLabel } from "~/rtl-ui";
|
2021-02-28 15:10:26 +00:00
|
|
|
import { localize } from "@nativescript/localize";
|
|
|
|
import { mapActions, mapState } from "vuex";
|
2021-05-22 08:56:31 +00:00
|
|
|
import CookingTimer from "./CookingTimer.vue";
|
2021-02-28 15:10:26 +00:00
|
|
|
import EditRecipe from "./EditRecipe.vue";
|
2021-05-25 14:32:53 +00:00
|
|
|
import Action from "./modals/Action.vue";
|
|
|
|
import Toast from "./sub/Toast.vue";
|
|
|
|
import Prompt from "./modals/Prompt.vue";
|
2021-04-12 18:09:48 +00:00
|
|
|
import * as utils from "~/shared/utils";
|
2021-06-15 11:04:42 +00:00
|
|
|
const Intl = require("nativescript-intl");
|
|
|
|
let barTimer;
|
|
|
|
declare const android: any;
|
2020-10-14 19:32:32 +00:00
|
|
|
export default {
|
2021-05-25 14:32:53 +00:00
|
|
|
components: { Toast },
|
2021-06-15 11:04:42 +00:00
|
|
|
props: ["filterTrylater", "recipeID", "yieldQuantity"],
|
2020-10-14 19:32:32 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-06-15 11:04:42 +00:00
|
|
|
busyEdit: 0,
|
|
|
|
busyDup: 0,
|
2020-11-02 11:36:53 +00:00
|
|
|
yieldMultiplier: 1,
|
2020-10-24 18:02:35 +00:00
|
|
|
recipe: null,
|
2020-11-15 10:51:10 +00:00
|
|
|
currentRecipeID: this.recipeID,
|
2021-04-01 10:55:35 +00:00
|
|
|
scrollview: null,
|
|
|
|
appbar: null,
|
2021-06-15 11:04:42 +00:00
|
|
|
sidebar: null,
|
|
|
|
toastbar: null,
|
2021-04-01 10:55:35 +00:00
|
|
|
ingcon: null,
|
|
|
|
inscon: null,
|
2021-04-14 09:27:40 +00:00
|
|
|
cmbcon: null,
|
2021-04-01 10:55:35 +00:00
|
|
|
notescon: null,
|
2021-04-14 09:27:40 +00:00
|
|
|
notesT: null,
|
2021-04-21 10:31:49 +00:00
|
|
|
imgView: null,
|
2021-01-13 05:02:48 +00:00
|
|
|
checks: [],
|
2021-04-12 18:09:48 +00:00
|
|
|
checked: 0,
|
|
|
|
stepsDid: 0,
|
2021-04-01 10:55:35 +00:00
|
|
|
toast: null,
|
2021-06-15 11:04:42 +00:00
|
|
|
photoOpen: 0,
|
|
|
|
showTitleArr: [0, 0, 0, 0],
|
|
|
|
view: null,
|
|
|
|
wv: null,
|
2021-06-20 17:54:47 +00:00
|
|
|
showTools: 0,
|
2021-06-29 15:01:03 +00:00
|
|
|
snackMsg: null,
|
|
|
|
recipeTried: 0,
|
2021-02-28 15:10:26 +00:00
|
|
|
};
|
2020-10-14 19:32:32 +00:00
|
|
|
},
|
|
|
|
computed: {
|
2021-07-03 16:27:14 +00:00
|
|
|
...mapState(["icon", "recipes", "RTL", "awakeV", "mSystem"]),
|
2021-04-12 18:09:48 +00:00
|
|
|
tempYieldQuantity() {
|
2021-02-28 15:10:26 +00:00
|
|
|
return Math.abs(this.yieldMultiplier) > 0
|
|
|
|
? Math.abs(parseFloat(this.yieldMultiplier))
|
|
|
|
: 1;
|
2020-10-14 19:32:32 +00:00
|
|
|
},
|
2021-04-21 10:31:49 +00:00
|
|
|
stickyTitle() {
|
|
|
|
let val = null;
|
|
|
|
switch (this.showTitleArr.lastIndexOf(true)) {
|
|
|
|
case 0:
|
|
|
|
val = this.getTitleCount("ings", "ingredients");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
val = this.getTitleCount("inss", "instructions");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
val = this.getTitleCount("cmbs", "combinations");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
val = this.getTitleCount("nos", "notes");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
hasPrinterSupport() {
|
|
|
|
return utils.Printer.isSupported();
|
|
|
|
},
|
2021-06-29 15:01:03 +00:00
|
|
|
getTags() {
|
|
|
|
return this.recipe.tags.join(" · ");
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
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;
|
|
|
|
}, []);
|
|
|
|
},
|
2020-10-14 19:32:32 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2021-06-18 18:37:01 +00:00
|
|
|
...mapActions(["toggleState", "setR"]),
|
2021-07-03 16:27:14 +00:00
|
|
|
pageL({ object }) {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.busyDup = this.busyEdit = this.photoOpen = 0;
|
2021-05-25 14:32:53 +00:00
|
|
|
object.bindingContext = new Observable();
|
2021-05-22 08:56:31 +00:00
|
|
|
if (this.yieldMultiplier == this.recipe.yieldQuantity)
|
|
|
|
this.yieldMultiplier = this.recipe.yieldQuantity;
|
2021-06-18 18:37:01 +00:00
|
|
|
if (this.awakeV) utils.keepScreenOn(1);
|
2021-02-28 15:10:26 +00:00
|
|
|
this.syncCombinations();
|
2021-06-15 11:04:42 +00:00
|
|
|
this.view = object.page.getViewById("printview");
|
2020-10-29 20:12:53 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
pageUL() {
|
2021-06-15 11:04:42 +00:00
|
|
|
utils.keepScreenOn(0);
|
2021-06-29 15:01:03 +00:00
|
|
|
if (this.recipeTried) this.markTried();
|
2021-06-15 11:04:42 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
sidebarL({ object }) {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.sidebar = object;
|
2020-11-10 18:28:48 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
appbarL({ object }) {
|
2021-04-01 10:55:35 +00:00
|
|
|
this.appbar = object;
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
toastL({ object }) {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.toastbar = object;
|
2021-06-29 15:01:03 +00:00
|
|
|
this.recipe.lastTried && this.showLastTried();
|
2021-06-15 11:04:42 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
ingCL({ object }) {
|
2021-04-01 10:55:35 +00:00
|
|
|
this.ingcon = object;
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
insCL({ object }) {
|
2021-04-01 10:55:35 +00:00
|
|
|
this.inscon = object;
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
cmbCL({ object }) {
|
2021-04-14 09:27:40 +00:00
|
|
|
this.cmbcon = object;
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
notesCL({ object }) {
|
2021-04-01 10:55:35 +00:00
|
|
|
this.notescon = object;
|
|
|
|
this.createNotes();
|
2021-01-13 05:02:48 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
notesCTL({ object }) {
|
|
|
|
this.notesT = object;
|
|
|
|
},
|
|
|
|
|
|
|
|
// ScrollView
|
|
|
|
scrollvL(args) {
|
2021-04-01 10:55:35 +00:00
|
|
|
this.scrollview = args.object;
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
scrollvS({ object, scrollY }) {
|
|
|
|
let swipeUp: boolean;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2021-04-21 10:31:49 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
fixTitle(object, swipeUp: boolean) {
|
2021-04-21 10:31:49 +00:00
|
|
|
let ingL = this.recipe.ingredients.length;
|
|
|
|
let insL = this.recipe.instructions.length;
|
|
|
|
let cmbL = this.recipe.combinations.length;
|
|
|
|
let notL = this.recipe.notes.length;
|
|
|
|
const isTop = (label): boolean => {
|
|
|
|
let pos = label.getLocationRelativeTo(object).y;
|
|
|
|
return label === this.cmbcon || label === this.notesT
|
|
|
|
? pos < 0
|
|
|
|
: pos + 32 < 0;
|
|
|
|
};
|
|
|
|
const setVisibleTitle = (n: number): void => {
|
|
|
|
let arr = [ingL, insL, cmbL, notL];
|
|
|
|
this.showTitleArr = Array.from(
|
|
|
|
{ length: 4 },
|
|
|
|
(v, i) => (v = arr[i] ? i < n : false)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
if (swipeUp) {
|
|
|
|
if (ingL && !this.showTitleArr[0] && isTop(this.ingcon))
|
|
|
|
setVisibleTitle(1);
|
|
|
|
else if (insL && !this.showTitleArr[1] && isTop(this.inscon))
|
|
|
|
setVisibleTitle(2);
|
|
|
|
else if (cmbL && !this.showTitleArr[2] && isTop(this.cmbcon))
|
|
|
|
setVisibleTitle(3);
|
|
|
|
else if (notL && !this.showTitleArr[3] && isTop(this.notesT))
|
|
|
|
setVisibleTitle(4);
|
|
|
|
} else {
|
|
|
|
if (notL && this.showTitleArr[3] && !isTop(this.notesT))
|
|
|
|
setVisibleTitle(3);
|
|
|
|
else if (cmbL && this.showTitleArr[2] && !isTop(this.cmbcon))
|
|
|
|
setVisibleTitle(2);
|
|
|
|
else if (insL && this.showTitleArr[1] && !isTop(this.inscon))
|
|
|
|
setVisibleTitle(1);
|
|
|
|
else if (ingL && this.showTitleArr[0] && !isTop(this.ingcon))
|
|
|
|
setVisibleTitle(0);
|
|
|
|
}
|
2021-04-14 09:27:40 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
|
|
|
|
// AppBars
|
2021-06-15 11:04:42 +00:00
|
|
|
showBars() {
|
2021-06-18 12:52:03 +00:00
|
|
|
this.animateBar(this.appbar, 1);
|
2021-06-15 11:04:42 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
hideBar() {
|
|
|
|
clearInterval(barTimer);
|
|
|
|
this.animateBar(this.toastbar, 0).then(() => {
|
|
|
|
this.toast = null;
|
|
|
|
this.photoOpen
|
|
|
|
? (this.appbar.opacity = 1)
|
|
|
|
: this.animateBar(this.appbar, 1);
|
|
|
|
});
|
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
hideBars() {
|
2021-06-20 17:54:47 +00:00
|
|
|
this.showTools && this.toggleTools();
|
2021-06-18 12:52:03 +00:00
|
|
|
this.animateBar(this.appbar, 0);
|
2021-06-15 11:04:42 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
showLastTried() {
|
|
|
|
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);
|
|
|
|
});
|
2021-06-28 11:38:21 +00:00
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
|
|
|
|
// Helpers
|
2021-06-28 11:38:21 +00:00
|
|
|
getTitleCount(title, type, unsel) {
|
|
|
|
let c;
|
2021-06-15 11:04:42 +00:00
|
|
|
let s = null;
|
2021-04-12 18:09:48 +00:00
|
|
|
switch (title) {
|
|
|
|
case "ings":
|
2021-06-15 11:04:42 +00:00
|
|
|
s = this.checked;
|
2021-06-28 11:38:21 +00:00
|
|
|
c = this.recipe[type].filter((e) => e.type).length;
|
2021-04-12 18:09:48 +00:00
|
|
|
break;
|
|
|
|
case "inss":
|
2021-06-15 11:04:42 +00:00
|
|
|
s = this.stepsDid;
|
2021-06-28 11:38:21 +00:00
|
|
|
c = this.recipe[type].filter((e) => e.type).length;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
c = this.recipe[type].length;
|
2021-04-12 18:09:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-06-18 18:37:01 +00:00
|
|
|
c = this.localeN(c);
|
|
|
|
s = s && this.localeN(s);
|
2021-06-28 11:38:21 +00:00
|
|
|
let text = s && !unsel ? ` (${s}/${c})` : ` (${c})`;
|
2021-04-12 18:09:48 +00:00
|
|
|
return localize(title) + text;
|
|
|
|
},
|
2021-06-29 15:01:03 +00:00
|
|
|
getIng(o) {
|
2021-07-03 16:27:14 +00:00
|
|
|
let q = o.quantity;
|
|
|
|
return `${q ? this.scaleUnit(q, o.unit) : ""}${o.value}`;
|
|
|
|
},
|
|
|
|
roundQ(q: number) {
|
|
|
|
return Math.abs(
|
|
|
|
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)} `;
|
2021-06-15 11:04:42 +00:00
|
|
|
},
|
2021-04-01 10:55:35 +00:00
|
|
|
changeYield() {
|
2021-05-25 14:32:53 +00:00
|
|
|
this.$showModal(Prompt, {
|
2021-04-01 10:55:35 +00:00
|
|
|
props: {
|
2021-05-22 08:56:31 +00:00
|
|
|
title: `${localize("req", localize(this.recipe.yieldUnit))}`,
|
2021-04-01 10:55:35 +00:00
|
|
|
placeholder: Math.abs(parseFloat(this.yieldMultiplier)),
|
|
|
|
action: "SET",
|
|
|
|
},
|
|
|
|
}).then((item) => {
|
|
|
|
if (item) this.yieldMultiplier = item;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
hasTime(time) {
|
|
|
|
return time != "00:00";
|
|
|
|
},
|
2021-07-03 16:27:14 +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}`;
|
|
|
|
},
|
2021-05-22 08:56:31 +00:00
|
|
|
niceDate(lastTried) {
|
2021-02-28 15:10:26 +00:00
|
|
|
let now = new Date().getTime();
|
|
|
|
let midnight = new Date().setHours(0, 0, 0, 0);
|
|
|
|
let diff = (now - lastTried) / 1000;
|
|
|
|
let dayDiff = Math.ceil(diff / 86400);
|
|
|
|
if (isNaN(dayDiff) || dayDiff < 0) return "";
|
2020-12-07 14:45:00 +00:00
|
|
|
|
2021-04-21 10:31:49 +00:00
|
|
|
function duration(value, number?) {
|
2021-04-17 16:24:47 +00:00
|
|
|
return number ? localize(value, number) : localize(value);
|
2020-12-07 14:45:00 +00:00
|
|
|
}
|
2020-10-29 20:12:53 +00:00
|
|
|
return (
|
2021-02-28 15:10:26 +00:00
|
|
|
(diff < 86400 && lastTried > midnight && duration("today")) ||
|
|
|
|
(dayDiff == 1 && "yesterday") ||
|
2021-04-17 16:24:47 +00:00
|
|
|
(dayDiff < 7 && duration("dAgo", dayDiff)) ||
|
|
|
|
(dayDiff < 31 && duration("wAgo", Math.round(dayDiff / 7))) ||
|
|
|
|
(dayDiff < 366 && duration("mAgo", Math.round(dayDiff / 30))) ||
|
2021-02-28 15:10:26 +00:00
|
|
|
(dayDiff > 365 && duration("ltAgo"))
|
|
|
|
);
|
2020-10-29 20:12:53 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
intlDate(date) {
|
2021-06-15 11:04:42 +00:00
|
|
|
return new Intl.DateTimeFormat(null, {
|
2021-02-28 15:10:26 +00:00
|
|
|
year: "numeric",
|
|
|
|
month: "long",
|
|
|
|
day: "numeric",
|
|
|
|
hour: "numeric",
|
|
|
|
minute: "numeric",
|
2021-06-15 11:04:42 +00:00
|
|
|
}).format(new Date(date));
|
2021-02-28 15:10:26 +00:00
|
|
|
},
|
2021-01-23 17:20:15 +00:00
|
|
|
|
2021-06-15 11:04:42 +00:00
|
|
|
// NavigationHandlers
|
2021-06-29 15:01:03 +00:00
|
|
|
hijackBackEvent() {
|
|
|
|
Application.android.on(
|
|
|
|
AndroidApplication.activityBackPressedEvent,
|
|
|
|
this.backEvent
|
|
|
|
);
|
|
|
|
},
|
|
|
|
releaseBackEvent() {
|
|
|
|
Application.android.off(
|
|
|
|
AndroidApplication.activityBackPressedEvent,
|
|
|
|
this.backEvent
|
|
|
|
);
|
|
|
|
},
|
|
|
|
backEvent(args) {
|
|
|
|
args.cancel = true;
|
|
|
|
this.closePhoto();
|
|
|
|
},
|
2020-10-14 19:32:32 +00:00
|
|
|
editRecipe() {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.busyEdit = 1;
|
2021-02-28 15:10:26 +00:00
|
|
|
this.$navigateTo(EditRecipe, {
|
2020-10-21 17:54:45 +00:00
|
|
|
props: {
|
2020-11-28 19:21:57 +00:00
|
|
|
filterTrylater: this.filterTrylater,
|
2020-11-15 10:51:10 +00:00
|
|
|
recipeID: this.currentRecipeID,
|
2020-10-21 17:54:45 +00:00
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
animated: false,
|
2021-02-28 15:10:26 +00:00
|
|
|
});
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
},
|
2021-02-28 15:10:26 +00:00
|
|
|
viewCombination(combination) {
|
2021-06-28 11:38:21 +00:00
|
|
|
this.hideBar();
|
2021-04-01 10:55:35 +00:00
|
|
|
this.scrollview.scrollToVerticalOffset(0, true);
|
2021-02-28 15:10:26 +00:00
|
|
|
this.recipe = this.recipes.filter((e) => e.id === combination)[0];
|
2021-06-15 11:04:42 +00:00
|
|
|
this.showTitleArr = new Array(4).fill(0);
|
2021-04-01 10:55:35 +00:00
|
|
|
this.clearChecks();
|
2021-04-12 18:09:48 +00:00
|
|
|
this.clearSteps();
|
2021-06-15 11:04:42 +00:00
|
|
|
this.recipe.ingredients.forEach(() => this.checks.push(0));
|
2021-02-28 15:10:26 +00:00
|
|
|
this.currentRecipeID = combination;
|
|
|
|
this.syncCombinations();
|
2021-04-01 10:55:35 +00:00
|
|
|
this.createNotes();
|
2021-05-22 08:56:31 +00:00
|
|
|
this.yieldMultiplier = this.recipe.yieldQuantity;
|
2021-06-29 15:01:03 +00:00
|
|
|
this.recipe.lastTried && this.showLastTried();
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
2021-01-23 17:20:15 +00:00
|
|
|
|
2021-06-20 17:54:47 +00:00
|
|
|
// Tools
|
|
|
|
toggleTools() {
|
|
|
|
if (this.showTools) {
|
|
|
|
this.sidebar
|
|
|
|
.animate({
|
|
|
|
height: 0,
|
|
|
|
translate: { x: 0, y: 48 },
|
|
|
|
duration: 200,
|
|
|
|
curve: CoreTypes.AnimationCurve.easeIn,
|
|
|
|
})
|
|
|
|
.then(() => (this.showTools = 0));
|
|
|
|
} else {
|
|
|
|
this.sidebar.height = 1;
|
|
|
|
this.showTools = 1;
|
|
|
|
setTimeout(() => {
|
|
|
|
this.sidebar.animate({
|
|
|
|
height: 216,
|
|
|
|
duration: 200,
|
|
|
|
translate: { x: 0, y: 0 },
|
|
|
|
curve: CoreTypes.AnimationCurve.easeOut,
|
|
|
|
});
|
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-15 11:04:42 +00:00
|
|
|
// ShareAction
|
2020-11-10 18:28:48 +00:00
|
|
|
shareHandler() {
|
2021-05-22 08:56:31 +00:00
|
|
|
if (this.recipe.image) {
|
2021-05-25 14:32:53 +00:00
|
|
|
this.$showModal(Action, {
|
2020-11-10 18:28:48 +00:00
|
|
|
props: {
|
2021-01-13 05:02:48 +00:00
|
|
|
title: "shr",
|
2021-04-18 13:28:25 +00:00
|
|
|
list: ["rec", "pht"],
|
2020-11-10 18:28:48 +00:00
|
|
|
},
|
2021-02-28 15:10:26 +00:00
|
|
|
}).then((result) => {
|
|
|
|
switch (result) {
|
2021-04-18 13:28:25 +00:00
|
|
|
case "rec":
|
|
|
|
this.shareRecipe();
|
|
|
|
break;
|
2021-04-01 10:55:35 +00:00
|
|
|
case "pht":
|
2021-05-22 08:56:31 +00:00
|
|
|
ImageSource.fromFile(this.recipe.image).then((res) =>
|
2021-06-15 11:04:42 +00:00
|
|
|
utils.shareImage(res, localize("srpu"), this.recipe.title)
|
2021-04-12 19:25:14 +00:00
|
|
|
);
|
2021-02-28 15:10:26 +00:00
|
|
|
break;
|
2020-11-10 18:28:48 +00:00
|
|
|
}
|
2021-02-28 15:10:26 +00:00
|
|
|
});
|
2020-12-29 10:35:19 +00:00
|
|
|
} else {
|
2021-02-28 15:10:26 +00:00
|
|
|
this.shareRecipe();
|
2020-11-10 18:28:48 +00:00
|
|
|
}
|
|
|
|
},
|
2020-10-29 20:12:53 +00:00
|
|
|
shareRecipe() {
|
2021-06-29 11:37:04 +00:00
|
|
|
let r = this.recipe;
|
|
|
|
let overview = `${r.title}\n\n`;
|
|
|
|
if (r.rating) overview += `${localize("stars")}: ${r.rating}\n`;
|
|
|
|
overview += `${localize("cui")}: ${localize(r.cuisine)}\n${localize(
|
|
|
|
"cat"
|
|
|
|
)}: ${localize(r.category)}\n`;
|
|
|
|
if (r.tags.length)
|
|
|
|
overview += `${localize("ts")}: ${r.tags.join(", ")}\n`;
|
|
|
|
if (r.prepTime != "00:00")
|
2021-07-03 16:27:14 +00:00
|
|
|
overview += `${localize("prepT")}: ${this.niceTime(r.prepTime)}\n`;
|
2021-06-29 11:37:04 +00:00
|
|
|
if (r.cookTime != "00:00")
|
2021-07-03 16:27:14 +00:00
|
|
|
overview += `${localize("cookT")}: ${this.niceTime(r.cookTime)}\n`;
|
2021-04-18 18:34:17 +00:00
|
|
|
overview += `${localize("yld")}: ${this.tempYieldQuantity} ${localize(
|
2021-06-29 11:37:04 +00:00
|
|
|
r.yieldUnit
|
|
|
|
)}\n${localize("Difficulty level")}: ${localize(r.difficulty)}\n`;
|
2021-04-18 18:34:17 +00:00
|
|
|
|
2021-02-28 15:10:26 +00:00
|
|
|
let shareContent = overview;
|
2021-06-29 11:37:04 +00:00
|
|
|
if (r.ingredients.length) {
|
2021-04-12 18:09:48 +00:00
|
|
|
let ingredients = `\n\n${localize("ings")}:\n\n`;
|
2021-06-29 11:37:04 +00:00
|
|
|
r.ingredients.forEach((e) => {
|
|
|
|
if (e.type) {
|
|
|
|
ingredients += `- ${
|
|
|
|
e.quantity
|
2021-07-03 16:27:14 +00:00
|
|
|
? this.roundQ(e.quantity) + " " + localize(e.unit) + " "
|
2021-06-29 11:37:04 +00:00
|
|
|
: ""
|
|
|
|
}${e.value}\n`;
|
|
|
|
} else {
|
|
|
|
ingredients += `\n${
|
|
|
|
e.quantity
|
2021-07-03 16:27:14 +00:00
|
|
|
? this.roundQ(e.quantity) + " " + localize(e.unit) + " "
|
2021-06-29 11:37:04 +00:00
|
|
|
: ""
|
|
|
|
}${e.value}\n\n`;
|
|
|
|
}
|
2021-02-28 15:10:26 +00:00
|
|
|
});
|
|
|
|
shareContent += ingredients;
|
2020-10-29 20:12:53 +00:00
|
|
|
}
|
2021-06-29 11:37:04 +00:00
|
|
|
let ins = r.instructions;
|
|
|
|
if (ins.length) {
|
|
|
|
let a = 1;
|
|
|
|
let b = 1;
|
|
|
|
let group = ins.reduce((acc, e) => {
|
|
|
|
if (!e.type) {
|
|
|
|
a = 1;
|
|
|
|
acc.push(b++);
|
|
|
|
} else acc.push(a++);
|
|
|
|
return acc;
|
|
|
|
}, []);
|
2021-04-12 18:09:48 +00:00
|
|
|
let instructions = `\n\n${localize("inss")}:\n\n`;
|
2021-06-29 11:37:04 +00:00
|
|
|
ins.forEach(
|
|
|
|
(e, i) =>
|
|
|
|
(instructions += (e.type ? group[i] + ". " : "") + `${e.value}\n\n`)
|
|
|
|
);
|
2021-02-28 15:10:26 +00:00
|
|
|
shareContent += instructions;
|
2020-10-29 20:12:53 +00:00
|
|
|
}
|
2021-06-29 11:37:04 +00:00
|
|
|
if (r.combinations.length) {
|
2021-02-28 15:10:26 +00:00
|
|
|
let combinations = `\n${localize("cmbs")}:\n\n`;
|
2021-06-29 11:37:04 +00:00
|
|
|
r.combinations.forEach((e, i) => {
|
2021-02-28 15:10:26 +00:00
|
|
|
combinations += `${i + 1}. ${this.getCombinationTitle(e)}\n\n`;
|
|
|
|
});
|
|
|
|
shareContent += combinations;
|
2020-12-29 10:35:19 +00:00
|
|
|
}
|
2021-06-29 11:37:04 +00:00
|
|
|
if (r.notes.length) {
|
2021-04-12 18:09:48 +00:00
|
|
|
let notes = `\n${localize("nos")}:\n\n`;
|
2021-06-29 11:37:04 +00:00
|
|
|
r.notes.forEach((e, i) => {
|
2021-06-28 11:38:21 +00:00
|
|
|
notes += `${i + 1}. ${e.value}\n\n`;
|
2021-04-12 18:09:48 +00:00
|
|
|
});
|
|
|
|
shareContent += notes;
|
|
|
|
}
|
2021-02-28 15:10:26 +00:00
|
|
|
let sharenote = "\n" + localize("appCrd");
|
|
|
|
shareContent += sharenote;
|
2021-04-12 19:25:14 +00:00
|
|
|
utils.shareText(shareContent, localize("sru"));
|
2020-10-29 20:12:53 +00:00
|
|
|
},
|
2021-01-23 17:20:15 +00:00
|
|
|
|
2021-07-03 16:27:14 +00:00
|
|
|
// Toggles
|
2021-06-29 15:01:03 +00:00
|
|
|
toggle(key: string, setDate: number) {
|
|
|
|
console.log(setDate);
|
|
|
|
if (setDate) {
|
|
|
|
this.recipeTried = !this.recipeTried;
|
|
|
|
} else
|
|
|
|
this.toggleState({
|
|
|
|
id: this.currentRecipeID,
|
|
|
|
key,
|
|
|
|
setDate,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
markTried() {
|
2021-06-18 18:37:01 +00:00
|
|
|
this.toggleState({
|
2020-11-15 10:51:10 +00:00
|
|
|
id: this.currentRecipeID,
|
2021-06-29 15:01:03 +00:00
|
|
|
key: "tried",
|
|
|
|
setDate: 1,
|
2021-02-28 15:10:26 +00:00
|
|
|
});
|
2020-10-14 19:32:32 +00:00
|
|
|
},
|
2021-06-29 15:01:03 +00:00
|
|
|
rate(r) {
|
2021-06-18 12:52:03 +00:00
|
|
|
if (r !== this.recipe.rating || r === 1) {
|
|
|
|
if (this.recipe.rating == 1 && r == 1) r = 0;
|
2021-06-18 18:37:01 +00:00
|
|
|
this.setR({
|
2020-12-29 10:35:19 +00:00
|
|
|
id: this.currentRecipeID,
|
2021-06-18 18:37:01 +00:00
|
|
|
r,
|
2021-02-28 15:10:26 +00:00
|
|
|
});
|
2020-12-29 10:35:19 +00:00
|
|
|
}
|
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
},
|
2021-01-23 17:20:15 +00:00
|
|
|
|
2021-06-15 11:04:42 +00:00
|
|
|
// Notes
|
2021-04-01 10:55:35 +00:00
|
|
|
createNote(note) {
|
2021-02-28 15:10:26 +00:00
|
|
|
let regex = /(https?:\/\/[^\s]+)/g;
|
2021-06-15 11:04:42 +00:00
|
|
|
const lbl = new RLabel();
|
2021-06-18 12:52:03 +00:00
|
|
|
lbl.className = "note tw";
|
2021-04-01 10:55:35 +00:00
|
|
|
lbl.textWrap = true;
|
|
|
|
let fString = new FormattedString();
|
|
|
|
let arr = note.split(regex);
|
2020-12-02 09:46:25 +00:00
|
|
|
|
2021-02-28 15:10:26 +00:00
|
|
|
function createSpan(text, isUrl) {
|
|
|
|
let span = new Span();
|
|
|
|
span.text = text;
|
|
|
|
span.fontSize = 14;
|
|
|
|
if (isUrl) {
|
|
|
|
span.textDecoration = "underline";
|
|
|
|
span.on("linkTap", () => Utils.openUrl(text));
|
2020-12-02 09:46:25 +00:00
|
|
|
}
|
2021-04-01 10:55:35 +00:00
|
|
|
fString.spans.push(span);
|
2020-12-02 09:46:25 +00:00
|
|
|
}
|
2021-04-01 10:55:35 +00:00
|
|
|
arr.forEach((text) => {
|
2021-02-28 15:10:26 +00:00
|
|
|
createSpan(text, regex.test(text));
|
|
|
|
});
|
2021-04-01 10:55:35 +00:00
|
|
|
lbl.formattedText = fString;
|
|
|
|
return lbl;
|
|
|
|
},
|
|
|
|
createNotes() {
|
|
|
|
const stack = this.notescon;
|
|
|
|
stack.removeChildren();
|
|
|
|
this.recipe.notes.forEach((note) =>
|
2021-06-28 11:38:21 +00:00
|
|
|
stack.addChild(this.createNote(note.value))
|
2021-04-01 10:55:35 +00:00
|
|
|
);
|
|
|
|
},
|
2021-06-29 15:01:03 +00:00
|
|
|
isValidURL(s) {
|
|
|
|
let pattern = new RegExp("^https?|^www", "ig");
|
|
|
|
return pattern.test(s);
|
2021-04-12 18:09:48 +00:00
|
|
|
},
|
2021-06-29 15:01:03 +00:00
|
|
|
|
|
|
|
// PhotoViewer
|
2021-07-03 16:27:14 +00:00
|
|
|
imgVLoad({ object }) {
|
|
|
|
this.imgView = object;
|
|
|
|
this.imgView.visibility = "collapsed";
|
|
|
|
this.imgView.top = 24;
|
|
|
|
this.imgView.left = this.RTL ? 16 : Screen.mainScreen.widthDIPs - 112;
|
|
|
|
},
|
2021-04-12 18:09:48 +00:00
|
|
|
viewPhoto() {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.hideBars();
|
|
|
|
this.photoOpen = 1;
|
2021-04-12 18:09:48 +00:00
|
|
|
this.hijackBackEvent();
|
2021-04-21 10:31:49 +00:00
|
|
|
let pv = this.imgView;
|
2021-04-12 18:09:48 +00:00
|
|
|
pv.visibility = "visible";
|
|
|
|
let sw = Screen.mainScreen.widthDIPs;
|
|
|
|
let sh = Screen.mainScreen.heightDIPs;
|
|
|
|
pv.animate({
|
|
|
|
opacity: 1,
|
|
|
|
duration: 50,
|
|
|
|
})
|
|
|
|
.then(() =>
|
|
|
|
pv.animate({
|
|
|
|
width: sw,
|
|
|
|
height: sw,
|
2021-06-15 11:04:42 +00:00
|
|
|
translate: { x: this.RTL ? -16 : 112 - sw, y: (sh - sw) / 3 },
|
|
|
|
duration: 200,
|
2021-04-12 18:09:48 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
.then(() =>
|
|
|
|
pv.animate({
|
2021-04-21 10:31:49 +00:00
|
|
|
height: sh,
|
2021-06-15 11:04:42 +00:00
|
|
|
translate: { x: this.RTL ? -16 : 112 - sw, y: -((sh - sw) / 6) },
|
|
|
|
duration: 200,
|
2021-04-12 18:09:48 +00:00
|
|
|
})
|
2021-04-01 10:55:35 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-12 18:09:48 +00:00
|
|
|
closePhoto() {
|
2021-04-21 10:31:49 +00:00
|
|
|
let pv = this.imgView;
|
2021-04-12 18:09:48 +00:00
|
|
|
let sw = Screen.mainScreen.widthDIPs;
|
|
|
|
let sh = Screen.mainScreen.heightDIPs;
|
|
|
|
pv.animate({
|
|
|
|
width: sw,
|
|
|
|
height: sw,
|
2021-06-15 11:04:42 +00:00
|
|
|
translate: { x: this.RTL ? -16 : 112 - sw, y: (sh - sw) / 3 },
|
|
|
|
duration: 200,
|
2021-04-12 18:09:48 +00:00
|
|
|
})
|
|
|
|
.then(() =>
|
|
|
|
pv.animate({
|
|
|
|
width: 96,
|
|
|
|
height: 96,
|
|
|
|
translate: { x: 0, y: 0 },
|
2021-06-15 11:04:42 +00:00
|
|
|
duration: 200,
|
2021-04-12 18:09:48 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
.then(() =>
|
|
|
|
pv.animate({
|
|
|
|
opacity: 0,
|
|
|
|
duration: 50,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.then(() => {
|
|
|
|
pv.visibility = "collapsed";
|
2021-06-15 11:04:42 +00:00
|
|
|
this.photoOpen = 0;
|
2021-04-12 18:09:48 +00:00
|
|
|
this.releaseBackEvent();
|
2021-06-15 11:04:42 +00:00
|
|
|
this.showBars();
|
2021-04-12 18:09:48 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-06-15 11:04:42 +00:00
|
|
|
// Timers
|
2021-05-22 08:56:31 +00:00
|
|
|
openCookingTimer() {
|
|
|
|
this.$navigateTo(CookingTimer, {
|
|
|
|
props: {
|
|
|
|
recipeID: this.recipe.id,
|
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
animated: false,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-06-29 15:01:03 +00:00
|
|
|
// Duplicate
|
2021-06-15 11:04:42 +00:00
|
|
|
duplicateRecipe() {
|
|
|
|
this.busyDup = 1;
|
|
|
|
let dupRecipe = Object.assign({}, this.recipe);
|
|
|
|
dupRecipe.id = utils.getRandomID(0);
|
|
|
|
dupRecipe.title = dupRecipe.title + " " + localize("cpy");
|
|
|
|
this.$navigateTo(EditRecipe, {
|
|
|
|
props: {
|
|
|
|
dupRecipe,
|
|
|
|
},
|
|
|
|
animated: false,
|
2021-05-22 08:56:31 +00:00
|
|
|
});
|
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
|
|
|
|
// Print
|
2021-07-03 16:27:14 +00:00
|
|
|
wvLoad({ object }) {
|
|
|
|
this.wv = object;
|
|
|
|
utils.updateLocale(); // required to set local RTL and language in webview
|
|
|
|
},
|
2021-06-15 11:04:42 +00:00
|
|
|
prepareHTML() {
|
|
|
|
let r = this.recipe;
|
2021-06-28 11:38:21 +00:00
|
|
|
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>`;
|
2021-06-15 11:04:42 +00:00
|
|
|
const getStarRating = () => {
|
|
|
|
let rate = `<svg width="100%" height="100%" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M10.756 2.826 8.419 7.98l-5.624.63c-.533.06-.982.425-1.147.935-.166.51-.018 1.07.378 1.431l4.179 3.816-1.138 5.543c-.108.525.101 1.065.535 1.38.434.315 1.012.348 1.478.083L12 19.002l4.92 2.796c.466.265 1.044.232 1.478-.083.434-.315.643-.855.535-1.38l-1.138-5.543 4.179-3.816c.396-.361.544-.921.378-1.431-.165-.51-.614-.875-1.147-.935l-5.624-.63-2.337-5.154c-.221-.489-.708-.802-1.244-.802s-1.023.313-1.244.802z"/></svg>`;
|
|
|
|
let unrate = `<svg width="100%" height="100%" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M10.756 2.826 8.419 7.98l-5.624.63c-.533.06-.982.425-1.147.935-.166.51-.018 1.07.378 1.431l4.179 3.816-1.138 5.543c-.108.525.101 1.065.535 1.38.434.315 1.012.348 1.478.083L12 19.002l4.92 2.796c.466.265 1.044.232 1.478-.083.434-.315.643-.855.535-1.38l-1.138-5.543 4.179-3.816c.396-.361.544-.921.378-1.431-.165-.51-.614-.875-1.147-.935l-5.624-.63-2.337-5.154c-.221-.489-.708-.802-1.244-.802s-1.023.313-1.244.802zM12 4.925l1.994 4.398c.146.321.45.542.8.581l4.799.538-3.567 3.256c-.26.237-.376.594-.305.94l.972 4.73-4.199-2.386c-.306-.174-.682-.174-.988.0l-4.199 2.386.972-4.73c.071-.346-.045-.703-.305-.94l-3.567-3.256 4.799-.538c.35-.039.654-.26.8-.581L12 4.925z"/></svg>`;
|
|
|
|
return rate.repeat(r.rating) + unrate.repeat(5 - r.rating);
|
|
|
|
};
|
|
|
|
const img = r.image ? `<img src="${r.image}" alt="${r.title}" />` : "";
|
|
|
|
const getIngs = () => {
|
2021-06-28 11:38:21 +00:00
|
|
|
let ings = r.ingredients;
|
|
|
|
return ings
|
|
|
|
.map((e, i) => {
|
|
|
|
if (!e.type)
|
|
|
|
return `${i > 0 ? "</ul>" : ""}<h3>${e.value}</h3>${
|
|
|
|
i < ings.length - 1 ? "<ul>" : ""
|
|
|
|
}`;
|
|
|
|
else
|
2021-06-29 15:01:03 +00:00
|
|
|
return `${i < 1 ? "<ul>" : ""}<li>${this.getIng(e)}</li>${
|
|
|
|
i == ings.length - 1 ? "</ul>" : ""
|
|
|
|
}`;
|
2021-06-28 11:38:21 +00:00
|
|
|
})
|
|
|
|
.join("");
|
2021-06-15 11:04:42 +00:00
|
|
|
};
|
|
|
|
const getIns = () => {
|
2021-06-28 11:38:21 +00:00
|
|
|
let inss = r.instructions;
|
|
|
|
return r.instructions
|
|
|
|
.map((e, i) => {
|
|
|
|
if (!e.type)
|
|
|
|
return `${i > 0 ? "</ol>" : ""}<h3>${e.value}</h3>${
|
|
|
|
i < inss.length - 1 ? "<ol>" : ""
|
|
|
|
}`;
|
|
|
|
else
|
|
|
|
return `${i < 1 ? "<ol>" : ""}<li>${e.value}</li>${
|
|
|
|
i == inss.length - 1 ? "</ol>" : ""
|
|
|
|
}`;
|
|
|
|
})
|
|
|
|
.join("");
|
2021-06-15 11:04:42 +00:00
|
|
|
};
|
|
|
|
const getCmbs = () => {
|
|
|
|
let cmb = [];
|
|
|
|
r.combinations.forEach((e) => {
|
|
|
|
cmb.push(`<p>${this.getCombinationTitle(e)}</p>`);
|
|
|
|
});
|
|
|
|
return cmb.join("");
|
|
|
|
};
|
|
|
|
const getNotes = () => {
|
|
|
|
let regex = /(https?:\/\/[^\s]+)/g;
|
|
|
|
let n = [];
|
|
|
|
const createSpan = (val, isUrl) => {
|
|
|
|
return isUrl
|
|
|
|
? `<a href="${val}" target="_blank" rel="noopener noreferrer">${val}</a>`
|
|
|
|
: val;
|
|
|
|
};
|
|
|
|
r.notes.forEach((e) => {
|
2021-06-28 11:38:21 +00:00
|
|
|
let arr = e.value.split(regex);
|
2021-06-15 11:04:42 +00:00
|
|
|
let single = [];
|
|
|
|
arr.forEach((f) => {
|
|
|
|
single.push(createSpan(f, regex.test(f)));
|
|
|
|
});
|
|
|
|
n.push(`<p>${single.join("")}</p>`);
|
|
|
|
});
|
|
|
|
return n.join("");
|
|
|
|
};
|
|
|
|
return `<html dir="${
|
|
|
|
this.RTL ? "rtl" : "ltr"
|
|
|
|
}">${head}<body><div id=header><div class=title><h1>${
|
|
|
|
r.title
|
|
|
|
}</h1><div class=rating>${getStarRating()}</div></div>${img}</div><div class=attr><div><p>${localize(
|
|
|
|
"cui"
|
|
|
|
)}<p>${r.cuisine}</div><div><p>${localize("cat")}<p>${
|
|
|
|
r.category
|
|
|
|
}</div></div>${
|
|
|
|
r.tags.length
|
|
|
|
? `<div class=attr><div style="grid-column:span 2"><p>${localize(
|
|
|
|
"ts"
|
2021-06-29 15:01:03 +00:00
|
|
|
)}<p>${this.getTags}</div></div>`
|
2021-06-15 11:04:42 +00:00
|
|
|
: ""
|
|
|
|
} ${
|
|
|
|
this.hasTime(r.prepTime) || this.hasTime(r.cookTime)
|
|
|
|
? `<div class=attr>${
|
|
|
|
this.hasTime(r.prepTime)
|
2021-07-03 16:27:14 +00:00
|
|
|
? `<div><p>${localize("prepT")}<p>${this.niceTime(
|
2021-06-15 11:04:42 +00:00
|
|
|
r.prepTime
|
|
|
|
)}</div>`
|
|
|
|
: ""
|
|
|
|
} ${
|
|
|
|
this.hasTime(r.cookTime)
|
2021-07-03 16:27:14 +00:00
|
|
|
? `<div><p>${localize("cookT")}<p>${this.niceTime(
|
2021-06-15 11:04:42 +00:00
|
|
|
r.cookTime
|
|
|
|
)}</div>`
|
|
|
|
: ""
|
|
|
|
}</div>`
|
|
|
|
: ""
|
|
|
|
}<div class=attr><div><p>${localize("yld")}<p>${
|
|
|
|
this.tempYieldQuantity
|
|
|
|
} ${localize(r.yieldUnit)}</div><div><p>${localize(
|
|
|
|
"Difficulty level"
|
|
|
|
)}<p>${r.difficulty}</div></div>${
|
|
|
|
r.ingredients.length
|
2021-06-28 11:38:21 +00:00
|
|
|
? `<h2>${this.getTitleCount("ings", "ingredients", 1)}</h2>`
|
2021-06-15 11:04:42 +00:00
|
|
|
: ""
|
2021-06-28 11:38:21 +00:00
|
|
|
}${getIngs()}${
|
2021-06-15 11:04:42 +00:00
|
|
|
r.instructions.length
|
2021-06-28 11:38:21 +00:00
|
|
|
? `<h2>${this.getTitleCount("inss", "instructions", 1)}</h2>`
|
2021-06-15 11:04:42 +00:00
|
|
|
: ""
|
2021-06-28 11:38:21 +00:00
|
|
|
}${getIns()}${
|
2021-06-15 11:04:42 +00:00
|
|
|
r.combinations.length
|
2021-06-28 11:38:21 +00:00
|
|
|
? `<h2>${this.getTitleCount("cmbs", "combinations", 1)}</h2>`
|
2021-06-15 11:04:42 +00:00
|
|
|
: ""
|
|
|
|
} ${getCmbs()} ${
|
2021-06-28 11:38:21 +00:00
|
|
|
r.notes.length
|
|
|
|
? `<h2>${this.getTitleCount("nos", "notes", 1)}</h2>`
|
|
|
|
: ""
|
2021-07-03 16:27:14 +00:00
|
|
|
} ${getNotes()}<div class=sub><p>${this.getDates.u}</p><p>${
|
|
|
|
this.getDates.c
|
|
|
|
}</p></div>
|
2021-06-15 11:04:42 +00:00
|
|
|
</body>
|
|
|
|
</html>`;
|
|
|
|
},
|
|
|
|
printView() {
|
|
|
|
let wv = this.wv as WebView;
|
|
|
|
const fileName = `${this.recipe.title} - ${localize("EnRecipes")}`;
|
|
|
|
wv.src = this.prepareHTML();
|
|
|
|
wv.once("loadFinished", () =>
|
|
|
|
utils.Printer.print(wv, fileName).then(() => (wv.src = null))
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2021-07-03 16:27:14 +00:00
|
|
|
// FeedBack
|
2021-06-29 15:01:03 +00:00
|
|
|
touchRate({ object, action }, r) {
|
|
|
|
this.touchFade(object, action);
|
|
|
|
if (action == "up") this.rate(r);
|
|
|
|
},
|
2021-04-01 10:55:35 +00:00
|
|
|
touchYield({ object, action }) {
|
2021-06-18 12:52:03 +00:00
|
|
|
this.touchFade(object, action);
|
|
|
|
|
2021-04-01 10:55:35 +00:00
|
|
|
if (action == "up") this.changeYield();
|
2020-10-29 20:12:53 +00:00
|
|
|
},
|
2021-07-03 16:27:14 +00:00
|
|
|
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);
|
|
|
|
},
|
2020-10-24 18:02:35 +00:00
|
|
|
},
|
|
|
|
created() {
|
2021-02-28 15:10:26 +00:00
|
|
|
this.recipe = this.recipes.filter((e) => e.id === this.currentRecipeID)[0];
|
2021-06-15 11:04:42 +00:00
|
|
|
this.recipe.ingredients.forEach((e) => this.checks.push(0));
|
2020-10-14 19:32:32 +00:00
|
|
|
},
|
2020-10-29 20:12:53 +00:00
|
|
|
mounted() {
|
2021-06-15 11:04:42 +00:00
|
|
|
this.yieldMultiplier = this.yieldQuantity || this.recipe.yieldQuantity;
|
2020-10-29 20:12:53 +00:00
|
|
|
},
|
2021-02-28 15:10:26 +00:00
|
|
|
};
|
2020-10-14 19:32:32 +00:00
|
|
|
</script>
|