diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 19faaa8..b641993 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -48,4 +48,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 -COCOAPODS: 1.14.2 +COCOAPODS: 1.12.1 diff --git a/lib/ui/views/home/home_view.dart b/lib/ui/views/home/home_view.dart index 3551db8..d3cbd1a 100644 --- a/lib/ui/views/home/home_view.dart +++ b/lib/ui/views/home/home_view.dart @@ -60,88 +60,92 @@ class HomeView extends StackedView { ), ), body: SafeArea( - child: OverlayLoader( - isBusy: viewModel.isBusy, - content: Column( - children: [ - SizedBox( - height: 18.h, - ), - Builder( - builder: (context) { - //Error - if (viewModel.hasError) { - return Center( - child: Column( - children: [ - Lottie.asset( - AppImages.noDishFound, - width: 200, - height: 200, - ), - Text( - viewModel.modelMessage ?? S.current.unknown_error, - textAlign: TextAlign.center, - ), - ], - ), - ); - } - //Data not yet ready - if (!viewModel.dataReady) { - return Align( - heightFactor: 20, - alignment: Alignment.bottomCenter, - child: Text( - viewModel.modelMessage ?? - S.current.generate_recipe_contents, - ), - ); - } + child: RefreshIndicator.adaptive( + onRefresh: () => viewModel.refreshHomeData(), + child: OverlayLoader( + isBusy: viewModel.isBusy, + content: Column( + children: [ + SizedBox( + height: 18.h, + ), + Builder( + builder: (context) { + //Error + if (viewModel.hasError) { + return Center( + child: Column( + children: [ + Lottie.asset( + AppImages.noDishFound, + width: 200, + height: 200, + ), + Text( + viewModel.modelMessage ?? S.current.unknown_error, + textAlign: TextAlign.center, + ), + ], + ), + ); + } + //Data not yet ready + if (!viewModel.dataReady) { + return Align( + heightFactor: 20, + alignment: Alignment.bottomCenter, + child: Text( + viewModel.modelMessage ?? + S.current.generate_recipe_contents, + ), + ); + } - // Empty - if (viewModel.data == null || viewModel.data!.isEmpty) { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Lottie.asset( - AppImages.noDishFound, - width: 200, - height: 200, - ), - Text(S.current.no_dish_available), - ], - ), - ); - } + // Empty + if (viewModel.data == null || viewModel.data!.isEmpty) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Lottie.asset( + AppImages.noDishFound, + width: 200, + height: 200, + ), + Text(S.current.no_dish_available), + ], + ), + ); + } - // Loaded - return Expanded( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: sidePadding), - child: GridView.builder( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - childAspectRatio: 0.90, - mainAxisSpacing: 20.h, - crossAxisSpacing: 16.w, + // Loaded + return Expanded( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: sidePadding), + child: GridView.builder( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.90, + mainAxisSpacing: 20.h, + crossAxisSpacing: 16.w, + ), + itemCount: viewModel.data?.length, + itemBuilder: (context, index) { + final recipe = viewModel.data?.elementAt(index); + return ProductItem( + recipe: recipe, + onTap: () => + viewModel.navigateToDishDetailsView(recipe), + ); + }, ), - itemCount: viewModel.data?.length, - itemBuilder: (context, index) { - final recipe = viewModel.data?.elementAt(index); - return ProductItem( - recipe: recipe, - onTap: () => - viewModel.navigateToDishDetailsView(recipe), - ); - }, ), - ), - ); - }, - ), - ], + ); + }, + ), + ], + ), ), ), ), diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index 93c4506..b9e341a 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -27,6 +27,10 @@ class HomeViewModel extends FutureViewModel?> { } } + Future refreshHomeData() async { + await initialise(); + } + void navigateToHome() { _navigationService.back(); }