Food Ordering Native APP: ADV-C42
Food Ordering Native APP: ADV-C42
1. Declared a variable to store the food names and its prices: We declared a variable
food_item which refers to menu items containing the food name and its price. We set
this variable to be an empty list.
2. Wrote code to set the ProjectBucket name of the Firebase database: When the
UpdateMenu screen gets initialized (that is opened) - we added code to set the
ProjectBucket name of the Firebase database.
Here, price is the Bucket which holds the Tags and Values in a Tag (Food item name)
Value (Food item price) pair.
➔ Code for setting the ProjectBucket name when the UpdateMenu screen is
opened (Initialized)
3. Got data from the Firebase database: We added code to get all the data from the
firebase database. This makes sure that all the Menu items are displayed.
section.
And inside this function, we added code to add all the menu items and their
respective prices in a list variable that we created earlier named food_item.
We joined the tag (food name) and value (food price) together and then stored
it in the list.
Example:
1. Food item:
- Name: Burger
- Price: 250
2. Food item:
- Name: Paneer 65
- Price: 300
These food items will be stored in the list in the below manner:
[ “Burger : 250” , “Paneer 65 : 300” ]
➔ Then we selected the tag variable from the DataChanged block. Click on the
tag. It gives you a code block to get the tag variable and set the tag variable
to a value. Since we wanted to use the tag name from the Firebase database,
we dragged the get tag code block to get the tag name.
➔ Similarly, we can get the value variable from the DataChanged block.
➔ Then as we wanted to display this list of menu items and their prices in the
ListViewer, we set the ListViewer Elements to this variable .
4. Got the user inputs and stored it in the database: We got the food name and food
price from the user and stored these in the Firebase database on click of the Add
Food Details button.
As we wanted to do this on click of the Add Food Details button, we got the on click
function for the add_food_details button.
So when a user clicks on the Add Food Details button, we get the food item name
and price from the respective text boxes and store these in the Firebase database.
The data in the Firebase database is stored in Tag (key) and Value pair. Therefore, we
stored the food item name as the tag and its price as the value.
This data is stored inside the price Bucket as price is the current active Bucket.
Then we started creating the “User App” of the Food Ordering System which the customers
used to order food.
We added code to Screen1:
2. Since we wanted to use these variables across all the screens of this
application, therefore we stored these variables in TinyDB. On click of the
Place Order button, we stored these variables in TinyDB and redirected the
user to the Menu screen.
➔ To store the data in TinyDB, we used the
➔ TinyDB also stores the value in Tag and Value pair just like the
Firebase database.
So, here inside the tag, we stored the finalDishList as a text, which is
basically a list name.
then inside the valueToStore variable, we stored the values of this list
in terms of name.
Therefore, we set the tag name to finalDishList and stored the
finalDishList variable in it.
What’s Next?
In the next class, we will add the functionality of fetching the items from the Firebase
database and display the items on the screen.