added ui-calendar

This commit is contained in:
Vishnu Raghav B 2020-11-16 02:43:06 +05:30
parent 01c9c32162
commit fd0b8ac4c0
12 changed files with 158 additions and 45 deletions

View file

@ -25,7 +25,7 @@ EnRecipes is an easy to use, privacy-friendly digital cookbook that lets you cre
- Add photo, notes and references to your recipes - Add photo, notes and references to your recipes
- Organise your recipes by category - Organise your recipes by category
- Search for your recipes based on the title - Search for your recipes based on the title
- Mark recipes as favorites and add them to your Try later list - Mark recipes as favorites and add them to your Try Later list
- Scale your recipe ingredients to serve more or less people - Scale your recipe ingredients to serve more or less people
- Get notified of the last time you tried a recipe - Get notified of the last time you tried a recipe
- Share your recipe to anyone by any means as a nicely formatted message. You can share the recipe photo too. - Share your recipe to anyone by any means as a nicely formatted message. You can share the recipe photo too.

View file

@ -61,7 +61,8 @@ Page,
.referenceItem, .referenceItem,
.recipeText, .recipeText,
.overviewItem, .overviewItem,
.recipeItem { .recipeItem,
TextField.combinationToken {
background: white; background: white;
} }
@ -124,7 +125,8 @@ Page,
.referenceItem, .referenceItem,
.recipeText, .recipeText,
.overviewItem, .overviewItem,
.recipeItem { .recipeItem,
TextField.combinationToken {
background: $gray8; background: $gray8;
} }
.sd-item, .sd-item,
@ -483,6 +485,9 @@ RadListView {
margin: 0; margin: 0;
line-height: 6; line-height: 6;
} }
.linkIcon {
padding: 0 16 0 0;
}
} }
.recipeText { .recipeText {
font-size: 16; font-size: 16;
@ -526,7 +531,6 @@ MDButton.closeBtn {
} }
TextField.combinationToken { TextField.combinationToken {
border-width: 0; border-width: 0;
background: white;
} }
// ----------------------------- // -----------------------------
// DIALOGS // DIALOGS

View file

@ -32,7 +32,24 @@
<Label col="0" row="0" class="bx" :text="icon[item.icon]" /> <Label col="0" row="0" class="bx" :text="icon[item.icon]" />
<Label col="2" row="0" :text="item.title" /> <Label col="2" row="0" :text="item.title" />
</GridLayout> </GridLayout>
<StackLayout class="hr m-10"></StackLayout> <StackLayout class="hr m-8"></StackLayout>
<GridLayout
rows="48"
columns="auto, 24, *"
class="sd-item orkm"
:class="{
'selected-sd-item': currentComponent === 'MealPlanner',
}"
>
<MDRipple
row="0"
colSpan="3"
@tap="navigateTo(mealPlanner, true, false)"
/>
<Label col="0" row="0" class="bx" :text="icon.calendar" />
<Label col="2" row="0" text="Meal Planner" />
</GridLayout>
<StackLayout class="hr m-8"></StackLayout>
<GridLayout <GridLayout
class="sd-group-header orkm" class="sd-group-header orkm"
rows="auto" rows="auto"
@ -137,6 +154,7 @@ import * as application from "tns-core-modules/application"
import { mapActions, mapState } from "vuex" import { mapActions, mapState } from "vuex"
import EnRecipes from "./EnRecipes.vue" import EnRecipes from "./EnRecipes.vue"
import MealPlanner from "./MealPlanner.vue"
import Settings from "./Settings.vue" import Settings from "./Settings.vue"
import About from "./About.vue" import About from "./About.vue"
@ -163,8 +181,8 @@ export default {
icon: "heart", icon: "heart",
}, },
{ {
title: "Try later", title: "Try Later",
component: "Try later", component: "Try Later",
icon: "trylater", icon: "trylater",
}, },
], ],
@ -182,6 +200,7 @@ export default {
], ],
editCategory: false, editCategory: false,
appTheme: "Light", appTheme: "Light",
mealPlanner: MealPlanner,
} }
}, },
computed: { computed: {
@ -313,7 +332,7 @@ export default {
vm.filterFavorites vm.filterFavorites
? vm.setComponent("Favorites") ? vm.setComponent("Favorites")
: vm.filterTrylater : vm.filterTrylater
? vm.setComponent("Try later") ? vm.setComponent("Try Later")
: vm.selectedCategory : vm.selectedCategory
? vm.setComponent(vm.selectedCategory) ? vm.setComponent(vm.selectedCategory)
: vm.setComponent("EnRecipes") : vm.setComponent("EnRecipes")
@ -323,7 +342,7 @@ export default {
this.closeDrawer() this.closeDrawer()
this.editCategory = false this.editCategory = false
} else if ( } else if (
["Favorites", "Try later", this.selectedCategory].includes( ["Favorites", "Try Later", this.selectedCategory].includes(
this.currentComponent this.currentComponent
) )
) { ) {
@ -355,7 +374,7 @@ export default {
this.setComponent(to) this.setComponent(to)
this.$navigateBack({ frame: "main-frame", backstackVisible: false }) this.$navigateBack({ frame: "main-frame", backstackVisible: false })
this.filterFavorites = to === "Favorites" ? true : false this.filterFavorites = to === "Favorites" ? true : false
this.filterTrylater = to === "Try later" ? true : false this.filterTrylater = to === "Try Later" ? true : false
this.selectedCategory = isCategory ? to : null this.selectedCategory = isCategory ? to : null
this.$refs.enrecipes.updateFilter() this.$refs.enrecipes.updateFilter()
this.closeDrawer() this.closeDrawer()

View file

@ -126,6 +126,7 @@
:key="index" :key="index"
> >
<TextField <TextField
ref="ingredient"
@loaded="focusField($event, 'sentence')" @loaded="focusField($event, 'sentence')"
col="0" col="0"
v-model="recipeContent.ingredients[index].item" v-model="recipeContent.ingredients[index].item"
@ -146,8 +147,8 @@
v-model="recipeContent.ingredients[index].unit" v-model="recipeContent.ingredients[index].unit"
hint="Unit" hint="Unit"
editable="false" editable="false"
@focus="modalOpen === false && showUnits($event, true)" @focus="modalOpen === false && showUnits($event, true, index)"
@tap="showUnits($event, false)" @tap="showUnits($event, false, index)"
/> />
<MDButton <MDButton
variant="text" variant="text"
@ -404,7 +405,7 @@ export default {
if (type) this.setInputTypeText(args, type) if (type) this.setInputTypeText(args, type)
if (!args.object.text) { if (!args.object.text) {
args.object.focus() args.object.focus()
setTimeout((e) => Utils.ad.showSoftInput(args.object.android), 1) setTimeout((e) => Utils.ad.showSoftInput(args.object.android), 10)
} }
}, },
setInputTypeText(args, type) { setInputTypeText(args, type) {
@ -549,7 +550,7 @@ export default {
} }
}) })
}, },
showUnits(e, focus) { showUnits(e, focus, index) {
this.modalOpen = true this.modalOpen = true
this.releaseBackEvent() this.releaseBackEvent()
this.$showModal(ActionDialog, { this.$showModal(ActionDialog, {
@ -562,7 +563,20 @@ export default {
if (action) { if (action) {
e.object.text = action e.object.text = action
this.modalOpen = false this.modalOpen = false
if (focus) this.addIngredient() if (focus) {
if (this.recipeContent.ingredients.length - 1 === index) {
this.addIngredient()
} else {
this.$refs.ingredient[index + 1].nativeView.focus()
setTimeout(
(e) =>
Utils.ad.showSoftInput(
this.$refs.ingredient[index + 1].nativeView.android
),
10
)
}
}
} }
}) })
}, },

View file

@ -293,7 +293,7 @@ export default {
this.filterFavorites this.filterFavorites
? this.setComponent("Favorites") ? this.setComponent("Favorites")
: this.filterTrylater : this.filterTrylater
? this.setComponent("Try later") ? this.setComponent("Try Later")
: this.selectedCategory : this.selectedCategory
? this.setComponent(this.selectedCategory) ? this.setComponent(this.selectedCategory)
: this.setComponent("EnRecipes") : this.setComponent("EnRecipes")

View file

@ -0,0 +1,68 @@
<template>
<Page @loaded="onPageLoad">
<ActionBar :flat="viewIsScrolled ? false : true">
<GridLayout rows="*" columns="auto, *">
<MDButton
class="bx left"
variant="text"
:text="icon.menu"
automationText="Back"
@tap="showDrawer"
col="0"
/>
<Label class="title orkm" text="Meal Planner" col="1" />
</GridLayout>
</ActionBar>
<GridLayout rows="*, auto, *, 88" columns="*" class="emptyStateContainer">
<StackLayout row="1" class="emptyState">
<Label class="title orkm" text="Coming soon!" textWrap="true" />
</StackLayout>
</GridLayout>
<!-- <RadCalendar
:viewMode="viewMode"
:transitionMode="transitionMode"
></RadCalendar> -->
</Page>
</template>
<script>
import { ApplicationSettings } from "@nativescript/core"
import {
CalendarViewMode,
CalendarTransitionMode,
CalendarEvent,
} from "nativescript-ui-calendar"
import { mapState, mapActions } from "vuex"
export default {
props: ["showDrawer", "releaseGlobalBackEvent"],
data() {
return {
viewIsScrolled: false,
appTheme: "Light",
viewMode: CalendarViewMode.Day,
transitionMode: CalendarTransitionMode.Slide,
}
},
computed: {
...mapState(["icon", "recipes"]),
},
methods: {
...mapActions(["setCurrentComponentAction"]),
onPageLoad() {
this.setCurrentComponentAction("MealPlanner")
this.releaseGlobalBackEvent()
},
// HELPERS
onScroll(args) {
args.scrollY
? (this.viewIsScrolled = true)
: (this.viewIsScrolled = false)
},
},
created() {
this.appTheme = ApplicationSettings.getString("appTheme", "Light")
},
}
</script>

View file

@ -32,6 +32,7 @@
<StackLayout class="hr m-10"></StackLayout> <StackLayout class="hr m-10"></StackLayout>
<Label text="Database" class="group-header orkm" /> <Label text="Database" class="group-header orkm" />
<GridLayout columns="auto, *" class="option"> <GridLayout columns="auto, *" class="option">
<!-- <MDRipple colSpan="2" @tap="folderPicker" /> -->
<MDRipple colSpan="2" @tap="exportCheck" /> <MDRipple colSpan="2" @tap="exportCheck" />
<Label col="0" class="bx" :text="icon.export" /> <Label col="0" class="bx" :text="icon.export" />
<StackLayout col="1"> <StackLayout col="1">
@ -62,7 +63,7 @@
<StackLayout col="1"> <StackLayout col="1">
<Label text="Import from backup" /> <Label text="Import from backup" />
<Label <Label
text="Supports full backups exported by this app." text="Supports full backups exported by this app"
class="info" class="info"
textWrap="true" textWrap="true"
/> />
@ -82,6 +83,7 @@ import {
Application, Application,
File, File,
Folder, Folder,
AndroidApplication,
} from "@nativescript/core" } from "@nativescript/core"
import * as Permissions from "@nativescript-community/perms" import * as Permissions from "@nativescript-community/perms"
import { Zip } from "@nativescript/zip" import { Zip } from "@nativescript/zip"
@ -97,7 +99,6 @@ export default {
props: [ props: [
"showDrawer", "showDrawer",
"restartApp", "restartApp",
"hijackGlobalBackEvent",
"releaseGlobalBackEvent", "releaseGlobalBackEvent",
"openAppSettingsPage", "openAppSettingsPage",
], ],
@ -194,9 +195,9 @@ export default {
("0" + date.getHours()).slice(-2) + ("0" + date.getHours()).slice(-2) +
("0" + date.getMinutes()).slice(-2) + ("0" + date.getMinutes()).slice(-2) +
("0" + date.getSeconds()).slice(-2) ("0" + date.getSeconds()).slice(-2)
const sdDownloadPath = android.os.Environment.getExternalStoragePublicDirectory( const sdDownloadPath = Folder.fromPath(
android.os.Environment.DIRECTORY_DOWNLOADS android.os.Environment.getExternalStorageDirectory().getAbsolutePath()
).toString() ).getFolder("Download").path
let fromPath = path.join(knownFolders.documents().path, "EnRecipes") let fromPath = path.join(knownFolders.documents().path, "EnRecipes")
let destPath = path.join( let destPath = path.join(
sdDownloadPath, sdDownloadPath,
@ -216,7 +217,7 @@ export default {
}, },
}).then((success) => { }).then((success) => {
Toast.makeText( Toast.makeText(
"Backup file successfully saved to Downloads", "Backup file successfully saved to Download folder",
"long" "long"
).show() ).show()
this.exportFiles("delete") this.exportFiles("delete")

View file

@ -413,7 +413,11 @@
class="referenceItem" class="referenceItem"
androidElevation="1" androidElevation="1"
> >
<MDRipple colSpan="3" @tap="copyURL(reference)" /> <MDRipple
colSpan="2"
@longPress="copyURL(reference)"
@tap="openURL(reference)"
/>
<Label <Label
col="0" col="0"
verticalAlignment="center" verticalAlignment="center"
@ -421,14 +425,7 @@
:text="reference" :text="reference"
textWrap="false" textWrap="false"
/> />
<MDButton <Label col="1" class="bx linkIcon" :text="icon.source" />
variant="text"
automationText="openURL"
col="1"
class="bx"
:text="icon.source"
@tap="openURL(reference)"
/>
</GridLayout> </GridLayout>
<Label <Label
v-else v-else
@ -516,7 +513,6 @@ import {
import { Feedback, FeedbackType, FeedbackPosition } from "nativescript-feedback" import { Feedback, FeedbackType, FeedbackPosition } from "nativescript-feedback"
import * as Toast from "nativescript-toast" import * as Toast from "nativescript-toast"
import * as SocialShare from "@nativescript/social-share" import * as SocialShare from "@nativescript/social-share"
import { setText } from "nativescript-clipboard"
import { Application } from "@nativescript/core" import { Application } from "@nativescript/core"
import { mapActions, mapState } from "vuex" import { mapActions, mapState } from "vuex"
@ -777,11 +773,11 @@ export default {
toggleTrylater() { toggleTrylater() {
this.recipe.tried this.recipe.tried
? this.filterTrylater ? this.filterTrylater
? Toast.makeText("Added back to Try later").show() ? Toast.makeText("Added back to Try Later").show()
: Toast.makeText("Added to Try later").show() : Toast.makeText("Added to Try Later").show()
: this.filterTrylater : this.filterTrylater
? Toast.makeText("You tried this recipe").show() ? Toast.makeText("You tried this recipe").show()
: Toast.makeText("Removed from Try later").show() : Toast.makeText("Removed from Try Later").show()
this.toggle("tried") this.toggle("tried")
}, },
recipeTried() { recipeTried() {
@ -794,9 +790,12 @@ export default {
Utils.openUrl(url) Utils.openUrl(url)
}, },
copyURL(url) { copyURL(url) {
setText(url).then((e) => { const clipboard = Utils.ad
.getApplicationContext()
.getSystemService(android.content.Context.CLIPBOARD_SERVICE)
const clip = android.content.ClipData.newPlainText("Reference URl", url)
clipboard.setPrimaryClip(clip)
Toast.makeText("URL Copied").show() Toast.makeText("URL Copied").show()
})
}, },
}, },
created() { created() {

View file

@ -20,6 +20,9 @@ Vue.use(FloatingActionButtonPlugin)
import ProgressPlugin from "@nativescript-community/ui-material-progress/vue" import ProgressPlugin from "@nativescript-community/ui-material-progress/vue"
Vue.use(ProgressPlugin) Vue.use(ProgressPlugin)
import CalendarView from "nativescript-ui-calendar/vue"
Vue.use(CalendarView)
Vue.registerElement( Vue.registerElement(
"RadSideDrawer", "RadSideDrawer",
() => require("nativescript-ui-sidedrawer").RadSideDrawer () => require("nativescript-ui-sidedrawer").RadSideDrawer

View file

@ -183,6 +183,7 @@ export default new Vuex.Store({
export: "\ued07", export: "\ued07",
import: "\ued0c", import: "\ued0c",
outline: "\ueb07", outline: "\ueb07",
calendar: "\uec55",
}, },
currentComponent: "EnRecipes", currentComponent: "EnRecipes",
}, },

14
package-lock.json generated
View file

@ -5843,11 +5843,6 @@
"to-regex": "^3.0.1" "to-regex": "^3.0.1"
} }
}, },
"nativescript-clipboard": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/nativescript-clipboard/-/nativescript-clipboard-2.0.0.tgz",
"integrity": "sha512-w7qRJiWiBeq55f3IW+pAkbrl+v+yqZf3bhcl1wH6Qm1JqZLWDv7HemzHTM5CvaqQ4gfz5dnGhJW1q1fsr5KSOw=="
},
"nativescript-couchbase-plugin": { "nativescript-couchbase-plugin": {
"version": "0.9.6", "version": "0.9.6",
"resolved": "https://registry.npmjs.org/nativescript-couchbase-plugin/-/nativescript-couchbase-plugin-0.9.6.tgz", "resolved": "https://registry.npmjs.org/nativescript-couchbase-plugin/-/nativescript-couchbase-plugin-0.9.6.tgz",
@ -5898,6 +5893,15 @@
"resolved": "https://registry.npmjs.org/nativescript-toast/-/nativescript-toast-2.0.0.tgz", "resolved": "https://registry.npmjs.org/nativescript-toast/-/nativescript-toast-2.0.0.tgz",
"integrity": "sha512-xqyNfFS894oGfrEVO7CjpioAQLiLNNcd77Euq9XIUTf1U3W0PsIgAJbLP7+kkVGIJxdLtlBkbcQ4wDmf2DCi1w==" "integrity": "sha512-xqyNfFS894oGfrEVO7CjpioAQLiLNNcd77Euq9XIUTf1U3W0PsIgAJbLP7+kkVGIJxdLtlBkbcQ4wDmf2DCi1w=="
}, },
"nativescript-ui-calendar": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/nativescript-ui-calendar/-/nativescript-ui-calendar-7.0.2.tgz",
"integrity": "sha512-yzSZPLFsboYj73BnVG0IYsiKHpPtmL/35QcXd7hC7kWdfjoaiE1eZgtqIRiTsNJaGAp9MeSrBdvuOCe7hI9rEA==",
"requires": {
"nativescript-ui-core": "~4.0.0",
"ts-node": "^8.10.2"
}
},
"nativescript-ui-core": { "nativescript-ui-core": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/nativescript-ui-core/-/nativescript-ui-core-4.0.0.tgz", "resolved": "https://registry.npmjs.org/nativescript-ui-core/-/nativescript-ui-core-4.0.0.tgz",

View file

@ -19,12 +19,12 @@
"@nativescript/theme": "^3.0.0", "@nativescript/theme": "^3.0.0",
"@nativescript/zip": "^5.0.0", "@nativescript/zip": "^5.0.0",
"@nstudio/nativescript-checkbox": "^2.0.4", "@nstudio/nativescript-checkbox": "^2.0.4",
"nativescript-clipboard": "^2.0.0",
"nativescript-couchbase-plugin": "^0.9.6", "nativescript-couchbase-plugin": "^0.9.6",
"nativescript-feedback": "^2.0.0", "nativescript-feedback": "^2.0.0",
"nativescript-imagecropper": "^4.0.1", "nativescript-imagecropper": "^4.0.1",
"nativescript-plugin-filepicker": "^1.0.0", "nativescript-plugin-filepicker": "^1.0.0",
"nativescript-toast": "^2.0.0", "nativescript-toast": "^2.0.0",
"nativescript-ui-calendar": "^7.0.2",
"nativescript-ui-listview": "^9.0.4", "nativescript-ui-listview": "^9.0.4",
"nativescript-ui-sidedrawer": "^9.0.3", "nativescript-ui-sidedrawer": "^9.0.3",
"nativescript-vue": "^2.6.1", "nativescript-vue": "^2.6.1",