feat: full local assets / album sync

This commit is contained in:
shenlong-tanwen
2024-10-17 23:33:00 +05:30
parent a09710ec7b
commit c91a2878dc
87 changed files with 2417 additions and 366 deletions
@@ -0,0 +1,56 @@
import 'dart:async';
import 'dart:io';
enum DeviceAssetRequestStatus {
preparing,
downloading,
success,
failed,
}
class DeviceAssetDownloadHandler {
DeviceAssetDownloadHandler() : stream = const Stream.empty() {
assert(
Platform.isIOS || Platform.isMacOS,
'$runtimeType should only be used on iOS or macOS.',
);
}
/// A stream that provides information about the download status and progress of the asset being downloaded.
Stream<DeviceAssetDownloadState> stream;
}
class DeviceAssetDownloadState {
final double progress;
final DeviceAssetRequestStatus status;
const DeviceAssetDownloadState({
required this.progress,
required this.status,
});
DeviceAssetDownloadState copyWith({
double? progress,
DeviceAssetRequestStatus? status,
}) {
return DeviceAssetDownloadState(
progress: progress ?? this.progress,
status: status ?? this.status,
);
}
@override
String toString() {
return 'DeviceAssetDownloadState(progress: $progress, status: $status)';
}
@override
bool operator ==(covariant DeviceAssetDownloadState other) {
return other.progress == progress && other.status == status;
}
@override
int get hashCode {
return progress.hashCode ^ status.hashCode;
}
}