Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Fix albums search dismissal

AmanRajSinghMourya296e57cff16b
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index 135601d11c..2968cc8749 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -1107,7 +1107,7 @@
"description": "The text displayed above folders/albums stored on device",
"type": "text"
},
- "onDevice": "On device",
+ "onDevice": "Device",
"@onEnte": {
"description": "The text displayed above albums backed up to Ente",
"type": "text"
diff --git a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
index 05b9601136..6ed6af3fc1 100644
--- a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
+++ b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart
@@ -36,9 +36,14 @@ enum _AlbumsFilter { ente, onDevice, shared }
enum _AlbumsMenuAction { toggleView, name, newest, updated }
class AlbumsTab extends StatefulWidget {
- const AlbumsTab({super.key, this.selectedAlbums});
+ const AlbumsTab({
+ super.key,
+ this.selectedAlbums,
+ this.isSearchActiveNotifier,
+ });
final SelectedAlbums? selectedAlbums;
+ final ValueNotifier<bool>? isSearchActiveNotifier;
@override
State<AlbumsTab> createState() => _AlbumsTabState();
@@ -143,6 +148,33 @@ class _AlbumsTabState extends State<AlbumsTab>
_enteCollections.value = null;
_sharedCollections.value = null;
});
+ widget.isSearchActiveNotifier?.addListener(_handleSearchStateChanged);
+ _syncSearchNotifier(_isSearchActive);
+ }
+
+ @override
+ void didUpdateWidget(covariant AlbumsTab oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (oldWidget.isSearchActiveNotifier == widget.isSearchActiveNotifier) {
+ return;
+ }
+ oldWidget.isSearchActiveNotifier?.removeListener(
+ _handleSearchStateChanged,
+ );
+ widget.isSearchActiveNotifier?.addListener(_handleSearchStateChanged);
+ _syncSearchNotifier(_isSearchActive);
+ }
+
+ void _handleSearchStateChanged() {
+ if (widget.isSearchActiveNotifier?.value == false && _isSearchActive) {
+ _deactivateSearch(syncNotifier: false);
+ }
+ }
+
+ void _syncSearchNotifier(bool isSearchActive) {
+ final notifier = widget.isSearchActiveNotifier;
+ if (notifier == null || notifier.value == isSearchActive) return;
+ notifier.value = isSearchActive;
}
Future<void> _loadAll() async {
@@ -194,6 +226,7 @@ class _AlbumsTabState extends State<AlbumsTab>
setState(() {
_isSearchActive = true;
});
+ _syncSearchNotifier(true);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
_searchFocusNode.requestFocus();
@@ -201,14 +234,22 @@ class _AlbumsTabState extends State<AlbumsTab>
});
}
- void _deactivateSearch() {
+ void _deactivateSearch({bool syncNotifier = true}) {
_searchController.clear();
_searchFocusNode.unfocus();
- if (!_isSearchActive && _searchQuery.isEmpty) return;
+ if (!_isSearchActive && _searchQuery.isEmpty) {
+ if (syncNotifier) {
+ _syncSearchNotifier(false);
+ }
+ return;
+ }
setState(() {
_isSearchActive = false;
_searchQuery = "";
});
+ if (syncNotifier) {
+ _syncSearchNotifier(false);
+ }
}
List<Collection> _filterCollectionsByQuery(List<Collection> collections) {
@@ -502,6 +543,7 @@ class _AlbumsTabState extends State<AlbumsTab>
_backupFoldersUpdatedEvent.cancel();
_appModeChangedEvent.cancel();
_loggedOutEvent.cancel();
+ widget.isSearchActiveNotifier?.removeListener(_handleSearchStateChanged);
_debouncer.cancelDebounceTimer();
_searchController.dispose();
_searchFocusNode.dispose();
@@ -583,6 +625,7 @@ class _AlbumsTabState extends State<AlbumsTab>
focusNode: _searchFocusNode,
hintText: strings.searchAlbums,
autofocus: true,
+ shouldUnfocusOnClearOrSubmit: true,
prefix: HugeIcon(
icon: HugeIcons.strokeRoundedSearch01,
size: 18,
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
index db5783126c..672c129d7d 100644
--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart
+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
@@ -125,6 +125,9 @@ class _HomeWidgetState extends State<HomeWidget> {
bool _collectionsSyncTriggered = false;
bool _isShowingChangeLog = false;
final isOnSearchTabNotifier = ValueNotifier<bool>(false);
+ final ValueNotifier<bool> _isAlbumsSearchActiveNotifier = ValueNotifier<bool>(
+ false,
+ );
final ValueNotifier<bool> _swipeToSelectInProgressNotifier =
ValueNotifier<bool>(false);
@@ -543,6 +546,7 @@ class _HomeWidgetState extends State<HomeWidget> {
_accountConfiguredEvent.cancel();
_intentDataStreamSubscription?.cancel();
isOnSearchTabNotifier.dispose();
+ _isAlbumsSearchActiveNotifier.dispose();
_pageController.dispose();
_publicAlbumLinkSubscription?.cancel();
_authDeepLinkSubscription?.cancel();
@@ -839,6 +843,17 @@ class _HomeWidgetState extends State<HomeWidget> {
_selectedAlbums.clearAll();
return;
}
+ if (_isAlbumsSearchActiveNotifier.value) {
+ if (MediaQuery.viewInsetsOf(context).bottom > 0) {
+ FocusManager.instance.primaryFocus?.unfocus();
+ return;
+ }
+ _isAlbumsSearchActiveNotifier.value = false;
+ Bus.instance.fire(
+ TabChangedEvent(0, TabChangedEventSource.backButton),
+ );
+ return;
+ }
}
Bus.instance.fire(
TabChangedEvent(0, TabChangedEventSource.backButton),
@@ -1034,7 +1049,11 @@ class _HomeWidgetState extends State<HomeWidget> {
_buildTabHeroMode(
1,
selectedTabIndex,
- AlbumsTab(selectedAlbums: _selectedAlbums),
+ AlbumsTab(
+ selectedAlbums: _selectedAlbums,
+ isSearchActiveNotifier:
+ _isAlbumsSearchActiveNotifier,
+ ),
),
_buildTabHeroMode(
2,
diff --git a/mobile/apps/photos/scripts/internal_changes.txt b/mobile/apps/photos/scripts/internal_changes.txt
index f634c633b4..2291477f09 100644
--- a/mobile/apps/photos/scripts/internal_changes.txt
+++ b/mobile/apps/photos/scripts/internal_changes.txt
@@ -1,4 +1,5 @@
Latest changes:
+- Aman: Album section redesign
- Neeraj: Ignore missing files during stale upload cleanup [Sentry]
- Neeraj: Fix blank gallery after switching from offline mode to online account
- Neeraj: Fix smart memories and ML lookup failures for large offline galleries [Sentry]