|
1 | 1 | // ignore_for_file: must_be_immutable
|
2 | 2 |
|
| 3 | +import 'package:emart/common_widgets/exit_dialog.dart'; |
3 | 4 | import 'package:emart/consts/consts.dart';
|
4 | 5 | import 'package:emart/views/cart_screen_view/cart_screen.dart';
|
5 | 6 | import 'package:emart/views/category_screen_view/category_screen.dart';
|
@@ -32,25 +33,35 @@ class Home extends StatelessWidget {
|
32 | 33 |
|
33 | 34 | @override
|
34 | 35 | Widget build(BuildContext context) {
|
35 |
| - return Scaffold( |
36 |
| - body: Column( |
37 |
| - children: [ |
38 |
| - Obx( |
39 |
| - () => Expanded( |
40 |
| - child: navBody.elementAt(controller.currentNavIndex.value), |
| 36 | + return WillPopScope( |
| 37 | + onWillPop: () async { |
| 38 | + showDialog( |
| 39 | + context: context, |
| 40 | + barrierDismissible: false, |
| 41 | + builder: (context) => exitDialog(context), |
| 42 | + ); |
| 43 | + return false; |
| 44 | + }, |
| 45 | + child: Scaffold( |
| 46 | + body: Column( |
| 47 | + children: [ |
| 48 | + Obx( |
| 49 | + () => Expanded( |
| 50 | + child: navBody.elementAt(controller.currentNavIndex.value), |
| 51 | + ), |
41 | 52 | ),
|
| 53 | + ], |
| 54 | + ), |
| 55 | + bottomNavigationBar: Obx( |
| 56 | + () => BottomNavigationBar( |
| 57 | + currentIndex: controller.currentNavIndex.value, |
| 58 | + type: BottomNavigationBarType.fixed, |
| 59 | + selectedLabelStyle: const TextStyle(fontFamily: semibold), |
| 60 | + selectedItemColor: redColor, |
| 61 | + items: navbarItems, |
| 62 | + backgroundColor: whiteColor, |
| 63 | + onTap: (newIndex) => controller.currentNavIndex.value = newIndex, |
42 | 64 | ),
|
43 |
| - ], |
44 |
| - ), |
45 |
| - bottomNavigationBar: Obx( |
46 |
| - () => BottomNavigationBar( |
47 |
| - currentIndex: controller.currentNavIndex.value, |
48 |
| - type: BottomNavigationBarType.fixed, |
49 |
| - selectedLabelStyle: const TextStyle(fontFamily: semibold), |
50 |
| - selectedItemColor: redColor, |
51 |
| - items: navbarItems, |
52 |
| - backgroundColor: whiteColor, |
53 |
| - onTap: (newIndex) => controller.currentNavIndex.value = newIndex, |
54 | 65 | ),
|
55 | 66 | ),
|
56 | 67 | );
|
|
0 commit comments