Skip to content

Commit cd8acb6

Browse files
committed
feat: Kirimkan flag apakah foto di halaman photo_view_page.dart bisa didownload atau tidak
Untuk saat ini, download foto hanya dipakai di halaman sync_page.dart dan report_screenshot_page.dart saja. Dan download foto ini hanya berlaku untuk foto user tersebut dan super admin.
1 parent 1af0456 commit cd8acb6

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ class _ReportScreenshotPageState extends State<ReportScreenshotPage> {
615615
})
616616
.map((e) => e)
617617
.toList(),
618+
PhotoViewPage.parameterIsShowIconDownload:
619+
userId == element.userId?.toString() || userRole == UserRole.superAdmin,
618620
},
619621
);
620622
},
@@ -845,27 +847,23 @@ class _ReportScreenshotPageState extends State<ReportScreenshotPage> {
845847
return;
846848
}
847849

848-
showDialog<bool?>(
849-
context: context,
850-
builder: (context) {
851-
return AlertDialog(
852-
title: Text('title_delete_track'.tr()),
853-
content: Text('content_delete_track'.tr()),
854-
actions: [
855-
TextButton(
856-
onPressed: () => context.pop(false),
857-
child: Text('cancel'.tr()),
858-
),
859-
TextButton(
860-
onPressed: () => context.pop(true),
861-
style: TextButton.styleFrom(
862-
foregroundColor: Colors.red,
863-
),
864-
child: Text('delete'.tr()),
865-
),
866-
],
867-
);
868-
},
850+
widgetHelper.showDialogConfirmation(
851+
context,
852+
'title_delete_track'.tr(),
853+
'content_delete_track'.tr(),
854+
[
855+
TextButton(
856+
onPressed: () => context.pop(false),
857+
child: Text('cancel'.tr()),
858+
),
859+
TextButton(
860+
onPressed: () => context.pop(true),
861+
style: TextButton.styleFrom(
862+
foregroundColor: Colors.red,
863+
),
864+
child: Text('delete'.tr()),
865+
),
866+
],
869867
).then((value) {
870868
if (value != null && value) {
871869
trackingBloc.add(

lib/feature/presentation/page/sync/sync_page.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:dipantau_desktop_client/core/util/shared_preferences_manager.dar
77
import 'package:dipantau_desktop_client/core/util/string_extension.dart';
88
import 'package:dipantau_desktop_client/core/util/widget_helper.dart';
99
import 'package:dipantau_desktop_client/feature/data/model/create_track/bulk_create_track_data_body.dart';
10+
import 'package:dipantau_desktop_client/feature/data/model/track_user/track_user_response.dart';
1011
import 'package:dipantau_desktop_client/feature/database/entity/track/track.dart';
1112
import 'package:dipantau_desktop_client/feature/presentation/bloc/sync_manual/sync_manual_bloc.dart';
1213
import 'package:dipantau_desktop_client/feature/presentation/page/photo_view/photo_view_page.dart';
@@ -333,7 +334,16 @@ class _SyncPageState extends State<SyncPage> {
333334
context.pushNamed(
334335
PhotoViewPage.routeName,
335336
extra: {
336-
PhotoViewPage.parameterListPhotos: listScreenshots.map((e) => e.path).toList(),
337+
PhotoViewPage.parameterListPhotos: listScreenshots.map((e) {
338+
return ItemFileTrackUserResponse(
339+
id: null,
340+
url: e.path,
341+
sizeInByte: 0,
342+
urlBlur: null,
343+
sizeBlurInByte: 0,
344+
);
345+
}).toList(),
346+
PhotoViewPage.parameterIsShowIconDownload: true,
337347
},
338348
);
339349
},

lib/main.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,14 @@ class _MyAppState extends State<MyApp> {
219219
final listPhotos = arguments != null && arguments.containsKey(PhotoViewPage.parameterListPhotos)
220220
? arguments[PhotoViewPage.parameterListPhotos] as List<ItemFileTrackUserResponse>?
221221
: null;
222-
return PhotoViewPage(listPhotos: listPhotos);
222+
final isShowIconDownload =
223+
arguments != null && arguments.containsKey(PhotoViewPage.parameterIsShowIconDownload)
224+
? arguments[PhotoViewPage.parameterIsShowIconDownload] as bool?
225+
: null;
226+
return PhotoViewPage(
227+
listPhotos: listPhotos,
228+
isShowIconDownload: isShowIconDownload,
229+
);
223230
},
224231
),
225232
GoRoute(

0 commit comments

Comments
 (0)