Tab Community, tombol Bayar di navbar, logo placeholder, fix crash PIN
- 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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f5e3075205
commit
bc751246d8
@@ -21,6 +21,14 @@ class _MainPageState extends State<MainPage> {
|
||||
context.read<AuthBloc>().add(const AuthEvent.fetchCurrentUser());
|
||||
}
|
||||
|
||||
/// Kode bayar di kasir; PIN diminta di halamannya sendiri.
|
||||
void _openPay() {
|
||||
final isAuthenticated = context.read<AuthBloc>().state.isAuthenticated;
|
||||
context.router.push(
|
||||
isAuthenticated ? const PaymentCodeRoute() : const OnboardingRoute(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AutoTabsRouter.pageView(
|
||||
@@ -28,15 +36,26 @@ class _MainPageState extends State<MainPage> {
|
||||
HomeRoute(),
|
||||
// VoucherRoute(),
|
||||
OrderRoute(),
|
||||
CommunityRoute(),
|
||||
ProfileRoute(),
|
||||
],
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
builder: (context, child, pageController) => Scaffold(
|
||||
body: child,
|
||||
bottomNavigationBar: MainBottomNavbar(
|
||||
tabsRouter: AutoTabsRouter.of(context),
|
||||
),
|
||||
),
|
||||
builder: (context, child, pageController) {
|
||||
// Docked FAB ikut naik ke atas keyboard; sembunyikan saat mengetik.
|
||||
final isKeyboardOpen = MediaQuery.viewInsetsOf(context).bottom > 0;
|
||||
|
||||
return Scaffold(
|
||||
body: child,
|
||||
floatingActionButton: isKeyboardOpen
|
||||
? null
|
||||
: MainPayButton(onPressed: _openPay),
|
||||
floatingActionButtonLocation: const MainPayButtonLocation(),
|
||||
bottomNavigationBar: MainBottomNavbar(
|
||||
tabsRouter: AutoTabsRouter.of(context),
|
||||
onPayTap: _openPay,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class _HomeMenu {
|
||||
required this.icon,
|
||||
this.route,
|
||||
this.requiresLogin = false,
|
||||
this.opensTab = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
@@ -23,6 +24,9 @@ class _HomeMenu {
|
||||
/// `null` berarti fitur belum tersedia.
|
||||
final PageRouteInfo? route;
|
||||
final bool requiresLogin;
|
||||
|
||||
/// [route] adalah tab di bottom navbar; dibuka dengan pindah tab, bukan push.
|
||||
final bool opensTab;
|
||||
}
|
||||
|
||||
class HomeServiceSection extends StatelessWidget {
|
||||
@@ -78,6 +82,7 @@ class HomeServiceSection extends StatelessWidget {
|
||||
label: 'EnakCommunity',
|
||||
icon: Assets.icons.enakcommunityIcon,
|
||||
route: const CommunityRoute(),
|
||||
opensTab: true,
|
||||
),
|
||||
];
|
||||
|
||||
@@ -94,6 +99,11 @@ class HomeServiceSection extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (menu.opensTab) {
|
||||
context.tabsRouter.navigate(route);
|
||||
return;
|
||||
}
|
||||
|
||||
context.router.push(route);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,33 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
|
||||
class MainBottomNavbar extends StatelessWidget {
|
||||
final TabsRouter tabsRouter;
|
||||
const MainBottomNavbar({super.key, required this.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: tabsRouter.activeIndex,
|
||||
currentIndex: activeIndex >= _payIndex ? activeIndex + 1 : activeIndex,
|
||||
onTap: (index) {
|
||||
tabsRouter.setActiveIndex(index);
|
||||
if (index == _payIndex) {
|
||||
onPayTap();
|
||||
return;
|
||||
}
|
||||
tabsRouter.setActiveIndex(index > _payIndex ? index - 1 : index);
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
@@ -28,6 +45,16 @@ class MainBottomNavbar extends StatelessWidget {
|
||||
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',
|
||||
@@ -37,3 +64,40 @@ class MainBottomNavbar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user