Skip to content

Conversation

@Quwaysim
Copy link
Contributor

@Quwaysim Quwaysim commented Sep 22, 2025

Description

This PR contains two important improvements:

  • UI Enhancement: Standardized button spacing and improved keyboard animation timing
  • Critical Bug Fix: Resolved RangeError crash in contact list rendering
  • Enhanced Keyboard Animation: Better synchronization with keyboard appearance/dismissal to make sure scroll to screen end works

Code Cleanup:
Removed unnecessary whitespace and formatting inconsistencies

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Tests

Checklist

  • Run just precommit to ensure that formatting and linting are correct
  • Run just check-flutter-coverage to ensure that flutter coverage rules are passing
  • Updated the CHANGELOG.md file with your changes (if they affect the user experience)

Summary by CodeRabbit

  • New Features

    • Smoother login experience: delayed scroll when keyboard appears for improved positioning.
  • Style

    • Adjusted spacing across screens: increased gap on welcome buttons, tightened DM chat and developer settings, and clearer spacing in Edit Profile.
  • Refactor

    • Simplified login screen layout for more consistent rendering.
  • Bug Fixes

    • Prevented possible crash in new chat flow by guarding against invalid contact indexing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Refactors the login screen layout and increases keyboard-visible scroll delay to 500ms. Adjusts vertical spacing in multiple UI screens and tightens developer/profile layouts. Adds a guard preventing negative indexing in the new chat bottom sheet. No exported API or core logic signature changes.

Changes

Cohort / File(s) Summary
Auth Flow Layout
lib/ui/auth_flow/login_screen.dart, lib/ui/auth_flow/welcome_screen.dart
Login: increased keyboard-visible scroll delay to 500ms and refactored layout from IntrinsicHeight to a flatter Column, preserving existing controls and logic. Welcome: increased gap between Login and Sign Up from 4.h to 8.h.
Contact List Index Guard
lib/ui/contact_list/new_chat_bottom_sheet.dart
Added contactIndex >= 0 check alongside existing upper-bound check before indexing filteredContacts, preventing negative-index access.
Chat Info Spacing
lib/ui/chat/chat_info/dm_chat_info.dart
Reduced two vertical gaps from 12.h to 8.h, tightening spacing between action buttons.
Settings / Profile Spacing
lib/ui/settings/developer/developer_settings_screen.dart, lib/ui/settings/profile/edit_profile_screen.dart
Developer: removed a 24.h gap and replaced two 12.h gaps with 8.h; minor comment/blank-line cleanup. Profile Edit: increased a gap from 4.h to 8.h in the unsaved-changes flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as NewChatBottomSheet
  participant Contacts as FilteredContacts

  User->>UI: Tap/contact selection
  UI->>UI: Compute contactIndex
  alt 0 <= contactIndex < Contacts.length
    UI->>Contacts: Access filteredContacts[contactIndex]
    Contacts-->>UI: Return contact
    UI-->>User: Open/start chat
  else invalid index
    UI-->>User: No-op / prevent access
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • josefinalliende
  • untreu2
  • codeswot

Poem

I nudged the gaps with careful paws, arranged each column right,
I waited half a heartbeat for the keyboard’s softest light.
I stopped a negative tumble, kept the list from sudden slips,
Now UI hops are orderly — small rabbit-made improvements, bliss. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix button paddings" is concise and correctly describes the primary UI work in this changeset (multiple button/spacing adjustments across screens), but it omits other important changes present in the PR such as the contact-list RangeError guard and keyboard animation timing tweaks.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f00133 and 8b8efc7.

📒 Files selected for processing (1)
  • lib/ui/settings/profile/edit_profile_screen.dart (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/ui/settings/profile/edit_profile_screen.dart (1)

368-371: Prevent RangeError when displayName is empty

Indexing displayName[0] can crash if the string is empty (e.g., no profile name yet).

Apply this diff:

-          displayName[0].toUpperCase(),
+          (displayName.isNotEmpty ? displayName[0] : '?').toUpperCase(),
🧹 Nitpick comments (3)
lib/ui/auth_flow/login_screen.dart (3)

60-69: Replace magic delay with a named constant; consider a metrics-stable trigger

A hardcoded 500ms is brittle across devices/OS versions.

Apply this diff to de‑magic the delay:

 class _LoginScreenState extends ConsumerState<LoginScreen> with WidgetsBindingObserver {
+  static const Duration kKeyboardScrollDelay = Duration(milliseconds: 500);
@@
-      Future.delayed(const Duration(milliseconds: 500), () {
+      Future.delayed(kKeyboardScrollDelay, () {
         if (mounted && _scrollController.hasClients) {
           _scrollController.animateTo(
             _scrollController.position.maxScrollExtent,
             duration: const Duration(milliseconds: 300),
             curve: Curves.easeInOut,
           );
         }
       });

Optional: instead of scrolling to maxScrollExtent, target the field with Scrollable.ensureVisible once viewInsets stabilizes to avoid overscroll.


152-163: Avoid “magic” vertical spacers

The twin Gap(79.5.h) reads like a tuned magic value. Prefer a named constant (e.g., Spacing.xxxLarge) to keep spacing consistent and discoverable.

Would you like a quick pass to introduce a shared spacing constants file and replace these literals across the touched screens?


200-205: Comment nit

Minor typos (“bothe”). Clean up for clarity.

Apply this diff:

-                        // Used .h for bothe to make it square and also go along with the 56.h
+                        // Used .h for both to make it square and to match the 56.h
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d6bee4 and 2f00133.

⛔ Files ignored due to path filters (1)
  • ios/Podfile.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • lib/ui/auth_flow/login_screen.dart (2 hunks)
  • lib/ui/auth_flow/welcome_screen.dart (1 hunks)
  • lib/ui/chat/chat_info/dm_chat_info.dart (2 hunks)
  • lib/ui/contact_list/new_chat_bottom_sheet.dart (1 hunks)
  • lib/ui/settings/developer/developer_settings_screen.dart (1 hunks)
  • lib/ui/settings/profile/edit_profile_screen.dart (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.dart

📄 CodeRabbit inference engine (.cursor/rules/flutter.mdc)

**/*.dart: Always declare the type of each variable and function (parameters and return value). Avoid using 'any'. Create necessary types.
Don't leave blank lines within a function.
One export per file.
Use PascalCase for classes.
Use camelCase for variables, functions, and methods.
Use underscores_case for file and directory names.
Use UPPERCASE for environment variables. Avoid magic numbers and define constants.
Start each function with a verb.
Use verbs for boolean variables. Example: isLoading, hasError, canDelete, etc.
Use complete words instead of abbreviations and correct spelling, except for standard and well-known abbreviations (API, URL, i, j, err, ctx, req, res, next).
Write short functions with a single purpose. Less than 20 instructions.
Name functions with a verb and something else. If it returns a boolean, use isX or hasX, canX, etc. If it doesn't return anything, use executeX or saveX, etc.
Avoid nesting blocks by early checks and returns, or extraction to utility functions.
Use higher-order functions (map, filter, reduce, etc.) to avoid function nesting. Use arrow functions for simple functions (less than 3 instructions). Use named functions for non-simple functions.
Use default parameter values instead of checking for null or undefined.
Reduce function parameters using RO-RO: use an object to pass multiple parameters and to return results. Declare necessary types for input arguments and output.
Use a single level of abstraction in functions.
Don't abuse primitive types and encapsulate data in composite types.
Avoid data validations in functions and use classes with internal validation.
Prefer immutability for data. Use readonly for data that doesn't change. Use 'as const' for literals that don't change.
Declare interfaces to define contracts.
Write small classes with a single purpose. Less than 200 instructions, less than 10 public methods, less than 10 properties.
Use exceptions to handle errors you don't expect. If you catch an exception, it sh...

Files:

  • lib/ui/settings/developer/developer_settings_screen.dart
  • lib/ui/contact_list/new_chat_bottom_sheet.dart
  • lib/ui/auth_flow/welcome_screen.dart
  • lib/ui/auth_flow/login_screen.dart
  • lib/ui/settings/profile/edit_profile_screen.dart
  • lib/ui/chat/chat_info/dm_chat_info.dart
🧠 Learnings (1)
📓 Common learnings
Learnt from: Quwaysim
PR: parres-hq/whitenoise_flutter#642
File: lib/ui/contact_list/new_chat_bottom_sheet.dart:324-336
Timestamp: 2025-09-16T07:24:07.489Z
Learning: In the whitenoise_flutter project, the user Quwaysim prefers to handle security improvements incrementally across different PRs rather than bundling them all together. Input trimming for search functionality was handled in PR #613, and private key security measures are planned for PR #505.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Flutter CI
🔇 Additional comments (5)
lib/ui/settings/profile/edit_profile_screen.dart (1)

310-311: Spacing tweak after “Discard Changes”: LGTM

8.h reads better than 4.h and keeps CTAs visually distinct.

lib/ui/auth_flow/welcome_screen.dart (1)

102-102: Button spacing: LGTM

Increasing to Gap(8.h) improves tap target separation in the bottom bar.

lib/ui/chat/chat_info/dm_chat_info.dart (1)

154-155: Tighter vertical rhythm: LGTM

Reducing gaps to 8.h between stacked actions (“Search Chat”, “Follow/Unfollow”, “Add to Group”) keeps the panel dense without harming readability.

Also applies to: 173-173

lib/ui/contact_list/new_chat_bottom_sheet.dart (1)

386-396: Fix for intermittent RangeError: good guard

The added check (contactIndex >= 0 && contactIndex < filteredContacts.length) addresses the out-of-range crash during list building.

Consider a small widget test to lock this in (e.g., rapidly toggling showTempContact and filteredContacts lengths while rebuilding the list) to ensure no regressions around section index math.

lib/ui/settings/developer/developer_settings_screen.dart (1)

293-293: Consistent spacing scale: LGTM

Standardizing to Gap(8.h) aligns with the PR’s spacing goals.

Also applies to: 299-299

Copy link
Contributor

@josefinalliende josefinalliende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the screens touched look good to me!! 👌🏻 I found just two other screens untouched in this PR where I think the spacing between buttos is not consistent yet.
edit-group-padding
edit-group-padding

);
},
),
// Gap(16.h),
Copy link
Contributor

@josefinalliende josefinalliende Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sug: remove commented code

Copy link
Member

@erskingardner erskingardner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually - I saw @josefinalliende 's point about the two screens that were missed. Can you also include a screenshot of the log in screen?

@josefinalliende
Copy link
Contributor

josefinalliende commented Sep 22, 2025

Actually - I saw @josefinalliende 's point about the two screens that were missed. Can you also include a screenshot of the log in screen?

Login screen looks fine to me!
login

@josefinalliende
Copy link
Contributor

@Quwaysim This tiny draft fixes the padding comments I made: #675
If it is useful, feel free to cherry-pick that commit 😉

@erskingardner erskingardner merged commit 2afc658 into master Sep 22, 2025
2 of 3 checks passed
@erskingardner erskingardner deleted the patch-fix-button-paddings branch September 22, 2025 19:01
@coderabbitai coderabbitai bot mentioned this pull request Oct 9, 2025
11 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 22, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants