Skip to content

fix: InvestScreen layout broken β€” triple-nested SafeAreaView, KeyboardAvoidingView, and ScrollView cause scroll conflict and amount truncationΒ #58

Description

@Josue19-08

πŸ”– Title

Fix `InvestScreen` layout β€” triple nesting causes scroll conflict, double top inset, and amount display truncation


πŸ“„ Description

`InvestScreen` is wrapped inside `MainLayout`, creating three separate layout conflicts:

Bug 1 β€” Double SafeAreaView (extra blank space at top):
`MainLayout` applies `` AND `InvestScreen` has its own `<SafeAreaView edges={['top']}>`. The top inset is applied twice, adding a large blank gap above the screen content.

Bug 2 β€” Nested KeyboardAvoidingViews (unpredictable keyboard offset):
`MainLayout` has `` and `InvestScreen` has its own with `keyboardVerticalOffset={0}`. Both use `behavior="padding"` on iOS. Nested KAVs stack their offsets β€” when the deposit input is focused, content jumps by an incorrect amount.

Bug 3 β€” Nested ScrollViews (scroll conflict + amount truncation):
`MainLayout` wraps `{children}` in a `` and `InvestScreen` has its own inner ``. React Native does not support nested ScrollViews in the same scroll direction. The deposit amount text is truncated because the inner ScrollView is constrained by the outer one and cannot calculate its own height correctly.

Bug 4 β€” Unintended outer scroll:
The user reported the home screen has scroll β€” this is the `MainLayout` ScrollView making the entire screen (including the header) scroll, which feels wrong. The header should be fixed; only the content area should scroll.


βœ… Tasks to complete

  • Remove `` from `InvestScreen.tsx` β€” let `MainLayout` handle safe area insets
  • Remove `` from `InvestScreen.tsx` β€” let `MainLayout` handle keyboard avoidance
  • Remove the inner `` from `InvestScreen.tsx` β€” let `MainLayout`'s ScrollView handle scrolling, OR remove it from `MainLayout` and use `` or `` only in `InvestScreen` directly
  • Refactor `MainLayout.tsx` β€” keep only the fixed header + `{children}` in a ``; remove the ScrollView wrapper so each child screen controls its own scroll behavior
  • Fix the deposit amount display in `InvestScreen` β€” ensure the amount text has `numberOfLines` properly unset and the container has no `overflow: hidden` or conflicting `flex` constraint that clips the value
  • Fix the `use-invest.ts` hook β€” `formatCurrency` is exported but unused in the component (component uses a raw template string `$${depositAmount}`); replace inline formatting with the hook's `formatCurrency` function to correctly format large numbers with commas
  • Test on both iOS and Android: deposit input should push content up correctly, amount should display without truncation, header should remain fixed while content scrolls

πŸ“š Documentation/context for AI

https://github.com/TrustUp-app/TrustUp-Frontend/tree/main/docs

Files to modify:

  • `components/pages/InvestScreen.tsx`
  • `components/shared/MainLayout.tsx`
  • `hooks/invest/use-invest.ts` (minor β€” wire formatCurrency)

πŸ—’οΈ Additional notes

  • The fix is structural β€” do not add workarounds like negative margins or absolute positioning to compensate for the double inset
  • After removing SafeAreaView from InvestScreen, test on a physical device with a notch (iPhone with Dynamic Island) to confirm top content is not hidden
  • The header in `MainLayout` (greeting, settings icon, avatar) must remain fixed at the top β€” it should NOT scroll with content
  • `InvestScreen` content (cards, deposit input) should scroll independently if content overflows the screen height

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions