update file view to work with window builder

This commit is contained in:
2024-09-26 12:31:38 +02:00
parent 257c8a0407
commit 2f12acc356
2 changed files with 245 additions and 170 deletions

View File

@@ -3,6 +3,7 @@ import 'package:patient_manager/main.dart';
import 'package:patient_manager/mih_objects/arguments.dart'; import 'package:patient_manager/mih_objects/arguments.dart';
import 'package:syncfusion_flutter_core/theme.dart'; import 'package:syncfusion_flutter_core/theme.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import "package:universal_html/html.dart" as html;
class BuildFileView extends StatefulWidget { class BuildFileView extends StatefulWidget {
final String link; final String link;
@@ -41,18 +42,24 @@ class _BuildFileViewState extends State<BuildFileView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// double width = MediaQuery.sizeOf(context).width; // double width = MediaQuery.sizeOf(context).width;
// double height = MediaQuery.sizeOf(context).height; //double height = MediaQuery.sizeOf(context).height;
if (getExtType(widget.path).toLowerCase() == "pdf") { if (getExtType(widget.path).toLowerCase() == "pdf") {
//print(widget.pdfLink); //print(widget.pdfLink);
return Stack( return Expanded(
child: Stack(
children: [ children: [
Column( Padding(
padding: const EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [ children: [
Expanded( Expanded(
child: SfPdfViewerTheme( child: SfPdfViewerTheme(
data: SfPdfViewerThemeData( data: SfPdfViewerThemeData(
backgroundColor: backgroundColor: MzanziInnovationHub.of(context)!
MzanziInnovationHub.of(context)!.theme.primaryColor(), .theme
.primaryColor(),
), ),
child: SfPdfViewer.network( child: SfPdfViewer.network(
widget.link, widget.link,
@@ -62,9 +69,10 @@ class _BuildFileViewState extends State<BuildFileView> {
), ),
], ],
), ),
),
Positioned( Positioned(
top: 5, bottom: 10,
right: 5, right: 10,
width: 50, width: 50,
height: 50, height: 50,
child: IconButton.filled( child: IconButton.filled(
@@ -84,25 +92,44 @@ class _BuildFileViewState extends State<BuildFileView> {
), ),
), ),
), ),
Positioned(
bottom: 10,
left: 10,
width: 50,
height: 50,
child: IconButton.filled(
onPressed: () {
html.window.open(
widget.link,
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
'download');
},
icon: Icon(
Icons.download,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
size: 35,
),
),
),
], ],
),
); );
} else { } else {
return Stack( return Expanded(
child: Stack(
fit: StackFit.expand,
children: [ children: [
Column( Padding(
children: [ padding: const EdgeInsets.all(10.0),
Expanded(
child: InteractiveViewer( child: InteractiveViewer(
maxScale: 5.0, maxScale: 5.0,
//minScale: 0., //minScale: 0.,
child: Image.network(widget.link), child: Image.network(widget.link),
), ),
), ),
],
),
Positioned( Positioned(
top: 5, bottom: 10,
right: 5, right: 10,
width: 50, width: 50,
height: 50, height: 50,
child: IconButton.filled( child: IconButton.filled(
@@ -123,7 +150,27 @@ class _BuildFileViewState extends State<BuildFileView> {
), ),
), ),
), ),
Positioned(
bottom: 10,
left: 10,
width: 50,
height: 50,
child: IconButton.filled(
onPressed: () {
html.window.open(
widget.link,
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
'download');
},
icon: Icon(
Icons.download,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
size: 35,
),
),
),
], ],
),
); );
} }
} }

View File

@@ -1,11 +1,11 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_window.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_delete_message.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_delete_message.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_error_message.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_success_message.dart'; import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_success_message.dart';
import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_button.dart';
import 'package:patient_manager/mih_env/env.dart'; import 'package:patient_manager/mih_env/env.dart';
import 'package:patient_manager/main.dart'; import 'package:patient_manager/main.dart';
import 'package:patient_manager/mih_packages/patient_profile/builder/build_file_view.dart'; import 'package:patient_manager/mih_packages/patient_profile/builder/build_file_view.dart';
@@ -16,7 +16,6 @@ import 'package:patient_manager/mih_objects/business_user.dart';
import 'package:patient_manager/mih_objects/files.dart'; import 'package:patient_manager/mih_objects/files.dart';
import 'package:patient_manager/mih_objects/patients.dart'; import 'package:patient_manager/mih_objects/patients.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
import "package:universal_html/html.dart" as html;
class BuildFilesList extends StatefulWidget { class BuildFilesList extends StatefulWidget {
final AppUser signedInUser; final AppUser signedInUser;
@@ -191,103 +190,132 @@ class _BuildFilesListState extends State<BuildFilesList> {
showDialog( showDialog(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
builder: (context) => Dialog( builder: (context) => MIHWindow(
child: Stack( windowTitle: fileName,
children: [ windowItems: [
Container( BuildFileView(
padding: const EdgeInsets.all(10.0),
width: 800.0,
//height: 475.0,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(
height: 25,
),
Text(
fileName,
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
Expanded(
child: BuildFileView(
link: url, link: url,
path: filePath, path: filePath,
//pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath', //pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
)),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
html.window.open(
url,
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
'download');
},
buttonText: "Dowload",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
), ),
)
], ],
), actionItems: [
), IconButton(
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
Positioned(
top: 5,
left: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () { onPressed: () {
deleteFilePopUp(filePath, fileID); deleteFilePopUp(filePath, fileID);
}, },
icon: Icon( icon: Icon(
size: 35,
Icons.delete, Icons.delete,
color: color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
), ),
), ),
], ],
), onTapClose: () {
Navigator.pop(context);
},
), ),
); );
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (context) => Dialog(
// child: Stack(
// children: [
// Container(
// padding: const EdgeInsets.all(10.0),
// width: 800.0,
// //height: 475.0,
// decoration: BoxDecoration(
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
// borderRadius: BorderRadius.circular(25.0),
// border: Border.all(
// color:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// width: 5.0),
// ),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: [
// const SizedBox(
// height: 25,
// ),
// Text(
// fileName,
// textAlign: TextAlign.center,
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// fontSize: 35.0,
// fontWeight: FontWeight.bold,
// ),
// ),
// const SizedBox(height: 25.0),
// Expanded(
// child: BuildFileView(
// link: url,
// path: filePath,
// //pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
// )),
// const SizedBox(height: 30.0),
// SizedBox(
// width: 300,
// height: 50,
// child: MIHButton(
// onTap: () {
// html.window.open(
// url,
// // '${AppEnviroment.baseFileUrl}/mih/$filePath',
// 'download');
// },
// buttonText: "Dowload",
// buttonColor: MzanziInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// textColor:
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
// ),
// )
// ],
// ),
// ),
// Positioned(
// top: 5,
// right: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// Navigator.pop(context);
// },
// icon: Icon(
// Icons.close,
// color: MzanziInnovationHub.of(context)!.theme.errorColor(),
// size: 35,
// ),
// ),
// ),
// Positioned(
// top: 5,
// left: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// deleteFilePopUp(filePath, fileID);
// },
// icon: Icon(
// Icons.delete,
// color:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// ),
// ),
// ),
// ],
// ),
// ),
// );
} }
@override @override