Added download

This commit is contained in:
verboomp
2026-02-03 09:51:03 +01:00
parent f9ca668b39
commit 5f1d2d8610
25 changed files with 874 additions and 145 deletions

View File

@@ -14,6 +14,7 @@ import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:go_router/go_router.dart';
import 'package:fotodocumentation/utils/file_download.dart';
import 'package:intl/intl.dart';
class CustomerWidget extends StatefulWidget {
@@ -202,6 +203,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
final dateStr = _dateFormat.format(pictureDto.pictureDate);
final evaluationColor = _generalStyle.evaluationColor(value: pictureDto.evaluation);
Header cred = HeaderUtils().getAuthHeader();
return InkWell(
key: Key("table_row_${customerDto.id}"),
onTap: () => _actionSelect(context, customerDto, pictureDto),
@@ -219,6 +221,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 70, maxHeight: 70),
child: Image.network(
headers: {cred.name: cred.value},
pictureDto.thumbnailSizeUrl,
fit: BoxFit.contain,
),
@@ -334,6 +337,10 @@ class _CustomerWidgetState extends State<CustomerWidget> {
}
Future<void> _actionDownload(BuildContext context, CustomerDto customerDto, PictureDto? pictureDto) async {
// FIXME: implement a download from the export
final bytes = await _customerController.export(customerId: customerDto.id, pictureId: pictureDto?.id);
final fileName = pictureDto != null
? '${customerDto.customerNumber}_${pictureDto.id}.pdf'
: '${customerDto.customerNumber}.pdf';
await downloadFile(bytes, fileName);
}
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/controller/base_controller.dart';
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart';
@@ -15,7 +16,8 @@ class PictureFullscreenDialog extends StatelessWidget {
final screenSize = MediaQuery.of(context).size;
final dialogWidth = screenSize.width * 0.9;
final dialogHeight = screenSize.height * 0.9 - 50;
Header cred = HeaderUtils().getAuthHeader();
return Dialog(
backgroundColor: Colors.black,
clipBehavior: Clip.hardEdge,
@@ -50,6 +52,7 @@ class PictureFullscreenDialog extends StatelessWidget {
minScale: 0.5,
maxScale: 5.0,
child: Image.network(
headers: {cred.name: cred.value},
dto.imageUrl,
),
),

View File

@@ -144,6 +144,8 @@ class _PictureWidgetState extends State<PictureWidget> {
}
Widget _imageWidget(PictureDto dto) {
Header cred = HeaderUtils().getAuthHeader();
return GestureDetector(
key: const Key("image"),
behavior: HitTestBehavior.opaque,
@@ -153,6 +155,7 @@ class _PictureWidgetState extends State<PictureWidget> {
child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100, minHeight: 100),
child: Image.network(
headers: {cred.name: cred.value},
dto.normalSizeUrl,
fit: BoxFit.contain,
),
@@ -176,16 +179,17 @@ class _PictureWidgetState extends State<PictureWidget> {
color: _generalStyle.secondaryTextLabelColor,
);
String dateText = _dateFormat.format(dto.pictureDate);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_dateFormat.format(dto.pictureDate),
"$dateText UHR",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 44,
fontSize: 32,
fontFamily: _generalStyle.fontFamily,
color: _generalStyle.primaryTextLabelColor,
color: _generalStyle.secondaryWidgetBackgroundColor,
),
),
const SizedBox(height: 20),