70 lines
2.3 KiB
Dart
70 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../../auth/data/providers/auth_provider.dart';
|
|
|
|
class SettingsPage extends ConsumerWidget {
|
|
const SettingsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Settings')),
|
|
body: ListView(
|
|
children: [
|
|
const ListTile(
|
|
leading: Icon(Icons.person),
|
|
title: Text('Profile'),
|
|
trailing: Icon(Icons.chevron_right),
|
|
),
|
|
const ListTile(
|
|
leading: Icon(Icons.business),
|
|
title: Text('Tenant'),
|
|
trailing: Icon(Icons.chevron_right),
|
|
),
|
|
const ListTile(
|
|
leading: Icon(Icons.notifications),
|
|
title: Text('Notifications'),
|
|
trailing: Icon(Icons.chevron_right),
|
|
),
|
|
const ListTile(
|
|
leading: Icon(Icons.color_lens),
|
|
title: Text('Theme'),
|
|
trailing: Icon(Icons.chevron_right),
|
|
),
|
|
const Divider(),
|
|
ListTile(
|
|
leading: const Icon(Icons.logout, color: Colors.red),
|
|
title: const Text('Logout', style: TextStyle(color: Colors.red)),
|
|
onTap: () async {
|
|
final confirmed = await showDialog<bool>(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
title: const Text('Logout'),
|
|
content: const Text('Are you sure you want to logout?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(ctx).pop(false),
|
|
child: const Text('Cancel'),
|
|
),
|
|
FilledButton(
|
|
onPressed: () => Navigator.of(ctx).pop(true),
|
|
child: const Text('Logout'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
if (confirmed == true) {
|
|
await ref.read(authStateProvider.notifier).logout();
|
|
if (context.mounted) {
|
|
context.go('/login');
|
|
}
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|