Kasir: indikator loading produk + empty/error state + tombol Coba lagi, refresh retry, login tanpa loading global

This commit is contained in:
Onie
2026-10-18 16:30:44 +07:00
parent aba36f5c60
commit 0174ca4f64
3 changed files with 193 additions and 29 deletions

View File

@@ -191,26 +191,25 @@ class AuthGate extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Selector<AppState, bool>(
selector: (context, state) => state.loading,
builder: (context, loading, child) {
if (loading) {
return Selector<AppState, ({bool loading, bool loggedIn, bool expired})>(
selector: (context, state) => (
loading: state.loading,
loggedIn: state.isLoggedIn,
expired: state.sessionExpired,
),
builder: (context, a, child) {
// Loading global hanya untuk init aplikasi. Proses login dihandle
// tombol LoginScreen, status data produk dihandle spinner khusus
// Kasir agar layar tidak melepas LoginScreen saat gagal login.
if (a.loading) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(color: kAccent),
),
body: Center(child: CircularProgressIndicator(color: kAccent)),
);
}
return Selector<AppState, ({bool loggedIn, bool expired})>(
selector: (context, state) =>
(loggedIn: state.isLoggedIn, expired: state.sessionExpired),
builder: (context, auth, child) {
if (auth.loggedIn && !auth.expired) {
return const HomePage();
}
return const LoginScreen();
},
);
if (a.loggedIn && !a.expired) {
return const HomePage();
}
return const LoginScreen();
},
);
}