|
|
|
|
@ -22,6 +22,7 @@ import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/simple_button.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/image_picker.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/input_widget.dart';
|
|
|
|
|
|
|
|
|
|
class RequestSubmitScreenParams {
|
|
|
|
|
@ -48,6 +49,7 @@ class _RequestSubmitScreenState extends State<RequestSubmitScreen> {
|
|
|
|
|
|
|
|
|
|
List<GetApprovesList> approverList = [];
|
|
|
|
|
List<File> attachmentFiles = [];
|
|
|
|
|
List<String> attachments = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -72,16 +74,16 @@ class _RequestSubmitScreenState extends State<RequestSubmitScreen> {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
List<Map<String, dynamic>> list = [];
|
|
|
|
|
if (attachmentFiles.isNotEmpty) {
|
|
|
|
|
attachmentFiles.asMap().forEach((index, value) async {
|
|
|
|
|
String type = value.path.split('.').last;
|
|
|
|
|
String name = value.path.split('/').last;
|
|
|
|
|
List<int> fileContent = await value.readAsBytes();
|
|
|
|
|
String encodedFile = base64Encode(fileContent);
|
|
|
|
|
attachments.asMap().forEach((index, value) async {
|
|
|
|
|
String type = attachmentFiles[index].path.split('.').last;
|
|
|
|
|
String name = attachmentFiles[index].path.split('/').last;
|
|
|
|
|
// List<int> fileContent = await value.readAsBytes();
|
|
|
|
|
// String encodedFile = base64Encode(fileContent);
|
|
|
|
|
list.add(AttachmentModel(
|
|
|
|
|
attachmentID: index,
|
|
|
|
|
pFILECONTENTTYPE: type,
|
|
|
|
|
pFILENAME: name,
|
|
|
|
|
pFILEDATA: encodedFile,
|
|
|
|
|
pFILEDATA: value,
|
|
|
|
|
pTRANSACTIONID: params!.transactionId,
|
|
|
|
|
).toJson());
|
|
|
|
|
});
|
|
|
|
|
@ -261,12 +263,18 @@ class _RequestSubmitScreenState extends State<RequestSubmitScreen> {
|
|
|
|
|
title.toText16().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
SimpleButton(LocaleKeys.add.tr(), () async {
|
|
|
|
|
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList();
|
|
|
|
|
attachmentFiles = attachmentFiles.toSet().toList();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
ImageOptions.showImageOptionsNew(context, false, (String image, File file) {
|
|
|
|
|
setState(() {
|
|
|
|
|
attachmentFiles.add(file);
|
|
|
|
|
attachments.add(image);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// if (result != null) {
|
|
|
|
|
// attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList();
|
|
|
|
|
// attachmentFiles = attachmentFiles.toSet().toList();
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
}, fontSize: 14),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|