diff --git a/lib/content_views/assigned_jobs_page.dart b/lib/content_views/assigned_jobs_page.dart new file mode 100644 index 0000000..d1a39b9 --- /dev/null +++ b/lib/content_views/assigned_jobs_page.dart @@ -0,0 +1,179 @@ +import 'package:expandable/expandable.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_broadcast_receiver/flutter_broadcast_receiver.dart'; +import 'package:isar/isar.dart'; +import 'package:stadtbote/content_views/tour_list_page.dart'; +import 'package:stadtbote/content_views/utils/content_view_widget.dart'; +import 'package:stadtbote/content_views/utils/header_info.dart'; +import 'package:intl/intl.dart'; +import 'package:badges/badges.dart' as badges; + +import '../main.dart'; +import '../model/job.dart'; +import '../tools/constants.dart'; +import '../tools/util.dart'; + +class AssignedJobsPage extends ContentViewWidget { + const AssignedJobsPage({super.key}); + + @override + State createState() => _AssignedJobsPageState(); + + @override + Future getHeaderInfo(BuildContext context) async { + return HeaderInfo( + titleWidget: const Text( + 'Zugewiesene Aufträge', + style: TextStyle( + color: Colors.white, + fontSize: 24.0, + ), + ), + rightButtonEnabled: false, + rightButtonVisible: false, + rightButtonImage: null, + rightButtonOnPressed: () async { + //BroadcastReceiver().publish(Constants.messageTopicPushContentView, arguments: EmployeeEditProfileWidget()); + }); + } +} + +class _AssignedJobsPageState extends State { + late bool _initCompleted = false; + + List _entries = []; + + @override + void initState() { + Future.delayed(const Duration(seconds: 0), () async { + _entries = await _createListEntries(); + + _initCompleted = true; + + setState(() {}); + }); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + if (!_initCompleted) { + return Util.getWaitWidget(context); + } + + return Container( + height: 100, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + border: Border.all( + color: Colors.grey, + width: 0.5, + ), + ), + child: SingleChildScrollView(child: Column(children: _entries)), + ); + } + + Future> _createListEntries() async { + List entries = []; + + var jobs = await MyApp.isarInstance.jobs.filter().stateEqualTo(0).findAll(); + for (var job in jobs) { + entries.add(ExpandableNotifier( + child: ListTile( + contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8), + title: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all( + color: Constants.colorPrimary, + width: 1, + ), + ), + child: badges.Badge( + position: badges.BadgePosition.topEnd(top: -13, end: -5), + showBadge: true, + badgeContent: const Text( + 'Neu', + style: TextStyle( + color: Colors.white, + fontSize: 18.0, + ), + ), + badgeStyle: badges.BadgeStyle( + shape: badges.BadgeShape.square, + badgeColor: Constants.colorPrimary, + padding: const EdgeInsets.all(5), + borderRadius: BorderRadius.circular(5), + borderSide: const BorderSide(color: Constants.colorPrimary, width: 0), + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + children: [ + Text(DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(), textAlign: TextAlign.left), + Text('Auftragsnummer: ${job.id}'), + Text(job.tours[0].comp), + Text(job.tours[0].street), + Text(job.tours[0].city), + const SizedBox(height: 20), + ScrollOnExpand( + scrollOnExpand: true, + scrollOnCollapse: false, + child: ExpandablePanel( + theme: const ExpandableThemeData( + headerAlignment: ExpandablePanelHeaderAlignment.center, + tapBodyToCollapse: true, + ), + header: const Padding( + padding: EdgeInsets.all(0), + child: Text( + "Weitere Infos....", + style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.bold), + )), + collapsed: SizedBox(), + expanded: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 200, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color(0xfffff4e4), + border: Border.all( + color: Colors.grey, + width: 0.5, + ), + ), + child: Text('asd asd asd asd asd asd asd asd asd asd asd asd asd asd asd '), + ), + ], + ), + ), + ), + const SizedBox(height: 20), + Row(children: [ + Expanded( + child: getDefaultButton('Ablehnen', () => {_sendAnswer()}), + ), + const SizedBox(width: 20), + Expanded( + child: getDefaultButton('Annehmen', () => {}), + ) + ]) + ], + ), + ), + ), + ), + ), + )); + } + + return entries; + } + + _sendAnswer() {} +} diff --git a/lib/content_views/main_page.dart b/lib/content_views/main_page.dart index ed61f0d..ab208b2 100644 --- a/lib/content_views/main_page.dart +++ b/lib/content_views/main_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_broadcast_receiver/flutter_broadcast_receiver.dart'; import 'package:isar/isar.dart'; import 'package:stadtbote/content_views/accepted_jobs_page.dart'; +import 'package:stadtbote/content_views/assigned_jobs_page.dart'; import 'package:stadtbote/content_views/finished_jobs_page.dart'; import 'package:stadtbote/content_views/messages_page.dart'; import 'package:stadtbote/content_views/utils/content_view_widget.dart'; @@ -124,7 +125,8 @@ class _MainPageState extends State { child: getDefaultButton( 'Zugewiesene Aufträge', image: Image.asset('assets/zugewiesene_auftraege.png', width: 30, height: 30), - () => {showAcceptJobsPopup(context)}), + () => {BroadcastReceiver() + .publish(Constants.messageTopicPushContentView, arguments: const AssignedJobsPage())}), ); }, ),