This commit is contained in:
Phuoc Nguyen
2025-10-10 17:36:10 +07:00
parent 04f7042b8d
commit bdaf0b96c5
82 changed files with 4753 additions and 329 deletions

View File

@@ -0,0 +1,6 @@
/// Export all settings presentation pages
///
/// Contains all screens related to settings
library;
export 'settings_page.dart';

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../providers/settings_provider.dart';
import '../../../auth/presentation/providers/auth_provider.dart';
import '../../../../core/constants/app_constants.dart';
/// Settings page
@@ -37,8 +38,105 @@ class SettingsPage extends ConsumerWidget {
),
),
data: (settings) {
final user = ref.watch(currentUserProvider);
return ListView(
children: [
// User Profile Section
if (user != null) ...[
Card(
margin: const EdgeInsets.all(16),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
CircleAvatar(
radius: 40,
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
child: Text(
user.name.isNotEmpty ? user.name[0].toUpperCase() : '?',
style: TextStyle(
fontSize: 32,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
),
const SizedBox(height: 12),
Text(
user.name,
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 4),
Text(
user.email,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
if (user.roles.isNotEmpty) ...[
const SizedBox(height: 12),
Wrap(
spacing: 8,
alignment: WrapAlignment.center,
children: user.roles
.map((role) => Chip(
label: Text(
role.toUpperCase(),
style: const TextStyle(fontSize: 11),
),
padding: const EdgeInsets.symmetric(horizontal: 8),
backgroundColor:
Theme.of(context).colorScheme.primaryContainer,
labelStyle: TextStyle(
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
))
.toList(),
),
],
const SizedBox(height: 16),
FilledButton.icon(
onPressed: () async {
// Show confirmation dialog
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Logout'),
content: const Text('Are you sure you want to logout?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
FilledButton(
onPressed: () => Navigator.pop(context, true),
style: FilledButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.error,
),
child: const Text('Logout'),
),
],
),
);
if (confirmed == true && context.mounted) {
await ref.read(authProvider.notifier).logout();
}
},
icon: const Icon(Icons.logout),
label: const Text('Logout'),
style: FilledButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.error,
foregroundColor: Theme.of(context).colorScheme.onError,
),
),
],
),
),
),
const Divider(),
],
// Appearance Section
_buildSectionHeader(context, 'Appearance'),
ListTile(