aggiunta staff section a OperationFormScreen
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
||||
import 'package:flux/features/operations/blocs/operations_cubit.dart';
|
||||
import 'package:flux/features/operations/models/operation_model.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
// IMPORTA IL TUO CUBIT DELLO STAFF
|
||||
// import 'package:flux/features/staff/blocs/staff_cubit.dart';
|
||||
|
||||
@@ -13,7 +16,9 @@ class StaffSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final selectedStaffId = currentOp?.staffId;
|
||||
final selectedStaffId =
|
||||
currentOp?.staffId ??
|
||||
GetIt.I.get<SessionCubit>().state.currentStaffMember?.id;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -27,37 +32,27 @@ class StaffSection extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Ascoltiamo il Cubit che contiene la lista dei membri dello staff del negozio
|
||||
// BlocBuilder<StaffCubit, StaffState>(
|
||||
// builder: (context, state) {
|
||||
// final staffMembers = state.storeStaff;
|
||||
|
||||
// Sostituisci questo blocco 'simulato' con i dati veri del tuo BlocBuilder
|
||||
Builder(
|
||||
builder: (context) {
|
||||
BlocBuilder<StaffCubit, StaffState>(
|
||||
builder: (context, state) {
|
||||
// Dati finti per farti vedere la UI, piallali quando attacchi il BlocBuilder!
|
||||
final staffMembers = [
|
||||
{'id': '1', 'name': 'Tu (Admin)'},
|
||||
{'id': '2', 'name': 'Marco'},
|
||||
{'id': '3', 'name': 'Giulia'},
|
||||
];
|
||||
final staffMembers = state.storeStaff;
|
||||
final currentLoggedStaffMember = GetIt.I
|
||||
.get<SessionCubit>()
|
||||
.state
|
||||
.currentStaffMember;
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: staffMembers.map((staff) {
|
||||
final staffId = staff['id'] as String;
|
||||
final staffName = staff['name'] as String;
|
||||
|
||||
final isSelected = staffId == selectedStaffId;
|
||||
final isSelected = staff.id == selectedStaffId;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// Aggiorniamo la form con un solo tap!
|
||||
context.read<OperationsCubit>().updateOperationFields(
|
||||
staffId: staffId,
|
||||
staffDisplayName: staffName,
|
||||
staffId: staff.id,
|
||||
staffDisplayName: staff.name,
|
||||
);
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
@@ -99,7 +94,7 @@ class StaffSection extends StatelessWidget {
|
||||
? Colors.white
|
||||
: theme.colorScheme.primaryContainer,
|
||||
child: Text(
|
||||
staffName.substring(0, 1).toUpperCase(),
|
||||
staff.name.substring(0, 1).toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -111,7 +106,9 @@ class StaffSection extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
staffName,
|
||||
staff == currentLoggedStaffMember
|
||||
? 'Tu (${staff.name})'
|
||||
: staff.name,
|
||||
style: TextStyle(
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
|
||||
Reference in New Issue
Block a user