From eb74c897a1aef503e8041172000f7cc38e55d929 Mon Sep 17 00:00:00 2001 From: AshutoshPatole Date: Sat, 13 Nov 2021 19:07:20 +0530 Subject: [PATCH] Add price in the service --- lib/core/locator.dart | 2 +- lib/core/services/{temp.dart => food_details_holder.dart} | 6 +++++- lib/views/home_page/home_page_view.dart | 3 ++- lib/views/home_page/home_page_view_model.dart | 8 +++++--- .../item_detail_page/item_detail_page_view_model.dart | 3 ++- 5 files changed, 15 insertions(+), 7 deletions(-) rename lib/core/services/{temp.dart => food_details_holder.dart} (67%) diff --git a/lib/core/locator.dart b/lib/core/locator.dart index 6f821f3..f149879 100644 --- a/lib/core/locator.dart +++ b/lib/core/locator.dart @@ -1,7 +1,7 @@ import 'package:get_it/get_it.dart'; import 'package:logger/logger.dart'; import 'package:stacked_services/stacked_services.dart'; -import 'package:zerosandones/core/services/temp.dart'; +import 'package:zerosandones/core/services/food_details_holder.dart'; import 'logger.dart'; final GetIt locator = GetIt.instance; diff --git a/lib/core/services/temp.dart b/lib/core/services/food_details_holder.dart similarity index 67% rename from lib/core/services/temp.dart rename to lib/core/services/food_details_holder.dart index 37b07ee..782ab16 100644 --- a/lib/core/services/temp.dart +++ b/lib/core/services/food_details_holder.dart @@ -4,15 +4,19 @@ class FoodDetailHolder extends BaseViewModel { late String _foodTag; late String _foodImagePath; late String _foodName; + late String _foodPrice; String get foodTag => _foodTag; String get foodImagePath => _foodImagePath; String get foodName => _foodName; + String get foodPrice => _foodPrice; - setAllProperties(String foodTag, String foodImagePath, String foodName) { + setAllProperties( + String foodTag, String foodImagePath, String foodName, String fodPrice) { _foodImagePath = foodImagePath; _foodTag = foodTag; _foodName = foodName; + _foodPrice = foodPrice; notifyListeners(); } } diff --git a/lib/views/home_page/home_page_view.dart b/lib/views/home_page/home_page_view.dart index 356ace2..21edc25 100644 --- a/lib/views/home_page/home_page_view.dart +++ b/lib/views/home_page/home_page_view.dart @@ -71,7 +71,8 @@ class HomePageView extends StatelessWidget { foodImagePath: data.imageLink, foodName: data.name, foodTag: - '${mockFood[index].imageLink}-$index,'); + '${data.imageLink}-$index,', + foodPrice: data.price); viewModel.navigateItemDetailPage(); }, child: Container( diff --git a/lib/views/home_page/home_page_view_model.dart b/lib/views/home_page/home_page_view_model.dart index 857d34c..26efbfe 100644 --- a/lib/views/home_page/home_page_view_model.dart +++ b/lib/views/home_page/home_page_view_model.dart @@ -9,7 +9,7 @@ import 'package:stacked_services/stacked_services.dart'; import 'package:zerosandones/core/locator.dart'; import 'package:zerosandones/core/logger.dart'; import 'package:zerosandones/core/models/user_location.dart'; -import 'package:zerosandones/core/services/temp.dart'; +import 'package:zerosandones/core/services/food_details_holder.dart'; import 'package:zerosandones/views/item_detail_page/item_detail_page_view.dart'; class HomePageViewModel extends BaseViewModel { @@ -83,8 +83,10 @@ class HomePageViewModel extends BaseViewModel { setFoodHolderProps( {required String foodTag, required String foodImagePath, - required String foodName}) { - foodDetailHolder.setAllProperties(foodTag, foodImagePath, foodName); + required String foodName, + required String foodPrice}) { + foodDetailHolder.setAllProperties( + foodTag, foodImagePath, foodName, foodPrice); } navigateItemDetailPage() async { diff --git a/lib/views/item_detail_page/item_detail_page_view_model.dart b/lib/views/item_detail_page/item_detail_page_view_model.dart index c01e879..2f63549 100644 --- a/lib/views/item_detail_page/item_detail_page_view_model.dart +++ b/lib/views/item_detail_page/item_detail_page_view_model.dart @@ -2,7 +2,7 @@ import 'package:logger/logger.dart'; import 'package:stacked/stacked.dart'; import 'package:zerosandones/core/locator.dart'; import 'package:zerosandones/core/logger.dart'; -import 'package:zerosandones/core/services/temp.dart'; +import 'package:zerosandones/core/services/food_details_holder.dart'; class ItemDetailPageViewModel extends BaseViewModel { late Logger log; @@ -14,4 +14,5 @@ class ItemDetailPageViewModel extends BaseViewModel { String get foodName => _foodDetailHolder.foodName; String get foodImagePath => _foodDetailHolder.foodImagePath; String get foodTag => _foodDetailHolder.foodTag; + String get foodPrice => _foodDetailHolder.foodPrice; }