mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:39:03 -04:00 
			
		
		
		
	* Refactor sharing to album * Added library page in the bottom navigation bar * Refactor SharedAlbumService to album service * Refactor apiProvider to its file * Added image grid * render album thumbnail * Using the wrap to render thumbnail and album info better * Navigate to album viewer * After deletion, navigate to the respective page of the shared and non-shared album * Correctly remove album in local state * Refactor create album page * Implemented create non-shared album
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:io';
 | |
| 
 | |
| import 'package:flutter/foundation.dart';
 | |
| import 'package:hooks_riverpod/hooks_riverpod.dart';
 | |
| import 'package:immich_mobile/shared/providers/api.provider.dart';
 | |
| import 'package:immich_mobile/shared/services/api.service.dart';
 | |
| import 'package:openapi/api.dart';
 | |
| import 'package:path/path.dart' as p;
 | |
| 
 | |
| import 'package:photo_manager/photo_manager.dart';
 | |
| import 'package:path_provider/path_provider.dart';
 | |
| 
 | |
| final imageViewerServiceProvider =
 | |
|     Provider((ref) => ImageViewerService(ref.watch(apiServiceProvider)));
 | |
| 
 | |
| class ImageViewerService {
 | |
|   final ApiService _apiService;
 | |
| 
 | |
|   ImageViewerService(this._apiService);
 | |
| 
 | |
|   Future<bool> downloadAssetToDevice(AssetResponseDto asset) async {
 | |
|     try {
 | |
|       String fileName = p.basename(asset.originalPath);
 | |
| 
 | |
|       var res = await _apiService.assetApi.downloadFileWithHttpInfo(
 | |
|         asset.deviceAssetId,
 | |
|         asset.deviceId,
 | |
|         isThumb: false,
 | |
|         isWeb: false,
 | |
|       );
 | |
| 
 | |
|       final AssetEntity? entity;
 | |
| 
 | |
|       if (asset.type == AssetTypeEnum.IMAGE) {
 | |
|         entity = await PhotoManager.editor.saveImage(
 | |
|           res.bodyBytes,
 | |
|           title: p.basename(asset.originalPath),
 | |
|         );
 | |
|       } else {
 | |
|         final tempDir = await getTemporaryDirectory();
 | |
|         File tempFile = await File('${tempDir.path}/$fileName').create();
 | |
|         tempFile.writeAsBytesSync(res.bodyBytes);
 | |
|         entity = await PhotoManager.editor.saveVideo(tempFile, title: fileName);
 | |
|       }
 | |
| 
 | |
|       return entity != null;
 | |
|     } catch (e) {
 | |
|       debugPrint("Error saving file $e");
 | |
|       return false;
 | |
|     }
 | |
|   }
 | |
| }
 |