immich_asset_with_exif.model.dart 3.6 KB

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