/// Settings tab: theme mode, data source, and about information. library; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/item_provider.dart'; import '../providers/theme_provider.dart'; import '../utils/constants.dart'; import '../utils/helpers.dart'; import '../widgets/responsive_body.dart'; class SettingsScreen extends StatelessWidget { const SettingsScreen({super.key}); @override Widget build(BuildContext context) { final themeController = context.watch(); final items = context.watch(); final theme = Theme.of(context); return Scaffold( appBar: AppBar(title: const Text('Settings')), body: ResponsiveBody( child: ListView( children: [ const SizedBox(height: 8), Text('Appearance', style: theme.textTheme.titleMedium), const SizedBox(height: 8), Text( 'Theme is saved with shared_preferences and restored on launch.', style: theme.textTheme.bodyMedium, ), const SizedBox(height: 16), SegmentedButton( segments: const [ ButtonSegment( value: ThemeMode.system, label: Text('System'), icon: Icon(Icons.brightness_auto), ), ButtonSegment( value: ThemeMode.light, label: Text('Light'), icon: Icon(Icons.light_mode_outlined), ), ButtonSegment( value: ThemeMode.dark, label: Text('Dark'), icon: Icon(Icons.dark_mode_outlined), ), ], selected: {themeController.themeMode}, onSelectionChanged: (selection) { themeController.setThemeMode(selection.first); }, ), const SizedBox(height: 28), Text('Data', style: theme.textTheme.titleMedium), const SizedBox(height: 8), Card( child: SwitchListTile( title: const Text('Use remote sample API'), subtitle: const Text( 'When on, items are fetched with the http package from ' 'JSONPlaceholder. Failures fall back to local mock data.', ), value: items.useRemoteData, onChanged: (value) => items.setUseRemoteData(value), ), ), const SizedBox(height: 28), Text('About', style: theme.textTheme.titleMedium), const SizedBox(height: 8), Card( child: Column( children: [ const ListTile( leading: Icon(Icons.apps), title: Text(kAppName), subtitle: Text('Generic Flutter Android starter'), ), const Divider(height: 1), const ListTile( leading: Icon(Icons.fingerprint), title: Text('Package'), subtitle: Text(kPackageName), ), const Divider(height: 1), ListTile( leading: const Icon(Icons.contrast), title: const Text('Active theme'), subtitle: Text(labelForThemeMode(themeController.themeMode)), ), ], ), ), const SizedBox(height: 24), ], ), ), ); } }