From 84a85bbae3d311fe3a0b7573c65cd447f14a385f Mon Sep 17 00:00:00 2001 From: Sapinder Singh Date: Wed, 24 Mar 2021 09:01:24 +0530 Subject: [PATCH 1/3] Fixed Issue #151 --- lib/dashboard.dart | 4 +- lib/helpers/constants.dart | 42 ++- lib/helpers/route_page.dart | 63 +++- lib/helpers/slide_route.dart | 7 +- lib/main.dart | 7 +- lib/views/auth/login_view.dart | 85 +++-- lib/views/auth/signup_view.dart | 19 +- lib/views/drawer_view.dart | 53 +-- lib/views/home_view.dart | 45 ++- lib/views/profile/profile_view.dart | 23 +- .../profile/settings/address_screen.dart | 82 +++-- .../profile/settings/manage_address.dart | 176 +++++----- lib/views/profile/settings/settings_view.dart | 211 ++++++------ lib/widgets/payment/payment_window.dart | 49 +-- lib/widgets/product/product_card.dart | 22 +- lib/widgets/product/product_page.dart | 308 +++++++++--------- lib/widgets/settings_item.dart | 14 +- test/widget_test.dart | 9 +- 18 files changed, 618 insertions(+), 601 deletions(-) diff --git a/lib/dashboard.dart b/lib/dashboard.dart index c965ac6..e59e61b 100644 --- a/lib/dashboard.dart +++ b/lib/dashboard.dart @@ -65,7 +65,9 @@ class _DashboardState extends State { }); }, children: [ - Home(), + Home( + pageController: _pageController, + ), Search(), const Cart(), ProfilePage(), diff --git a/lib/helpers/constants.dart b/lib/helpers/constants.dart index 5ee77a0..0e92324 100644 --- a/lib/helpers/constants.dart +++ b/lib/helpers/constants.dart @@ -16,6 +16,11 @@ class RouteConstant { static const String ORDERS_SCREEN = '/orders'; static const String SETTINGS_SCREEN = '/settings'; static const String ABOUT_SCREEN = '/about'; + static const String FAQs_SCREEN = '/faqs-screen'; + static const String ADDRESS_SCREEN = '/address-screen'; + static const String SIGN_UP_SCREEN = '/sign-up-screen'; + static const String MANAGE_ADDRESS_SCREEN = '/manage-address-screen'; + static const String PAYMENT_SUCCESSFULL = '/payment-successfull'; } class RelicColors { @@ -37,44 +42,49 @@ List productsList = [ height: 51, ), ), - ProductCard( + ProductCard( product: Product( text: 'EDISON TURNTABLE', owner: 'by Tony Stark', amount: '₹ 5035', image: 'assets/items/4.png', seller: 'SciPedia', - height: 43),), - ProductCard( + height: 43), + ), + ProductCard( product: Product( text: 'TATUNG EINSTEIN', owner: 'by Lloyd Duran', amount: '₹ 4035', image: 'assets/items/1.png', seller: 'Diz Arts', - height: 48),), - ProductCard( + height: 48), + ), + ProductCard( product: Product( text: 'MYRON DISC THROWER', owner: 'by Lloyd Duran', amount: '₹ 4035', image: 'assets/items/2.png', seller: 'AB Retial', - height: 32),), - ProductCard( - product: Product( - text: 'GUARDIAN CLOCK', - owner: 'by Claudia Davies', - amount: '₹ 4035', - image: 'assets/items/5.png', - seller: 'Electrica', - height: 19),), - ProductCard( + height: 32), + ), + ProductCard( + product: Product( + text: 'GUARDIAN CLOCK', + owner: 'by Claudia Davies', + amount: '₹ 4035', + image: 'assets/items/5.png', + seller: 'Electrica', + height: 19), + ), + ProductCard( product: Product( text: 'ROTATORY DIALER', owner: 'by Lloyd Duran', amount: '₹ 4035', image: 'assets/items/6.png', seller: 'RS Telecom', - height: 29),), + height: 29), + ), ]; diff --git a/lib/helpers/route_page.dart b/lib/helpers/route_page.dart index 951f9cd..c0693ec 100644 --- a/lib/helpers/route_page.dart +++ b/lib/helpers/route_page.dart @@ -2,11 +2,22 @@ import 'package:flutter/cupertino.dart'; import 'package:retro_shopping/dashboard.dart'; import 'package:retro_shopping/helpers/constants.dart'; import 'package:retro_shopping/helpers/slide_route.dart'; +import 'package:retro_shopping/views/auth/signup_view.dart'; +import 'package:retro_shopping/views/profile/orders.dart'; + +import 'package:retro_shopping/views/auth/login_view.dart'; import 'package:retro_shopping/views/cart_view.dart'; import 'package:retro_shopping/views/home_view.dart'; import 'package:retro_shopping/views/profile/profile_view.dart'; +import 'package:retro_shopping/views/profile/settings/about.dart'; +import 'package:retro_shopping/views/profile/settings/address_screen.dart'; +import 'package:retro_shopping/views/profile/settings/faqs_screen.dart'; +import 'package:retro_shopping/views/profile/settings/manage_address.dart'; +import 'package:retro_shopping/views/profile/settings/settings_view.dart'; +import 'package:retro_shopping/views/profile/wishlist.dart'; import 'package:retro_shopping/views/search_view.dart'; +import 'package:retro_shopping/widgets/payment/payment_successful.dart'; import 'package:retro_shopping/widgets/product/product_page.dart'; class RoutePage { @@ -16,7 +27,10 @@ class RoutePage { return SlideLeftRoute( page: const Cart(), ); - + case '/': + return PageRouteBuilder( + pageBuilder: (ctx, firstAni, secondAni) => LoginScreen(), + ); case RouteConstant.HOME_SCREEN: return SlideLeftRoute( page: Home(), @@ -24,9 +38,7 @@ class RoutePage { case RouteConstant.LOGIN_SCREEN: return SlideLeftRoute( - page: const SizedBox( - child: Text('Login Screen'), - ), + page: LoginScreen(), ); case RouteConstant.PROFILE_SCREEN: @@ -41,9 +53,7 @@ class RoutePage { case RouteConstant.ABOUT_SCREEN: return SlideLeftRoute( - page: const SizedBox( - child: Text('About'), - ), + page: AboutScreen(), ); case RouteConstant.DASHBOARD_SCREEN: @@ -52,33 +62,50 @@ class RoutePage { ); case RouteConstant.PRODUCTS_SCREEN: return SlideBottomRoute( + settings: settings, page: ProductPage(), ); case RouteConstant.WISHLIST_SCREEN: return SlideLeftRoute( - page: const SizedBox( - child: Text('Wishlist Screen'), - ), + page: const Wishlist(), + ); + case RouteConstant.MANAGE_ADDRESS_SCREEN: + return SlideLeftRoute( + page: ManageAddress(), ); case RouteConstant.ORDERS_SCREEN: return SlideLeftRoute( - page: const SizedBox( - child: Text('Orders Screen'), - ), + page: Order(), ); - + case RouteConstant.SETTINGS_SCREEN: return SlideLeftRoute( - page: const SizedBox( - child: Text('Settings Screen'), - ), + page: Settings(), + ); + case RouteConstant.PAYMENT_SUCCESSFULL: + return SlideLeftRoute( + page: const PaymentSuccessful(), + ); + case RouteConstant.FAQs_SCREEN: + return SlideLeftRoute( + page: FaqsScreen(), + ); + case RouteConstant.ADDRESS_SCREEN: + return SlideLeftRoute( + page: AddressScreen(), + ); + case RouteConstant.SIGN_UP_SCREEN: + return SlideLeftRoute( + page: SignUpScreen(), ); //TODO: Needs to have a separate screen for this default: return PageRouteBuilder( - pageBuilder: (_, Animation firstAni, Animation secondAni) => const SizedBox( + pageBuilder: + (_, Animation firstAni, Animation secondAni) => + const SizedBox( child: Text('Nothing'), ), ); diff --git a/lib/helpers/slide_route.dart b/lib/helpers/slide_route.dart index 0846b99..fa87029 100644 --- a/lib/helpers/slide_route.dart +++ b/lib/helpers/slide_route.dart @@ -79,8 +79,10 @@ class SlideTopRoute extends PageRouteBuilder { } class SlideBottomRoute extends PageRouteBuilder { - SlideBottomRoute({this.page}) - : super( + SlideBottomRoute({ + this.page, + this.settings, + }) : super( pageBuilder: ( BuildContext context, Animation animation, @@ -102,4 +104,5 @@ class SlideBottomRoute extends PageRouteBuilder { ), ); final Widget page; + final RouteSettings settings; } diff --git a/lib/main.dart b/lib/main.dart index 00851ff..287b827 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,7 +5,7 @@ import 'package:provider/provider.dart'; import 'package:retro_shopping/helpers/ad_state.dart'; import 'package:retro_shopping/helpers/constants.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; -import 'package:retro_shopping/views/auth/login_view.dart'; +import 'package:retro_shopping/helpers/route_page.dart'; Future main() async { //firebase Initialization @@ -50,10 +50,7 @@ class MyApp extends StatelessWidget { visualDensity: VisualDensity.adaptivePlatformDensity, textTheme: GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme)), - routes: { - '/login': (BuildContext context) => LoginScreen(), - }, - home: LoginScreen(), + onGenerateRoute: RoutePage.generateRoute, ), ); } diff --git a/lib/views/auth/login_view.dart b/lib/views/auth/login_view.dart index 07eff6f..20632dc 100644 --- a/lib/views/auth/login_view.dart +++ b/lib/views/auth/login_view.dart @@ -1,9 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:retro_shopping/helpers/constants.dart'; import 'package:retro_shopping/services/auth_service.dart'; -import 'package:retro_shopping/views/auth/signup_view.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; -import 'package:retro_shopping/dashboard.dart'; import 'package:retro_shopping/widgets/stacked_container.dart'; class LoginScreen extends StatefulWidget { @@ -76,37 +75,38 @@ class LoginScreenState extends State { height: height * 0.020, ), Stack( - // ignore: always_specify_types - children: [ - Transform.translate( - offset: const Offset(25, 10), - child: Container( - color: Colors.black, - width: width * 0.77, - height: height * 0.065, - ), + // ignore: always_specify_types + children: [ + Transform.translate( + offset: const Offset(25, 10), + child: Container( + color: Colors.black, + width: width * 0.77, + height: height * 0.065, ), - Padding( - padding: const EdgeInsets.only( - left: 20.0, right: 20.0), - // ignore: sized_box_for_whitespace - child: Container( - height: height * 0.07, - child: TextField( - controller: _emailController, - decoration: const InputDecoration( - labelText: 'Email Address', - labelStyle: TextStyle( - fontSize: 20.0, - color: Colors.black), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: - BorderRadius.zero))), + ), + Padding( + padding: const EdgeInsets.only( + left: 20.0, right: 20.0), + // ignore: sized_box_for_whitespace + child: Container( + height: height * 0.07, + child: TextField( + controller: _emailController, + decoration: const InputDecoration( + labelText: 'Email Address', + labelStyle: TextStyle( + fontSize: 20.0, color: Colors.black), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero), + ), ), ), - ]), + ), + ], + ), SizedBox( height: height * 0.030, ), @@ -155,10 +155,9 @@ class LoginScreenState extends State { onTap: () { debugPrint('Login!'); // ignore: always_specify_types - Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context) { - return Dashboard(); - })); + Navigator.of(context).pushNamed( + RouteConstant.DASHBOARD_SCREEN, + ); }, child: RetroButton( upperColor: Colors.black, @@ -196,13 +195,9 @@ class LoginScreenState extends State { .then( (String result) { if (result != null) { - Navigator.of(context).pushReplacement( - // ignore: always_specify_types - MaterialPageRoute( - builder: (BuildContext context) { - return Dashboard(); - }, - ), + Navigator.of(context) + .pushReplacementNamed( + RouteConstant.DASHBOARD_SCREEN, ); } }, @@ -242,12 +237,8 @@ class LoginScreenState extends State { InkWell( onTap: () { // ignore: always_specify_types - Navigator.pushReplacement(context, - MaterialPageRoute( - builder: (BuildContext context) { - debugPrint('Navigate to sign up page'); - return SignUpScreen(); - })); + Navigator.of(context) + .pushNamed(RouteConstant.SIGN_UP_SCREEN); }, child: const Text( 'SignUp', diff --git a/lib/views/auth/signup_view.dart b/lib/views/auth/signup_view.dart index a9b678e..a0057da 100644 --- a/lib/views/auth/signup_view.dart +++ b/lib/views/auth/signup_view.dart @@ -1,9 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:retro_shopping/helpers/constants.dart'; -import 'package:retro_shopping/views/auth/login_view.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; -import 'package:retro_shopping/dashboard.dart'; import 'package:retro_shopping/services/auth_service.dart'; class SignUpScreen extends StatefulWidget { @@ -205,10 +203,8 @@ class SignUpScreenState extends State { onTap: () { debugPrint('SignUp!!'); // ignore: always_specify_types - Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context) { - return LoginScreen(); - })); + Navigator.of(context).pushNamed( + RouteConstant.LOGIN_SCREEN); }, child: RetroButton( upperColor: Colors.black, @@ -248,14 +244,9 @@ class SignUpScreenState extends State { (String result) { if (result != null) { Navigator.of(context) - .pushReplacement( - // ignore: always_specify_types - MaterialPageRoute( - builder: - (BuildContext context) { - return Dashboard(); - }, - ), + .pushNamedAndRemoveUntil( + RouteConstant.DASHBOARD_SCREEN, + (Route route) => false, ); } }, diff --git a/lib/views/drawer_view.dart b/lib/views/drawer_view.dart index d43cf6c..5791030 100644 --- a/lib/views/drawer_view.dart +++ b/lib/views/drawer_view.dart @@ -1,16 +1,30 @@ import 'package:flutter/material.dart'; +import 'package:retro_shopping/helpers/constants.dart'; import 'package:retro_shopping/services/auth_service.dart'; -import 'package:retro_shopping/views/profile/settings/about.dart'; -import 'package:retro_shopping/views/auth/login_view.dart'; -import 'package:retro_shopping/views/profile/orders.dart'; -import 'package:retro_shopping/views/profile/wishlist.dart'; import '../widgets/drawer_item.dart'; -class DrawerWidget extends StatelessWidget { +class DrawerWidget extends StatefulWidget { + final PageController pageController; const DrawerWidget({ + this.pageController, Key key, }) : super(key: key); + @override + _DrawerWidgetState createState() => _DrawerWidgetState(); +} + +class _DrawerWidgetState extends State { + void goToScreen(int index) { + if (widget.pageController.initialPage == index) { + Navigator.of(context).pop(); + } else { + setState(() { + widget.pageController.jumpToPage(index); + }); + } + } + @override Widget build(BuildContext context) { return Drawer( @@ -21,25 +35,21 @@ class DrawerWidget extends StatelessWidget { icon: Icons.person, title: 'ABOUT', onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => AboutScreen()), + Navigator.of(context).pushNamed( + RouteConstant.ABOUT_SCREEN, ); }), DrawerItem( icon: Icons.shopping_cart, title: 'CART', - onTap: () {}, + onTap: () => goToScreen(2), ), DrawerItem( icon: Icons.inbox, title: 'ORDERS', onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => Order()), + Navigator.of(context).pushNamed( + RouteConstant.ORDERS_SCREEN, ); }, ), @@ -47,17 +57,15 @@ class DrawerWidget extends StatelessWidget { icon: Icons.list, title: 'WISHLIST', onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => const Wishlist()), + Navigator.of(context).pushNamed( + RouteConstant.WISHLIST_SCREEN, ); }, ), DrawerItem( icon: Icons.category, title: 'PRODUCTS', - onTap: () {}, + onTap: () => goToScreen(0), ), DrawerItem( icon: Icons.logout, @@ -65,10 +73,9 @@ class DrawerWidget extends StatelessWidget { onTap: () { AuthenticationService.signOutGoogle().then( (void res) { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (BuildContext context) => LoginScreen()), + Navigator.of(context).pushNamedAndRemoveUntil( + RouteConstant.LOGIN_SCREEN, + (Route route) => false, ); }, ); diff --git a/lib/views/home_view.dart b/lib/views/home_view.dart index 64b690d..2275e90 100644 --- a/lib/views/home_view.dart +++ b/lib/views/home_view.dart @@ -5,20 +5,36 @@ import 'package:retro_shopping/views/drawer_view.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; import 'package:retro_shopping/widgets/stacked_container.dart'; -class Home extends StatelessWidget { +class Home extends StatefulWidget { + final PageController pageController; + Home({this.pageController}); + + @override + _HomeState createState() => _HomeState(); +} + +class _HomeState extends State { final GlobalKey _drawerKey = GlobalKey(); void _openDrawer() { _drawerKey.currentState.openDrawer(); } + void _goToCart() { + setState(() { + widget.pageController.jumpToPage(2); + }); + } + @override Widget build(BuildContext context) { final double height = MediaQuery.of(context).size.height; final double width = MediaQuery.of(context).size.width; return Scaffold( key: _drawerKey, - drawer: const DrawerWidget(), + drawer: DrawerWidget( + pageController: widget.pageController, + ), body: SingleChildScrollView( primary: true, child: SizedBox( @@ -99,17 +115,20 @@ class Home extends StatelessWidget { child: const Icon(Icons.menu), ), ), - RetroButton( - upperColor: Colors.white, - lowerColor: Colors.black, - width: 35, - height: 35, - borderColor: Colors.white, - child: const Padding( - padding: EdgeInsets.only(top: 7, left: 6), - child: Icon( - RelicIcons.cart, - size: 32, + GestureDetector( + onTap: _goToCart, + child: RetroButton( + upperColor: Colors.white, + lowerColor: Colors.black, + width: 35, + height: 35, + borderColor: Colors.white, + child: const Padding( + padding: EdgeInsets.only(top: 7, left: 6), + child: Icon( + RelicIcons.cart, + size: 32, + ), ), ), ), diff --git a/lib/views/profile/profile_view.dart b/lib/views/profile/profile_view.dart index 2913dfa..4777c91 100644 --- a/lib/views/profile/profile_view.dart +++ b/lib/views/profile/profile_view.dart @@ -214,16 +214,12 @@ class TopSection extends StatelessWidget { width: 140, decoration: const BoxDecoration( image: DecorationImage( - image: AssetImage('assets/person.png'), fit: BoxFit.cover)), + image: AssetImage('assets/person.png'), + fit: BoxFit.cover)), ), - - - - Column( crossAxisAlignment: CrossAxisAlignment.start, children: const [ - Text( 'Linus', style: TextStyle( @@ -246,17 +242,14 @@ class TopSection extends StatelessWidget { ), ], ), - ], + ], ), Positioned( top: 0, right: 0, child: GestureDetector( - onTap: (){ - Navigator.push( - context, - MaterialPageRoute(builder: (BuildContext context) => Settings()), - ); + onTap: () { + Navigator.of(context).pushNamed(RouteConstant.SETTINGS_SCREEN); }, child: RetroButton( upperColor: Colors.white, @@ -264,8 +257,10 @@ class TopSection extends StatelessWidget { width: 35, height: 35, borderColor: Colors.white, - child: const Icon(Icons.settings,color: Colors.black,), - + child: const Icon( + Icons.settings, + color: Colors.black, + ), ), ), ), diff --git a/lib/views/profile/settings/address_screen.dart b/lib/views/profile/settings/address_screen.dart index 245cc3c..812f330 100644 --- a/lib/views/profile/settings/address_screen.dart +++ b/lib/views/profile/settings/address_screen.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:retro_shopping/helpers/constants.dart'; import 'package:retro_shopping/model/address_model.dart'; -import 'package:retro_shopping/views/profile/settings/manage_address.dart'; -import 'package:retro_shopping/views/profile/settings/settings_view.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; class AddressScreen extends StatefulWidget { @@ -22,11 +20,10 @@ class _AddressScreenState extends State { padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { - Navigator.pushAndRemoveUntil(context, MaterialPageRoute( - builder: (BuildContext context) { - return Settings(); - }, - ), (Route route) => false); + Navigator.of(context).pushNamedAndRemoveUntil( + RouteConstant.SETTINGS_SCREEN, + (Route route) => false, + ); }, child: RetroButton( upperColor: Colors.white, @@ -66,43 +63,43 @@ class _AddressScreenState extends State { const BoxDecoration(color: RelicColors.primaryColor), child: Column( children: [ - const SizedBox( - height: 10, - ), - Stack( - children: [ - Container( - width: - MediaQuery.of(context).size.width * 0.65 + - 3, - height: 220, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.black), + const SizedBox( + height: 10, ), - Container( - width: MediaQuery.of(context).size.width * 0.65, - height: 220, - decoration: BoxDecoration( - border: Border.all(), - borderRadius: BorderRadius.circular(10), - color: Colors.white), - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - address.toString(), - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), + Stack( + children: [ + Container( + width: + MediaQuery.of(context).size.width * 0.65 + + 3, + height: 220, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.black), + ), + Container( + width: MediaQuery.of(context).size.width * 0.65, + height: 220, + decoration: BoxDecoration( + border: Border.all(), + borderRadius: BorderRadius.circular(10), + color: Colors.white), + child: Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + address.toString(), + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + )), ), - )), + ], ), ], ), - ], - ), ), ], ), @@ -111,11 +108,8 @@ class _AddressScreenState extends State { ), GestureDetector( onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - ManageAddress())); + Navigator.of(context) + .pushNamed(RouteConstant.MANAGE_ADDRESS_SCREEN); }, child: RetroButton( upperColor: Colors.white, diff --git a/lib/views/profile/settings/manage_address.dart b/lib/views/profile/settings/manage_address.dart index ef53e85..ceb56da 100644 --- a/lib/views/profile/settings/manage_address.dart +++ b/lib/views/profile/settings/manage_address.dart @@ -153,58 +153,58 @@ class _ManageAddressState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text('Add Address', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18)), - const SizedBox( - height: 5, - ), - const Text('Line1:', - style: TextStyle(fontSize: 15)), - addressTextField(context, - icon: Icons.house, - hint: 'House No, Building Name', - text: line1, - type: TextInputType.streetAddress), - const SizedBox( - height: 8, - ), - const Text('Line2:', - style: TextStyle(fontSize: 15)), - addressTextField(context, - icon: Icons.house, - hint: 'Road name, Area Colony', - text: line2, - type: TextInputType.streetAddress), - const SizedBox( - height: 8, - ), - const Text('City:', style: TextStyle(fontSize: 15)), - addressTextField(context, - icon: Icons.location_city, - hint: 'City', - text: city, - type: TextInputType.streetAddress), - const SizedBox( - height: 8, - ), - const Text('State:', - style: TextStyle(fontSize: 15)), - addressTextField(context, - icon: Icons.location_pin, - hint: 'State', - text: state, - type: TextInputType.streetAddress), - const SizedBox( - height: 8, - ), - const Text('Pincode:', - style: TextStyle(fontSize: 15)), - addressTextField(context, - icon: Icons.location_pin, - hint: 'Pincode', - text: pincode, - type: TextInputType.number), + const Text('Add Address', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18)), + const SizedBox( + height: 5, + ), + const Text('Line1:', + style: TextStyle(fontSize: 15)), + addressTextField(context, + icon: Icons.house, + hint: 'House No, Building Name', + text: line1, + type: TextInputType.streetAddress), + const SizedBox( + height: 8, + ), + const Text('Line2:', + style: TextStyle(fontSize: 15)), + addressTextField(context, + icon: Icons.house, + hint: 'Road name, Area Colony', + text: line2, + type: TextInputType.streetAddress), + const SizedBox( + height: 8, + ), + const Text('City:', style: TextStyle(fontSize: 15)), + addressTextField(context, + icon: Icons.location_city, + hint: 'City', + text: city, + type: TextInputType.streetAddress), + const SizedBox( + height: 8, + ), + const Text('State:', + style: TextStyle(fontSize: 15)), + addressTextField(context, + icon: Icons.location_pin, + hint: 'State', + text: state, + type: TextInputType.streetAddress), + const SizedBox( + height: 8, + ), + const Text('Pincode:', + style: TextStyle(fontSize: 15)), + addressTextField(context, + icon: Icons.location_pin, + hint: 'Pincode', + text: pincode, + type: TextInputType.number), ], ), ), @@ -227,41 +227,41 @@ class _ManageAddressState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Stack( - children: [ - Container( - width: - MediaQuery.of(context).size.width * 0.65 + - 3, - height: 180, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.black), - ), - Container( - width: - MediaQuery.of(context).size.width * 0.65, - height: 180, - decoration: BoxDecoration( - border: Border.all(), - borderRadius: BorderRadius.circular(10), - color: Colors.white), - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - loc.text, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), + Stack( + children: [ + Container( + width: + MediaQuery.of(context).size.width * 0.65 + + 3, + height: 180, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.black), ), - )), + Container( + width: + MediaQuery.of(context).size.width * 0.65, + height: 180, + decoration: BoxDecoration( + border: Border.all(), + borderRadius: BorderRadius.circular(10), + color: Colors.white), + child: Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + loc.text, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + )), + ), + ], ), ], ), - ], - ), ), ], ), @@ -353,12 +353,10 @@ class _ManageAddressState extends State { }); } address = finalAddress; - Navigator.pushAndRemoveUntil(context, - MaterialPageRoute( - builder: (BuildContext context) { - return AddressScreen(); - }, - ), (Route route) => false); + Navigator.of(context).pushNamedAndRemoveUntil( + RouteConstant.ADDRESS_SCREEN, + (Route route) => false, + ); }, child: const Text( 'Yes', diff --git a/lib/views/profile/settings/settings_view.dart b/lib/views/profile/settings/settings_view.dart index b0d2386..3fc1274 100644 --- a/lib/views/profile/settings/settings_view.dart +++ b/lib/views/profile/settings/settings_view.dart @@ -1,8 +1,5 @@ import 'package:flutter/material.dart'; import 'package:retro_shopping/helpers/constants.dart'; -import 'package:retro_shopping/views/profile/settings/address_screen.dart'; -import 'package:retro_shopping/views/profile/settings/faqs_screen.dart'; -import 'package:retro_shopping/views/profile/orders.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; import 'package:retro_shopping/widgets/settings_item.dart'; @@ -59,109 +56,123 @@ class _SettingsState extends State { decoration: const BoxDecoration(color: Colors.black), ), Container( - padding: const EdgeInsets.symmetric( - vertical: 16, horizontal: 12), + padding: + const EdgeInsets.symmetric(vertical: 16, horizontal: 12), width: MediaQuery.of(context).size.width * 0.92 - 3, height: MediaQuery.of(context).size.height * 0.85 + 5, decoration: const BoxDecoration(color: RelicColors.primaryColor), child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - settingsItem(context, 'Your Orders', - Icons.bookmark_border_sharp, - tags: Order()), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - settingsItem(context, 'Change Username/\nPassword', - Icons.person), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - settingsItem(context, 'FAQs', Icons.question_answer,tags: FaqsScreen()), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - settingsItem( - context, 'Manage Address', Icons.location_pin, - tags: AddressScreen()), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - settingsItem( - context, 'T&C', Icons.quick_contacts_dialer), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - Row( - children: [ - const SizedBox( - height: 70, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + settingsItem( + context, + 'Your Orders', + Icons.bookmark_border_sharp, + routeName: RouteConstant.ORDERS_SCREEN, + push: true, + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + settingsItem( + context, + 'Change Username/\nPassword', + Icons.person, + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + settingsItem( + context, + 'FAQs', + Icons.question_answer, + routeName: RouteConstant.FAQs_SCREEN, + push: true, + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + settingsItem( + context, + 'Manage Address', + Icons.location_pin, + routeName: RouteConstant.ADDRESS_SCREEN, + push: true, + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + settingsItem(context, 'T&C', Icons.quick_contacts_dialer), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + Row( + children: [ + const SizedBox( + height: 70, + ), + Expanded( + child: Row( + children: const [ + SizedBox( + width: 5, + ), + Icon( + Icons.notifications_active, + size: 30, + color: Colors.white, + ), + SizedBox( + width: 5, + ), + Text('Notifications(on/off)', + style: TextStyle( + fontWeight: FontWeight.normal, + fontSize: 20)) + ], ), - Expanded( - child: Row( - children: const [ - SizedBox( - width: 5, - ), - Icon( - Icons.notifications_active, - size: 30, - color: Colors.white, - ), - SizedBox( - width: 5, - ), - Text('Notifications(on/off)', - style: TextStyle( - fontWeight: FontWeight.normal, - fontSize: 20)) - ], - ), - ), - Switch( - value: switchedOn, - onChanged: (bool value) { - setState(() { - switchedOn = value; - }); - }, - activeColor: Colors.white, - activeTrackColor: Colors.black, - ) - ], - ), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - settingsItem(context, 'LogOut', Icons.logout), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - settingsItem(context, 'GitHub Repo Link', - Icons.verified_user_outlined), - Padding( - padding: - const EdgeInsets.only(left: 16.0, right: 16.0), - child: divider(), - ), - ], - ), + ), + Switch( + value: switchedOn, + onChanged: (bool value) { + setState(() { + switchedOn = value; + }); + }, + activeColor: Colors.white, + activeTrackColor: Colors.black, + ) + ], + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + settingsItem( + context, + 'LogOut', + Icons.logout, + routeName: RouteConstant.LOGIN_SCREEN, + push: false, + ), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + settingsItem(context, 'GitHub Repo Link', + Icons.verified_user_outlined), + Padding( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: divider(), + ), + ], + ), ), ], ), diff --git a/lib/widgets/payment/payment_window.dart b/lib/widgets/payment/payment_window.dart index f53a793..79db3a4 100644 --- a/lib/widgets/payment/payment_window.dart +++ b/lib/widgets/payment/payment_window.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:retro_shopping/helpers/constants.dart'; -import 'package:retro_shopping/widgets/payment/payment_successful.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; import 'package:razorpay_flutter/razorpay_flutter.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -52,8 +51,7 @@ class _PaymentWindowState extends State { Future _handlePaymentSuccess(PaymentSuccessResponse response) async { Fluttertoast.showToast(msg: 'SUCCESS: ${response.paymentId}'); - Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) => const PaymentSuccessful())); + Navigator.of(context).pushNamed(RouteConstant.PAYMENT_SUCCESSFULL); } void _handlePaymentError(PaymentFailureResponse response) { @@ -111,7 +109,8 @@ class _PaymentWindowState extends State { height: height * 0.005, ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + padding: + const EdgeInsets.symmetric(horizontal: 10, vertical: 2), child: Column( children: [ SizedBox( @@ -137,7 +136,7 @@ class _PaymentWindowState extends State { children: [ Container( height: height * 0.4, - width: width*0.08, + width: width * 0.08, // height: 30, // width: 30, decoration: BoxDecoration( @@ -167,15 +166,17 @@ class _PaymentWindowState extends State { child: Padding( padding: const EdgeInsets.all(4.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ FittedBox( child: Text( 'Premium Next Day Shipping ', style: TextStyle( fontSize: 16, - color: - cnt2 == 1 ? Colors.white : Colors.black, + color: cnt2 == 1 + ? Colors.white + : Colors.black, ), ), ), @@ -184,8 +185,9 @@ class _PaymentWindowState extends State { '₹31', style: TextStyle( fontSize: 16, - color: - cnt2 == 1 ? Colors.white : Colors.black, + color: cnt2 == 1 + ? Colors.white + : Colors.black, ), ), ), @@ -222,7 +224,7 @@ class _PaymentWindowState extends State { children: [ Container( height: height * 0.4, - width: width*0.08, + width: width * 0.08, // height: 30, // width: 30, decoration: BoxDecoration( @@ -247,34 +249,37 @@ class _PaymentWindowState extends State { ), ), Container( - width: width*0.7, + width: width * 0.7, //width: width * 0.7, color: cnt1 == 1 ? Colors.black : Colors.grey[300], child: Padding( padding: const EdgeInsets.all(4.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ FittedBox( child: Text( 'Basic Shipping', style: TextStyle( fontSize: 16, - color: - cnt1 == 1 ? Colors.white : Colors.black, + color: cnt1 == 1 + ? Colors.white + : Colors.black, ), ), ), FittedBox( - child: Text( - '₹31', - style: TextStyle( - fontSize: 16, - color: - cnt1 == 1 ? Colors.white : Colors.black, + child: Text( + '₹31', + style: TextStyle( + fontSize: 16, + color: cnt1 == 1 + ? Colors.white + : Colors.black, + ), ), ), - ), ], ), ), diff --git a/lib/widgets/product/product_card.dart b/lib/widgets/product/product_card.dart index 19d6fa6..e252f87 100644 --- a/lib/widgets/product/product_card.dart +++ b/lib/widgets/product/product_card.dart @@ -1,31 +1,19 @@ import 'package:flutter/material.dart'; import 'package:retro_shopping/helpers/constants.dart'; -import 'package:retro_shopping/helpers/slide_route.dart'; import 'package:retro_shopping/model/product_model.dart'; -import 'package:retro_shopping/widgets/product/product_page.dart'; class ProductCard extends StatelessWidget { - const ProductCard( - {Key key, - this.product}) - : super(key: key); + const ProductCard({Key key, this.product}) : super(key: key); final Product product; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { - Navigator.push( - context, - SlideBottomRoute( - page: ProductPage( - text: product.text, - owner: product.owner, - image: product.image, - prodHeight: product.height, - seller: product.seller, - amount: product.amount, - ))); + Navigator.of(context).pushNamed( + RouteConstant.PRODUCTS_SCREEN, + arguments: product, + ); }, child: Container( width: 155.0, diff --git a/lib/widgets/product/product_page.dart b/lib/widgets/product/product_page.dart index e670ea1..a989e9c 100644 --- a/lib/widgets/product/product_page.dart +++ b/lib/widgets/product/product_page.dart @@ -3,26 +3,12 @@ import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:provider/provider.dart'; import 'package:retro_shopping/helpers/ad_state.dart'; import 'package:retro_shopping/helpers/constants.dart'; - +import 'package:retro_shopping/model/product_model.dart'; import '../../helpers/app_icons.dart'; import '../retro_button.dart'; // ignore: must_be_immutable class ProductPage extends StatefulWidget { - ProductPage( - {this.text, - this.prodHeight, - this.seller, - this.owner, - this.amount, - this.image}); - String text; - String image; - String owner; - String seller; - int prodHeight; - String amount; - @override _ProductPageState createState() => _ProductPageState(); } @@ -50,6 +36,7 @@ class _ProductPageState extends State { @override Widget build(BuildContext context) { + final Product args = ModalRoute.of(context).settings.arguments as Product; final double height = MediaQuery.of(context).size.height; final double width = MediaQuery.of(context).size.width; return Scaffold( @@ -116,7 +103,7 @@ class _ProductPageState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - for (String s in widget.text.split(' ')) + for (String s in args.text.split(' ')) Text( s, style: const TextStyle( @@ -148,7 +135,7 @@ class _ProductPageState extends State { ], ), Text( - widget.owner, + args.owner, style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.white), ), @@ -172,7 +159,7 @@ class _ProductPageState extends State { fontSize: 11), ), Text( - widget.prodHeight.toString(), + args.height.toString(), overflow: TextOverflow.ellipsis, style: const TextStyle( fontWeight: FontWeight.bold, @@ -193,7 +180,7 @@ class _ProductPageState extends State { fontSize: 11), ), Text( - widget.seller, + args.seller, overflow: TextOverflow.ellipsis, style: const TextStyle( fontWeight: FontWeight.bold, @@ -217,7 +204,7 @@ class _ProductPageState extends State { borderColor: Colors.white, child: Center( child: Text( - widget.amount, + args.amount, style: const TextStyle( fontWeight: FontWeight.bold, color: RelicColors.primaryColor, @@ -228,8 +215,145 @@ class _ProductPageState extends State { SizedBox( height: height * 0.025, ), - discription(), - const SizedBox(height: 60), + SizedBox( + height: height * 0.55, + width: width, + child: Stack( + children: [ + Transform.translate( + offset: const Offset(10, 10), + child: Container( + width: width * 0.9, + height: height * 0.54, + decoration: const BoxDecoration( + color: RelicColors.primaryBlack, + ), + ), + ), + Container( + width: width * 0.9, + height: height * 0.54, + decoration: const BoxDecoration( + color: RelicColors.primaryColor, + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 20), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + SizedBox( + height: height * 0.05, + ), + SizedBox( + width: width * 0.4, + child: const Text( + 'HISTORICAL SIGNIFICANCE', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white), + ), + ), + SizedBox( + height: height * .005, + ), + const Text( + 'A British Royal Doulton glazed stoneware antique with lovely shades of blue, grey and gold.', + style: TextStyle( + // fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white), + ), + SizedBox( + height: height * .02, + ), + const Text( + 'CONDITION', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white), + ), + SizedBox( + height: height * .005, + ), + const Text( + 'Mild scratches and normal signs of wear and tear might be there. Still, All antiques must be handled with care,', + style: TextStyle( + // fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white), + ), + ], + ), + )), + Transform.translate( + offset: const Offset(120, -180), + child: Image.asset( + args.image, + width: 300, + height: 300, + ), + ), + Transform.translate( + offset: const Offset(210, 375), + child: Row( + children: [ + RetroButton( + upperColor: Colors.white, + lowerColor: Colors.black, + width: width * 0.35, + height: height * 0.05, + borderColor: Colors.white, + child: Center( + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: const [ + Icon( + Icons.add, + color: RelicColors.primaryColor, + ), + Text( + 'ADD TO CART', + style: TextStyle( + color: RelicColors.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 15), + ), + ], + ), + ), + ) + ], + ), + ), + Transform.translate( + offset: const Offset(145, 375), + child: Row( + children: [ + RetroButton( + upperColor: Colors.white, + lowerColor: Colors.black, + width: width * 0.12, + height: height * 0.05, + borderColor: Colors.white, + child: const Center( + child: Icon( + Icons.favorite, + color: RelicColors.primaryColor, + ), + ), + ) + ], + ), + ), + ], + ), + ), + const SizedBox(height: 60), ], ), ), @@ -249,144 +373,4 @@ class _ProductPageState extends State { ), ); } - - Widget discription() { - final double height = MediaQuery.of(context).size.height; - final double width = MediaQuery.of(context).size.width; - return SizedBox( - height: height * 0.55, - width: width, - child: Stack( - children: [ - Transform.translate( - offset: const Offset(10, 10), - child: Container( - width: width * 0.9, - height: height * 0.54, - decoration: const BoxDecoration( - color: RelicColors.primaryBlack, - ), - ), - ), - Container( - width: width * 0.9, - height: height * 0.54, - decoration: const BoxDecoration( - color: RelicColors.primaryColor, - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: height * 0.05, - ), - SizedBox( - width: width * 0.4, - child: const Text( - 'HISTORICAL SIGNIFICANCE', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white), - ), - ), - SizedBox( - height: height * .005, - ), - const Text( - 'A British Royal Doulton glazed stoneware antique with lovely shades of blue, grey and gold.', - style: TextStyle( - // fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white), - ), - SizedBox( - height: height * .02, - ), - const Text( - 'CONDITION', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white), - ), - SizedBox( - height: height * .005, - ), - const Text( - 'Mild scratches and normal signs of wear and tear might be there. Still, All antiques must be handled with care,', - style: TextStyle( - // fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.white), - ), - ], - ), - )), - Transform.translate( - offset: const Offset(120, -180), - child: Image.asset( - widget.image, - width: 300, - height: 300, - ), - ), - Transform.translate( - offset: const Offset(210, 375), - child: Row( - children: [ - RetroButton( - upperColor: Colors.white, - lowerColor: Colors.black, - width: width * 0.35, - height: height * 0.05, - borderColor: Colors.white, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: const [ - Icon( - Icons.add, - color: RelicColors.primaryColor, - ), - Text( - 'ADD TO CART', - style: TextStyle( - color: RelicColors.primaryColor, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ], - ), - ), - ) - ], - ), - ), - Transform.translate( - offset: const Offset(145, 375), - child: Row( - children: [ - RetroButton( - upperColor: Colors.white, - lowerColor: Colors.black, - width: width * 0.12, - height: height * 0.05, - borderColor: Colors.white, - child: const Center( - child: Icon( - Icons.favorite, - color: RelicColors.primaryColor, - ), - ), - ) - ], - ), - ), - ], - ), - ); - } } diff --git a/lib/widgets/settings_item.dart b/lib/widgets/settings_item.dart index 37daf1b..04b95df 100644 --- a/lib/widgets/settings_item.dart +++ b/lib/widgets/settings_item.dart @@ -1,14 +1,16 @@ import 'package:flutter/material.dart'; Widget settingsItem(BuildContext context, String text, IconData ic, - {Widget tags}) { + {String routeName, bool push}) { return InkWell( onTap: () { - if (tags != null) { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => tags)); + if (routeName != null) { + if (push) { + Navigator.of(context).pushNamed(routeName); + } else { + Navigator.of(context).pushNamedAndRemoveUntil( + routeName, (Route route) => false); + } } }, child: Row( diff --git a/test/widget_test.dart b/test/widget_test.dart index 694fac4..a3fcb0a 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -49,14 +49,7 @@ void main() { data: const MediaQueryData(), child: Directionality( textDirection: TextDirection.ltr, - child: ProductPage( - text: 'text', - image: 'assets/items/3.png', - owner: 'owner', - amount: 'amount', - prodHeight: 10, - seller: 'seller', - ), + child: ProductPage(), ), )); From 5b592f2828b364b4a46afe7d616f05689dcb7844 Mon Sep 17 00:00:00 2001 From: Sapinder Singh Date: Wed, 24 Mar 2021 09:48:55 +0530 Subject: [PATCH 2/3] back to shop button on cart screen made to work. --- lib/dashboard.dart | 4 ++- lib/helpers/route_page.dart | 2 +- lib/views/cart_view.dart | 57 +++++++++++++++++++++---------------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/lib/dashboard.dart b/lib/dashboard.dart index e59e61b..c4be991 100644 --- a/lib/dashboard.dart +++ b/lib/dashboard.dart @@ -69,7 +69,9 @@ class _DashboardState extends State { pageController: _pageController, ), Search(), - const Cart(), + Cart( + pageController: _pageController, + ), ProfilePage(), ], ), diff --git a/lib/helpers/route_page.dart b/lib/helpers/route_page.dart index c0693ec..02cfe64 100644 --- a/lib/helpers/route_page.dart +++ b/lib/helpers/route_page.dart @@ -25,7 +25,7 @@ class RoutePage { switch (settings.name) { case RouteConstant.CART_SCREEN: return SlideLeftRoute( - page: const Cart(), + page: Cart(), ); case '/': return PageRouteBuilder( diff --git a/lib/views/cart_view.dart b/lib/views/cart_view.dart index 2acc4c0..69c8993 100644 --- a/lib/views/cart_view.dart +++ b/lib/views/cart_view.dart @@ -5,7 +5,9 @@ import 'package:retro_shopping/widgets/payment/payment_window.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; class Cart extends StatefulWidget { - const Cart({ + final PageController pageController; + Cart({ + this.pageController, Key key, }) : super(key: key); @@ -43,30 +45,37 @@ class _CartState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RetroButton( - upperColor: Colors.white, - lowerColor: Colors.black, - height: height * 0.045, - width: width * 0.4, - borderColor: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - Icon( - Icons.arrow_back, - size: 20, - ), - Text( - ' back to shop', - style: TextStyle( - fontFamily: 'pix M 8pt', - fontSize: 15, - fontWeight: FontWeight.bold, - color: RelicColors.primaryBlack, + GestureDetector( + onTap: () { + setState(() { + widget.pageController.jumpTo(0); + }); + }, + child: RetroButton( + upperColor: Colors.white, + lowerColor: Colors.black, + height: height * 0.045, + width: width * 0.4, + borderColor: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon( + Icons.arrow_back, + size: 20, ), - // textAlign: TextAlign.left, - ), - ], + Text( + ' back to shop', + style: TextStyle( + fontFamily: 'pix M 8pt', + fontSize: 15, + fontWeight: FontWeight.bold, + color: RelicColors.primaryBlack, + ), + // textAlign: TextAlign.left, + ), + ], + ), ), ), RetroButton( From e44022f57380e09a866e39b59266bd5df6bbcbf5 Mon Sep 17 00:00:00 2001 From: Sapinder Singh Date: Wed, 24 Mar 2021 16:58:45 +0530 Subject: [PATCH 3/3] Made the changes Issue #151 --- lib/helpers/route_page.dart | 11 +++++------ lib/helpers/slide_route.dart | 7 ++----- lib/main.dart | 1 + lib/views/profile/settings/address_screen.dart | 5 +---- lib/views/profile/settings/manage_address.dart | 5 +---- lib/widgets/product/product_page.dart | 18 +++++++++++------- 6 files changed, 21 insertions(+), 26 deletions(-) diff --git a/lib/helpers/route_page.dart b/lib/helpers/route_page.dart index 02cfe64..eef15a5 100644 --- a/lib/helpers/route_page.dart +++ b/lib/helpers/route_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:retro_shopping/dashboard.dart'; import 'package:retro_shopping/helpers/constants.dart'; import 'package:retro_shopping/helpers/slide_route.dart'; +import 'package:retro_shopping/model/product_model.dart'; import 'package:retro_shopping/views/auth/signup_view.dart'; import 'package:retro_shopping/views/profile/orders.dart'; @@ -27,10 +28,6 @@ class RoutePage { return SlideLeftRoute( page: Cart(), ); - case '/': - return PageRouteBuilder( - pageBuilder: (ctx, firstAni, secondAni) => LoginScreen(), - ); case RouteConstant.HOME_SCREEN: return SlideLeftRoute( page: Home(), @@ -61,9 +58,11 @@ class RoutePage { page: Dashboard(), ); case RouteConstant.PRODUCTS_SCREEN: + Product product = settings.arguments as Product; return SlideBottomRoute( - settings: settings, - page: ProductPage(), + page: ProductPage( + product: product, + ), ); case RouteConstant.WISHLIST_SCREEN: diff --git a/lib/helpers/slide_route.dart b/lib/helpers/slide_route.dart index fa87029..0846b99 100644 --- a/lib/helpers/slide_route.dart +++ b/lib/helpers/slide_route.dart @@ -79,10 +79,8 @@ class SlideTopRoute extends PageRouteBuilder { } class SlideBottomRoute extends PageRouteBuilder { - SlideBottomRoute({ - this.page, - this.settings, - }) : super( + SlideBottomRoute({this.page}) + : super( pageBuilder: ( BuildContext context, Animation animation, @@ -104,5 +102,4 @@ class SlideBottomRoute extends PageRouteBuilder { ), ); final Widget page; - final RouteSettings settings; } diff --git a/lib/main.dart b/lib/main.dart index 287b827..caf4759 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,6 +51,7 @@ class MyApp extends StatelessWidget { textTheme: GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme)), onGenerateRoute: RoutePage.generateRoute, + initialRoute: RouteConstant.DASHBOARD_SCREEN, ), ); } diff --git a/lib/views/profile/settings/address_screen.dart b/lib/views/profile/settings/address_screen.dart index 812f330..90d1ad7 100644 --- a/lib/views/profile/settings/address_screen.dart +++ b/lib/views/profile/settings/address_screen.dart @@ -20,10 +20,7 @@ class _AddressScreenState extends State { padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { - Navigator.of(context).pushNamedAndRemoveUntil( - RouteConstant.SETTINGS_SCREEN, - (Route route) => false, - ); + Navigator.of(context).pop(); }, child: RetroButton( upperColor: Colors.white, diff --git a/lib/views/profile/settings/manage_address.dart b/lib/views/profile/settings/manage_address.dart index ceb56da..420ac90 100644 --- a/lib/views/profile/settings/manage_address.dart +++ b/lib/views/profile/settings/manage_address.dart @@ -353,10 +353,7 @@ class _ManageAddressState extends State { }); } address = finalAddress; - Navigator.of(context).pushNamedAndRemoveUntil( - RouteConstant.ADDRESS_SCREEN, - (Route route) => false, - ); + Navigator.of(context).pop(); }, child: const Text( 'Yes', diff --git a/lib/widgets/product/product_page.dart b/lib/widgets/product/product_page.dart index a989e9c..43bcbd4 100644 --- a/lib/widgets/product/product_page.dart +++ b/lib/widgets/product/product_page.dart @@ -9,6 +9,10 @@ import '../retro_button.dart'; // ignore: must_be_immutable class ProductPage extends StatefulWidget { + final Product product; + +const ProductPage({this.product}); + @override _ProductPageState createState() => _ProductPageState(); } @@ -36,7 +40,7 @@ class _ProductPageState extends State { @override Widget build(BuildContext context) { - final Product args = ModalRoute.of(context).settings.arguments as Product; + final double height = MediaQuery.of(context).size.height; final double width = MediaQuery.of(context).size.width; return Scaffold( @@ -103,7 +107,7 @@ class _ProductPageState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - for (String s in args.text.split(' ')) + for (String s in widget.product.text.split(' ')) Text( s, style: const TextStyle( @@ -135,7 +139,7 @@ class _ProductPageState extends State { ], ), Text( - args.owner, + widget.product.owner, style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.white), ), @@ -159,7 +163,7 @@ class _ProductPageState extends State { fontSize: 11), ), Text( - args.height.toString(), + widget.product.height.toString(), overflow: TextOverflow.ellipsis, style: const TextStyle( fontWeight: FontWeight.bold, @@ -180,7 +184,7 @@ class _ProductPageState extends State { fontSize: 11), ), Text( - args.seller, + widget.product.seller, overflow: TextOverflow.ellipsis, style: const TextStyle( fontWeight: FontWeight.bold, @@ -204,7 +208,7 @@ class _ProductPageState extends State { borderColor: Colors.white, child: Center( child: Text( - args.amount, + widget.product.amount, style: const TextStyle( fontWeight: FontWeight.bold, color: RelicColors.primaryColor, @@ -292,7 +296,7 @@ class _ProductPageState extends State { Transform.translate( offset: const Offset(120, -180), child: Image.asset( - args.image, + widget.product.image, width: 300, height: 300, ),