Initial draft
This commit is contained in:
79
lib/widget/home/presentation/home.dart
Normal file
79
lib/widget/home/presentation/home.dart
Normal file
@ -0,0 +1,79 @@
|
||||
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/cars/presentation/car_management_page.dart';
|
||||
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/widget/navigation_bar/presentation/navigation_bar.dart';
|
||||
|
||||
import '../../../bloc/app_bloc.dart';
|
||||
import '../../../bloc/app_states.dart';
|
||||
import '../../../feature/cars/bloc/cars_bloc.dart';
|
||||
import '../../../feature/cars/repository/cars_repository.dart';
|
||||
import '../../../feature/cars/service/cars_service.dart';
|
||||
import '../../operations/bloc/operation_bloc.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
const Home({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _HomeState();
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
Widget _buildPage(index) {
|
||||
if (index == 0) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
if (index == 1) {
|
||||
return DeliveryOverviewPage();
|
||||
}
|
||||
|
||||
if (index == 2) {
|
||||
final currentAppState = context.read<AppBloc>().state as AppConfigLoaded;
|
||||
return BlocProvider(
|
||||
create:
|
||||
(context) => CarsBloc(
|
||||
repository: CarsRepository(
|
||||
service: CarService(config: currentAppState.config),
|
||||
),
|
||||
opBloc: context.read<OperationBloc>(),
|
||||
),
|
||||
child: CarManagementPage(),
|
||||
);
|
||||
}
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user