Imrpoved image handling since the size of the image is about 5MB.
This commit is contained in:
@@ -4,13 +4,15 @@ class PictureDto {
|
||||
final int id;
|
||||
final String? comment;
|
||||
final String? category;
|
||||
final String image;
|
||||
int evaluation;
|
||||
final DateTime pictureDate;
|
||||
final String? username;
|
||||
final String imageUrl;
|
||||
final String normalSizeUrl;
|
||||
final String thumbnailSizeUrl;
|
||||
|
||||
PictureDto(
|
||||
{required this.id, required this.comment, required this.category, required this.image, required this.evaluation, required this.pictureDate, required this.username});
|
||||
{required this.id, required this.comment, required this.category, required this.evaluation, required this.pictureDate, required this.username, required this.imageUrl, required this.normalSizeUrl, required this.thumbnailSizeUrl});
|
||||
|
||||
/// Create from JSON response
|
||||
factory PictureDto.fromJson(Map<String, dynamic> json) {
|
||||
@@ -18,10 +20,12 @@ class PictureDto {
|
||||
id: json['id'] as int,
|
||||
comment: json['comment'] as String?,
|
||||
category: json['category'] as String?,
|
||||
image: json['image'] as String,
|
||||
evaluation: json["evaluation"] as int,
|
||||
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
|
||||
username: json['username'] as String?
|
||||
username: json['username'] as String?,
|
||||
imageUrl: json['imageUrl'] as String,
|
||||
normalSizeUrl: json['normalSizeUrl'] as String,
|
||||
thumbnailSizeUrl: json['thumbnailSizeUrl'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/controller/base_controller.dart';
|
||||
import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||
@@ -218,8 +216,8 @@ class _CustomerWidgetState extends State<CustomerWidget> {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 70, maxHeight: 70),
|
||||
child: Image.memory(
|
||||
base64Decode(pictureDto.image),
|
||||
child: Image.network(
|
||||
pictureDto.thumbnailSizeUrl,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/dto/picture_dto.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
@@ -18,7 +16,6 @@ class PictureFullscreenDialog extends StatelessWidget {
|
||||
final dialogWidth = screenSize.width * 0.9;
|
||||
final dialogHeight = screenSize.height * 0.9 - 50;
|
||||
|
||||
final imageBytes = base64Decode(dto.image);
|
||||
return Dialog(
|
||||
backgroundColor: Colors.black,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
@@ -52,8 +49,8 @@ class PictureFullscreenDialog extends StatelessWidget {
|
||||
scaleEnabled: true,
|
||||
minScale: 0.5,
|
||||
maxScale: 5.0,
|
||||
child: Image.memory(
|
||||
imageBytes,
|
||||
child: Image.network(
|
||||
dto.imageUrl,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/controller/base_controller.dart';
|
||||
import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||
@@ -154,8 +152,8 @@ class _PictureWidgetState extends State<PictureWidget> {
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 100, minHeight: 100),
|
||||
child: Image.memory(
|
||||
base64Decode(dto.image),
|
||||
child: Image.network(
|
||||
dto.normalSizeUrl,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
@@ -350,13 +348,10 @@ class _PictureWidgetState extends State<PictureWidget> {
|
||||
// Bottom navigation buttons
|
||||
Widget _bottomNavigationWidget(List<PictureDto> pictures, PictureDto selectedPicture) {
|
||||
pictures.sort((a, b) => a.pictureDate.compareTo(b.pictureDate));
|
||||
print(pictures);
|
||||
final currentIndex = pictures.indexWhere((p) => p.id == selectedPicture.id);
|
||||
final hasPrevious = currentIndex > 0;
|
||||
final hasNext = currentIndex < pictures.length - 1;
|
||||
|
||||
print("hasnext $hasNext hasPrevious $hasPrevious current $currentIndex");
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: Row(
|
||||
@@ -435,7 +430,7 @@ class _PictureWidgetState extends State<PictureWidget> {
|
||||
setState(() {
|
||||
_selectedPicture = pictures[index];
|
||||
});
|
||||
}else {
|
||||
} else {
|
||||
print("empty");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user