Daily commit

This commit is contained in:
Dennis Nemec
2026-02-05 10:46:13 +01:00
parent 4e808e234d
commit e0007dcf33
51 changed files with 2131 additions and 139 deletions

View File

@ -1,4 +1,17 @@
import 'package:app_gaslieferung/bloc/authentication/auth_bloc.dart';
import 'package:app_gaslieferung/bloc/authentication/auth_event.dart';
import 'package:app_gaslieferung/bloc/authentication/auth_state.dart';
import 'package:app_gaslieferung/bloc/message_wrapper/message_bloc.dart';
import 'package:app_gaslieferung/bloc/message_wrapper/message_event.dart';
import 'package:app_gaslieferung/exceptions/login.dart';
import 'package:app_links/app_links.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../bloc/tour_select/bloc.dart';
import '../../repository/tour_repository.dart';
import '../../service/tour_service.dart';
import '../../util/login.dart';
import 'tour_select.dart';
class LoginPage extends StatefulWidget {
@ -9,46 +22,67 @@ class LoginPage extends StatefulWidget {
}
class _LoginPageState extends State<LoginPage> {
void _onLogin() {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const TourSelectPage()));
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.1,
),
child: Column(
children: [
Image.asset(
"assets/graphics/bg-supplier-clouds.png",
fit: BoxFit.contain,
),
Text(
"Willkommen bei\nGaslieferung!",
style: Theme.of(context).textTheme.headlineMedium,
textAlign: TextAlign.center,
body: BlocConsumer<AuthBloc, AuthState>(
builder: (context, state) {
return Center(
child: Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.1,
),
child: Column(
children: [
Image.asset(
"assets/graphics/bg-supplier-clouds.png",
fit: BoxFit.contain,
),
Text(
"Willkommen bei\nGaslieferung!",
style: Theme.of(context).textTheme.headlineMedium,
textAlign: TextAlign.center,
),
Text(
"\nMelden Sie sich an, um Ihre Tour zu starten.",
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.center,
),
Text(
"\nMelden Sie sich an, um Ihre Tour zu starten.",
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.center,
),
Padding(
padding: const EdgeInsets.all(50),
child: FilledButton(
onPressed: _onLogin,
child: Text("Einloggen"),
Padding(
padding: const EdgeInsets.all(50),
child: FilledButton(
onPressed: () {
context.read<AuthBloc>().add(AuthLoginEvent());
},
child: Text("Einloggen"),
),
),
],
),
),
);
},
listener: (context, state) {
if (state is AuthenticatedState) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => BlocProvider(
create: (context) => TourSelectBloc(
repository: TourRepository(
service: TourService(
baseUrl: "http://127.0.0.1:3000",
),
),
),
child: TourSelectPage(),
),
),
],
),
),
);
}
},
),
);
}

View File

@ -1,18 +1,425 @@
import 'package:app_gaslieferung/bloc/authentication/auth_bloc.dart';
import 'package:app_gaslieferung/bloc/authentication/auth_state.dart';
import 'package:app_gaslieferung/bloc/tour/tour_bloc.dart';
import 'package:app_gaslieferung/bloc/tour/tour_event.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/tour/tour_state.dart';
import '../../model/tour.dart';
class TourPage extends StatefulWidget {
const TourPage({super.key});
final String carId;
const TourPage({super.key, required this.carId});
@override
State<StatefulWidget> createState() => _TourPageState();
}
class _TourPageState extends State<TourPage> {
@override
void initState() {
super.initState();
var authState = context.read<AuthBloc>().state as AuthenticatedState;
context.read<TourBloc>().add(
TourLoadEvent(carId: "1234", sessionId: authState.sessionId),
);
}
Widget _upperInfo(Tour tour) {
return Row(
children: [
SizedBox(
width: 128,
height: 128,
child: Image.asset(
"assets/graphics/bg-supplier-clouds.png",
fit: BoxFit.contain,
),
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Heutige Lieferungen",
style: Theme.of(context).textTheme.titleLarge,
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: Text(
"Sie haben ${tour.deliveries.length.toString()} Lieferungen für heute",
),
),
],
),
),
],
);
}
Widget _progressCard(Tour tour) {
return Padding(
padding: const EdgeInsets.only(left: 12, right: 12, bottom: 10),
child: Card(
color: Theme.of(context).colorScheme.surfaceContainerLowest,
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
children: [
Row(
children: [
SizedBox(
width: 48,
height: 48,
child: Image.asset(
"assets/graphics/truck.png",
fit: BoxFit.contain,
),
),
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
"Tour-Fortschritt",
style: Theme.of(context).textTheme.titleMedium,
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 0),
child: Column(
children: [
Text(
"${tour.progressPercentage.toStringAsFixed(0)}% erledigt",
style: TextStyle(fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.only(top: 8, bottom: 16),
child: LinearProgressIndicator(
value: tour.progress,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
),
Padding(padding: const EdgeInsets.only(bottom: 15)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
children: [
Row(
children: [
Icon(
Icons.check_circle,
color: Theme.of(context).colorScheme.tertiary,
),
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
"Erledigte Lieferungen",
style: Theme.of(context).textTheme.labelSmall,
),
),
],
),
Text(
"${tour.amountFinishedDeliveries} von ${tour.amountDeliveries}",
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
],
),
),
const VerticalDivider(
width: 20,
thickness: 1,
indent: 20,
endIndent: 1,
color: Colors.black,
),
Expanded(
child: Column(
children: [
Row(
children: [
Icon(
Icons.event_note_outlined,
color: Theme.of(context).colorScheme.primary,
),
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
"Offene Lieferungen",
style: Theme.of(context).textTheme.labelSmall,
),
),
],
),
Text(
"${tour.amountDeliveriesLeft} übrig",
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
),
),
],
),
),
],
),
],
),
),
),
);
}
Widget _nextDeliveryCard(Tour tour) {
return Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
child: Card(
color: Theme.of(context).colorScheme.surfaceContainer,
child: Padding(
padding: const EdgeInsets.all(15),
child: Padding(
padding: const EdgeInsets.all(0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Nächste Lieferung",
style: Theme.of(context).textTheme.titleMedium,
),
SizedBox(
width: 48,
height: 48,
child: Image.asset(
"assets/graphics/location-pin-cloud.png",
),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 0),
child: SizedBox(
width: double.infinity,
child: Card(
color: Theme.of(
context,
).colorScheme.surfaceContainerLowest,
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
tour.deliveries[0].receipt.customer.name,
style: Theme.of(
context,
).textTheme.titleSmall,
),
Text(
tour
.deliveries[0]
.receipt
.customer
.displayAddress,
),
],
),
IconButton(
onPressed: () {},
icon: Icon(Icons.map, size: 32),
color: Theme.of(
context,
).colorScheme.secondary,
),
],
),
Padding(
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
),
child: const Divider(),
),
Row(
children: [
Row(
children: [
Icon(
Icons.location_pin,
color: Theme.of(
context,
).colorScheme.secondary,
),
Padding(
padding: const EdgeInsets.only(left: 2),
child: Text("10km"),
),
],
),
Padding(
padding: const EdgeInsets.only(left: 15),
child: Row(
children: [
Icon(
Icons.access_time_filled,
color: Theme.of(
context,
).colorScheme.primary,
),
Padding(
padding: const EdgeInsets.only(left: 2),
child: Text("Ankunft in 10min"),
),
],
),
),
],
),
],
),
),
),
),
),
],
),
),
),
),
);
}
Widget _openDeliveries(Tour tour) {
return Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: Card(
color: Theme.of(context).colorScheme.surfaceContainer,
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Lieferungen",
style: Theme.of(context).textTheme.titleMedium,
),
],
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: SizedBox(
width: double.infinity,
child: ListView.separated(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final delivery = tour.deliveries[index];
return ListTile(
leading: SizedBox(
width: 32,
height: 32,
child: Image.asset("assets/graphics/gas-tank.png"),
),
tileColor: Theme.of(
context,
).colorScheme.surfaceContainerLowest,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
delivery.receipt.customer.name,
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(delivery.receipt.customer.displayAddress, style: TextStyle(fontSize: 13)),
],
),
trailing: Icon(Icons.arrow_forward_ios),
);
},
separatorBuilder: (context, index) =>
Padding(padding: const EdgeInsets.only(top: 10)),
itemCount: tour.amountDeliveries,
),
),
),
],
),
),
),
);
}
Widget _listTour(Tour tour) {
return ListView(
children: [
_upperInfo(tour),
_progressCard(tour),
_nextDeliveryCard(tour),
_openDeliveries(tour),
],
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Lieferungen")),
body: Center(child: const Text("HI")),
body: BlocBuilder<TourBloc, TourState>(
builder: (context, state) {
if (state is TourLoading) {
return Center(child: CircularProgressIndicator());
}
if (state is TourLoaded) {
return _listTour(state.tour);
}
if (state is TourLoadingFailed) {
return Center(child: Text(state.message));
}
return Container();
},
),
);
}
}

View File

@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
class TourDetailPage extends StatefulWidget {
/// The id of the car that has been chosen a step before.
final String supplierCarId;
const TourDetailPage({super.key, required this.supplierCarId});
@override
State<StatefulWidget> createState() => _TourDetailPageState();
}
class _TourDetailPageState extends State<TourDetailPage> {
@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
}
}

View File

@ -1,4 +1,13 @@
import 'package:app_gaslieferung/bloc/authentication/auth_bloc.dart';
import 'package:app_gaslieferung/bloc/authentication/auth_state.dart';
import 'package:app_gaslieferung/bloc/tour_select/bloc.dart';
import 'package:app_gaslieferung/model/supplier.dart';
import 'package:app_gaslieferung/ui/page/tour.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/tour_select/event.dart';
import '../../bloc/tour_select/state.dart';
class TourSelectPage extends StatefulWidget {
const TourSelectPage({super.key});
@ -8,95 +17,156 @@ class TourSelectPage extends StatefulWidget {
}
class _TourSelectPageState extends State<TourSelectPage> {
Widget _listTour() {
@override
void initState() {
super.initState();
context.read<TourSelectBloc>().add(
TourSelectLoadMetadataEvent(
sessionId:
(context.read<AuthBloc>().state as AuthenticatedState).sessionId,
),
);
}
Widget _listTour(SupplierTourMetadata data) {
return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
TourMetadata tourData = data.tours[index];
return ListTile(
leading: Icon(Icons.local_shipping_outlined),
title: const Text("Dennis Nemec"),
subtitle: const Text("15 Lieferungen"),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TourPage(carId: tourData.car.id.toString()),
),
),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Text(tourData.car.driverName ?? tourData.car.carName)],
),
subtitle: Row(
children: [
tourData.car.driverName != null
? Text("${tourData.car.carName} | ")
: Container(),
Text("${tourData.amountDeliveries} Lieferungen"),
],
),
tileColor: Theme.of(context).colorScheme.surface,
trailing: Icon(Icons.arrow_forward_ios),
);
},
separatorBuilder: (BuildContext context, int index) =>
SizedBox(height: 10),
itemCount: 6,
itemCount: data.tours.length,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ListView(
children: [
Image.asset(
"assets/graphics/bg-carrier-cylinder-duo.png",
fit: BoxFit.contain,
),
body: BlocBuilder<TourSelectBloc, TourSelectState>(
builder: (context, state) {
if (state is TourSelectLoading) {
return const Center(child: CircularProgressIndicator());
}
Padding(padding: const EdgeInsets.only(top: 25), child: Text(
"Wählen Sie Ihre Tour aus:",
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),),
if (state is TourSelectError) {
return Center(child: Text(state.message));
}
Padding(
padding: const EdgeInsets.all(15),
child: SizedBox(
width: double.infinity,
child: Card(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 10),
child: Icon(Icons.tour),
),
Text(
"Touren",
style: Theme.of(context).textTheme.titleMedium,
),
],
),
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 10),
child: Icon(Icons.calendar_month),
),
Text(
"01.02.2026",
style: Theme.of(context).textTheme.labelLarge,
),
],
),
],
),
if (state is TourSelectLoaded) {
return Center(
child: ListView(
children: [
Image.asset(
"assets/graphics/bg-carrier-cylinder-duo.png",
fit: BoxFit.contain,
),
Padding(
padding: const EdgeInsets.only(top: 15),
child: _listTour(),
),
],
Padding(
padding: const EdgeInsets.only(top: 25),
child: Text(
"Wählen Sie Ihre Tour aus:",
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
),
),
Padding(
padding: const EdgeInsets.all(15),
child: SizedBox(
width: double.infinity,
child: Card(
color: Theme.of(
context,
).colorScheme.surfaceContainerHighest,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(
right: 10,
),
child: Icon(Icons.tour),
),
Text(
"Touren",
style: Theme.of(
context,
).textTheme.titleMedium,
),
],
),
Row(
children: [
Padding(
padding: const EdgeInsets.only(
right: 10,
),
child: Icon(Icons.calendar_month),
),
Text(
state.data.date,
style: Theme.of(
context,
).textTheme.labelLarge,
),
],
),
],
),
Padding(
padding: const EdgeInsets.only(top: 15),
child: _listTour(state.data),
),
],
),
),
),
),
),
],
),
),
],
),
);
}
return Container();
},
),
);
}

View File

@ -29,9 +29,14 @@ class AppTheme {
onErrorContainer: Color(0xFF410E0B),
surface: Color(0xFFFFF8F2),
surfaceContainerLowest: Color(0xFFFFFFFF),
surfaceContainerLow: Color(0xFFFFF4EB),
surfaceContainer: Color(0xFFFAEFE5),
surfaceContainerHigh: Color(0xFFF5E9DE),
surfaceContainerHighest: Color(0xFFEFE3D8),
onSurface: Color(0xFF1F1F1F),
surfaceContainerHighest: Color(0xFFF2E6DA),
//surfaceContainerHighest: Color(0xFFF2E6DA),
onSurfaceVariant: Color(0xFF4A4A4A),
outline: Color(0xFFC8BEB4),

View File

@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../bloc/message_wrapper/message_bloc.dart';
import '../../../bloc/message_wrapper/message_state.dart';
class MessageWrapperWidget extends StatefulWidget {
final Widget child;
const MessageWrapperWidget({super.key, required this.child});
@override
State<StatefulWidget> createState() => MessageWrapperWidgetState();
static MessageWrapperWidgetState of(BuildContext context) {
return context.findAncestorStateOfType<MessageWrapperWidgetState>()!;
}
}
class MessageWrapperWidgetState extends State<MessageWrapperWidget> {
@override
Widget build(BuildContext context) {
return BlocBuilder<MessageBloc, MessageState>(
builder: (context, state) {
if (state is MessageShowState) {
return Stack(
children: [
widget.child,
Positioned(
top: 50,
left: 0,
right: 0,
child: Padding(
padding: const EdgeInsets.all(10),
child: Material(
color: Colors.transparent,
child: Container(
margin: EdgeInsets.all(8),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 15),
child: Icon(Icons.info, size: 32),
),
Expanded(child: Text(state.message)),
],
),
),
),
),
),
),
],
);
}
return widget.child;
},
);
}
}