- Bottom navbar: Home, Pesanan, Bayar (tombol tengah ke kode bayar), Community, Profil; menu EnakCommunity di beranda pindah ke tab - Image placeholder: logo Enaklo diperbesar, ilustrasi gelas dihapus - Fix assertion Navigator saat PIN gagal karena error non-PIN: flushbar kini tampil lewat onFailure setelah sheet PIN tertutup (bayar, tukar, transfer) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
2.9 KiB
Dart
104 lines
2.9 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../common/theme/theme.dart';
|
|
|
|
class MainBottomNavbar extends StatelessWidget {
|
|
final TabsRouter tabsRouter;
|
|
final VoidCallback onPayTap;
|
|
const MainBottomNavbar({
|
|
super.key,
|
|
required this.tabsRouter,
|
|
required this.onPayTap,
|
|
});
|
|
|
|
/// Slot tengah hanya tempat label tombol Bayar; lingkarannya
|
|
/// [MainPayButton] yang menempel di atas navbar.
|
|
static const int _payIndex = 2;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final activeIndex = tabsRouter.activeIndex;
|
|
|
|
return BottomNavigationBar(
|
|
currentIndex: activeIndex >= _payIndex ? activeIndex + 1 : activeIndex,
|
|
onTap: (index) {
|
|
if (index == _payIndex) {
|
|
onPayTap();
|
|
return;
|
|
}
|
|
tabsRouter.setActiveIndex(index > _payIndex ? index - 1 : index);
|
|
},
|
|
items: const [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.home),
|
|
label: 'Home',
|
|
tooltip: 'Home',
|
|
),
|
|
// BottomNavigationBarItem(
|
|
// icon: Icon(Icons.discount),
|
|
// label: 'Voucher',
|
|
// tooltip: 'Voucher',
|
|
// ),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.list),
|
|
label: 'Pesanan',
|
|
tooltip: 'Pesanan',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: SizedBox(height: 24),
|
|
label: 'Bayar',
|
|
tooltip: 'Bayar di kasir',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.groups),
|
|
label: 'Community',
|
|
tooltip: 'Community',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.person),
|
|
label: 'Profil',
|
|
tooltip: 'Profil',
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Seperti [FloatingActionButtonLocation.centerDocked], tapi tombolnya lebih
|
|
/// menonjol ke atas supaya tidak menempel ke label "Bayar".
|
|
class MainPayButtonLocation extends StandardFabLocation
|
|
with FabCenterOffsetX, FabDockedOffsetY {
|
|
const MainPayButtonLocation();
|
|
|
|
static const double _raise = 10;
|
|
|
|
@override
|
|
double getOffsetY(
|
|
ScaffoldPrelayoutGeometry scaffoldGeometry,
|
|
double adjustment,
|
|
) => super.getOffsetY(scaffoldGeometry, adjustment) - _raise;
|
|
}
|
|
|
|
/// Tombol bulat di tengah navbar, dipasang di [MainPayButtonLocation].
|
|
class MainPayButton extends StatelessWidget {
|
|
final VoidCallback onPressed;
|
|
const MainPayButton({super.key, required this.onPressed});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FloatingActionButton(
|
|
onPressed: onPressed,
|
|
// Halaman tab (mis. Community) juga punya FAB; tanpa hero supaya tag
|
|
// default tidak bentrok saat pindah halaman.
|
|
heroTag: null,
|
|
tooltip: 'Bayar di kasir',
|
|
elevation: 4,
|
|
backgroundColor: AppColor.primary,
|
|
foregroundColor: AppColor.white,
|
|
shape: const CircleBorder(),
|
|
child: const Icon(Icons.qr_code_scanner_rounded, size: 28),
|
|
);
|
|
}
|
|
}
|