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 4 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';

final scrollToDateNotifierProvider = ScrollToDateNotifier(null);

class ScrollToDateNotifier extends ValueNotifier<DateTime?> {
ScrollToDateNotifier(super.value);

void scrollToDate(DateTime date) {
value = date;

// Manually notify listeners to trigger the scroll, even if the value hasn't changed
notifyListeners();
}
}
29 changes: 29 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/modules/asset_viewer/providers/scroll_to_date_notifier.provider.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");
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);
}
}

@override
void didUpdateWidget(ImmichAssetGridView oldWidget) {
super.didUpdateWidget(oldWidget);
Expand All @@ -237,6 +263,9 @@ class ImmichAssetGridViewState extends State<ImmichAssetGridView> {
void initState() {
super.initState();
scrollToTopNotifierProvider.addListener(_scrollToTop);
scrollToDateNotifierProvider
.addListener(() => _scrollToDate(scrollToDateNotifierProvider.value));

if (widget.visibleItemsListener != null) {
_itemPositionsListener.itemPositions.addListener(_positionListener);
}
Expand Down
65 changes: 41 additions & 24 deletions mobile/lib/modules/memories/ui/memory_bottom_info.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// ignore_for_file: require_trailing_commas

import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:immich_mobile/modules/memories/models/memory.dart';
import 'package:immich_mobile/modules/asset_viewer/providers/scroll_to_date_notifier.provider.dart';

class MemoryBottomInfo extends StatelessWidget {
final Memory memory;
Expand All @@ -12,33 +16,46 @@ 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,
),
Text(
df.format(
memory.assets[0].fileCreatedAt,
),
style: const TextStyle(
color: Colors.white,
fontSize: 15.0,
fontWeight: FontWeight.w500,
),
style: const TextStyle(
color: Colors.white,
fontSize: 15.0,
fontWeight: FontWeight.w500,
),
],
),
],
),
MaterialButton(
minWidth: 0,
onPressed: () {
context.popRoute();
scrollToDateNotifierProvider
.scrollToDate(memory.assets[0].fileCreatedAt);
},
shape: const CircleBorder(),
color: Colors.white.withOpacity(0.2),
elevation: 0,
child: const Icon(
Icons.open_in_new,
color: Colors.white,
),
],
),
),
]),
);
}
}
4 changes: 3 additions & 1 deletion mobile/lib/modules/memories/views/memory_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ class MemoryPage extends HookConsumerWidget {
],
),
),
MemoryBottomInfo(memory: memories[mIndex]),
MemoryBottomInfo(
memory: memories[mIndex],
),
],
);
},
Expand Down
56 changes: 16 additions & 40 deletions mobile/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ packages:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
version: "6.1.4"
file_selector_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -860,30 +860,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.8.1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -931,18 +907,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: "direct overridden"
description:
Expand Down Expand Up @@ -1026,10 +1002,10 @@ packages:
dependency: "direct main"
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.8.3"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1162,10 +1138,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
url: "https://pub.dev"
source: hosted
version: "3.1.4"
version: "3.1.2"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -1194,10 +1170,10 @@ packages:
dependency: transitive
description:
name: process
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "4.2.4"
provider:
dependency: transitive
description:
Expand Down Expand Up @@ -1655,10 +1631,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "11.10.0"
wakelock_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1703,10 +1679,10 @@ packages:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.2"
win32:
dependency: transitive
description:
Expand Down