@@ -6,6 +6,7 @@ import 'package:e_shoppe/features/cart/bloc/cart_bloc.dart';
66import 'package:e_shoppe/shared/utils/formatter.dart' ;
77import 'package:e_shoppe/theme/app_theme.dart' ;
88import 'package:e_shoppe/features/checkout/checkout_page.dart' ;
9+ import 'package:e_shoppe/shared/responsive.dart' ;
910
1011class CartPage extends StatelessWidget {
1112 const CartPage ({super .key});
@@ -16,30 +17,35 @@ class CartPage extends StatelessWidget {
1617 appBar: AppBar (title: const Text ('Giỏ hàng' )),
1718 body: BlocBuilder <CartBloc , CartState >(
1819 builder: (context, state) {
20+ // Build main content scroll list.
21+ Widget content;
1922 if (state.items.isEmpty) {
20- return const Center (child: Text ('Cart is empty' ));
23+ content = const Center (child: Text ('Cart is empty' ));
24+ } else {
25+ content = ListView .separated (
26+ padding: const EdgeInsets .only (
27+ bottom: kBottomNavigationBarHeight + 60 ),
28+ // Extra padding so last item isn't hidden under summary & nav.
29+ itemCount: state.items.length,
30+ separatorBuilder: (_, __) => const Divider (height: 1 ),
31+ itemBuilder: (context, index) {
32+ final item = state.items[index];
33+ return _CartListTile (item: item);
34+ },
35+ );
2136 }
22- return ListView .separated (
23- itemCount: state.items.length,
24- separatorBuilder: (_, __) => const Divider (height: 1 ),
25- itemBuilder: (context, index) {
26- final item = state.items[index];
27- return _CartListTile (item: item);
28- },
29- );
30- },
31- ),
32- bottomNavigationBar: BlocBuilder <CartBloc , CartState >(
33- builder: (context, state) {
34- return Container (
37+
38+ // Summary bar that stays just above the app-wide bottom nav.
39+ final summaryBar = Container (
3540 padding: const EdgeInsets .symmetric (horizontal: 16 , vertical: 10 ),
3641 color: AppColors .white,
3742 child: Row (
3843 children: [
3944 Expanded (
40- child: Text ('Tổng: ${formatCurrency (state .total )}' ,
41- style: const TextStyle (
42- fontSize: 16 , fontWeight: FontWeight .bold))),
45+ child: Text ('Tổng: ${formatCurrency (state .total )}' ,
46+ style: const TextStyle (
47+ fontSize: 16 , fontWeight: FontWeight .bold)),
48+ ),
4349 ElevatedButton (
4450 onPressed: state.items.isNotEmpty
4551 ? () {
@@ -54,6 +60,20 @@ class CartPage extends StatelessWidget {
5460 ],
5561 ),
5662 );
63+
64+ return Stack (
65+ children: [
66+ content,
67+ Positioned (
68+ left: 0 ,
69+ right: 0 ,
70+ bottom: Responsive .isMobile (context)
71+ ? kBottomNavigationBarHeight
72+ : 0 ,
73+ child: summaryBar,
74+ ),
75+ ],
76+ );
5777 },
5878 ),
5979 );
0 commit comments