2026-04-04 17:13:25 +02:00
|
|
|
// lib/ui/impostazioni/impostazioni_view.dart
|
|
|
|
|
import 'package:flutter/material.dart';
|
2026-05-08 18:51:28 +02:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
2026-05-09 20:42:42 +02:00
|
|
|
import 'package:flux/core/routes/routes.dart';
|
2026-04-07 11:30:22 +02:00
|
|
|
import 'package:flux/core/theme/theme.dart';
|
2026-05-13 12:41:07 +02:00
|
|
|
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
2026-05-24 10:25:16 +02:00
|
|
|
import 'package:get_it/get_it.dart';
|
2026-05-08 18:51:28 +02:00
|
|
|
import 'package:go_router/go_router.dart';
|
2026-04-04 17:13:25 +02:00
|
|
|
|
2026-05-13 12:41:07 +02:00
|
|
|
class SettingsScreen extends StatelessWidget {
|
|
|
|
|
const SettingsScreen({super.key});
|
2026-04-04 17:13:25 +02:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(title: const Text('Impostazioni')),
|
|
|
|
|
body: ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
children: [
|
2026-05-29 12:26:41 +02:00
|
|
|
_settingsSection('Utente', [
|
|
|
|
|
_settingsTile(
|
|
|
|
|
title: 'Impostazioni Promemoria',
|
|
|
|
|
icon: Icons.notifications,
|
|
|
|
|
subtitle: 'Notifiche predefinite',
|
|
|
|
|
context: context,
|
|
|
|
|
onTap: () => context.pushNamed(Routes.reminderSettings),
|
|
|
|
|
),
|
|
|
|
|
]),
|
2026-05-24 10:25:16 +02:00
|
|
|
_settingsSection('Azienda', [
|
2026-04-04 17:13:25 +02:00
|
|
|
_settingsTile(
|
2026-05-24 10:25:16 +02:00
|
|
|
title: 'Impostazioni Azienda',
|
|
|
|
|
icon: Icons.business,
|
|
|
|
|
subtitle: 'Configura i dati aziendali',
|
|
|
|
|
context: context,
|
|
|
|
|
onTap: () => context.pushNamed(Routes.companySettings),
|
|
|
|
|
),
|
|
|
|
|
const Divider(height: 30),
|
|
|
|
|
_settingsTile(
|
|
|
|
|
title: 'Impostazione Negozi',
|
|
|
|
|
icon: Icons.store,
|
|
|
|
|
subtitle: 'Crea o configura i negozi',
|
2026-05-08 18:51:28 +02:00
|
|
|
context: context,
|
2026-05-24 10:25:16 +02:00
|
|
|
onTap: () => context.pushNamed(Routes.stores),
|
2026-04-05 10:06:26 +02:00
|
|
|
),
|
2026-05-13 15:55:06 +02:00
|
|
|
const Divider(height: 30),
|
2026-05-24 10:25:16 +02:00
|
|
|
_settingsTile(
|
|
|
|
|
title: 'Impostazione Staff / Utenti',
|
|
|
|
|
icon: Icons.group,
|
|
|
|
|
subtitle:
|
|
|
|
|
'Configura i membri dei negozi o invita nuovi utenti in azienda',
|
|
|
|
|
context: context,
|
|
|
|
|
onTap: () => context.pushNamed(Routes.staff),
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
_settingsSection('Applicazione', [
|
2026-05-13 12:41:07 +02:00
|
|
|
BlocBuilder<SettingsCubit, SettingsState>(
|
|
|
|
|
builder: (context, state) => CheckboxListTile(
|
|
|
|
|
value: state.isSingleUserMode,
|
2026-05-24 10:25:16 +02:00
|
|
|
|
|
|
|
|
title: Row(
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(Icons.person, color: FluxColors.primaryBlue),
|
|
|
|
|
const SizedBox(width: 12),
|
2026-05-25 12:49:04 +02:00
|
|
|
Flexible(
|
|
|
|
|
child: Text(
|
|
|
|
|
'Modalità utente singolo (dispositivo personale)',
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
|
|
|
),
|
2026-05-24 10:25:16 +02:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
subtitle: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 36),
|
|
|
|
|
child: Text(
|
|
|
|
|
'Utente ${GetIt.I.get<SessionCubit>().state.currentStaffMember?.name ?? 'Nessuno'} selezionato automaticamente',
|
|
|
|
|
),
|
2026-05-13 15:55:06 +02:00
|
|
|
),
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
context.read<SessionCubit>().setIsSingleUserMode(value!);
|
|
|
|
|
context.read<SettingsCubit>().toggleSingleUserMode();
|
|
|
|
|
},
|
2026-05-13 12:41:07 +02:00
|
|
|
),
|
|
|
|
|
),
|
2026-05-13 15:55:06 +02:00
|
|
|
const Divider(height: 30),
|
2026-04-05 10:06:26 +02:00
|
|
|
_settingsTile(
|
2026-05-08 18:51:28 +02:00
|
|
|
icon: Icons.dark_mode,
|
|
|
|
|
title: 'Tema (FLUX Dark)',
|
|
|
|
|
subtitle: 'Configurazione visiva',
|
|
|
|
|
context: context,
|
2026-05-09 20:42:42 +02:00
|
|
|
onTap: () => context.pushNamed(Routes.themeSettings),
|
2026-04-04 17:13:25 +02:00
|
|
|
),
|
|
|
|
|
]),
|
2026-05-29 12:26:41 +02:00
|
|
|
|
2026-04-04 17:13:25 +02:00
|
|
|
const SizedBox(height: 24),
|
|
|
|
|
TextButton.icon(
|
2026-05-08 18:51:28 +02:00
|
|
|
onPressed: () => context.read<SessionCubit>().signOut(),
|
2026-04-04 17:13:25 +02:00
|
|
|
icon: const Icon(Icons.exit_to_app, color: Colors.red),
|
|
|
|
|
label: const Text('Logout', style: TextStyle(color: Colors.red)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _settingsSection(String title, List<Widget> tiles) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
title.toUpperCase(),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: FluxColors.accentTurquoise,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
letterSpacing: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Card(child: Column(children: tiles)),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 18:51:28 +02:00
|
|
|
Widget _settingsTile({
|
|
|
|
|
required BuildContext context,
|
|
|
|
|
required IconData icon,
|
|
|
|
|
required String title,
|
|
|
|
|
String? subtitle,
|
|
|
|
|
required VoidCallback onTap,
|
|
|
|
|
}) {
|
2026-04-04 17:13:25 +02:00
|
|
|
return ListTile(
|
|
|
|
|
leading: Icon(icon, color: FluxColors.primaryBlue),
|
2026-04-05 10:06:26 +02:00
|
|
|
title: Text(title, style: Theme.of(context).textTheme.titleLarge),
|
2026-05-08 18:51:28 +02:00
|
|
|
subtitle: Text(subtitle ?? ''),
|
2026-04-05 10:06:26 +02:00
|
|
|
trailing: Icon(
|
2026-04-04 17:13:25 +02:00
|
|
|
Icons.chevron_right,
|
2026-04-05 10:06:26 +02:00
|
|
|
color: Theme.of(context).textTheme.bodyMedium?.color,
|
2026-04-04 17:13:25 +02:00
|
|
|
),
|
2026-05-08 18:51:28 +02:00
|
|
|
onTap: onTap,
|
2026-04-04 17:13:25 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|