immich/mobile/lib/domain/models/exif.model.dart
Adam Gastineau 18d4a796bb
chore(mobile): simple freezed implementation on some models (#30168)
* chore(mobile): example freezed implementation on some models

* Don't commit Freezed generated code

* Freezed easy pass

* Formatting fix

* Generate Flutter debugging info
2026-08-05 12:00:49 -07:00

54 lines
1.3 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'exif.model.freezed.dart';
@freezed
abstract class ExifInfo with _$ExifInfo {
const ExifInfo._();
const factory ExifInfo({
int? assetId,
int? fileSize,
String? description,
@Default(false) bool isFlipped,
String? orientation,
String? timeZone,
DateTime? dateTimeOriginal,
int? rating,
int? width,
int? height,
// GPS
double? latitude,
double? longitude,
String? city,
String? state,
String? country,
// Camera related
String? make,
String? model,
String? lens,
double? f,
double? mm,
int? iso,
double? exposureSeconds,
}) = _ExifInfo;
bool get hasCoordinates => latitude != null && longitude != null && latitude != 0 && longitude != 0;
String get exposureTime {
if (exposureSeconds == null || exposureSeconds! <= 0 || exposureSeconds!.isNaN) {
return "";
}
if (exposureSeconds! < 1) {
return "1/${(1.0 / exposureSeconds!).round()} s";
}
return "${exposureSeconds!.toStringAsFixed(1)} s";
}
String get fNumber => f == null ? "" : f!.toStringAsFixed(1);
String get focalLength => mm == null ? "" : mm!.toStringAsFixed(3);
}