Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mobile): Added "jump to date" functionality to the memory view #7323

Merged
merged 25 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1a33abc
implemented jump to date from memory
arnolicious Feb 21, 2024
25ca730
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Feb 21, 2024
779f210
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Feb 23, 2024
2d411e9
Changed implementation to a ValueNotifier & fixes
arnolicious Feb 23, 2024
fd3f3b0
Merge branch 'main' of github.com:immich-app/immich into pr/arnolicio…
alextran1502 Feb 27, 2024
ce66af0
remove debug code
alextran1502 Feb 27, 2024
bd85381
Merge branch 'immich-app:main' into feat(mobile)-jump-to-asset
arnolicious Feb 27, 2024
e3bb602
feat(mobile):
arnolicious Feb 27, 2024
da09de6
feat(mobile): fixed debug index offset & added debug toast for scroll…
arnolicious Feb 29, 2024
b532534
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Feb 29, 2024
0c7acb3
feat(mobile): added more debug toasts...
arnolicious Feb 29, 2024
19b9cbf
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Feb 29, 2024
669bd9f
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 2, 2024
5135a31
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 7, 2024
28beb9b
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 12, 2024
b176340
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 12, 2024
98a007b
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 16, 2024
6cd9b60
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 19, 2024
a3d5a47
Merge branch 'main' of github.com:immich-app/immich into feat(mobile)…
alextran1502 Mar 20, 2024
fd795e9
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 22, 2024
6e6b499
feat(mobile): scroll to month, if timeline is not grouped by days
arnolicious Mar 22, 2024
f736d09
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Mar 30, 2024
8e213a9
Merge branch 'main' into feat(mobile)-jump-to-asset
arnolicious Apr 7, 2024
367231d
Merge branch 'main' into feat(mobile)-jump-to-asset
alextran1502 Apr 21, 2024
3dd1d1d
Merge branch 'main' of github.com:immich-app/immich into feat(mobile)…
alextran1502 Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mobile/assets/i18n/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"image_viewer_page_state_provider_download_error": "Fehler beim Herunterladen",
"image_viewer_page_state_provider_download_success": "Erfolgreich heruntergeladen",
"image_viewer_page_state_provider_share_error": "Fehler beim Teilen",
"jump_to_date": "Zu Datum springen",
arnolicious marked this conversation as resolved.
Show resolved Hide resolved
"library_page_albums": "Alben",
"library_page_archive": "Archiv",
"library_page_device_albums": "Alben auf dem Gerät",
Expand Down
1 change: 1 addition & 0 deletions mobile/assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"image_viewer_page_state_provider_download_error": "Download Error",
"image_viewer_page_state_provider_download_success": "Download Success",
"image_viewer_page_state_provider_share_error": "Share Error",
"jump_to_date": "Jump to date",
"library_page_albums": "Albums",
"library_page_archive": "Archive",
"library_page_device_albums": "Albums on Device",
Expand Down
1 change: 1 addition & 0 deletions mobile/assets/i18n/fr-CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"image_viewer_page_state_provider_download_error": "Erreur de téléchargement",
"image_viewer_page_state_provider_download_success": "Téléchargement réussi",
"image_viewer_page_state_provider_share_error": "Erreur de partage",
"jump_to_date": "Aller à la date",
"library_page_albums": "Albums",
"library_page_archive": "Archive",
"library_page_device_albums": "Albums sur l'appareil",
Expand Down
1 change: 1 addition & 0 deletions mobile/assets/i18n/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"image_viewer_page_state_provider_download_error": "Erreur de téléchargement",
"image_viewer_page_state_provider_download_success": "Téléchargement réussi",
"image_viewer_page_state_provider_share_error": "Erreur de partage",
"jump_to_date": "Aller à la date",
"library_page_albums": "Albums",
"library_page_archive": "Archive",
"library_page_device_albums": "Albums sur l'appareil",
Expand Down
31 changes: 31 additions & 0 deletions mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:immich_mobile/modules/asset_viewer/providers/scroll_notifier.pro
import 'package:immich_mobile/modules/home/ui/asset_grid/thumbnail_image.dart';
import 'package:immich_mobile/modules/home/ui/asset_grid/thumbnail_placeholder.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/services/event.service.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';

import 'asset_grid_data_structure.dart';
Expand Down Expand Up @@ -128,6 +129,14 @@ class ImmichAssetGridViewState extends State<ImmichAssetGridView> {
assets.firstWhereOrNull((e) => !_selectedAssets.contains(e)) == null;
}

Future<void> _scrollToIndex(int index) async {
await _itemScrollController.scrollTo(
index: index,
alignment: 0,
duration: const Duration(milliseconds: 500),
);
}

Widget _itemBuilder(BuildContext c, int position) {
int index = position;
if (widget.topWidget != null) {
Expand All @@ -138,6 +147,7 @@ class ImmichAssetGridViewState extends State<ImmichAssetGridView> {
}

final section = widget.renderList.elements[index];
// debugPrint("section: ${section.date} $index");
arnolicious marked this conversation as resolved.
Show resolved Hide resolved
return _Section(
showStorageIndicator: widget.showStorageIndicator,
selectedAssets: _selectedAssets,
Expand Down Expand Up @@ -223,6 +233,22 @@ class ImmichAssetGridViewState extends State<ImmichAssetGridView> {
: RefreshIndicator(onRefresh: widget.onRefresh!, child: child);
}

void _scrollToDate(DateTime? date) {
if (date == null) {
return;
}
final index = widget.renderList.elements.indexWhere(
(e) =>
e.date.year == date.year &&
e.date.month == date.month &&
e.date.day == date.day,
);
if (index != -1) {
// Not sure why the index is shifted, but it works. :3
_scrollToIndex(index + 1);
arnolicious marked this conversation as resolved.
Show resolved Hide resolved
}
}

@override
void didUpdateWidget(ImmichAssetGridView oldWidget) {
super.didUpdateWidget(oldWidget);
Expand All @@ -237,6 +263,11 @@ class ImmichAssetGridViewState extends State<ImmichAssetGridView> {
void initState() {
super.initState();
scrollToTopNotifierProvider.addListener(_scrollToTop);
scrollToDateEvent.subscribe((args) {
if (args?.value != null) {
_scrollToDate(args?.value);
}
});
if (widget.visibleItemsListener != null) {
_itemPositionsListener.itemPositions.addListener(_positionListener);
}
Expand Down
68 changes: 43 additions & 25 deletions mobile/lib/modules/memories/ui/memory_bottom_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// ignore_for_file: require_trailing_commas

import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:event/event.dart';
import 'package:flutter/material.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:immich_mobile/modules/memories/models/memory.dart';
import 'package:immich_mobile/shared/services/event.service.dart';

class MemoryBottomInfo extends StatelessWidget {
final Memory memory;
Expand All @@ -12,33 +18,45 @@ class MemoryBottomInfo extends StatelessWidget {
final df = DateFormat.yMMMMd();
return Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
memory.title,
style: TextStyle(
color: Colors.grey[400],
fontSize: 13.0,
fontWeight: FontWeight.w500,
),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
memory.title,
style: TextStyle(
color: Colors.grey[400],
fontSize: 13.0,
fontWeight: FontWeight.w500,
),
),
Text(
df.format(
memory.assets[0].fileCreatedAt,
),
style: const TextStyle(
color: Colors.white,
fontSize: 15.0,
fontWeight: FontWeight.w500,
),
Text(
df.format(
memory.assets[0].fileCreatedAt,
),
style: const TextStyle(
color: Colors.white,
fontSize: 15.0,
fontWeight: FontWeight.w500,
),
),
],
),
TextButton(
onPressed: () {
context.popRoute();
scrollToDateEvent.broadcast(
Value(memory.assets[0].fileCreatedAt),
);
},
child: Text(
'jump_to_date',
style: TextStyle(
color: context.primaryColor,
fontWeight: FontWeight.bold,
),
],
),
],
),
).tr())
]),
);
}
}
3 changes: 3 additions & 0 deletions mobile/lib/shared/services/event.service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:event/event.dart';

final scrollToDateEvent = Event<Value<DateTime>>();
arnolicious marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions mobile/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.0.2"
event:
dependency: "direct main"
description:
name: event
sha256: eb4814de94cbf6a10da9c4f652bc654087d7066e33566b5036822e6c0b24befb
url: "https://pub.dev"
source: hosted
version: "2.1.2"
fake_async:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies:
flutter_local_notifications: ^16.3.2
timezone: ^0.9.2
octo_image: ^2.0.0
event: ^2.1.2

openapi:
path: openapi
Expand Down