add flutter
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ontime_merchant_flutter/features/auth/application/auth_controller.dart';
|
||||
|
||||
class HomeShell extends ConsumerStatefulWidget {
|
||||
const HomeShell({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<HomeShell> createState() => _HomeShellState();
|
||||
}
|
||||
|
||||
class _HomeShellState extends ConsumerState<HomeShell> {
|
||||
int _index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final merchant = ref.watch(authControllerProvider).merchant;
|
||||
final pages = <Widget>[
|
||||
const Center(child: Text('Toko – pesanan & saldo')),
|
||||
const Center(child: Text('Riwayat')),
|
||||
const Center(child: Text('Chat')),
|
||||
const Center(child: Text('Menu (kategori & item)')),
|
||||
_ProfileTab(),
|
||||
];
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(merchant?.namaMerchant ?? 'Merchant'),
|
||||
),
|
||||
body: SafeArea(child: pages[_index]),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: _index,
|
||||
onDestinationSelected: (i) => setState(() => _index = i),
|
||||
destinations: const [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.store_outlined),
|
||||
selectedIcon: Icon(Icons.store),
|
||||
label: 'Toko',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.history),
|
||||
selectedIcon: Icon(Icons.history),
|
||||
label: 'Riwayat',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.chat_outlined),
|
||||
selectedIcon: Icon(Icons.chat),
|
||||
label: 'Chat',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.restaurant_menu_outlined),
|
||||
selectedIcon: Icon(Icons.restaurant_menu),
|
||||
label: 'Menu',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.settings_outlined),
|
||||
selectedIcon: Icon(Icons.settings),
|
||||
label: 'Pengaturan',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ProfileTab extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
ref.read(authControllerProvider.notifier).logout();
|
||||
await AuthController.clearStored();
|
||||
if (context.mounted) context.go('/auth/login');
|
||||
},
|
||||
child: const Text('Keluar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user