mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Extract photo list item widget
This commit is contained in:
parent
f86ea228bb
commit
6e793ff14f
3 changed files with 57 additions and 56 deletions
|
@ -18,6 +18,7 @@ import 'package:nc_photos/pref.dart';
|
|||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/use_case/update_album.dart';
|
||||
import 'package:nc_photos/widget/photo_list_item.dart';
|
||||
import 'package:nc_photos/widget/popup_menu_zoom.dart';
|
||||
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
||||
import 'package:nc_photos/widget/viewer.dart';
|
||||
|
@ -305,33 +306,9 @@ class _ImageListItem extends SelectableItemStreamListItem {
|
|||
|
||||
@override
|
||||
buildWidget(BuildContext context) {
|
||||
return FittedBox(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
fit: BoxFit.cover,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: previewUrl,
|
||||
httpHeaders: {
|
||||
"Authorization": Api.getAuthorizationHeaderValue(account),
|
||||
},
|
||||
fadeInDuration: const Duration(),
|
||||
filterQuality: FilterQuality.high,
|
||||
errorWidget: (context, url, error) {
|
||||
// where's the preview???
|
||||
return Container(
|
||||
color: AppTheme.getListItemBackgroundColor(context),
|
||||
width: 128,
|
||||
height: 128,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 56,
|
||||
color: Colors.white.withOpacity(.8),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||
),
|
||||
return PhotoListImage(
|
||||
account: account,
|
||||
previewUrl: previewUrl,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -9,7 +8,6 @@ import 'package:intl/intl.dart';
|
|||
import 'package:kiwi/kiwi.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:nc_photos/account.dart';
|
||||
import 'package:nc_photos/api/api.dart';
|
||||
import 'package:nc_photos/api/api_util.dart' as api_util;
|
||||
import 'package:nc_photos/bloc/scan_dir.dart';
|
||||
import 'package:nc_photos/entity/album.dart';
|
||||
|
@ -26,6 +24,7 @@ import 'package:nc_photos/use_case/remove.dart';
|
|||
import 'package:nc_photos/use_case/update_album.dart';
|
||||
import 'package:nc_photos/widget/album_picker_dialog.dart';
|
||||
import 'package:nc_photos/widget/home_app_bar.dart';
|
||||
import 'package:nc_photos/widget/photo_list_item.dart';
|
||||
import 'package:nc_photos/widget/popup_menu_zoom.dart';
|
||||
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
||||
import 'package:nc_photos/widget/viewer.dart';
|
||||
|
@ -476,33 +475,9 @@ class _ImageListItem extends _FileListItem {
|
|||
|
||||
@override
|
||||
buildWidget(BuildContext context) {
|
||||
return FittedBox(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
fit: BoxFit.cover,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: previewUrl,
|
||||
httpHeaders: {
|
||||
"Authorization": Api.getAuthorizationHeaderValue(account),
|
||||
},
|
||||
fadeInDuration: const Duration(),
|
||||
filterQuality: FilterQuality.high,
|
||||
errorWidget: (context, url, error) {
|
||||
// where's the preview???
|
||||
return Container(
|
||||
color: AppTheme.getListItemBackgroundColor(context),
|
||||
width: 128,
|
||||
height: 128,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 56,
|
||||
color: Colors.white.withOpacity(.8),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||
),
|
||||
return PhotoListImage(
|
||||
account: account,
|
||||
previewUrl: previewUrl,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
49
lib/widget/photo_list_item.dart
Normal file
49
lib/widget/photo_list_item.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:nc_photos/account.dart';
|
||||
import 'package:nc_photos/api/api.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
|
||||
class PhotoListImage extends StatelessWidget {
|
||||
const PhotoListImage({
|
||||
Key key,
|
||||
@required this.account,
|
||||
@required this.previewUrl,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return FittedBox(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
fit: BoxFit.cover,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: previewUrl,
|
||||
httpHeaders: {
|
||||
"Authorization": Api.getAuthorizationHeaderValue(account),
|
||||
},
|
||||
fadeInDuration: const Duration(),
|
||||
filterQuality: FilterQuality.high,
|
||||
errorWidget: (context, url, error) {
|
||||
// where's the preview???
|
||||
return Container(
|
||||
color: AppTheme.getListItemBackgroundColor(context),
|
||||
width: 128,
|
||||
height: 128,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 56,
|
||||
color: Colors.white.withOpacity(.8),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final Account account;
|
||||
final String previewUrl;
|
||||
}
|
Loading…
Reference in a new issue