Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-04 12:50:00 +02:00
parent 212f33ff51
commit 68b075f0b1
15 changed files with 1345 additions and 15 deletions

View File

@@ -5,6 +5,7 @@ import 'package:flux/features/operations/blocs/operations_cubit.dart';
import 'package:flux/features/operations/models/operation_model.dart';
import 'package:flux/features/operations/ui/widgets/customer_section.dart';
import 'package:flux/features/operations/ui/widgets/details_section.dart';
import 'package:flux/features/operations/ui/widgets/operation_files_section.dart';
import 'package:flux/features/operations/ui/widgets/staff_section.dart';
import 'package:get_it/get_it.dart'; // ASSICURATI DEL PATH
// import 'package:flux/features/attachments/ui/operation_files_section.dart';
@@ -29,6 +30,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
final _referenceController = TextEditingController();
final _noteController = TextEditingController();
final _freeTextSubtypeController = TextEditingController();
final _freeTextDescriptionController = TextEditingController();
final List<String> _availableTypes = [
'AL',
@@ -89,6 +91,11 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
model.subtype!.isNotEmpty) {
_freeTextSubtypeController.text = model.subtype!;
}
if (_freeTextDescriptionController.text.isEmpty &&
model.description != null &&
model.description!.isNotEmpty) {
_freeTextDescriptionController.text = model.description!;
}
_isInitialized = true;
}
@@ -103,6 +110,9 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
subtype: ['Entertainment', 'Custom'].contains(currentOperation.type)
? _freeTextSubtypeController.text
: currentOperation.subtype,
description: ['Energy', 'Custom'].contains(currentOperation.type)
? _freeTextDescriptionController.text
: currentOperation.description,
);
cubit.initOperationForm(existingOperation: operationToSave);
@@ -138,6 +148,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
),
);
_freeTextSubtypeController.clear();
_freeTextDescriptionController.clear();
} else if (state.status == OperationsStatus.failure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@@ -168,8 +179,51 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
key: _formKey,
child: LayoutBuilder(
builder: (context, constraints) {
final isUltraWide = constraints.maxWidth > 1400;
final isDesktop = constraints.maxWidth > 900;
if (isDesktop) {
if (isUltraWide) {
// --- LAYOUT 3 COLONNE (Schermi giganti) ---
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 1. FORM PRINCIPALE (40%)
Expanded(
flex: 4,
child: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
// Attenzione: devi togliere la sezione file dal _buildMainFormContent!
child: _buildMainFormContent(
theme,
state,
showFiles: false,
),
),
),
VerticalDivider(width: 1, color: theme.dividerColor),
// 2. NOTE (30%)
Expanded(
flex: 3,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: _buildNotesSection(isDesktop: true),
),
),
VerticalDivider(width: 1, color: theme.dividerColor),
// 3. FILE (30%)
Expanded(
flex: 3,
child: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: OperationFilesSection(
currentOp: state.currentOperation!,
),
),
),
],
);
} else if (isDesktop) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -252,7 +306,11 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
);
}
Widget _buildMainFormContent(ThemeData theme, OperationsState state) {
Widget _buildMainFormContent(
ThemeData theme,
OperationsState state, {
bool showFiles = true,
}) {
final currentOp = state.currentOperation;
final currentType = currentOp?.type ?? 'AL';
@@ -296,6 +354,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
currentOp: currentOp,
currentType: currentType,
freeTextSubtypeController: _freeTextSubtypeController,
freeTextDescriptionController: _freeTextDescriptionController,
durationQuickPicks: _buildDurationQuickPicks(currentOp),
),
@@ -331,13 +390,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
),
const Divider(height: 32),
_buildSectionTitle('Documenti & Foto'),
const Center(
child: Text(
"Widget File in arrivo...",
style: TextStyle(color: Colors.grey),
),
),
if (showFiles) ...[OperationFilesSection(currentOp: currentOp!)],
],
);
}