immich_asset_with_exif.model.dart 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import 'dart:convert';
  2. import 'package:immich_mobile/shared/models/exif.model.dart';
  3. class ImmichAssetWithExif {
  4. final String id;
  5. final String deviceAssetId;
  6. final String userId;
  7. final String deviceId;
  8. final String type;
  9. final String createdAt;
  10. final String modifiedAt;
  11. final String originalPath;
  12. final bool isFavorite;
  13. final String? duration;
  14. final ImmichExif? exifInfo;
  15. ImmichAssetWithExif({
  16. required this.id,
  17. required this.deviceAssetId,
  18. required this.userId,
  19. required this.deviceId,
  20. required this.type,
  21. required this.createdAt,
  22. required this.modifiedAt,
  23. required this.originalPath,
  24. required this.isFavorite,
  25. this.duration,
  26. this.exifInfo,
  27. });
  28. ImmichAssetWithExif copyWith({
  29. String? id,
  30. String? deviceAssetId,
  31. String? userId,
  32. String? deviceId,
  33. String? type,
  34. String? createdAt,
  35. String? modifiedAt,
  36. String? originalPath,
  37. bool? isFavorite,
  38. String? duration,
  39. ImmichExif? exifInfo,
  40. }) {
  41. return ImmichAssetWithExif(
  42. id: id ?? this.id,
  43. deviceAssetId: deviceAssetId ?? this.deviceAssetId,
  44. userId: userId ?? this.userId,
  45. deviceId: deviceId ?? this.deviceId,
  46. type: type ?? this.type,
  47. createdAt: createdAt ?? this.createdAt,
  48. modifiedAt: modifiedAt ?? this.modifiedAt,
  49. originalPath: originalPath ?? this.originalPath,
  50. isFavorite: isFavorite ?? this.isFavorite,
  51. duration: duration ?? this.duration,
  52. exifInfo: exifInfo ?? this.exifInfo,
  53. );
  54. }
  55. Map<String, dynamic> toMap() {
  56. return {
  57. 'id': id,
  58. 'deviceAssetId': deviceAssetId,
  59. 'userId': userId,
  60. 'deviceId': deviceId,
  61. 'type': type,
  62. 'createdAt': createdAt,
  63. 'modifiedAt': modifiedAt,
  64. 'originalPath': originalPath,
  65. 'isFavorite': isFavorite,
  66. 'duration': duration,
  67. 'exifInfo': exifInfo?.toMap(),
  68. };
  69. }
  70. factory ImmichAssetWithExif.fromMap(Map<String, dynamic> map) {
  71. return ImmichAssetWithExif(
  72. id: map['id'] ?? '',
  73. deviceAssetId: map['deviceAssetId'] ?? '',
  74. userId: map['userId'] ?? '',
  75. deviceId: map['deviceId'] ?? '',
  76. type: map['type'] ?? '',
  77. createdAt: map['createdAt'] ?? '',
  78. modifiedAt: map['modifiedAt'] ?? '',
  79. originalPath: map['originalPath'] ?? '',
  80. isFavorite: map['isFavorite'] ?? false,
  81. duration: map['duration'],
  82. exifInfo: map['exifInfo'] != null ? ImmichExif.fromMap(map['exifInfo']) : null,
  83. );
  84. }
  85. String toJson() => json.encode(toMap());
  86. factory ImmichAssetWithExif.fromJson(String source) => ImmichAssetWithExif.fromMap(json.decode(source));
  87. @override
  88. String toString() {
  89. return 'ImmichAssetWithExif(id: $id, deviceAssetId: $deviceAssetId, userId: $userId, deviceId: $deviceId, type: $type, createdAt: $createdAt, modifiedAt: $modifiedAt, originalPath: $originalPath, isFavorite: $isFavorite, duration: $duration, exifInfo: $exifInfo)';
  90. }
  91. @override
  92. bool operator ==(Object other) {
  93. if (identical(this, other)) return true;
  94. return other is ImmichAssetWithExif &&
  95. other.id == id &&
  96. other.deviceAssetId == deviceAssetId &&
  97. other.userId == userId &&
  98. other.deviceId == deviceId &&
  99. other.type == type &&
  100. other.createdAt == createdAt &&
  101. other.modifiedAt == modifiedAt &&
  102. other.originalPath == originalPath &&
  103. other.isFavorite == isFavorite &&
  104. other.duration == duration &&
  105. other.exifInfo == exifInfo;
  106. }
  107. @override
  108. int get hashCode {
  109. return id.hashCode ^
  110. deviceAssetId.hashCode ^
  111. userId.hashCode ^
  112. deviceId.hashCode ^
  113. type.hashCode ^
  114. createdAt.hashCode ^
  115. modifiedAt.hashCode ^
  116. originalPath.hashCode ^
  117. isFavorite.hashCode ^
  118. duration.hashCode ^
  119. exifInfo.hashCode;
  120. }
  121. }