104 lines
3.0 KiB
Dart
104 lines
3.0 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 onWalletTap;
|
|
const MainBottomNavbar({
|
|
super.key,
|
|
required this.tabsRouter,
|
|
required this.onWalletTap,
|
|
});
|
|
|
|
/// Slot tengah hanya tempat label tombol Poin; lingkarannya
|
|
/// [MainWalletButton] yang menempel di atas navbar.
|
|
static const int _walletIndex = 2;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final activeIndex = tabsRouter.activeIndex;
|
|
|
|
return BottomNavigationBar(
|
|
currentIndex: activeIndex >= _walletIndex ? activeIndex + 1 : activeIndex,
|
|
onTap: (index) {
|
|
if (index == _walletIndex) {
|
|
onWalletTap();
|
|
return;
|
|
}
|
|
tabsRouter.setActiveIndex(index > _walletIndex ? 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: 'Poin',
|
|
tooltip: 'EnakPoint & EnakCoin',
|
|
),
|
|
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 "Poin".
|
|
class MainWalletButtonLocation extends StandardFabLocation
|
|
with FabCenterOffsetX, FabDockedOffsetY {
|
|
const MainWalletButtonLocation();
|
|
|
|
static const double _raise = 10;
|
|
|
|
@override
|
|
double getOffsetY(
|
|
ScaffoldPrelayoutGeometry scaffoldGeometry,
|
|
double adjustment,
|
|
) => super.getOffsetY(scaffoldGeometry, adjustment) - _raise;
|
|
}
|
|
|
|
/// Tombol bulat di tengah navbar, dipasang di [MainWalletButtonLocation].
|
|
class MainWalletButton extends StatelessWidget {
|
|
final VoidCallback onPressed;
|
|
const MainWalletButton({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: 'EnakPoint & EnakCoin',
|
|
elevation: 4,
|
|
backgroundColor: AppColor.primary,
|
|
foregroundColor: AppColor.white,
|
|
shape: const CircleBorder(),
|
|
child: const Icon(Icons.stars_rounded, size: 30),
|
|
);
|
|
}
|
|
}
|