home
This commit is contained in:
parent
c264c546f1
commit
a6b1993c27
@ -1,5 +1,7 @@
|
|||||||
import 'package:e_receipt_mobile/domain/entities/login_user.dart';
|
import 'package:e_receipt_mobile/domain/entities/login_user.dart';
|
||||||
|
import 'package:e_receipt_mobile/presentation/auth/session_controller.dart';
|
||||||
import 'package:e_receipt_mobile/presentation/home/home_view_model.dart';
|
import 'package:e_receipt_mobile/presentation/home/home_view_model.dart';
|
||||||
|
import 'package:e_receipt_mobile/presentation/login/login_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
@ -10,7 +12,6 @@ class HomeScreen extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final role = user.role.toLowerCase();
|
|
||||||
final merchantsAsync = ref.watch(merchantListProvider);
|
final merchantsAsync = ref.watch(merchantListProvider);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -18,6 +19,76 @@ class HomeScreen extends ConsumerWidget {
|
|||||||
title: Text("Merchants"),
|
title: Text("Merchants"),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
),
|
||||||
|
drawer: Drawer(
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
UserAccountsDrawerHeader(
|
||||||
|
accountName: Text(user.username),
|
||||||
|
accountEmail: Text('Role: ${user.role}'),
|
||||||
|
currentAccountPicture: CircleAvatar(
|
||||||
|
child: Text(
|
||||||
|
(user.username.isNotEmpty ? user.username[0] : 'U')
|
||||||
|
.toUpperCase(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.person_outline),
|
||||||
|
title: const Text('Profile'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_showProfile(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.storefront_outlined),
|
||||||
|
title: const Text('Merchants'),
|
||||||
|
onTap: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.analytics_outlined),
|
||||||
|
title: const Text('Reports'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_showComingSoon(context, 'Reports');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.settings_outlined),
|
||||||
|
title: const Text('Settings'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_showComingSoon(context, 'Settings');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.help_outline),
|
||||||
|
title: const Text('Help'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_showComingSoon(context, 'Help');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
const Divider(height: 1),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.logout),
|
||||||
|
title: const Text('Logout'),
|
||||||
|
onTap: () {
|
||||||
|
ref.read(sessionControllerProvider.notifier).clearUser();
|
||||||
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
|
MaterialPageRoute<void>(
|
||||||
|
builder: (_) => const LoginPage(),
|
||||||
|
),
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: merchantsAsync.when(
|
child: merchantsAsync.when(
|
||||||
@ -80,4 +151,36 @@ class HomeScreen extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showComingSoon(BuildContext context, String feature) {
|
||||||
|
ScaffoldMessenger.of(
|
||||||
|
context,
|
||||||
|
).showSnackBar(SnackBar(content: Text('$feature is coming soon')));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showProfile(BuildContext context) {
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Profile'),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Username: ${user.username}'),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text('Role: ${user.role}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('Close'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user