import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:hl_lieferservice/model/article.dart'; import 'package:hl_lieferservice/model/delivery.dart'; import '../../../overview/bloc/tour_bloc.dart'; import '../../../overview/bloc/tour_state.dart'; class DeliveryStepInfo extends StatefulWidget { final Delivery delivery; const DeliveryStepInfo({required this.delivery, super.key}); @override State createState() => _DeliveryStepInfo(); } class _DeliveryStepInfo extends State { Widget _fastActions() { return SizedBox( width: double.infinity, child: Card( color: Theme.of(context).colorScheme.onSecondary, child: Padding( padding: const EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( children: [ IconButton.filled(onPressed: () {}, icon: Icon(Icons.phone)), Text("Anrufen"), ], ), Column( children: [ IconButton.filled( onPressed: () {}, icon: Icon(Icons.map_outlined), ), Text("Navigation starten"), ], ), ], ), ), ), ); } Widget _customerInformation() { return SizedBox( width: double.infinity, child: Card( color: Theme.of(context).colorScheme.onSecondary, child: Padding( padding: const EdgeInsets.all(10), child: Column( children: [ Row( children: [ Icon(Icons.person, color: Theme.of(context).primaryColor), Padding( padding: const EdgeInsets.only(left: 10), child: Text( widget.delivery.customer.name, style: TextStyle(fontWeight: FontWeight.bold), ), ), ], ), Padding( padding: const EdgeInsets.only(top: 15), child: Row( children: [ Icon( Icons.other_houses, color: Theme.of(context).primaryColor, ), Padding( padding: const EdgeInsets.only(left: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.delivery.customer.address.street), Text( "${widget.delivery.customer.address.postalCode} ${widget.delivery.customer.address.city}", ), ], ), ), ], ), ), Padding( padding: const EdgeInsets.only(top: 15), child: Row( children: [ Icon(Icons.phone, color: Theme.of(context).primaryColor), Padding( padding: const EdgeInsets.only(left: 10), child: Text( widget.delivery.contactPerson?.phoneNumber.toString() ?? "", ), ), ], ), ), ], ), ), ), ); } Widget _articleList() { TourLoaded tour = context.read().state as TourLoaded; List
filteredArticles = widget.delivery.articles .where( (article) => article.articleNumber != tour.tour.discountArticleNumber, ) .toList(); return ListView.separated( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemBuilder: (context, index) { Article article = filteredArticles[index]; return DecoratedBox( decoration: BoxDecoration( color: Theme.of(context).colorScheme.onSecondary, ), child: ListTile( title: Text(article.name), subtitle: Text("Artikelnr. ${article.articleNumber}"), leading: Chip(label: Text("${article.amount.toString()}x")), ), ); }, separatorBuilder: (context, index) => const Divider(height: 0), itemCount: filteredArticles.length, ); } @override Widget build(BuildContext context) { return Container( alignment: Alignment.centerLeft, child: Padding( padding: const EdgeInsets.all(10), child: ListView( children: [ Text( "Schnellaktionen", style: Theme.of(context).textTheme.headlineSmall, ), Padding( padding: const EdgeInsets.only(top: 10), child: _fastActions(), ), Padding( padding: const EdgeInsets.only(top: 20), child: Text( "Kundeninformationen", style: Theme.of(context).textTheme.headlineSmall, ), ), Padding( padding: const EdgeInsets.only(top: 10), child: _customerInformation(), ), Padding( padding: const EdgeInsets.only(top: 20), child: Text( "Zu liefernde Artikel", style: Theme.of(context).textTheme.headlineSmall, ), ), Padding( padding: const EdgeInsets.only(top: 20), child: _articleList(), ), ], ), ), ); } }