@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/features/home/latest_store_services/bloc/latest_store_services_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class LatestStoreServicesCard extends StatelessWidget {
|
||||
const LatestStoreServicesCard({super.key});
|
||||
@@ -15,7 +17,7 @@ class LatestStoreServicesCard extends StatelessWidget {
|
||||
// 1. Creiamo il Bloc e facciamo partire subito la query
|
||||
create: (context) =>
|
||||
LatestStoreServicesBloc()
|
||||
..add(InitLastServicesEvent(currentStoreId ?? '')),
|
||||
..add(InitLastStoreServicesEvent(currentStoreId ?? '')),
|
||||
child: BlocListener<SessionCubit, SessionState>(
|
||||
// 2. MAGIA: Se l'utente cambia negozio dalla barra in alto, riavviamo lo stream!
|
||||
listenWhen: (previous, current) =>
|
||||
@@ -23,7 +25,7 @@ class LatestStoreServicesCard extends StatelessWidget {
|
||||
listener: (context, state) {
|
||||
if (state.currentStore?.id != null) {
|
||||
context.read<LatestStoreServicesBloc>().add(
|
||||
InitLastServicesEvent(state.currentStore!.id!),
|
||||
InitLastStoreServicesEvent(state.currentStore!.id!),
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -67,15 +69,18 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Ultimi Servizi",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: context.primaryText,
|
||||
child: TextButton(
|
||||
onPressed: () => context.push('/services'),
|
||||
child: Text(
|
||||
context.l10n.homeLatestServices,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: context.primaryText,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -120,31 +125,46 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final service = state.services[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
service.number,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: context.primaryText,
|
||||
return InkWell(
|
||||
onTap: () =>
|
||||
context.push('/service-form', extra: service),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
service.customerDisplayName ??
|
||||
'Cliente sconosciuto',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: context.primaryText,
|
||||
),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
// Se hai formattato la data, stampala qui (es. 12/04/2026)
|
||||
Text(
|
||||
"${service.createdAt?.day}/${service.createdAt?.month}",
|
||||
style: TextStyle(
|
||||
color: context.secondaryText,
|
||||
fontSize: 12,
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
service.number,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: context.primaryText,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
"${service.createdAt?.day}/${service.createdAt?.month}",
|
||||
style: TextStyle(
|
||||
color: context.secondaryText,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user