From b1b01f03b825c2b8bd44145f5e494f43313fdc4c Mon Sep 17 00:00:00 2001 From: AshutoshPatole Date: Sat, 13 Nov 2021 19:35:42 +0530 Subject: [PATCH] Change the entire not serviceable flow --- lib/views/home_page/home_page_view.dart | 191 +++++++++--------- lib/views/home_page/home_page_view_model.dart | 2 +- .../not_serviceable_location.dart | 44 ++-- 3 files changed, 129 insertions(+), 108 deletions(-) diff --git a/lib/views/home_page/home_page_view.dart b/lib/views/home_page/home_page_view.dart index 21edc25..bd350b9 100644 --- a/lib/views/home_page/home_page_view.dart +++ b/lib/views/home_page/home_page_view.dart @@ -30,102 +30,107 @@ class HomePageView extends StatelessWidget { builder: (context, snapshot) { return viewModel.serviceableDistance < 0 ? const GetLocationCircularProgressIndicator() - : viewModel.isServiceableDistance - ? SingleChildScrollView( - physics: const BouncingScrollPhysics(), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - HomeHeader(address: viewModel.address), - SizedBox( - height: size.height * 0.05, - ), - GestureDetector( - onTap: () { - // TODO : Open a page with terms and condition for the coupon code. - }, - child: const Coupon(), - ), - SizedBox( - height: size.height * 0.05, - ), - const Text( - "Categories", - style: AppTheme.title, - ), - SizedBox( - height: size.height * 0.25, - child: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.horizontal, - physics: const BouncingScrollPhysics(), - itemCount: mockFood.length, - itemBuilder: (context, index) { - final data = mockFood[index]; - return GestureDetector( - onTap: () { - viewModel.setFoodHolderProps( - foodImagePath: data.imageLink, - foodName: data.name, - foodTag: - '${data.imageLink}-$index,', - foodPrice: data.price); - viewModel.navigateItemDetailPage(); - }, - child: Container( - width: size.width * 0.35, - height: size.height * 0.1, - margin: const EdgeInsets.all(10), - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - color: AppTheme.primaryColor, - borderRadius: - BorderRadius.circular(20.0), - boxShadow: [ - BoxShadow( - color: AppTheme.primaryColor - .withOpacity(0.75), - spreadRadius: 1, - blurRadius: 5, - offset: const Offset(2, 4.5), - ) - ], + : SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + HomeHeader(address: viewModel.address), + SizedBox( + height: size.height * 0.01, + ), + viewModel.isServiceableDistance + ? SizedBox( + height: size.height * 0.03, + ) + : const NotServiceableLocation(), + SizedBox( + height: size.height * 0.02, + ), + GestureDetector( + onTap: () { + // TODO : Open a page with terms and condition for the coupon code. + }, + child: const Coupon(), + ), + SizedBox( + height: size.height * 0.05, + ), + const Text( + "Categories", + style: AppTheme.title, + ), + SizedBox( + height: size.height * 0.25, + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + physics: const BouncingScrollPhysics(), + itemCount: mockFood.length, + itemBuilder: (context, index) { + final data = mockFood[index]; + return GestureDetector( + onTap: () { + viewModel.setFoodHolderProps( + foodImagePath: data.imageLink, + foodName: data.name, + foodTag: + '${data.imageLink}-$index,', + foodPrice: data.price); + viewModel.navigateItemDetailPage(); + }, + child: Container( + width: size.width * 0.35, + height: size.height * 0.1, + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: AppTheme.primaryColor, + borderRadius: + BorderRadius.circular(20.0), + boxShadow: [ + BoxShadow( + color: AppTheme.primaryColor + .withOpacity(0.75), + spreadRadius: 1, + blurRadius: 5, + offset: const Offset(2, 4.5), + ) + ], + ), + child: Column( + children: [ + SizedBox( + height: size.height * 0.025, ), - child: Column( - children: [ - SizedBox( - height: size.height * 0.025, - ), - Hero( - tag: - '${mockFood[index].imageLink}-$index,', - child: Image.asset( - data.imageLink, - ), - ), - const Spacer(), - Text( - data.name, - style: const TextStyle( - color: Colors.white, - fontSize: 16.0, - ), - ), - ], + Hero( + tag: + '${mockFood[index].imageLink}-$index,', + child: Image.asset( + data.imageLink, + ), ), - ), - ); - }, - ), - ), - ], + const Spacer(), + Text( + data.name, + style: const TextStyle( + color: Colors.white, + fontSize: 16.0, + ), + ), + ], + ), + ), + ); + }, + ), ), - ), - ) - : const NotServiceableLocation(); + ], + ), + ), + ); }, ), ), diff --git a/lib/views/home_page/home_page_view_model.dart b/lib/views/home_page/home_page_view_model.dart index 26efbfe..b491ce1 100644 --- a/lib/views/home_page/home_page_view_model.dart +++ b/lib/views/home_page/home_page_view_model.dart @@ -44,7 +44,7 @@ class HomePageViewModel extends BaseViewModel { serviceableDistance = Geolocator.distanceBetween( locationData.latitude!, locationData.longitude!, - 12.7806459999, + 20.7806459999, 80.2186767, ) / 1000; diff --git a/lib/widgets/dumb_widgets/not_serviceable_location.dart b/lib/widgets/dumb_widgets/not_serviceable_location.dart index 42c6f73..8eb55af 100644 --- a/lib/widgets/dumb_widgets/not_serviceable_location.dart +++ b/lib/widgets/dumb_widgets/not_serviceable_location.dart @@ -1,27 +1,43 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; class NotServiceableLocation extends StatelessWidget { const NotServiceableLocation({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SvgPicture.asset( - 'assets/svg/nolocation.svg', - height: 300, - width: 300, - ), - const Padding( - padding: EdgeInsets.all(16.0), - child: Text( - "Sorry! We are not available at this location till now but we hope reaching your nearest location soon.", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.w600, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 32.0), + child: Container( + width: size.width, + height: size.height * 0.04, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.0), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + CupertinoIcons.info_circle, + size: 20.0, + color: Colors.red, + ), + SizedBox( + width: 10, + ), + Text( + "Sorry! We are not available at this location", + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.w600, + color: Colors.red, + ), + ), + ], ), ), )