Initial draft

This commit is contained in:
Dennis Nemec
2025-09-20 16:14:06 +02:00
commit b19a6e1cd4
219 changed files with 10317 additions and 0 deletions

View File

@ -0,0 +1,28 @@
import 'package:hl_lieferservice/feature/authentication/bloc/auth_event.dart';
import 'package:hl_lieferservice/feature/authentication/bloc/auth_state.dart';
import 'package:hl_lieferservice/repository/user_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart';
import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart';
class AuthBloc extends Bloc<AuthEvent, AuthState> {
UserRepository repository;
OperationBloc operationBloc;
AuthBloc({required this.repository, required this.operationBloc})
: super(Unauthenticated()) {
on<Authenticate>(_auth);
on<Logout>(_logout);
}
Future<void> _auth(Authenticate event, Emitter<AuthState> emit) async {
operationBloc.add(LoadOperation());
await Future.delayed(Duration(seconds: 5));
emit(Authenticated(teamId: event.username));
operationBloc.add(FinishOperation());
}
Future<void> _logout(Logout event, Emitter<AuthState> emit) async {
emit(Unauthenticated());
}
}

View File

@ -0,0 +1,14 @@
abstract class AuthEvent {}
class Authenticate extends AuthEvent {
String username;
String password;
Authenticate({required this.username, required this.password});
}
class Logout extends AuthEvent {
String username;
Logout({required this.username});
}

View File

@ -0,0 +1,9 @@
abstract class AuthState {}
class Unauthenticated extends AuthState {}
class Authenticated extends AuthState {
String teamId;
Authenticated({required this.teamId});
}