Download asset to local and error fixing (#100)

* Update photo_manager pub package
* Added download endpoint for assets
* Successfully save a photo to the local device's gallery
* Save save a video to the local device's gallery
* Fixed #97
* Added download loading indicator
* Refactor and increase the font size for curated search thumbnail images
* Reposition loading animation on the search result page
This commit is contained in:
Alex 2022-04-02 12:31:53 -05:00 committed by GitHub
parent 60df387459
commit 90ef64efa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 538 additions and 257 deletions

View file

@ -1,28 +1,34 @@
import 'dart:convert';
enum DownloadAssetStatus { idle, loading, success, error }
class ImageViewerPageState {
final bool isBottomSheetEnable;
// enum
final DownloadAssetStatus downloadAssetStatus;
ImageViewerPageState({
required this.isBottomSheetEnable,
required this.downloadAssetStatus,
});
ImageViewerPageState copyWith({
bool? isBottomSheetEnable,
DownloadAssetStatus? downloadAssetStatus,
}) {
return ImageViewerPageState(
isBottomSheetEnable: isBottomSheetEnable ?? this.isBottomSheetEnable,
downloadAssetStatus: downloadAssetStatus ?? this.downloadAssetStatus,
);
}
Map<String, dynamic> toMap() {
return {
'isBottomSheetEnable': isBottomSheetEnable,
};
final result = <String, dynamic>{};
result.addAll({'downloadAssetStatus': downloadAssetStatus.index});
return result;
}
factory ImageViewerPageState.fromMap(Map<String, dynamic> map) {
return ImageViewerPageState(
isBottomSheetEnable: map['isBottomSheetEnable'] ?? false,
downloadAssetStatus: DownloadAssetStatus.values[map['downloadAssetStatus'] ?? 0],
);
}
@ -31,15 +37,15 @@ class ImageViewerPageState {
factory ImageViewerPageState.fromJson(String source) => ImageViewerPageState.fromMap(json.decode(source));
@override
String toString() => 'ImageViewerPageState(isBottomSheetEnable: $isBottomSheetEnable)';
String toString() => 'ImageViewerPageState(downloadAssetStatus: $downloadAssetStatus)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ImageViewerPageState && other.isBottomSheetEnable == isBottomSheetEnable;
return other is ImageViewerPageState && other.downloadAssetStatus == downloadAssetStatus;
}
@override
int get hashCode => isBottomSheetEnable.hashCode;
int get hashCode => downloadAssetStatus.hashCode;
}

View file

@ -0,0 +1,6 @@
class RequestDownloadAssetInfo {
final String assetId;
final String deviceId;
RequestDownloadAssetInfo(this.assetId, this.deviceId);
}