This commit is contained in:
davmar
2026-08-28 18:23:56 +02:00
commit 0311b8955a
50 changed files with 3120 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
/// 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<ThemeController>();
final items = context.watch<ItemController>();
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<ThemeMode>(
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),
],
),
),
);
}
}