Skip to content

Commit

Permalink
feat: Handle url screenshot blur di halaman report screenshot dan pre…
Browse files Browse the repository at this point in the history
…view photo
  • Loading branch information
CoderJava committed Sep 14, 2023
1 parent 8574b0b commit a856f9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
50 changes: 21 additions & 29 deletions lib/feature/presentation/page/photo_view/photo_view_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:dipantau_desktop_client/core/util/images.dart';
import 'package:dipantau_desktop_client/feature/data/model/track_user/track_user_response.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
Expand All @@ -10,8 +11,9 @@ class PhotoViewPage extends StatefulWidget {
static const routePath = '/photo-view';
static const routeName = 'photo-view';
static const parameterListPhotos = 'list_photos';
static const parameterListPhotosBlur = 'list_photos_blur';

final List<String>? listPhotos;
final List<ItemFileTrackUserResponse>? listPhotos;

PhotoViewPage({
Key? key,
Expand All @@ -24,7 +26,7 @@ class PhotoViewPage extends StatefulWidget {

class _PhotoViewPageState extends State<PhotoViewPage> {
final pageController = PageController();
final listPhotos = <String>[];
final listPhotos = <ItemFileTrackUserResponse>[];

var indexSelectedPhoto = 0;

Expand All @@ -48,7 +50,10 @@ class _PhotoViewPageState extends State<PhotoViewPage> {
pageController: pageController,
scrollPhysics: const BouncingScrollPhysics(),
builder: (BuildContext context, int index) {
final photo = listPhotos[index];
var photo = listPhotos[index].urlBlur ?? '';
if (photo.isEmpty) {
photo = listPhotos[index].url ?? '';
}
return photo.startsWith('http')
? PhotoViewGalleryPageOptions(
imageProvider: NetworkImage(photo),
Expand Down Expand Up @@ -126,37 +131,24 @@ class _PhotoViewPageState extends State<PhotoViewPage> {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: listPhotos.map((photo) {
final index = listPhotos.indexOf(photo);
final isSelected = photo == listPhotos[indexSelectedPhoto];
children: listPhotos.map((element) {
final index = listPhotos.indexOf(element);
final elementId = element.id;
final selectedId = listPhotos[indexSelectedPhoto].id;
var isSelected = false;
if (elementId != null || selectedId != null) {
isSelected = elementId == selectedId;
}
var photo = element.urlBlur ?? '';
if (photo.isEmpty) {
photo = element.url ?? '';
}

final widgetImage = SizedBox(
width: defaultSize,
height: defaultSize,
child: photo.startsWith('http')
? /*CachedNetworkImage(
imageUrl: photo,
fit: BoxFit.cover,
width: defaultSize,
height: defaultSize,
errorWidget: (context, error, stacktrace) {
return Image.asset(
BaseImage.imagePlaceholder,
fit: BoxFit.cover,
width: defaultSize,
height: defaultSize,
);
},
progressIndicatorBuilder: (context, url, downloadProgress) {
return Center(
child: CircularProgressIndicator(
strokeWidth: 1,
value: downloadProgress.progress,
),
);
},
)*/
Image.network(
? Image.network(
photo,
fit: BoxFit.cover,
width: defaultSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,10 @@ class _ReportScreenshotPageState extends State<ReportScreenshotPage> {
String? thumbnail;
final listFiles = element.files ?? [];
if (listFiles.isNotEmpty) {
thumbnail = listFiles.first.url;
thumbnail = listFiles.first.urlBlur ?? '';
if (thumbnail.isEmpty) {
thumbnail = listFiles.first.url;
}
}
const heightImage = 92.0;

Expand Down Expand Up @@ -606,8 +609,12 @@ class _ReportScreenshotPageState extends State<ReportScreenshotPage> {
context.pushNamed(
PhotoViewPage.routeName,
extra: {
PhotoViewPage.parameterListPhotos:
listFiles.where((element) => element.url != null).map((e) => e.url!).toList(),
PhotoViewPage.parameterListPhotos: listFiles
.where((element) {
return element.url != null;
})
.map((e) => e)
.toList(),
},
);
},
Expand Down
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:dipantau_desktop_client/config/flavor_config.dart';
import 'package:dipantau_desktop_client/core/util/enum/appearance_mode.dart';
import 'package:dipantau_desktop_client/core/util/enum/global_variable.dart';
import 'package:dipantau_desktop_client/core/util/shared_preferences_manager.dart';
import 'package:dipantau_desktop_client/feature/data/model/track_user/track_user_response.dart';
import 'package:dipantau_desktop_client/feature/data/model/user_profile/user_profile_response.dart';
import 'package:dipantau_desktop_client/feature/presentation/bloc/appearance/appearance_bloc.dart';
import 'package:dipantau_desktop_client/feature/presentation/page/add_member/add_edit_member_page.dart';
Expand Down Expand Up @@ -215,7 +216,7 @@ class _MyAppState extends State<MyApp> {
builder: (context, state) {
final arguments = state.extra as Map<String, dynamic>?;
final listPhotos = arguments != null && arguments.containsKey(PhotoViewPage.parameterListPhotos)
? arguments[PhotoViewPage.parameterListPhotos] as List<String>?
? arguments[PhotoViewPage.parameterListPhotos] as List<ItemFileTrackUserResponse>?
: null;
return PhotoViewPage(listPhotos: listPhotos);
},
Expand Down

0 comments on commit a856f9e

Please sign in to comment.