Skip to content

Commit a856f9e

Browse files
committed
feat: Handle url screenshot blur di halaman report screenshot dan preview photo
1 parent 8574b0b commit a856f9e

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

lib/feature/presentation/page/photo_view/photo_view_page.dart

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:io';
22

33
import 'package:dipantau_desktop_client/core/util/images.dart';
4+
import 'package:dipantau_desktop_client/feature/data/model/track_user/track_user_response.dart';
45
import 'package:easy_localization/easy_localization.dart';
56
import 'package:flutter/material.dart';
67
import 'package:photo_view/photo_view.dart';
@@ -10,8 +11,9 @@ class PhotoViewPage extends StatefulWidget {
1011
static const routePath = '/photo-view';
1112
static const routeName = 'photo-view';
1213
static const parameterListPhotos = 'list_photos';
14+
static const parameterListPhotosBlur = 'list_photos_blur';
1315

14-
final List<String>? listPhotos;
16+
final List<ItemFileTrackUserResponse>? listPhotos;
1517

1618
PhotoViewPage({
1719
Key? key,
@@ -24,7 +26,7 @@ class PhotoViewPage extends StatefulWidget {
2426

2527
class _PhotoViewPageState extends State<PhotoViewPage> {
2628
final pageController = PageController();
27-
final listPhotos = <String>[];
29+
final listPhotos = <ItemFileTrackUserResponse>[];
2830

2931
var indexSelectedPhoto = 0;
3032

@@ -48,7 +50,10 @@ class _PhotoViewPageState extends State<PhotoViewPage> {
4850
pageController: pageController,
4951
scrollPhysics: const BouncingScrollPhysics(),
5052
builder: (BuildContext context, int index) {
51-
final photo = listPhotos[index];
53+
var photo = listPhotos[index].urlBlur ?? '';
54+
if (photo.isEmpty) {
55+
photo = listPhotos[index].url ?? '';
56+
}
5257
return photo.startsWith('http')
5358
? PhotoViewGalleryPageOptions(
5459
imageProvider: NetworkImage(photo),
@@ -126,37 +131,24 @@ class _PhotoViewPageState extends State<PhotoViewPage> {
126131
child: Row(
127132
mainAxisAlignment: MainAxisAlignment.center,
128133
mainAxisSize: MainAxisSize.max,
129-
children: listPhotos.map((photo) {
130-
final index = listPhotos.indexOf(photo);
131-
final isSelected = photo == listPhotos[indexSelectedPhoto];
134+
children: listPhotos.map((element) {
135+
final index = listPhotos.indexOf(element);
136+
final elementId = element.id;
137+
final selectedId = listPhotos[indexSelectedPhoto].id;
138+
var isSelected = false;
139+
if (elementId != null || selectedId != null) {
140+
isSelected = elementId == selectedId;
141+
}
142+
var photo = element.urlBlur ?? '';
143+
if (photo.isEmpty) {
144+
photo = element.url ?? '';
145+
}
132146

133147
final widgetImage = SizedBox(
134148
width: defaultSize,
135149
height: defaultSize,
136150
child: photo.startsWith('http')
137-
? /*CachedNetworkImage(
138-
imageUrl: photo,
139-
fit: BoxFit.cover,
140-
width: defaultSize,
141-
height: defaultSize,
142-
errorWidget: (context, error, stacktrace) {
143-
return Image.asset(
144-
BaseImage.imagePlaceholder,
145-
fit: BoxFit.cover,
146-
width: defaultSize,
147-
height: defaultSize,
148-
);
149-
},
150-
progressIndicatorBuilder: (context, url, downloadProgress) {
151-
return Center(
152-
child: CircularProgressIndicator(
153-
strokeWidth: 1,
154-
value: downloadProgress.progress,
155-
),
156-
);
157-
},
158-
)*/
159-
Image.network(
151+
? Image.network(
160152
photo,
161153
fit: BoxFit.cover,
162154
width: defaultSize,

lib/feature/presentation/page/report_screenshot/report_screenshot_page.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ class _ReportScreenshotPageState extends State<ReportScreenshotPage> {
530530
String? thumbnail;
531531
final listFiles = element.files ?? [];
532532
if (listFiles.isNotEmpty) {
533-
thumbnail = listFiles.first.url;
533+
thumbnail = listFiles.first.urlBlur ?? '';
534+
if (thumbnail.isEmpty) {
535+
thumbnail = listFiles.first.url;
536+
}
534537
}
535538
const heightImage = 92.0;
536539

@@ -606,8 +609,12 @@ class _ReportScreenshotPageState extends State<ReportScreenshotPage> {
606609
context.pushNamed(
607610
PhotoViewPage.routeName,
608611
extra: {
609-
PhotoViewPage.parameterListPhotos:
610-
listFiles.where((element) => element.url != null).map((e) => e.url!).toList(),
612+
PhotoViewPage.parameterListPhotos: listFiles
613+
.where((element) {
614+
return element.url != null;
615+
})
616+
.map((e) => e)
617+
.toList(),
611618
},
612619
);
613620
},

lib/main.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:dipantau_desktop_client/config/flavor_config.dart';
66
import 'package:dipantau_desktop_client/core/util/enum/appearance_mode.dart';
77
import 'package:dipantau_desktop_client/core/util/enum/global_variable.dart';
88
import 'package:dipantau_desktop_client/core/util/shared_preferences_manager.dart';
9+
import 'package:dipantau_desktop_client/feature/data/model/track_user/track_user_response.dart';
910
import 'package:dipantau_desktop_client/feature/data/model/user_profile/user_profile_response.dart';
1011
import 'package:dipantau_desktop_client/feature/presentation/bloc/appearance/appearance_bloc.dart';
1112
import 'package:dipantau_desktop_client/feature/presentation/page/add_member/add_edit_member_page.dart';
@@ -215,7 +216,7 @@ class _MyAppState extends State<MyApp> {
215216
builder: (context, state) {
216217
final arguments = state.extra as Map<String, dynamic>?;
217218
final listPhotos = arguments != null && arguments.containsKey(PhotoViewPage.parameterListPhotos)
218-
? arguments[PhotoViewPage.parameterListPhotos] as List<String>?
219+
? arguments[PhotoViewPage.parameterListPhotos] as List<ItemFileTrackUserResponse>?
219220
: null;
220221
return PhotoViewPage(listPhotos: listPhotos);
221222
},

0 commit comments

Comments
 (0)