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

emoji: Fix bottom padding of emoji picker #1315

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Jan 30, 2025

Previously, the body of the bottom sheet was wrapped in SafeArea. This pads the bottom unconditionally, shifting the bottom of the list view above the device bottom inset.

This is undesirable, because the area beneath the bottom inset is still visible, and the list view should extend to the bottom regardless of the bottom inset.

By just removing the SafeArea, the list view extends to the bottom. However, if the bottom inset is more than 8px, we can't scroll past the last item in the list view. Essentially, we want the behavior of SafeArea.minimum with a ListView — the bottom of the list should always be padded by at least 8px, so that we can scroll past the shadow; and if the bottom inset is more than 8px, use that as the padding instead — which is achieved through the use ListView.padding and MediaQuery.

@PIG208
Copy link
Member Author

PIG208 commented Jan 30, 2025

Comparisons

The bottom bar represents the device padding.

before (SafeArea + 8px bottom padding) after max(8px, bottom inset) bottom padding
partially scrolled to the bottom, with shadow visible
Screenshot_20250130_172009 Screenshot_20250130_171918
fully scrolled to the bottom
Screenshot_20250130_172003 Screenshot_20250130_171906
with keyboard open, unscrolled
Screenshot_20250130_172020 Screenshot_20250130_172056

The following patch was used to make the builds in the screenshots:

diff --git a/lib/widgets/app.dart b/lib/widgets/app.dart
index 75fec7bc8..ea1e3726a 100644
--- a/lib/widgets/app.dart
+++ b/lib/widgets/app.dart
@@ -175,6 +175,7 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
   @override
   Widget build(BuildContext context) {
     final themeData = zulipThemeData(context);
+    final mediaQuery = MediaQuery.maybeOf(context);
     return GlobalStoreWidget(
       child: Builder(builder: (context) {
         final globalStore = GlobalStoreWidget.of(context);
@@ -194,7 +195,21 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
                 (_) => widget._declareReady());
             }
             GlobalLocalizations.zulipLocalizations = ZulipLocalizations.of(context);
-            return child!;
+            return Center(
+              child: Stack(
+                children: [
+                  MediaQuery(
+                    data: mediaQuery!.copyWith(
+                      viewPadding: mediaQuery.viewPadding.copyWith(bottom: 30),
+                      padding: mediaQuery.padding.copyWith(bottom: 30)),
+                    child: child!),
+                  Positioned(
+                    left: 0,
+                    right: 0,
+                    bottom: 0,
+                    child: Container(height: 30, decoration: BoxDecoration(color: Colors.black.withValues(alpha: 0.5)))),
+                ]),
+            );
           },
 
           // We use onGenerateInitialRoutes for the real work of specifying the

@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Jan 30, 2025
Previously, the body of the bottom sheet was wrapped in `SafeArea`. This
pads the bottom unconditionally, shifting the bottom of the list view
above the device bottom padding.

This is undesirable, because the area beneath the bottom padding is still
visible, and the list view should extend to the bottom regardless of the
bottom inset.

By just removing the `SafeArea`, the list view extends to the bottom.
However, if the bottom padding is more than 8px, we can't scroll past the
last item in the list view.  Essentially, we want the behavior of
`SafeArea.minimum` with a `ListView` — the bottom of the list should
always be padded by at least 8px, so that we can scroll past the shadow;
and if the bottom padding is more than 8px, use that as the padding
instead — which is achieved through the use `ListView.padding` and
`MediaQuery`.

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208 PIG208 requested a review from chrisbobbe January 30, 2025 23:11
@PIG208 PIG208 changed the title emoji: Fix bottom inset padding of emoji picker emoji: Fix bottom padding of emoji picker Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer review PR ready for review by Zulip maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants