
Implements a dedicated page for viewing detailed stock picking information. - Introduces `getStockPikingById` API call to fetch a single stock picking record by ID. - Enhances `MainAppbarComponent` to support customizable leading widgets, enabling a back button on detail pages. - Improves `QuickActionComponent` by allowing optional `onTap` callbacks for actions, making buttons conditionally visible and reusable across different contexts. - Adds `margin` property to `StockPickingCard` for flexible layout adjustments. - Refactors `ReceptionDetailsPage` to utilize the new API call and display a single stock picking's details, adapting its app bar and quick actions accordingly.
50 lines
1.6 KiB
Dart
50 lines
1.6 KiB
Dart
import 'package:barcode_scanner/backend/api/api_calls.dart';
|
|
import 'package:barcode_scanner/backend/schema/stock_picking/stock_picking_model.dart';
|
|
import 'package:barcode_scanner/backend/schema/user/user_struct.dart';
|
|
import 'package:barcode_scanner/services/secure_storage.dart';
|
|
import 'package:barcode_scanner/services/token_provider.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'reception_details_page_model.freezed.dart';
|
|
|
|
final receptionDetailsPageModelProvider =
|
|
StateNotifierProvider.autoDispose<
|
|
ReceptionDetailsPageModel,
|
|
ReceptionDetailsPageState
|
|
>((ref) {
|
|
return ReceptionDetailsPageModel();
|
|
});
|
|
|
|
class ReceptionDetailsPageModel
|
|
extends StateNotifier<ReceptionDetailsPageState> {
|
|
ReceptionDetailsPageModel() : super(const ReceptionDetailsPageState());
|
|
|
|
Future getReceptionById({required int id}) async {
|
|
try {
|
|
state = state.copyWith(loading: true);
|
|
final res = await ApiCalls.getStockPikingById(id: id);
|
|
res.when(
|
|
(data) {
|
|
state = state.copyWith(loading: false, reception: data);
|
|
},
|
|
(error) {
|
|
state = state.copyWith(loading: false);
|
|
},
|
|
);
|
|
} catch (e) {
|
|
state = state.copyWith(loading: false);
|
|
}
|
|
}
|
|
}
|
|
|
|
@freezed
|
|
abstract class ReceptionDetailsPageState with _$ReceptionDetailsPageState {
|
|
const factory ReceptionDetailsPageState({
|
|
StockPickingRecordModel? reception,
|
|
@Default(false) bool loading,
|
|
}) = _ReceptionDetailsPageState;
|
|
}
|