Added Google Drive storage location

This commit is contained in:
Courtney Arnold 2026-08-08 14:59:18 -05:00
parent e630f2a3ec
commit 73a7c93e64
22 changed files with 1690 additions and 205 deletions

View file

@ -6,6 +6,8 @@ class FuelEntry {
final double pricePerGallon;
final double totalCost;
final String? receiptImagePath;
final String? receiptDriveFileId;
final DateTime updatedAt;
FuelEntry({
required this.id,
@ -14,9 +16,40 @@ class FuelEntry {
required this.gallons,
required this.pricePerGallon,
required this.totalCost,
required this.updatedAt,
this.receiptImagePath,
this.receiptDriveFileId,
});
/// True once the receipt photo has been uploaded to Drive and the local
/// copy removed. Viewing it then requires downloading it on demand.
bool get isReceiptUploadedToDrive =>
receiptImagePath == null && receiptDriveFileId != null;
/// True while a receipt photo exists only locally and still needs to be
/// uploaded next sync.
bool get hasPendingLocalReceipt => receiptImagePath != null;
FuelEntry copyWith({
String? receiptImagePath,
String? receiptDriveFileId,
DateTime? updatedAt,
bool clearReceiptImagePath = false,
}) {
return FuelEntry(
id: id,
vehicleId: vehicleId,
date: date,
gallons: gallons,
pricePerGallon: pricePerGallon,
totalCost: totalCost,
updatedAt: updatedAt ?? this.updatedAt,
receiptImagePath:
clearReceiptImagePath ? null : (receiptImagePath ?? this.receiptImagePath),
receiptDriveFileId: receiptDriveFileId ?? this.receiptDriveFileId,
);
}
Map<String, dynamic> toJson() => {
'id': id,
'vehicleId': vehicleId,
@ -25,6 +58,8 @@ class FuelEntry {
'pricePerGallon': pricePerGallon,
'totalCost': totalCost,
'receiptImagePath': receiptImagePath,
'receiptDriveFileId': receiptDriveFileId,
'updatedAt': updatedAt.toIso8601String(),
};
factory FuelEntry.fromJson(Map<String, dynamic> json) => FuelEntry(
@ -35,5 +70,9 @@ class FuelEntry {
pricePerGallon: (json['pricePerGallon'] as num).toDouble(),
totalCost: (json['totalCost'] as num).toDouble(),
receiptImagePath: json['receiptImagePath'] as String?,
receiptDriveFileId: json['receiptDriveFileId'] as String?,
updatedAt: json['updatedAt'] != null
? DateTime.parse(json['updatedAt'] as String)
: DateTime.fromMillisecondsSinceEpoch(0),
);
}

View file

@ -4,6 +4,7 @@ class Vehicle {
final String model;
final String color;
final String licensePlate;
final DateTime updatedAt;
Vehicle({
required this.id,
@ -11,6 +12,7 @@ class Vehicle {
required this.model,
required this.color,
required this.licensePlate,
required this.updatedAt,
});
String get displayName => '$color $make $model ($licensePlate)';
@ -20,6 +22,7 @@ class Vehicle {
String? model,
String? color,
String? licensePlate,
DateTime? updatedAt,
}) {
return Vehicle(
id: id,
@ -27,6 +30,7 @@ class Vehicle {
model: model ?? this.model,
color: color ?? this.color,
licensePlate: licensePlate ?? this.licensePlate,
updatedAt: updatedAt ?? this.updatedAt,
);
}
@ -36,6 +40,7 @@ class Vehicle {
'model': model,
'color': color,
'licensePlate': licensePlate,
'updatedAt': updatedAt.toIso8601String(),
};
factory Vehicle.fromJson(Map<String, dynamic> json) => Vehicle(
@ -44,5 +49,8 @@ class Vehicle {
model: json['model'] as String,
color: json['color'] as String,
licensePlate: json['licensePlate'] as String,
updatedAt: json['updatedAt'] != null
? DateTime.parse(json['updatedAt'] as String)
: DateTime.fromMillisecondsSinceEpoch(0),
);
}