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<SlideTopRoute> { } class SlideBottomRoute extends PageRouteBuilder<SlideBottomRoute> { - SlideBottomRoute({ - this.page, - this.settings, - }) : super( + SlideBottomRoute({this.page}) + : super( pageBuilder: ( BuildContext context, Animation<double> animation, @@ -104,5 +102,4 @@ class SlideBottomRoute extends PageRouteBuilder<SlideBottomRoute> { ), ); 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<AddressScreen> { padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { - Navigator.of(context).pushNamedAndRemoveUntil( - RouteConstant.SETTINGS_SCREEN, - (Route<dynamic> 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<ManageAddress> { }); } address = finalAddress; - Navigator.of(context).pushNamedAndRemoveUntil( - RouteConstant.ADDRESS_SCREEN, - (Route<dynamic> 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<ProductPage> { @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<ProductPage> { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ - 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<ProductPage> { ], ), Text( - args.owner, + widget.product.owner, style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.white), ), @@ -159,7 +163,7 @@ class _ProductPageState extends State<ProductPage> { 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<ProductPage> { 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<ProductPage> { 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<ProductPage> { Transform.translate( offset: const Offset(120, -180), child: Image.asset( - args.image, + widget.product.image, width: 300, height: 300, ),