sistemato assets, finito creazione company, inizio lavoro store
This commit is contained in:
42
lib/features/settings/settings.dart
Normal file
42
lib/features/settings/settings.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:flux/features/company/models/company_model.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppSettings {
|
||||
late String _themeModeSetting;
|
||||
late String? _currentUserId;
|
||||
late SharedPreferences _prefs;
|
||||
late CompanyModel? _currentCompany;
|
||||
|
||||
// Singleton
|
||||
|
||||
static final AppSettings _instance = AppSettings._internal();
|
||||
|
||||
factory AppSettings() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
AppSettings._internal() {
|
||||
_prefs = GetIt.I.get<SharedPreferences>();
|
||||
_themeModeSetting = _prefs.getString('theme') ?? 'light';
|
||||
}
|
||||
|
||||
String get themeModeSetting => _themeModeSetting;
|
||||
|
||||
void setThemeModeSetting(String value) {
|
||||
_themeModeSetting = value;
|
||||
_prefs.setString('theme', value);
|
||||
}
|
||||
|
||||
String? get currentUserId => _currentUserId;
|
||||
|
||||
void setCurrentUserId(String? value) {
|
||||
_currentUserId = value;
|
||||
}
|
||||
|
||||
CompanyModel? get currentCompany => _currentCompany;
|
||||
|
||||
void setCurrentCompany(CompanyModel? value) {
|
||||
_currentCompany = value;
|
||||
}
|
||||
}
|
||||
104
lib/features/settings/settings_view.dart
Normal file
104
lib/features/settings/settings_view.dart
Normal file
@@ -0,0 +1,104 @@
|
||||
// lib/ui/impostazioni/impostazioni_view.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/features/settings/theme_settings_view.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
const SettingsView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Impostazioni')),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_settingsSection('Account', [
|
||||
_settingsTile(
|
||||
Icons.person,
|
||||
'Profilo Utente',
|
||||
'Configura i tuoi dati',
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ThemeSettingsView(),
|
||||
),
|
||||
),
|
||||
_settingsTile(
|
||||
Icons.store,
|
||||
'Mio Negozio',
|
||||
'Piacenza Centro',
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ThemeSettingsView(),
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_settingsSection('Applicazione', [
|
||||
_settingsTile(
|
||||
Icons.sync,
|
||||
'Sincronizzazione',
|
||||
'Ultima: 5 min fa',
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ThemeSettingsView(),
|
||||
),
|
||||
),
|
||||
_settingsTile(
|
||||
Icons.dark_mode,
|
||||
'Tema (FLUX Dark)',
|
||||
'Configurazione visiva',
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ThemeSettingsView(),
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 24),
|
||||
TextButton.icon(
|
||||
onPressed: () {},
|
||||
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)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _settingsTile(
|
||||
IconData icon,
|
||||
String title,
|
||||
String subtitle,
|
||||
BuildContext context,
|
||||
MaterialPageRoute route,
|
||||
) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: FluxColors.primaryBlue),
|
||||
title: Text(title, style: Theme.of(context).textTheme.titleLarge),
|
||||
subtitle: Text(subtitle),
|
||||
trailing: Icon(
|
||||
Icons.chevron_right,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
onTap: () => Navigator.of(context).push(route),
|
||||
);
|
||||
}
|
||||
}
|
||||
35
lib/features/settings/theme_settings_view.dart
Normal file
35
lib/features/settings/theme_settings_view.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/enums/enums.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/core/theme/bloc/theme_bloc.dart';
|
||||
|
||||
class ThemeSettingsView extends StatelessWidget {
|
||||
const ThemeSettingsView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Impostazioni Tema')),
|
||||
body: BlocBuilder<ThemeBloc, ThemeState>(
|
||||
builder: (context, state) => RadioGroup<AppThemeMode>(
|
||||
groupValue: state.currentTheme,
|
||||
onChanged: (newTheme) {
|
||||
if (newTheme != null) {
|
||||
context.read<ThemeBloc>().add(ChangeThemeEvent(newTheme));
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
children: AppThemeMode.values.map((theme) {
|
||||
return RadioListTile<AppThemeMode>(
|
||||
title: Text(theme.label),
|
||||
secondary: Icon(theme.icon, color: context.accent),
|
||||
value: theme,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user