Add comprehensive theme management system with iOS system integration: - System theme detection: App follows iOS dark/light mode preferences via ThemeMode.system - Theme provider: Centralized theme state management with Riverpod (defaults to dark mode) - Settings toggle: Segmented button UI for Light/Dark/Auto theme selection - iOS system UI: Status bar and navigation bar adapt to current theme brightness Dark mode map styling (Android-ready): - DarkModeMapComponent: Reactive theme change detection with didChangeDependencies - Map style application: Custom dark JSON style for navigation maps - Theme-aware styling: Automatically applies/resets map style on theme changes - Note: Map styling currently Android-only due to iOS SDK limitations Updates: - main.dart: System UI overlay styling for iOS, theme provider integration - settings_page.dart: SegmentedButton theme toggle with icons - providers.dart: themeModeProvider for app-wide theme state - dark_mode_map.dart: Theme reactivity and style application logic - navigation_page.dart: Theme detection infrastructure (prepared for future use) Design philosophy: - Follow system preferences by default for native iOS experience - Manual override available for user preference - Clean separation between Flutter UI theming and native map styling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
213 lines
8.0 KiB
Dart
213 lines
8.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../providers/providers.dart';
|
|
|
|
class SettingsPage extends ConsumerWidget {
|
|
const SettingsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final userProfile = ref.watch(userProfileProvider);
|
|
final language = ref.watch(languageProvider);
|
|
final themeMode = ref.watch(themeModeProvider);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Settings'),
|
|
),
|
|
body: ListView(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'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 Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 32,
|
|
child: Text(
|
|
profile.firstName[0].toUpperCase(),
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
profile.fullName,
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
profile.email,
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
loading: () => const CircularProgressIndicator(),
|
|
error: (error, stackTrace) => Text('Error: $error'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const Divider(),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Preferences',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 16),
|
|
ListTile(
|
|
title: const Text('Language'),
|
|
subtitle: Text(language == 'fr' ? 'Franais' : 'English'),
|
|
trailing: DropdownButton<String>(
|
|
value: language,
|
|
onChanged: (String? newValue) {
|
|
if (newValue != null) {
|
|
ref.read(languageProvider.notifier).state = newValue;
|
|
}
|
|
},
|
|
items: const [
|
|
DropdownMenuItem(
|
|
value: 'en',
|
|
child: Text('English'),
|
|
),
|
|
DropdownMenuItem(
|
|
value: 'fr',
|
|
child: Text('Franais'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Theme',
|
|
style: Theme.of(context).textTheme.titleSmall,
|
|
),
|
|
const SizedBox(height: 8),
|
|
SegmentedButton<ThemeMode>(
|
|
selected: {themeMode},
|
|
onSelectionChanged: (Set<ThemeMode> newSelection) {
|
|
ref.read(themeModeProvider.notifier).state = newSelection.first;
|
|
},
|
|
segments: const [
|
|
ButtonSegment<ThemeMode>(
|
|
value: ThemeMode.light,
|
|
label: Text('Light'),
|
|
icon: Icon(Icons.light_mode),
|
|
),
|
|
ButtonSegment<ThemeMode>(
|
|
value: ThemeMode.dark,
|
|
label: Text('Dark'),
|
|
icon: Icon(Icons.dark_mode),
|
|
),
|
|
ButtonSegment<ThemeMode>(
|
|
value: ThemeMode.system,
|
|
label: Text('Auto'),
|
|
icon: Icon(Icons.brightness_auto),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const Divider(),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Account',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 16),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton.icon(
|
|
icon: const Icon(Icons.logout),
|
|
label: const Text('Logout'),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Theme.of(context).colorScheme.error,
|
|
foregroundColor: Theme.of(context).colorScheme.onError,
|
|
),
|
|
onPressed: () async {
|
|
final authService = ref.read(authServiceProvider);
|
|
await authService.logout();
|
|
if (context.mounted) {
|
|
// ignore: unused_result
|
|
ref.refresh(isAuthenticatedProvider);
|
|
if (context.mounted) {
|
|
Navigator.of(context).pushReplacementNamed('/');
|
|
}
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const Divider(),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'About',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 16),
|
|
ListTile(
|
|
title: const Text('App Version'),
|
|
subtitle: const Text('1.0.0'),
|
|
),
|
|
ListTile(
|
|
title: const Text('Built with Flutter'),
|
|
subtitle: const Text('Plan B Logistics Management System'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|