-
-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mob][photos] Trips memories (internal users only) (#5035)
## Description Added trips memories for internal users in the moments section ## Tests Tested in debug mode on my pixel phone.
- Loading branch information
Showing
3 changed files
with
507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import "package:photos/models/file/file.dart"; | ||
import "package:photos/models/location/location.dart"; | ||
|
||
class BaseLocation { | ||
final List<EnteFile> files; | ||
int? firstCreationTime; | ||
int? lastCreationTime; | ||
final Location location; | ||
final bool isCurrentBase; | ||
|
||
BaseLocation( | ||
this.files, | ||
this.location, | ||
this.isCurrentBase, { | ||
this.firstCreationTime, | ||
this.lastCreationTime, | ||
}); | ||
|
||
int averageCreationTime() { | ||
if (firstCreationTime != null && lastCreationTime != null) { | ||
return (firstCreationTime! + lastCreationTime!) ~/ 2; | ||
} | ||
final List<int> creationTimes = files | ||
.where((file) => file.creationTime != null) | ||
.map((file) => file.creationTime!) | ||
.toList(); | ||
if (creationTimes.length < 2) { | ||
return creationTimes.isEmpty ? 0 : creationTimes.first; | ||
} | ||
creationTimes.sort(); | ||
firstCreationTime ??= creationTimes.first; | ||
lastCreationTime ??= creationTimes.last; | ||
return (firstCreationTime! + lastCreationTime!) ~/ 2; | ||
} | ||
|
||
BaseLocation copyWith({ | ||
List<EnteFile>? files, | ||
int? firstCreationTime, | ||
int? lastCreationTime, | ||
Location? location, | ||
bool? isCurrentBase, | ||
}) { | ||
return BaseLocation( | ||
files ?? this.files, | ||
location ?? this.location, | ||
isCurrentBase ?? this.isCurrentBase, | ||
firstCreationTime: firstCreationTime ?? this.firstCreationTime, | ||
lastCreationTime: lastCreationTime ?? this.lastCreationTime, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import "package:photos/models/file/file.dart"; | ||
import "package:photos/models/location/location.dart"; | ||
|
||
class TripMemory { | ||
final List<EnteFile> files; | ||
final Location location; | ||
final int firstCreationTime; | ||
final int lastCreationTime; | ||
|
||
TripMemory( | ||
this.files, | ||
this.location, | ||
this.firstCreationTime, | ||
this.lastCreationTime, | ||
); | ||
|
||
int get averageCreationTime => (firstCreationTime + lastCreationTime) ~/ 2; | ||
|
||
TripMemory copyWith({ | ||
List<EnteFile>? files, | ||
Location? location, | ||
int? firstCreationTime, | ||
int? lastCreationTime, | ||
}) { | ||
return TripMemory( | ||
files ?? this.files, | ||
location ?? this.location, | ||
firstCreationTime ?? this.firstCreationTime, | ||
lastCreationTime ?? this.lastCreationTime, | ||
); | ||
} | ||
} |
Oops, something went wrong.