Implemented settings, new scan, enhanced UI/UX
This commit is contained in:
@ -6,23 +6,11 @@ import 'navigation_state.dart';
|
||||
|
||||
// Navigation BLoC
|
||||
class NavigationBloc extends Bloc<NavigationEvent, NavigationState> {
|
||||
NavigationBloc() : super(NavigateToRoute('/scan', index: 0)) {
|
||||
on<NavigateToCars>((event, emit) {
|
||||
emit(NavigateToRoute('/cars', index: 2));
|
||||
});
|
||||
|
||||
on<NavigateToDeliveries>((event, emit) {
|
||||
emit(NavigateToRoute('/deliveries', index: 1));
|
||||
});
|
||||
|
||||
on<NavigateToDelivery>((event, emit) {
|
||||
emit(NavigateToRoute('/delivery'));
|
||||
});
|
||||
|
||||
on<NavigateToScan>((event, emit) {
|
||||
emit(NavigateToRoute('/scan', index: 0));
|
||||
});
|
||||
|
||||
// Add more navigation handlers...
|
||||
NavigationBloc() : super(NavigationInfo(navigationIndex: 0)) {
|
||||
on<NavigateToIndex>(_navigate);
|
||||
}
|
||||
}
|
||||
|
||||
void _navigate(NavigateToIndex event, Emitter<NavigationState> emit) {
|
||||
emit(NavigationInfo(navigationIndex: event.index));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
abstract class NavigationEvent {}
|
||||
|
||||
class NavigateToHome extends NavigationEvent {}
|
||||
class NavigateToDeliveries extends NavigationEvent {}
|
||||
class NavigateToDelivery extends NavigationEvent {}
|
||||
class NavigateToScan extends NavigationEvent {}
|
||||
class NavigateToCars extends NavigationEvent {}
|
||||
class GoBack extends NavigationEvent {}
|
||||
class NavigateToIndex extends NavigationEvent {
|
||||
int index;
|
||||
|
||||
NavigateToIndex({required this.index});
|
||||
}
|
||||
@ -1,11 +1,8 @@
|
||||
// Navigation states
|
||||
abstract class NavigationState {}
|
||||
|
||||
class NavigationInitial extends NavigationState {}
|
||||
class NavigateToRoute extends NavigationState {
|
||||
final String routeName;
|
||||
final int? index;
|
||||
final Object? arguments;
|
||||
class NavigationInfo extends NavigationState {
|
||||
int navigationIndex;
|
||||
|
||||
NavigateToRoute(this.routeName, {this.arguments, this.index});
|
||||
}
|
||||
NavigationInfo({required this.navigationIndex});
|
||||
}
|
||||
|
||||
@ -6,6 +6,10 @@ import 'package:hl_lieferservice/feature/cars/presentation/car_management_page.d
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_event.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_overview_page.dart';
|
||||
import 'package:hl_lieferservice/feature/scan/presentation/scan_page.dart';
|
||||
import 'package:hl_lieferservice/widget/app_bar.dart';
|
||||
import 'package:hl_lieferservice/widget/home/bloc/navigation_bloc.dart';
|
||||
import 'package:hl_lieferservice/widget/home/bloc/navigation_state.dart';
|
||||
import 'package:hl_lieferservice/widget/navigation_bar/presentation/navigation_bar.dart';
|
||||
|
||||
import '../../../bloc/app_bloc.dart';
|
||||
@ -23,20 +27,18 @@ class Home extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
int _selectedPage = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Load deliveries
|
||||
Authenticated state = context.read<AuthBloc>().state as Authenticated;
|
||||
context.read<TourBloc>().add(LoadTour(teamId: state.teamId));
|
||||
context.read<TourBloc>().add(LoadTour(teamId: state.user.number));
|
||||
}
|
||||
|
||||
Widget _buildPage(index) {
|
||||
if (index == 0) {
|
||||
return Container();
|
||||
return ScanPage();
|
||||
}
|
||||
|
||||
if (index == 1) {
|
||||
@ -60,20 +62,21 @@ class _HomeState extends State<Home> {
|
||||
return Container();
|
||||
}
|
||||
|
||||
void _onSelect(int index) {
|
||||
setState(() {
|
||||
_selectedPage = index;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Center(child: Text("Holzleitner Lieferservice")),
|
||||
),
|
||||
body: _buildPage(_selectedPage),
|
||||
bottomNavigationBar: AppNavigationBar(onSelect: _onSelect),
|
||||
return BlocBuilder<NavigationBloc, NavigationState>(
|
||||
builder: (context, state) {
|
||||
final currentState = state as NavigationInfo;
|
||||
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(kToolbarHeight),
|
||||
child: CustomAppBar(),
|
||||
),
|
||||
body: _buildPage(currentState.navigationIndex),
|
||||
bottomNavigationBar: AppNavigationBar(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user