barcode_scanner/lib/pages/operation/reception/reception_page_model.dart
mandreshope 855770b428 refactor: Replaces Home page with Reception page
Removes the dedicated `HomePage` and its associated model files.

Configures `ReceptionPage` as the new default landing page after successful login and product form submission. Updates navigation and state management dependencies to direct users to the primary operational interface upon entry.
2025-07-23 17:19:37 +03:00

41 lines
1.5 KiB
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_page_model.freezed.dart';
final receptionPageModelProvider =
StateNotifierProvider<ReceptionPageModel, ReceptionPageState>((ref) {
return ReceptionPageModel(
secureStorage: ref.read(sharedPrefsProvider),
tokenProvider: ref.read(tokenProvider),
);
});
class ReceptionPageModel extends StateNotifier<ReceptionPageState> {
/// Constructor initializes the TaskRepository using the provider reference.
ReceptionPageModel({required this.secureStorage, required this.tokenProvider})
: super(const ReceptionPageState());
late FlutterSecureStorage secureStorage;
late TokenProvider tokenProvider;
Future getUserConnected() async {
state = state.copyWith(loading: true);
final user = await UserStruct(id: '1').getFromLocalStorage();
state = state.copyWith(user: user, loading: false);
}
}
@freezed
abstract class ReceptionPageState with _$ReceptionPageState {
const factory ReceptionPageState({
UserStruct? user,
@Default(false) bool loading,
}) = _ReceptionPageState;
}