π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add keyboard padding to search results (#10727)
Aman Raj921eba9aa6a0
diff --git a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart b/mobile/apps/photos/lib/ui/tabs/albums_tab.dartindex 86247baec3..9322a6f808 100644--- a/mobile/apps/photos/lib/ui/tabs/albums_tab.dart+++ b/mobile/apps/photos/lib/ui/tabs/albums_tab.dart@@ -238,6 +238,13 @@ class _AlbumsTabState extends State<AlbumsTab>bool get _hasSearchQuery => _searchQuery.trim().isNotEmpty;+ double _keyboardAwareBottomPadding(double defaultPadding) {+ final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;+ if (keyboardInset <= 0) return defaultPadding;+ final keyboardPadding = keyboardInset + 50.0;+ return keyboardPadding > defaultPadding ? keyboardPadding : defaultPadding;+ }+void _syncSortState() {_sortKey.value = localSettings.albumSortKey();_sortDirection.value = localSettings.albumSortDirection();@@ -349,6 +356,7 @@ class _AlbumsTabState extends State<AlbumsTab>required bool showCreateAlbum,required Widget emptyState,Widget? leadingSliver,+ double? bottomPadding,}) {if (collections.isEmpty && _searchQuery.trim().isEmpty) {return SliverFillRemaining(hasScrollBody: false, child: emptyState);@@ -366,6 +374,7 @@ class _AlbumsTabState extends State<AlbumsTab>shrinkWrap: true,shouldShowCreateAlbum: showCreateAlbum && !_hasSearchQuery,enableSelectionMode: !_isSearchActive,+ bottomPadding: bottomPadding ?? 200,),],);@@ -460,6 +469,7 @@ class _AlbumsTabState extends State<AlbumsTab>}Widget _buildGlobalSearchResultsSliver(AppLocalizations strings) {+ final bottomPadding = _keyboardAwareBottomPadding(200);if (_isLocalGalleryMode) {return SliverMainAxisGroup(slivers: [@@ -475,7 +485,7 @@ class _AlbumsTabState extends State<AlbumsTab>sectionHeader: _buildSearchSectionHeader(strings.onDevice),emptyStateSliver: _buildGlobalSearchEmptyStateSliver(strings),),- const SliverToBoxAdapter(child: SizedBox(height: 200)),+ SliverToBoxAdapter(child: SizedBox(height: bottomPadding)),],);}@@ -522,7 +532,7 @@ class _AlbumsTabState extends State<AlbumsTab>tag: "album_search_shared",collections: filteredSharedCollections,),- const SliverToBoxAdapter(child: SizedBox(height: 200)),+ SliverToBoxAdapter(child: SizedBox(height: bottomPadding)),],);}@@ -550,6 +560,7 @@ class _AlbumsTabState extends State<AlbumsTab>albumViewType: _viewType.value,sortKey: _sortKey.value,sortDirection: _sortDirection.value,+ bottomPadding: _keyboardAwareBottomPadding(200),);}if (collections == null) {@@ -564,6 +575,7 @@ class _AlbumsTabState extends State<AlbumsTab>collections: collections,showCreateAlbum: showCreateAlbum,emptyState: emptyState,+ bottomPadding: _keyboardAwareBottomPadding(200),leadingSliver: filter == _AlbumsFilter.ente && !_hasSearchQuery? SliverToBoxAdapter(child: _buildDeleteEmptyAlbumsActionSlot()): null,diff --git a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_banner.dart b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_banner.dartindex febffc3cae..e7a16b25af 100644--- a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_banner.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_banner.dart@@ -11,6 +11,7 @@ import "package:photos/models/ml/face/face.dart";import "package:photos/models/ml/face/person.dart";import "package:photos/services/memory_lane/memory_lane_service.dart";import "package:photos/theme/ente_theme.dart";+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";import "package:photos/utils/face/face_thumbnail_cache.dart";class MemoryLaneBanner extends StatelessWidget {@@ -28,45 +29,26 @@ class MemoryLaneBanner extends StatelessWidget {@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final brightness = Theme.of(context).brightness;- final Color backgroundColor = brightness == Brightness.dark- ? colorScheme.backgroundElevated2- : colorScheme.fillBaseGrey;- final TextStyle titleStyle = textTheme.body.copyWith(- fontFamily: "Inter",- fontWeight: FontWeight.w500,- fontSize: 16,- height: 20 / 16,- letterSpacing: -0.32,- color: brightness == Brightness.dark- ? colorScheme.textBase- : Colors.black,- );- return GestureDetector(- onTap: onTap,- child: Container(- margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- padding: const EdgeInsets.fromLTRB(9, 7, 18, 7),- decoration: BoxDecoration(- color: backgroundColor,- borderRadius: BorderRadius.circular(28),- ),- child: Row(- children: [- _FaceThumbnail(image: thumbnail, backgroundColor: backgroundColor),- const SizedBox(width: 14),- Expanded(- child: Text(- title,- style: titleStyle,- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- ),- Icon(Icons.chevron_right, color: colorScheme.textBase),- ],+ final backgroundColor = colorScheme.fill;+ return Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),+ child: MenuItemWidgetNew(+ title: title,+ titleMaxLines: 1,+ titleColor: colorScheme.textBase,+ leadingIconSize: 56,++ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),+ leadingIconWidget: _FaceThumbnail(+ image: thumbnail,+ backgroundColor: backgroundColor,),++ trailingIcon: Icons.chevron_right,++ trailingIconColor: colorScheme.textBase,+ menuItemColor: backgroundColor,+ onTap: () async => onTap(),),);}diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/no_result_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/result/no_result_widget.dartindex 13a1a061f2..34d94c4ba2 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/no_result_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/no_result_widget.dart@@ -58,6 +58,8 @@ class _NoResultWidgetState extends State<NoResultWidget> {@overrideWidget build(BuildContext context) {final textTheme = getEnteTextTheme(context);+ final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;+ final bottomPadding = keyboardInset + (keyboardInset > 0 ? 50 : 0);final searchTypeAndSuggestion = <Widget>[];searchTypeToQuerySuggestion.forEach((key, value) {searchTypeAndSuggestion.add(@@ -78,8 +80,9 @@ class _NoResultWidgetState extends State<NoResultWidget> {);});return Scaffold(- body: Padding(- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),+ body: SingleChildScrollView(+ physics: const BouncingScrollPhysics(),+ padding: EdgeInsets.fromLTRB(12, 8, 12, bottomPadding),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [@@ -113,6 +116,7 @@ class _NoResultWidgetState extends State<NoResultWidget> {},itemCount: searchTypeToQuerySuggestion.length,shrinkWrap: true,+ physics: const NeverScrollableScrollPhysics(),),),],diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dartindex f22d167c0e..44adf63ec3 100644--- a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart@@ -129,6 +129,12 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {? colorScheme.backgroundColour: colorScheme.backgroundElevated2;final sectionWidgets = _buildSectionWidgets(context);+ final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;+ final defaultBottomPadding = (MediaQuery.sizeOf(context).height / 2) + 50.0;+ final keyboardBottomPadding = keyboardInset + 50.0;+ final bottomPadding = keyboardBottomPadding > defaultBottomPadding+ ? keyboardBottomPadding+ : defaultBottomPadding;if (_resultsCount > 0) {sectionWidgets.insert(0,@@ -153,9 +159,7 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {Expanded(child: ListView(physics: const BouncingScrollPhysics(),- padding: EdgeInsets.only(- bottom: (MediaQuery.sizeOf(context).height / 2) + 50,- ),+ padding: EdgeInsets.only(bottom: bottomPadding),children: sectionWidgets,),),diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dartindex 94490ad609..802192acf1 100644--- a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart@@ -3,7 +3,6 @@ import "dart:async";import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";-import "package:flutter/scheduler.dart";import "package:hugeicons/hugeicons.dart";import "package:logging/logging.dart";import "package:photos/core/event_bus.dart";@@ -40,9 +39,6 @@ class SearchWidgetState extends State<SearchWidget> {late FocusNode focusNode;StreamSubscription<TabChangedEvent>? _tabChangedEvent;StreamSubscription<TabDoubleTapEvent>? _tabDoubleTapEvent;- double _bottomPadding = 0.0;- double _distanceOfWidgetFromBottom = 0;- GlobalKey widgetKey = GlobalKey();TextEditingController textController = TextEditingController();late final StreamSubscription<ClearAndUnfocusSearchBar>_clearAndUnfocusSearchBar;@@ -75,23 +71,7 @@ class SearchWidgetState extends State<SearchWidget> {}});- SchedulerBinding.instance.addPostFrameCallback((_) {- //This buffer is for doing this operation only after SearchWidget's- //animation is complete.- Future.delayed(const Duration(milliseconds: 300), () {- if (mounted) {- final RenderBox box =- widgetKey.currentContext!.findRenderObject() as RenderBox;- final heightOfWidget = box.size.height;- final offsetPosition = box.localToGlobal(Offset.zero);- final y = offsetPosition.dy;- final heightOfScreen = MediaQuery.sizeOf(context).height;- _distanceOfWidgetFromBottom = heightOfScreen - (y + heightOfWidget);- }- });-- textController.addListener(textControllerListener);- });+ textController.addListener(textControllerListener);//Populate the serach tab with the latest query when coming back//to the serach tab.@@ -117,19 +97,6 @@ class SearchWidgetState extends State<SearchWidget> {}}- @override- void didChangeDependencies() {- super.didChangeDependencies();- //https://api.flutter.dev/flutter/dart-ui/FlutterView-class.html- _bottomPadding =- (MediaQuery.viewInsetsOf(context).bottom - _distanceOfWidgetFromBottom);- if (_bottomPadding < 0) {- _bottomPadding = 0;- } else if (_bottomPadding != 0) {- _bottomPadding += MediaQuery.viewPaddingOf(context).bottom;- }- }-@overridevoid dispose() {_syncSearchBackNotifier(false);@@ -180,30 +147,26 @@ class SearchWidgetState extends State<SearchWidget> {MediaQuery.viewInsetsOf(context).bottom > 0 ||textController.text.trim().isNotEmpty;return RepaintBoundary(- key: widgetKey,child: Padding(- padding: EdgeInsets.only(bottom: _bottomPadding),- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),- child: TextInputComponent(- controller: textController,- focusNode: focusNode,- hintText: AppLocalizations.of(context).search,- shouldUnfocusOnClearOrSubmit: true,- prefix: HugeIcon(- icon: HugeIcons.strokeRoundedSearch01,- size: 18,- color: componentColors.textLight,- ),- suffix: ValueListenableBuilder(- valueListenable: isLoading,- builder: (BuildContext context, bool isSearching, Widget? child) {- return SearchSuffixIcon(- isSearching,- showClearButton: shouldShowClearButton,- );- },- ),+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),+ child: TextInputComponent(+ controller: textController,+ focusNode: focusNode,+ hintText: AppLocalizations.of(context).search,+ shouldUnfocusOnClearOrSubmit: true,+ prefix: HugeIcon(+ icon: HugeIcons.strokeRoundedSearch01,+ size: 18,+ color: componentColors.textLight,+ ),+ suffix: ValueListenableBuilder(+ valueListenable: isLoading,+ builder: (BuildContext context, bool isSearching, Widget? child) {+ return SearchSuffixIcon(+ isSearching,+ showClearButton: shouldShowClearButton,+ );+ },),),),diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dartindex 0e8ac10b0a..1c793536f3 100644--- a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart@@ -109,6 +109,8 @@ class _AllSearchSectionsState extends State<AllSearchSections> {@overrideWidget build(BuildContext context) {final searchTypes = SectionType.values.toList(growable: true);+ final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;+ final bottomPadding = keyboardInset > 130.0 ? keyboardInset + 50.0 : 180.0;return Padding(padding: const EdgeInsets.only(top: 4),@@ -151,7 +153,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {faceSectionIndex < sectionResultsByType.length &§ionResultsByType.elementAt(faceSectionIndex).isNotEmpty;return ListView.builder(- padding: const EdgeInsets.only(bottom: 180),+ padding: EdgeInsets.only(bottom: bottomPadding),physics: const BouncingScrollPhysics(),itemCount: searchTypes.length + 1,itemBuilder: (context, index) {