mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-30 17:38:40 +00:00 
			
		
		
		
	 552f2a73de
			
		
	
	
		552f2a73de
		
			
		
	
	
	
	
		
			
			* fix: row cover improvements * feat: set image from media cell as cover * fix: duplicate row meta when duplicating row * fix: use serialize repr and deserialize repr * chore: update collab revision * fix: failing test and bug w/ document icon * fix: show empty cover on load failure * fix: tauri collab revision
		
			
				
	
	
		
			72 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:io';
 | |
| 
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| import 'package:appflowy/shared/appflowy_network_image.dart';
 | |
| import 'package:appflowy_backend/protobuf/flowy-database2/file_entities.pbenum.dart';
 | |
| import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
 | |
| 
 | |
| class AFImage extends StatelessWidget {
 | |
|   const AFImage({
 | |
|     super.key,
 | |
|     required this.url,
 | |
|     required this.uploadType,
 | |
|     this.height,
 | |
|     this.width,
 | |
|     this.fit = BoxFit.cover,
 | |
|     this.userProfile,
 | |
|   }) : assert(
 | |
|           uploadType != FileUploadTypePB.CloudFile || userProfile != null,
 | |
|           'userProfile must be provided for accessing files from AF Cloud',
 | |
|         );
 | |
| 
 | |
|   final String url;
 | |
|   final FileUploadTypePB uploadType;
 | |
|   final double? height;
 | |
|   final double? width;
 | |
|   final BoxFit fit;
 | |
|   final UserProfilePB? userProfile;
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     if (uploadType == FileUploadTypePB.CloudFile && userProfile == null) {
 | |
|       return const SizedBox.shrink();
 | |
|     }
 | |
| 
 | |
|     Widget child;
 | |
|     if (uploadType == FileUploadTypePB.NetworkFile) {
 | |
|       child = Image.network(
 | |
|         url,
 | |
|         height: height,
 | |
|         width: width,
 | |
|         fit: fit,
 | |
|         errorBuilder: (context, error, stackTrace) {
 | |
|           return const SizedBox.shrink();
 | |
|         },
 | |
|       );
 | |
|     } else if (uploadType == FileUploadTypePB.LocalFile) {
 | |
|       child = Image.file(
 | |
|         File(url),
 | |
|         height: height,
 | |
|         width: width,
 | |
|         fit: fit,
 | |
|         errorBuilder: (context, error, stackTrace) {
 | |
|           return const SizedBox.shrink();
 | |
|         },
 | |
|       );
 | |
|     } else {
 | |
|       child = FlowyNetworkImage(
 | |
|         url: url,
 | |
|         userProfilePB: userProfile,
 | |
|         height: height,
 | |
|         width: width,
 | |
|         errorWidgetBuilder: (context, url, error) {
 | |
|           return const SizedBox.shrink();
 | |
|         },
 | |
|       );
 | |
|     }
 | |
| 
 | |
|     return child;
 | |
|   }
 | |
| }
 |