Erweiterungen
This commit is contained in:
1 parent
1732a634be
commit
ce66ed2ba0
2 files changed
+32
-47
No files matched your search
@@ -284,15 +284,13 @@ class _TaskListPageState extends State<TaskListPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_processTakePhotos(TaskInfo taskInfo) {
|
_processTakePhotos(TaskInfo taskInfo) {
|
||||||
_popup = showTakePhotosPopup(context, taskInfo, () {
|
showTakePhotosPopup(context, taskInfo, () {
|
||||||
taskInfo.additionalText = "Fotos aufgenommen";
|
taskInfo.additionalText = "Fotos aufgenommen";
|
||||||
taskInfo.completed = true;
|
taskInfo.completed = true;
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
_finishTaskProcessing(taskInfo);
|
_finishTaskProcessing(taskInfo);
|
||||||
|
|
||||||
_popup.dismiss(context);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
import 'package:carousel_slider/carousel_slider.dart';
|
import 'package:carousel_slider/carousel_slider.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:kumi_popup_window/kumi_popup_window.dart';
|
|
||||||
import 'package:stadtbote/model/task_info.dart';
|
import 'package:stadtbote/model/task_info.dart';
|
||||||
import 'package:stadtbote/tools/util.dart';
|
import 'package:stadtbote/tools/util.dart';
|
||||||
|
|
||||||
KumiPopupWindow showTakePhotosPopup(BuildContext context, TaskInfo taskInfo, Function() onFinished) {
|
Future<void> showTakePhotosPopup(BuildContext context, TaskInfo taskInfo, Function() onFinished) async {
|
||||||
return showPopupWindow(
|
List<Uint8List> imageDataList = [];
|
||||||
context,
|
|
||||||
//childSize:Size(240, MediaQuery.of(context).size.width * 0.8),
|
|
||||||
gravity: KumiPopupGravity.center,
|
|
||||||
//curve: Curves.elasticOut,
|
|
||||||
bgColor: Colors.grey.withOpacity(0.5),
|
|
||||||
clickOutDismiss: true,
|
|
||||||
clickBackDismiss: true,
|
|
||||||
customAnimation: false,
|
|
||||||
customPop: false,
|
|
||||||
customPage: false,
|
|
||||||
// targetRenderBox: (btnKey.currentContext.findRenderObject() as RenderBox),
|
|
||||||
//needSafeDisplay: true,
|
|
||||||
underStatusBar: false,
|
|
||||||
underAppBar: false,
|
|
||||||
//offsetX: -180,
|
|
||||||
//offsetY: 50,
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
onShowStart: (pop) {},
|
|
||||||
onShowFinish: (pop) {},
|
|
||||||
onDismissStart: (pop) {},
|
|
||||||
onDismissFinish: (pop) {},
|
|
||||||
onClickOut: (pop) {},
|
|
||||||
onClickBack: (pop) {},
|
|
||||||
childFun: (pop) {
|
|
||||||
List<Uint8List> imageList = [];
|
|
||||||
List<Widget> imageWidgetsList = [];
|
List<Widget> imageWidgetsList = [];
|
||||||
|
|
||||||
ValueNotifier<List<Widget>> imageWidgetsListNotifier = ValueNotifier<List<Widget>>([]);
|
ValueNotifier<List<Widget>> imageWidgetsListNotifier = ValueNotifier<List<Widget>>([]);
|
||||||
|
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||||
void capturePhoto() async {
|
void capturePhoto() async {
|
||||||
var photo = await Util.capturePhoto();
|
var photo = await Util.capturePhoto();
|
||||||
|
|
||||||
@@ -43,25 +25,22 @@ KumiPopupWindow showTakePhotosPopup(BuildContext context, TaskInfo taskInfo, Fun
|
|||||||
var imageData = await photo.readAsBytes();
|
var imageData = await photo.readAsBytes();
|
||||||
photo.delete();
|
photo.delete();
|
||||||
|
|
||||||
imageList.add(imageData);
|
imageDataList.add(imageData);
|
||||||
|
|
||||||
imageWidgetsList.clear();
|
|
||||||
for(var image in imageList) {
|
|
||||||
imageWidgetsList.add(GestureDetector(
|
imageWidgetsList.add(GestureDetector(
|
||||||
onTap: () {
|
onTap: () {},
|
||||||
},
|
child: Image.memory(imageData),
|
||||||
child: Image.memory(image),
|
|
||||||
));
|
));
|
||||||
}
|
|
||||||
|
|
||||||
imageWidgetsListNotifier.value = imageWidgetsList;
|
imageWidgetsListNotifier.value = imageWidgetsList;
|
||||||
imageWidgetsListNotifier.notifyListeners();
|
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
key: GlobalKey(),
|
key: GlobalKey(),
|
||||||
height: 530,
|
height: 545,
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 100,
|
height: 100,
|
||||||
@@ -97,18 +76,26 @@ KumiPopupWindow showTakePhotosPopup(BuildContext context, TaskInfo taskInfo, Fun
|
|||||||
disableCenter: false,
|
disableCenter: false,
|
||||||
enableInfiniteScroll: false,
|
enableInfiniteScroll: false,
|
||||||
),
|
),
|
||||||
items: imageWidgetsList.toList()
|
items: imageWidgetsList.toList());
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
getDefaultButton('Hinzufügen', buttonHeight: 50, () => {capturePhoto()}),
|
Visibility(visible: imageDataList.length < taskInfo.task.max!, child: getDefaultButton('Hinzufügen', buttonHeight: 50, () => {capturePhoto()})),
|
||||||
getDefaultButton('Übernehmen', buttonHeight: 50, () => {onFinished()})
|
const SizedBox(height: 12),
|
||||||
|
getDefaultButton(
|
||||||
|
'Übernehmen',
|
||||||
|
buttonHeight: 50,
|
||||||
|
() => {
|
||||||
|
if (imageDataList.length == taskInfo.task.min! && imageDataList.length <= taskInfo.task.max!)
|
||||||
|
{Navigator.of(context).pop(), onFinished()}
|
||||||
|
else
|
||||||
|
{showAlertDialog(context, 'Fehler', 'Sie müssen mindestens ${taskInfo.task.min} Foto(s) aufnehmen')}
|
||||||
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
},
|
}));
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user