|
|
|
|
@ -17,8 +17,10 @@ import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart
|
|
|
|
|
import 'package:mohem_flutter_app/models/mowadhafhi/get_transaction_attachment_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/screens/mowadhafhi/view_transaction_attachment.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
import 'package:open_file/open_file.dart';
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
|
|
|
|
class MowadhafhiRequestDetails extends StatefulWidget {
|
|
|
|
|
const MowadhafhiRequestDetails({Key? key}) : super(key: key);
|
|
|
|
|
@ -263,6 +265,11 @@ class _RequestDetailsState extends State<MowadhafhiRequestDetails> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleTransactionAttachment() async {
|
|
|
|
|
|
|
|
|
|
Permission.storage.isGranted.then((isGranted) {
|
|
|
|
|
if (!isGranted) {
|
|
|
|
|
Permission.manageExternalStorage.request().then((granted) async {
|
|
|
|
|
if (granted == PermissionStatus.granted) {
|
|
|
|
|
String ext = '';
|
|
|
|
|
String? rFile = getTransactionAttachmentModel!.base64String;
|
|
|
|
|
String? rFileExt = getTransactionAttachmentModel!.fileName;
|
|
|
|
|
@ -271,12 +278,25 @@ class _RequestDetailsState extends State<MowadhafhiRequestDetails> {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String path = await _createFileFromString(rFile!.split("base64,").last ?? "", ext ?? "");
|
|
|
|
|
debugPrint(path);
|
|
|
|
|
|
|
|
|
|
print(" file here: ${File(path).existsSync()}");
|
|
|
|
|
await OpenFile.open(path);
|
|
|
|
|
await OpenFile.open(path).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.showToast("Cannot open file.");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: "You need to give storage permission to view files.",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|