enrecipes/app/components/GroceryList.vue

83 lines
2.1 KiB
Vue
Raw Normal View History

2021-01-13 05:02:48 +00:00
<template>
2021-02-28 15:10:26 +00:00
<Page @loaded="onPageLoad">
<ActionBar flat="true">
<GridLayout rows="*" columns="auto, *, auto">
<MDButton
class="er left"
variant="text"
:text="icon.back"
automationText="Back"
@tap="$navigateBack()"
col="0"
/>
<Label class="title orkm" :text="'grocery' | L" col="1" />
<MDButton
class="er left"
variant="text"
:text="icon.today"
automationText="today"
col="2"
/>
</GridLayout>
</ActionBar>
<GridLayout columns="" rows=""> </GridLayout>
</Page>
2021-01-13 05:02:48 +00:00
</template>
<script>
2021-02-28 15:10:26 +00:00
import { ApplicationSettings, Observable } from "@nativescript/core";
import { SnackBar } from "@nativescript-community/ui-material-snackbar";
2021-01-13 05:02:48 +00:00
const snackbar = new SnackBar();
2021-02-28 15:10:26 +00:00
import { mapState, mapActions } from "vuex";
2021-01-13 05:02:48 +00:00
export default {
data() {
return {
appTheme: "Light",
2021-02-28 15:10:26 +00:00
};
2021-01-13 05:02:48 +00:00
},
computed: {
2021-02-28 15:10:26 +00:00
...mapState(["icon", "recipes", "mealPlans"]),
2021-01-13 05:02:48 +00:00
isLightMode() {
2021-02-28 15:10:26 +00:00
return this.appTheme === "Light";
2021-01-13 05:02:48 +00:00
},
},
methods: {
2021-02-28 15:10:26 +00:00
...mapActions(["setCurrentComponentAction"]),
onPageLoad(args) {
2021-01-13 05:02:48 +00:00
const page = args.object;
page.bindingContext = new Observable();
2021-02-28 15:10:26 +00:00
this.setCurrentComponentAction("GroceryList");
2021-01-13 05:02:48 +00:00
},
// HELPERS
// NAVIGATION HANDLERS
2021-02-28 15:10:26 +00:00
viewRecipe(recipeID) {
let recipe = this.recipes.filter((e) => e.id === recipeID)[0];
if (recipe) {
this.$navigateTo(ViewRecipe, {
2021-01-13 05:02:48 +00:00
props: {
filterTrylater: true,
recipeID,
},
backstackVisible: false,
2021-02-28 15:10:26 +00:00
});
2021-01-13 05:02:48 +00:00
}
},
// DATA HANDLERS
2021-02-28 15:10:26 +00:00
undoRemove(message) {
return snackbar.action({
message,
textColor: this.appTheme == "Light" ? "#fff" : "#292929",
actionTextColor: "#ff5200",
backgroundColor: this.appTheme == "Light" ? "#292929" : "#fff",
actionText: "Undo",
hideDelay: 5000,
});
2021-01-13 05:02:48 +00:00
},
},
created() {
2021-02-28 15:10:26 +00:00
this.appTheme = ApplicationSettings.getString("appTheme", "Light");
2021-01-13 05:02:48 +00:00
},
2021-02-28 15:10:26 +00:00
};
2021-01-13 05:02:48 +00:00
</script>