Erweiterungen
This commit is contained in:
1 parent
3dab4025e7
commit
3d7ae9de2a
16 files changed
+438
-327
No files matched your search
@@ -3,13 +3,16 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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';
|
||||
import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||
import 'package:stadtbote/model/status.dart';
|
||||
import 'package:stadtbote/popups/infos_popup.dart';
|
||||
import 'package:stadtbote/tools/session_info_update.dart';
|
||||
|
||||
import '../main.dart';
|
||||
import '../model/job.dart';
|
||||
@@ -17,7 +20,16 @@ import '../tools/constants.dart';
|
||||
import '../tools/util.dart';
|
||||
|
||||
class MainPage extends ContentViewWidget {
|
||||
const MainPage({super.key});
|
||||
final ValueNotifier<String> _zipValueNotifier = ValueNotifier("----");
|
||||
final ValueNotifier<String> _sidValueNotifier = ValueNotifier("----");
|
||||
|
||||
MainPage({super.key}) {
|
||||
Status? status = MyApp.isarInstance.status.where().findFirstSync();
|
||||
if (status != null) {
|
||||
_zipValueNotifier.value = status.locZip;
|
||||
_sidValueNotifier.value = status.sid;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
@@ -27,21 +39,31 @@ class MainPage extends ContentViewWidget {
|
||||
return HeaderInfo(
|
||||
titleWidget: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 3),
|
||||
child: const Column(children: [
|
||||
Text(
|
||||
'Zeile 1',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
child: Column(children: [
|
||||
ValueListenableBuilder<String>(
|
||||
valueListenable: _zipValueNotifier,
|
||||
builder: (context, value, child) {
|
||||
return Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
'Zeile 2',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
ValueListenableBuilder<String>(
|
||||
valueListenable: _sidValueNotifier,
|
||||
builder: (context, value, child) {
|
||||
return Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
]),
|
||||
),
|
||||
@@ -55,6 +77,13 @@ class MainPage extends ContentViewWidget {
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_initMessages();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
@@ -123,7 +152,7 @@ class _MainPageState extends State<MainPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void _test() async {
|
||||
_test() async {
|
||||
var json = await rootBundle.loadString('assets/job.json');
|
||||
var jsonMap = jsonDecode(json);
|
||||
var payload = jsonMap["payload"];
|
||||
@@ -138,4 +167,10 @@ class _MainPageState extends State<MainPage> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_initMessages() {
|
||||
BroadcastReceiver().subscribe<StatusInfoUpdate>(Constants.messageTopicStatusInfoUpdate, (statusInfoUpdate) {
|
||||
widget._sidValueNotifier.value = statusInfoUpdate.status.sid;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import 'package:stadtbote/popups/tasks_popups/scan_barcodes_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/signature_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/station_notice_popup.dart';
|
||||
import 'package:stadtbote/popups/tasks_popups/take_photos_popup.dart';
|
||||
import 'package:stadtbote/tools/constants.dart';
|
||||
|
||||
import '../main.dart';
|
||||
import '../model/task_info.dart';
|
||||
@@ -105,11 +106,11 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
children: [
|
||||
Positioned(
|
||||
left: 16.5,
|
||||
top: i == 0 ? 5 : 0,
|
||||
top: i == 0 ? 40 : 40,
|
||||
child: Container(
|
||||
height: i == widget.tour.tasks.length - 1 ? 1: 60,
|
||||
height: i == widget.tour.tasks.length - 1 ? 0 : 20,
|
||||
width: 6,
|
||||
color: Colors.green
|
||||
color: isTaskActive(i) ? Constants.colorPrimary : Constants.colorPrimaryOpaque,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
@@ -117,9 +118,9 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.grey,
|
||||
color: isTaskActive(i) ? Constants.colorPrimary : Constants.colorPrimaryOpaque,
|
||||
),
|
||||
child: const Icon(Icons.check, size: 30.0, color: Colors.white),
|
||||
),
|
||||
@@ -130,7 +131,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
const SizedBox(width: 20),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
taskInfo.task.topic,
|
||||
@@ -142,7 +143,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
taskInfo.additionalText ?? 'Additonal text',
|
||||
taskInfo.additionalText ?? '',
|
||||
textAlign: TextAlign.left,
|
||||
style: const TextStyle(
|
||||
color: Colors.blue,
|
||||
@@ -169,12 +170,14 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
|
||||
for(var task in widget.tour.tasks) {
|
||||
var taskInfo = await MyApp.isarInstance.taskInfos.filter().sIdEqualTo(task.sId).findFirst();
|
||||
taskInfo ??= TaskInfo();
|
||||
if (taskInfo == null) {
|
||||
taskInfo = TaskInfo();
|
||||
taskInfo.answer = null;
|
||||
taskInfo.additionalText = null;
|
||||
taskInfo.completed = task.opt as bool;
|
||||
}
|
||||
|
||||
taskInfo.task = task;
|
||||
|
||||
taskInfo.answer = null;
|
||||
taskInfo.additionalText = null;
|
||||
|
||||
taskList.add(taskInfo);
|
||||
}
|
||||
|
||||
@@ -225,6 +228,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
DateFormat dateFormat = DateFormat("dd.MM.yyyy HH:mm");
|
||||
|
||||
taskInfo.additionalText = dateFormat.format(DateTime.now());
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
@@ -239,6 +243,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
_popup.dismiss(context);
|
||||
|
||||
taskInfo.additionalText = comissionNumber;
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
@@ -253,16 +258,26 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
_popup.dismiss(context);
|
||||
|
||||
taskInfo.additionalText = "Barcodes gescannt";
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void _processTakePhotos(TaskInfo taskInfo) {
|
||||
_processTakePhotos(TaskInfo taskInfo) {
|
||||
_popup = showTakePhotosPopup(context, taskInfo, () => {
|
||||
_popup.dismiss(context)
|
||||
_finishProcessTakePhotos(taskInfo)
|
||||
});
|
||||
}
|
||||
|
||||
_finishProcessTakePhotos(TaskInfo taskInfo) {
|
||||
_popup.dismiss(context);
|
||||
|
||||
taskInfo.additionalText = "Fotos aufgenommen";
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void _processStationNotice(TaskInfo taskInfo) {
|
||||
_popup = showStationNoticePopup(context, taskInfo, (notice) => {
|
||||
_finishProcessStationNotice(taskInfo, notice)
|
||||
@@ -273,6 +288,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
_popup.dismiss(context);
|
||||
|
||||
taskInfo.additionalText = notice;
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
@@ -287,6 +303,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
_popup.dismiss(context);
|
||||
|
||||
taskInfo.additionalText = receiptGiver;
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
@@ -298,8 +315,20 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
_popup = showSignaturePopup(context, taskInfo, () => {
|
||||
_popup.dismiss(context),
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
|
||||
taskInfo.completed = true,
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bool isTaskActive(int index) {
|
||||
for (int i = 0; i < index; i++) {
|
||||
var taskInfo = _taskList[i];
|
||||
|
||||
if (!taskInfo.completed) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user