mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	Enable swiping between assets (#381)
Enable swiping between assets (#381) Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Malte Kiefer <59220985+MalteKiefer@users.noreply.github.com> Co-authored-by: Matthias Rupp <matthias.rupp@posteo.de>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							e8d1f89a47
						
					
				
				
					commit
					8c184dc4d4
				
			@@ -3,10 +3,18 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
 | 
			
		||||
import 'package:immich_mobile/modules/home/ui/thumbnail_image.dart';
 | 
			
		||||
import 'package:openapi/api.dart';
 | 
			
		||||
 | 
			
		||||
// ignore: must_be_immutable
 | 
			
		||||
class ImageGrid extends ConsumerWidget {
 | 
			
		||||
  final List<AssetResponseDto> assetGroup;
 | 
			
		||||
  final List<AssetResponseDto> sortedAssetGroup;
 | 
			
		||||
 | 
			
		||||
  const ImageGrid({Key? key, required this.assetGroup}) : super(key: key);
 | 
			
		||||
  ImageGrid({
 | 
			
		||||
    Key? key,
 | 
			
		||||
    required this.assetGroup,
 | 
			
		||||
    required this.sortedAssetGroup,
 | 
			
		||||
  }) : super(key: key);
 | 
			
		||||
 | 
			
		||||
  List<AssetResponseDto> imageSortedList = [];
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context, WidgetRef ref) {
 | 
			
		||||
@@ -19,12 +27,14 @@ class ImageGrid extends ConsumerWidget {
 | 
			
		||||
      delegate: SliverChildBuilderDelegate(
 | 
			
		||||
        (BuildContext context, int index) {
 | 
			
		||||
          var assetType = assetGroup[index].type;
 | 
			
		||||
 | 
			
		||||
          return GestureDetector(
 | 
			
		||||
            onTap: () {},
 | 
			
		||||
            child: Stack(
 | 
			
		||||
              children: [
 | 
			
		||||
                ThumbnailImage(asset: assetGroup[index]),
 | 
			
		||||
                ThumbnailImage(
 | 
			
		||||
                  asset: assetGroup[index],
 | 
			
		||||
                  assetList: sortedAssetGroup,
 | 
			
		||||
                ),
 | 
			
		||||
                if (assetType != AssetTypeEnum.IMAGE)
 | 
			
		||||
                  Positioned(
 | 
			
		||||
                    top: 5,
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,10 @@ import 'package:openapi/api.dart';
 | 
			
		||||
 | 
			
		||||
class ThumbnailImage extends HookConsumerWidget {
 | 
			
		||||
  final AssetResponseDto asset;
 | 
			
		||||
  final List<AssetResponseDto> assetList;
 | 
			
		||||
 | 
			
		||||
  const ThumbnailImage({Key? key, required this.asset}) : super(key: key);
 | 
			
		||||
  const ThumbnailImage({Key? key, required this.asset, required this.assetList})
 | 
			
		||||
      : super(key: key);
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context, WidgetRef ref) {
 | 
			
		||||
@@ -60,29 +62,17 @@ class ThumbnailImage extends HookConsumerWidget {
 | 
			
		||||
              .watch(homePageStateProvider.notifier)
 | 
			
		||||
              .addSingleSelectedItem(asset);
 | 
			
		||||
        } else {
 | 
			
		||||
          if (asset.type == AssetTypeEnum.IMAGE) {
 | 
			
		||||
            AutoRouter.of(context).push(
 | 
			
		||||
              ImageViewerRoute(
 | 
			
		||||
                imageUrl:
 | 
			
		||||
                    '${box.get(serverEndpointKey)}/asset/file?aid=${asset.deviceAssetId}&did=${asset.deviceId}&isThumb=false',
 | 
			
		||||
                heroTag: asset.id,
 | 
			
		||||
                thumbnailUrl: thumbnailRequestUrl,
 | 
			
		||||
                asset: asset,
 | 
			
		||||
              ),
 | 
			
		||||
            );
 | 
			
		||||
          } else {
 | 
			
		||||
            AutoRouter.of(context).push(
 | 
			
		||||
              VideoViewerRoute(
 | 
			
		||||
                videoUrl:
 | 
			
		||||
                    '${box.get(serverEndpointKey)}/asset/file?aid=${asset.deviceAssetId}&did=${asset.deviceId}',
 | 
			
		||||
                asset: asset,
 | 
			
		||||
              ),
 | 
			
		||||
            );
 | 
			
		||||
          }
 | 
			
		||||
          AutoRouter.of(context).push(
 | 
			
		||||
            GalleryViewerRoute(
 | 
			
		||||
              assetList: assetList,
 | 
			
		||||
              thumbnailRequestUrl: thumbnailRequestUrl,
 | 
			
		||||
              asset: asset,
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      onLongPress: () {
 | 
			
		||||
        // Enable multi selecte function
 | 
			
		||||
        // Enable multi select function
 | 
			
		||||
        ref.watch(homePageStateProvider.notifier).enableMultiSelect({asset});
 | 
			
		||||
        HapticFeedback.heavyImpact();
 | 
			
		||||
      },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user