aboutsummaryrefslogtreecommitdiff
path: root/plugins/aves_model/lib/src/storage
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/aves_model/lib/src/storage')
-rw-r--r--plugins/aves_model/lib/src/storage/relative_dir.dart44
-rw-r--r--plugins/aves_model/lib/src/storage/volume.dart31
2 files changed, 75 insertions, 0 deletions
diff --git a/plugins/aves_model/lib/src/storage/relative_dir.dart b/plugins/aves_model/lib/src/storage/relative_dir.dart
new file mode 100644
index 0000000..377318f
--- /dev/null
+++ b/plugins/aves_model/lib/src/storage/relative_dir.dart
@@ -0,0 +1,44 @@
+import 'package:aves_model/aves_model.dart';
+import 'package:equatable/equatable.dart';
+import 'package:meta/meta.dart';
+
+@immutable
+class VolumeRelativeDirectory extends Equatable {
+ final String volumePath, relativeDir;
+
+ @override
+ List<Object?> get props => [volumePath, relativeDir];
+
+ String get dirPath => '$volumePath$relativeDir';
+
+ const VolumeRelativeDirectory({
+ required this.volumePath,
+ required this.relativeDir,
+ });
+
+ factory VolumeRelativeDirectory.volume(StorageVolume volume) {
+ return VolumeRelativeDirectory(volumePath: volume.path, relativeDir: '');
+ }
+
+ static VolumeRelativeDirectory fromMap(Map map) {
+ return VolumeRelativeDirectory(
+ volumePath: map['volumePath'] ?? '',
+ relativeDir: map['relativeDir'] ?? '',
+ );
+ }
+
+ Map<String, dynamic> toMap() => {
+ 'volumePath': volumePath,
+ 'relativeDir': relativeDir,
+ };
+
+ VolumeRelativeDirectory copyWith({
+ String? volumePath,
+ String? relativeDir,
+ }) {
+ return VolumeRelativeDirectory(
+ volumePath: volumePath ?? this.volumePath,
+ relativeDir: relativeDir ?? this.relativeDir,
+ );
+ }
+}
diff --git a/plugins/aves_model/lib/src/storage/volume.dart b/plugins/aves_model/lib/src/storage/volume.dart
new file mode 100644
index 0000000..ff6df3d
--- /dev/null
+++ b/plugins/aves_model/lib/src/storage/volume.dart
@@ -0,0 +1,31 @@
+import 'package:equatable/equatable.dart';
+import 'package:meta/meta.dart';
+
+@immutable
+class StorageVolume extends Equatable {
+ final String? description;
+ final String path, state;
+ final bool isPrimary, isRemovable;
+
+ @override
+ List<Object?> get props => [description, path, state, isPrimary, isRemovable];
+
+ const StorageVolume({
+ required this.description,
+ required this.isPrimary,
+ required this.isRemovable,
+ required this.path,
+ required this.state,
+ });
+
+ factory StorageVolume.fromMap(Map map) {
+ final isPrimary = map['isPrimary'] ?? false;
+ return StorageVolume(
+ description: map['description'],
+ isPrimary: isPrimary,
+ isRemovable: map['isRemovable'] ?? false,
+ path: map['path'] ?? '',
+ state: map['state'] ?? '',
+ );
+ }
+}