mandreshope d09d8ace8c feat: Implements visual status for pickings
Introduces an `isDone` extension property for stock picking records to simplify status checks.

Enhances the `StockPickingCard` to visually represent the picking's completion status with a distinct icon and color (green for 'done', grey for 'in progress'), improving clarity at a glance. Information row values are now consistently uppercased.

Conditionally displays scan-related actions (QuickActionComponent and FloatingActionButton) in the reception details page, making them available only when the picking is not yet completed. This guides users by preventing interactions on finished operations.
2025-07-30 10:49:51 +03:00

112 lines
4.4 KiB
Dart

import 'package:e_scan/backend/schema/stock_picking/stock_picking_model.dart';
import 'package:e_scan/components/components.dart';
import 'package:e_scan/pages/operation/reception/reception_page_model.dart';
import 'package:e_scan/router/go_secure_router_builder.dart';
import 'package:e_scan/themes/app_theme.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter/material.dart';
class ReceptionPage extends ConsumerStatefulWidget {
const ReceptionPage({super.key});
@override
ConsumerState<ReceptionPage> createState() => _ReceptionPageState();
}
class _ReceptionPageState extends ConsumerState<ReceptionPage> {
final globalKey = GlobalKey<ScaffoldState>();
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) {
ref.read(receptionPageModelProvider.notifier).getUserConnected();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppTheme.of(context).primaryBackground,
key: globalKey,
drawer: DrawerComponent(isOperationExpanded: true),
appBar: MainAppbarComponent(
scaffoledKey: globalKey,
title: "Réceptions",
subTitle: "Opérations d'Entrepôt",
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ListView(
children: [
const SizedBox(height: 16),
QuickActionComponent(
onTapAdd: () {},
onTapScan: () {},
onTapSearch: () {},
),
const SizedBox(height: 16),
Consumer(
builder: (_, WidgetRef ref, _) {
final state = ref.watch(receptionPageModelProvider);
if (state.loadingReceptions) {
return Center(child: LoadingProgressComponent());
}
return Column(
spacing: 10,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Text(
// 'Réceptions',
// style: AppTheme.of(
// context,
// ).bodyMedium.copyWith(fontWeight: FontWeight.bold),
// ),
state.receptions?.result?.records?.isEmpty == true
? Text('No data')
: ListView.builder(
physics: NeverScrollableScrollPhysics(),
primary: true,
shrinkWrap: true,
itemCount:
(state.receptions?.result?.records ??
<StockPickingRecordModel>[])
.length,
itemBuilder: (context, index) {
final reception =
state.receptions?.result?.records![index];
return GestureDetector(
onTap: () {
final id = reception?.id;
if (id == null) return;
ReceptionDetailsRoute(
receptionId: id,
).push(context);
},
child: StockPickingCard(
margin: EdgeInsets.symmetric(
horizontal: 5,
vertical: 5,
),
isDone: reception?.isDone == true,
reference: reception?.name ?? '',
from: reception?.locationId?.completeName,
to: reception?.locationDestId?.completeName,
contact: reception?.partnerId?.displayName,
origin: reception?.origin,
status: reception?.state,
),
);
},
),
],
);
},
),
],
),
),
);
}
}