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

Redesign Brave Wallet main layout introducing latest material 2 components #19650

Merged
merged 20 commits into from
Aug 15, 2023

Conversation

simoarpe
Copy link
Collaborator

@simoarpe simoarpe commented Aug 11, 2023

Resolves brave/brave-browser#32197

demo.mov
  • Remove logic for old Android versions below Nougat (< API level 24).

  • Switch from old ViewPager to new and more performant ViewPager2 class.

  • Switch from deprecated FragmentStatePagerAdapter to new FragmentStateAdapter.

  • Rename Market section to Explore section per Figma design.

  • Implement BottomNavigationViewIndicator to display sections: Portfolio, NFTs, Activity, Accounts, Explore.
    ⚠️ Note: NFTs section will be removed from the bottom navigation view and it will be merged into the portfolio section in a follow up PR (Main umbrella Issue: ☂️ Main umbrella issue for Wallet 2.0 sections redesign brave-browser#32196)

Screenshot_2023-08-11_at_2_12_30_PM

UI Changes

Bottom Navigation View

Remove tab layout in favor of bottom navigation view with gradient indicator that animates when tapped.

navigator-indicator.mov

App Bar Layout

Add app bar layout and rewrite layout to scroll correctly.

toolbar.mov

Tweak FAB behavior

FAB "follows" bottom navigation view

fab.mov

Banner layout

Improved layout with bottom margin and thin separator.

Screenshot_2023-08-11_at_2_27_07_PM

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  • Open Brave Wallet.
  • Observe the new bottom navigation view is displayed instead of the old tabs on top.
  • Tap on its sections.
  • Observe the pages switch accordingly.
  • Navigate back to Portfolio section and scroll down
  • Observe the bottom navigation view disappears.
  • Observe the FAB button animation
  • Observe the toolbar can disappear
  • Scroll up
  • Observe the bottom navigation view is shown again
  • Observe the FAB "follows" the bottom navigation view
  • Observe the toolbar reappears.

simoarpe added 19 commits August 9, 2023 14:16
Removes logic for old Android versions below Nougat (< API level 24).
Replaces tab layout in favor of bottom navigation view in Brave Wallet activity layout.
Shadows are so messed up on Android that even Google itself stopped using native support
and decided to add them manually to solve the problem. We are adopting the same approach used
for the Chromium bottom bar.
Link: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/android/toolbar/java/res/layout/bottom_control_container.xml;l=1?q=bottom_control_container.xml
Improves layout by introducing a frame layout that will render the shadow in the correct position.
Improves performance and stability by switching to new ViewPager2 based on modern RecyclerView implementation.
@simoarpe simoarpe added CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-ios Do not run CI builds for iOS CI/skip-windows-x86 CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 labels Aug 11, 2023
@simoarpe simoarpe requested a review from a team as a code owner August 11, 2023 09:16
@simoarpe simoarpe self-assigned this Aug 11, 2023
@simoarpe simoarpe requested a review from Pavneet-Sing August 11, 2023 12:39
Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

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

++

Comment on lines +35 to +109
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<include layout="@layout/wallet_backup_banner" />

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/navigation_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

<LinearLayout
android:id="@+id/bottom_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicator="@drawable/tab_gradient_separator"
app:tabIndicatorHeight="@dimen/brave_wallet_tab_indicator_height"
app:tabIndicatorColor="@null"
android:background="@color/wallet_toolbar_bg_color"
app:tabTextAppearance="@style/BraveWalletTabsTextAppearance"
app:tabGravity="fill"
app:tabSelectedTextColor="@color/tab_color"
app:tabTextColor="@color/wallet_text_color" />
<include layout="@layout/wallet_backup_banner"/>
<org.chromium.chrome.browser.custom_layout.NonSwipeableViewPager
android:id="@+id/navigation_view_pager"
android:layout_gravity="bottom"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">

<ImageView
android:id="@+id/bottom_container_top_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_shadow_height"
android:scaleType="fitXY"
android:scaleY="-1"
android:src="@drawable/modern_toolbar_shadow"
tools:ignore="ContentDescription" />

<org.chromium.chrome.browser.custom_layout.BottomNavigationViewWithIndicator
android:id="@+id/wallet_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@color/wallet_toolbar_bg_color"
app:itemHorizontalTranslationEnabled="false"
app:itemIconTint="@color/wallet_bottom_navigation_color"
app:labelVisibilityMode="labeled"
app:menu="@menu/wallet_bottom_navigation_items" />
</LinearLayout>

<LinearLayout
android:id="@+id/fab_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:orientation="vertical"
app:layout_anchor="@id/bottom_view_container"
app:layout_anchorGravity="top|end">

<ImageView
android:id="@+id/pending_tx_notification"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/ic_pending_tx_notification_bg"
android:contentDescription="@null"
android:elevation="10dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_pending_tx_notification_icon" />

<ImageView
android:id="@+id/buy_send_swap_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/ic_swap_bg"
android:contentDescription="@null"
android:elevation="10dp"
android:scaleType="center"
android:src="@drawable/ic_swap_icon" />
</LinearLayout>

Choose a reason for hiding this comment

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

nit: can be inside one constraint layout

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I should try harder to make this a constraint layout.
I'm going to tackle this task in the PR solving issue brave/brave-browser#32256

Choose a reason for hiding this comment

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

Feel free to keep it as it is if it takes more of your time, just a nit.

Comment on lines 41 to 43
public CryptoFragmentPageAdapter(FragmentActivity fm) {
super(fm);
Resources resources = fm.getResources();

Choose a reason for hiding this comment

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

nit: fm should be activity, no longer a FragmentManager

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment on lines 449 to 452
if (hasPendingTx())
((BraveWalletActivity) activity).setPendingTxNotificationVisibility(View.VISIBLE);
((BraveWalletActivity) activity).showPendingTxNotification(true);
else
((BraveWalletActivity) activity).setPendingTxNotificationVisibility(View.GONE);
((BraveWalletActivity) activity).showPendingTxNotification(false);

Choose a reason for hiding this comment

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

Replace with ((BraveWalletActivity) activity).showPendingTxNotification(hasPendingTx());

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

strings++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-ios Do not run CI builds for iOS CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 feature/web3/wallet unused-CI/skip-linux-x64 Do not run CI builds for Linux x64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign Brave Wallet main layout introducing latest material 2 components
4 participants