tetraq/lib/ui/settings/settings_screen.dart
2026-02-27 23:35:54 +01:00

113 lines
No EOL
4 KiB
Dart

// ===========================================================================
// FILE: lib/ui/settings/settings_screen.dart
// ===========================================================================
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../core/theme_manager.dart';
import '../../core/app_colors.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
final themeManager = context.watch<ThemeManager>();
final theme = themeManager.currentColors;
return Scaffold(
backgroundColor: theme.background,
appBar: AppBar(
title: Text("SELEZIONA TEMA", style: TextStyle(fontWeight: FontWeight.bold, color: theme.text)),
backgroundColor: Colors.transparent,
elevation: 0,
iconTheme: IconThemeData(color: theme.text),
),
body: ListView(
padding: const EdgeInsets.all(20),
children: [
_ThemeCard(
title: "Minimal",
subtitle: "Linee pulite, sfondo chiaro",
type: AppThemeType.minimal,
previewColors: AppColors.minimal,
),
const SizedBox(height: 15),
_ThemeCard(
title: "Quaderno (Doodle)",
subtitle: "Sfondo a quadretti, tratto a penna",
type: AppThemeType.doodle,
previewColors: AppColors.doodle,
),
const SizedBox(height: 15),
_ThemeCard(
title: "Cyberpunk",
subtitle: "Nero profondo, luci al neon",
type: AppThemeType.cyberpunk,
previewColors: AppColors.cyberpunk,
),
const SizedBox(height: 15),
_ThemeCard(
title: "Legno & Fiammiferi",
subtitle: "Tavolo di legno, linee come fiammiferi",
type: AppThemeType.wood,
previewColors: AppColors.wood,
),
],
),
);
}
}
class _ThemeCard extends StatelessWidget {
final String title;
final String subtitle;
final AppThemeType type;
final ThemeColors previewColors;
const _ThemeCard({required this.title, required this.subtitle, required this.type, required this.previewColors});
@override
Widget build(BuildContext context) {
final themeManager = context.watch<ThemeManager>();
bool isSelected = themeManager.currentThemeType == type;
return GestureDetector(
onTap: () {
themeManager.setTheme(type);
// --- LA MODIFICA È QUI ---
// Chiude la schermata e torna automaticamente alla Home!
Navigator.pop(context);
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: previewColors.background,
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: isSelected ? previewColors.playerBlue : previewColors.gridLine.withOpacity(0.5),
width: isSelected ? 4 : 2,
),
boxShadow: isSelected ? [BoxShadow(color: previewColors.playerBlue.withOpacity(0.4), blurRadius: 10, spreadRadius: 2)] : [],
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: previewColors.text)),
Text(subtitle, style: TextStyle(fontSize: 14, color: previewColors.text.withOpacity(0.7))),
],
),
),
Container(width: 20, height: 20, decoration: BoxDecoration(color: previewColors.playerRed, shape: BoxShape.circle)),
const SizedBox(width: 10),
Container(width: 20, height: 20, decoration: BoxDecoration(color: previewColors.playerBlue, shape: BoxShape.circle)),
],
),
),
);
}
}