checkpoint

This commit is contained in:
2025-11-26 17:41:37 -05:00
parent ef5c0c1a95
commit 2ecd1c5b4e
15 changed files with 794 additions and 152 deletions
+34 -27
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../l10n/app_localizations.dart';
import '../providers/providers.dart';
class SettingsPage extends ConsumerWidget {
@@ -8,12 +9,18 @@ class SettingsPage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final userProfile = ref.watch(userProfileProvider);
final language = ref.watch(languageProvider);
final languageAsync = ref.watch(languageProvider);
final themeMode = ref.watch(themeModeProvider);
final l10n = AppLocalizations.of(context)!;
final language = languageAsync.maybeWhen(
data: (value) => value,
orElse: () => 'system',
);
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
title: Text(l10n.settings),
),
body: ListView(
children: [
@@ -23,14 +30,14 @@ class SettingsPage extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Profile',
l10n.profile,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 16),
userProfile.when(
data: (profile) {
if (profile == null) {
return const Text('No profile information');
return Text(l10n.noProfileInfo);
}
return Card(
child: Padding(
@@ -78,7 +85,7 @@ class SettingsPage extends ConsumerWidget {
}
},
color: Theme.of(context).colorScheme.error,
tooltip: 'Logout',
tooltip: l10n.logout,
),
],
),
@@ -88,7 +95,7 @@ class SettingsPage extends ConsumerWidget {
);
},
loading: () => const CircularProgressIndicator(),
error: (error, stackTrace) => Text('Error: $error'),
error: (error, stackTrace) => Text(l10n.error(error.toString())),
),
],
),
@@ -100,18 +107,18 @@ class SettingsPage extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Preferences',
l10n.preferences,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 16),
ListTile(
title: const Text('Language'),
title: Text(l10n.language),
subtitle: Text(
language == 'system'
? 'System'
? l10n.systemLanguage
: language == 'fr'
? 'Français'
: 'English'
? l10n.french
: l10n.english
),
trailing: DropdownButton<String>(
value: language,
@@ -120,18 +127,18 @@ class SettingsPage extends ConsumerWidget {
ref.read(languageProvider.notifier).setLanguage(newValue);
}
},
items: const [
items: [
DropdownMenuItem(
value: 'system',
child: Text('System'),
child: Text(l10n.systemLanguage),
),
DropdownMenuItem(
value: 'en',
child: Text('English'),
child: Text(l10n.english),
),
DropdownMenuItem(
value: 'fr',
child: Text('Français'),
child: Text(l10n.french),
),
],
),
@@ -141,7 +148,7 @@ class SettingsPage extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Theme',
l10n.theme,
style: Theme.of(context).textTheme.titleSmall,
),
const SizedBox(height: 8),
@@ -150,21 +157,21 @@ class SettingsPage extends ConsumerWidget {
onSelectionChanged: (Set<ThemeMode> newSelection) {
ref.read(themeModeProvider.notifier).setThemeMode(newSelection.first);
},
segments: const [
segments: [
ButtonSegment<ThemeMode>(
value: ThemeMode.light,
label: Text('Light'),
icon: Icon(Icons.light_mode),
label: Text(l10n.themeLight),
icon: const Icon(Icons.light_mode),
),
ButtonSegment<ThemeMode>(
value: ThemeMode.dark,
label: Text('Dark'),
icon: Icon(Icons.dark_mode),
label: Text(l10n.themeDark),
icon: const Icon(Icons.dark_mode),
),
ButtonSegment<ThemeMode>(
value: ThemeMode.system,
label: Text('Auto'),
icon: Icon(Icons.brightness_auto),
label: Text(l10n.themeSystem),
icon: const Icon(Icons.brightness_auto),
),
],
),
@@ -180,17 +187,17 @@ class SettingsPage extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'About',
l10n.about,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 16),
ListTile(
title: const Text('App Version'),
title: Text(l10n.appVersion),
subtitle: const Text('1.0.0'),
),
ListTile(
title: const Text('Built with Flutter'),
subtitle: const Text('Plan B Logistics Management System'),
title: Text(l10n.builtWithFlutter),
subtitle: Text(l10n.appDescription),
),
],
),