Added components to article
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/authentication/bloc/auth_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/authentication/bloc/auth_state.dart';
|
||||
import 'package:hl_lieferservice/feature/car_selection/bloc/bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/car_selection/bloc/events.dart';
|
||||
import 'package:hl_lieferservice/feature/car_selection/bloc/state.dart';
|
||||
@ -18,7 +20,12 @@ class _CarSelectionEnforcerState extends State<CarSelectionEnforcer> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
context.read<CarSelectBloc>().add(CarSelectLoad());
|
||||
final authState = context.read<AuthBloc>().state;
|
||||
if (authState is Authenticated) {
|
||||
context
|
||||
.read<CarSelectBloc>()
|
||||
.add(CarSelectLoad(userId: authState.user.number));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -53,8 +60,14 @@ class _CarSelectionEnforcerState extends State<CarSelectionEnforcer> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton(
|
||||
onPressed: () =>
|
||||
context.read<CarSelectBloc>().add(CarSelectLoad()),
|
||||
onPressed: () {
|
||||
final authState = context.read<AuthBloc>().state;
|
||||
if (authState is Authenticated) {
|
||||
context.read<CarSelectBloc>().add(
|
||||
CarSelectLoad(userId: authState.user.number),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text("Erneut versuchen"),
|
||||
),
|
||||
],
|
||||
|
||||
@ -52,7 +52,13 @@ class _CarSelectionPageState extends State<CarSelectionPage> {
|
||||
|
||||
void _onConfirm() {
|
||||
if (_selectedCar == null) return;
|
||||
context.read<CarSelectBloc>().add(CarSelectConfirm(car: _selectedCar!));
|
||||
final authState = context.read<AuthBloc>().state as Authenticated;
|
||||
context.read<CarSelectBloc>().add(
|
||||
CarSelectConfirm(
|
||||
userId: authState.user.number,
|
||||
car: _selectedCar!,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCarList(List<Car> cars) {
|
||||
|
||||
Reference in New Issue
Block a user