This commit is contained in:
Rene Kievits
2025-10-31 13:40:14 +01:00
parent ad61292263
commit 4eb488e28c
16 changed files with 691 additions and 395 deletions

View File

@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hirameki_srs/src/models/theme_model.dart';
import 'package:hirameki_srs/src/themes.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../services/deck_repository.dart';
@@ -50,24 +52,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
await repo.setApiKey(apiKey);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('API key saved!')),
);
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('API key saved!')));
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const HomeScreen()),
);
Navigator.of(
context,
).pushReplacement(MaterialPageRoute(builder: (_) => const HomeScreen()));
}
}
@override
Widget build(BuildContext context) {
final themeModel = Provider.of<ThemeModel>(context);
return Scaffold(
backgroundColor: const Color(0xFF121212),
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
title: const Text('Settings'),
backgroundColor: const Color(0xFF1F1F1F),
foregroundColor: Colors.white,
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
foregroundColor: Theme.of(context).colorScheme.onSurface,
),
body: Padding(
padding: const EdgeInsets.all(16.0),
@@ -76,15 +80,19 @@ class _SettingsScreenState extends State<SettingsScreen> {
TextField(
controller: _apiKeyController,
obscureText: true,
style: const TextStyle(color: Colors.white),
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
decoration: InputDecoration(
labelText: 'WaniKani API Key',
labelStyle: const TextStyle(color: Colors.grey),
labelStyle: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
filled: true,
fillColor: const Color(0xFF1E1E1E),
fillColor: Theme.of(context).colorScheme.surfaceContainer,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
borderSide: const BorderSide(color: Colors.grey),
borderSide: BorderSide(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
),
@@ -92,16 +100,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
ElevatedButton(
onPressed: _saveApiKey,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueAccent,
foregroundColor: Colors.white,
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
),
child: const Text('Save & Start Quiz'),
),
const SizedBox(height: 24),
SwitchListTile(
title: const Text(
title: Text(
'Play audio for vocabulary',
style: TextStyle(color: Colors.white),
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
value: _playAudio,
onChanged: (value) async {
@@ -111,18 +121,22 @@ class _SettingsScreenState extends State<SettingsScreen> {
_playAudio = value;
});
},
activeThumbColor: Colors.blueAccent,
inactiveThumbColor: Colors.grey,
tileColor: const Color(0xFF1E1E1E),
activeThumbColor: Theme.of(context).colorScheme.primary,
inactiveThumbColor: Theme.of(
context,
).colorScheme.onSurfaceVariant,
tileColor: Theme.of(context).colorScheme.surfaceContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
const SizedBox(height: 12),
SwitchListTile(
title: const Text(
title: Text(
'Play sound on correct answer',
style: TextStyle(color: Colors.white),
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
value: _playCorrectSound,
onChanged: (value) async {
@@ -132,9 +146,50 @@ class _SettingsScreenState extends State<SettingsScreen> {
_playCorrectSound = value;
});
},
activeThumbColor: Colors.blueAccent,
inactiveThumbColor: Colors.grey,
tileColor: const Color(0xFF1E1E1E),
activeThumbColor: Theme.of(context).colorScheme.primary,
inactiveThumbColor: Theme.of(
context,
).colorScheme.onSurfaceVariant,
tileColor: Theme.of(context).colorScheme.surfaceContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
const SizedBox(height: 12),
ListTile(
title: Text(
'Theme',
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
trailing: DropdownButton<ThemeData>(
value: themeModel.currentTheme,
dropdownColor: Theme.of(context).colorScheme.surfaceContainer,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
items: [
DropdownMenuItem(
value: Themes.dark,
child: const Text('Dark'),
),
DropdownMenuItem(
value: Themes.light,
child: const Text('Light'),
),
DropdownMenuItem(
value: Themes.nier,
child: const Text('Nier'),
),
],
onChanged: (theme) {
if (theme != null) {
themeModel.setTheme(theme);
}
},
),
tileColor: Theme.of(context).colorScheme.surfaceContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),