ticket labels e ticket receipt
This commit is contained in:
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/features/company/bloc/company_settings_cubit.dart';
|
||||
import 'package:flux/features/company/models/company_model.dart';
|
||||
import 'package:flux/features/settings/document_sequence/blocs/document_sequence_cubit.dart';
|
||||
import 'package:flux/features/settings/document_sequence/ui/document_sequence_section.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class CompanySettingsScreen extends StatefulWidget {
|
||||
@@ -24,6 +26,7 @@ class _CompanySettingsScreenState extends State<CompanySettingsScreen> {
|
||||
final _zipCtrl = TextEditingController();
|
||||
final _phoneCtrl = TextEditingController();
|
||||
final _emailCtrl = TextEditingController();
|
||||
final _disclaimerCtrl = TextEditingController();
|
||||
|
||||
bool _isInitialized = false;
|
||||
|
||||
@@ -50,6 +53,8 @@ class _CompanySettingsScreenState extends State<CompanySettingsScreen> {
|
||||
_zipCtrl.dispose();
|
||||
_phoneCtrl.dispose();
|
||||
_emailCtrl.dispose();
|
||||
_disclaimerCtrl.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -69,6 +74,9 @@ class _CompanySettingsScreenState extends State<CompanySettingsScreen> {
|
||||
if (_phoneCtrl.text.isEmpty) _phoneCtrl.text = company.phone ?? '';
|
||||
if (_emailCtrl.text.isEmpty) _emailCtrl.text = company.email ?? '';
|
||||
_isInitialized = true;
|
||||
if (_disclaimerCtrl.text.isEmpty) {
|
||||
_disclaimerCtrl.text = company.ticketDisclaimer ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
void _flushToCubit() {
|
||||
@@ -83,6 +91,7 @@ class _CompanySettingsScreenState extends State<CompanySettingsScreen> {
|
||||
zipCode: _zipCtrl.text,
|
||||
phone: _phoneCtrl.text,
|
||||
email: _emailCtrl.text,
|
||||
ticketDisclaimer: _disclaimerCtrl.text,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,6 +108,36 @@ class _CompanySettingsScreenState extends State<CompanySettingsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onLabelFormatChanged(LabelFormat selectedFormat) {
|
||||
double? w;
|
||||
double? h;
|
||||
|
||||
switch (selectedFormat) {
|
||||
case LabelFormat.small_62x29:
|
||||
w = 62.0;
|
||||
h = 29.0;
|
||||
break;
|
||||
case LabelFormat.medium_54x101:
|
||||
w = 54.0;
|
||||
h = 101.0;
|
||||
break;
|
||||
case LabelFormat.large_102x152:
|
||||
w = 102.0;
|
||||
h = 152.0;
|
||||
break;
|
||||
case LabelFormat.custom:
|
||||
case LabelFormat.none:
|
||||
// Lasciamo i valori null o quelli vecchi
|
||||
break;
|
||||
}
|
||||
|
||||
context.read<CompanySettingsCubit>().updateFields(
|
||||
labelFormat: selectedFormat,
|
||||
labelWidth: w,
|
||||
labelHeight: h,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -312,6 +351,63 @@ class _CompanySettingsScreenState extends State<CompanySettingsScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BlocProvider(
|
||||
create: (context) =>
|
||||
DocumentSequenceCubit(state.company!.id!)
|
||||
..loadSequences(),
|
||||
child: const DocumentSequenceSection(),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Sezione Disclaimer
|
||||
Text(
|
||||
"Note Legali Ricevuta",
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: _disclaimerCtrl,
|
||||
maxLines: 5,
|
||||
decoration: const InputDecoration(
|
||||
hintText:
|
||||
"Inserisci qui la liberatoria legale che apparirà sulla ricevuta dei ticket...",
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (val) => context
|
||||
.read<CompanySettingsCubit>()
|
||||
.updateFields(ticketDisclaimer: val),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Sezione Etichette
|
||||
Text(
|
||||
"Configurazione Etichette",
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonFormField<LabelFormat>(
|
||||
initialValue: company.labelFormat,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.label_outline),
|
||||
labelText: "Formato Stampa Etichetta",
|
||||
),
|
||||
items: LabelFormat.values
|
||||
.map(
|
||||
(f) => DropdownMenuItem(
|
||||
value: f,
|
||||
child: Text(
|
||||
f.name.replaceAll('_', ' ').toUpperCase(),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
_onLabelFormatChanged(val);
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
|
||||
// --- PULSANTE SALVATAGGIO ---
|
||||
|
||||
Reference in New Issue
Block a user