Kasir: indikator loading produk + empty/error state + tombol Coba lagi, refresh retry, login tanpa loading global
This commit is contained in:
@@ -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();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user