Added custom tour ordering

This commit is contained in:
Dennis Nemec
2025-12-20 21:00:33 +01:00
parent 0c61f65961
commit edb8676f5a
13 changed files with 502 additions and 166 deletions

View File

@ -48,11 +48,29 @@ class _SignatureViewState extends State<SignatureView> {
bool _customerAccepted = false;
bool _noteAccepted = false;
bool _notesEmpty = true;
bool _isCustomerSignatureEmpty = true;
bool _isDriverSignatureEmpty = true;
@override
void initState() {
super.initState();
_customerController.addListener(() {
if (_isCustomerSignatureEmpty != _customerController.isEmpty) {
setState(() {
_isCustomerSignatureEmpty = _customerController.isEmpty;
});
}
});
_driverController.addListener(() {
if (_isDriverSignatureEmpty != _driverController.isEmpty) {
setState(() {
_isDriverSignatureEmpty = _driverController.isEmpty;
});
}
});
// only load notes if they are not already loaded
final noteState = context.read<NoteBloc>().state;
if (noteState is NoteInitial) {
@ -63,6 +81,7 @@ class _SignatureViewState extends State<SignatureView> {
@override
void dispose() {
_customerController.dispose();
_driverController.dispose();
super.dispose();
}
@ -92,12 +111,18 @@ class _SignatureViewState extends State<SignatureView> {
_notesEmpty = current.notes.isEmpty;
});
}
if (current is NoteLoadedBase) {
setState(() {
_notesEmpty = current.notes.isEmpty;
});
}
},
builder: (context, state) {
final current = state;
if (current is NoteLoaded) {
if (current is NoteLoadedBase) {
if (current.notes.isEmpty) {
return const SizedBox(
width: double.infinity,
@ -107,12 +132,12 @@ class _SignatureViewState extends State<SignatureView> {
return ListView.separated(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return ListTile(
leading: const Icon(Icons.event_note_outlined),
title: Text(current.notes[index].content),
contentPadding: EdgeInsets.all(20),
contentPadding: const EdgeInsets.all(20),
tileColor: Theme.of(context).colorScheme.onSecondary,
);
},
@ -121,7 +146,7 @@ class _SignatureViewState extends State<SignatureView> {
);
}
return SizedBox(
return const SizedBox(
width: double.infinity,
child: Center(child: CircularProgressIndicator()),
);
@ -156,10 +181,17 @@ class _SignatureViewState extends State<SignatureView> {
});
},
),
const Flexible(
child: Text(
"Ich nehme die oben genannten Anmerkungen zur Lieferung zur Kenntnis.",
overflow: TextOverflow.fade,
Flexible(
child: InkWell(
onTap: _notesEmpty ? null : () {
setState(() {
_noteAccepted = !_noteAccepted;
});
},
child: Text(
"Ich nehme die oben genannten Anmerkungen zur Lieferung zur Kenntnis.",
overflow: TextOverflow.fade,
),
),
),
],
@ -177,10 +209,17 @@ class _SignatureViewState extends State<SignatureView> {
});
},
),
const Flexible(
child: Text(
"Ich bestätige, dass ich die Ware im ordnungsgemäßen Zustand erhalten habe und, dass die Aufstell- und Einbauarbeiten korrekt durchgeführt wurden.",
overflow: TextOverflow.fade,
Flexible(
child: InkWell(
child: Text(
"Ich bestätige, dass ich die Ware im ordnungsgemäßen Zustand erhalten habe und, dass die Aufstell- und Einbauarbeiten korrekt durchgeführt wurden.",
overflow: TextOverflow.fade,
),
onTap: () {
setState(() {
_customerAccepted = !_customerAccepted;
});
},
),
),
],
@ -195,6 +234,16 @@ class _SignatureViewState extends State<SignatureView> {
Widget build(BuildContext context) {
String formattedDate = DateFormat("dd.MM.yyyy").format(DateTime.now());
bool isButtonEnabled;
if (!_isDriverSigning) {
isButtonEnabled =
_customerAccepted &&
(_noteAccepted || _notesEmpty) &&
!_isCustomerSignatureEmpty;
} else {
isButtonEnabled = !_isDriverSignatureEmpty;
}
return Scaffold(
appBar: AppBar(
title:
@ -247,9 +296,8 @@ class _SignatureViewState extends State<SignatureView> {
child: Center(
child: FilledButton(
onPressed:
!(_customerAccepted && (_noteAccepted || _notesEmpty))
? null
: () async {
isButtonEnabled
? () async {
if (!_isDriverSigning) {
setState(() {
_isDriverSigning = true;
@ -260,7 +308,8 @@ class _SignatureViewState extends State<SignatureView> {
(await _driverController.toPngBytes())!,
);
}
},
}
: null,
child:
!_isDriverSigning
? const Text("Weiter")