-
Notifications
You must be signed in to change notification settings - Fork 635
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
Browser upgrades #6269
Browser upgrades #6269
Conversation
Also adds turbo-haptics and an internal scale animation, giving GestureHandlerButton full platform parity
Reloading the page by calling reload() on the ref doesn't successfully restart the WebView. This was causing tabs to occasionally become blank after the app sat backgrounded for long enough, and upon returning to the app they'd be stuck. This change forces a new WebView by providing a new key, which should resolve the issue.
Fixes a bug that exists with manually activated gestures where when the app returns to the foreground, the first interaction with the manually activated handler doesn't trigger any events
RN was complaining that this iOS code was not Android compliant
// const willAnimate = tabViewGestureProgress.value !== 0 || tabSwitchGestureX.value !== 0; | ||
// if (willAnimate) { | ||
tabViewGestureProgress.value = withSpring( | ||
0, | ||
{ ...SPRING_CONFIGS.tabGestureConfig, velocity: -yVelocity * VELOCITY_FACTOR_Y * velocityDamper }, | ||
onComplete | ||
); | ||
// } else { | ||
// tabViewGestureState.value = TabViewGestureStates.INACTIVE; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will clean this up
if (!success) { | ||
updateTabGestureState(activeTabCloseGestures, { | ||
gestureScale: 1, | ||
gestureX: 0, | ||
isActive: false, | ||
tabId: touchInfo.value.initialTappedTab.tabId, | ||
tabIndex: touchInfo.value.initialTappedTab.tabIndex, | ||
}); | ||
gestureManagerState.value = 'inactive'; | ||
touchInfo.value = undefined; | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to better ensure the close gesture values always get cleaned up after tab close interactions (if the tab isn't closed). Current logic might miss cleanup in certain rare cases, causing the tab to be temporarily stuck with its last gestureScale
and gestureX
values until you interact with it again. There's also a bit of redundancy between onTouchesUp
, onTouchesCancelled
, and onEnd
that should be cleaned up.
No longer needed as there's a dedicated activeTabId Shared Value
A few tab switching styles were applied for all tabs when tab switching, when only the active tab and the tabs to the left and right need full-size tab styles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of functional changes I need to play around with still. some small nitpick comments
<Animated.View style={[enabled ? styles.webViewBorderStyle : {}, webViewBorderStyle]} /> | ||
</Cover> | ||
); | ||
return <Animated.View style={[enabled && isDarkMode ? styles.webViewBorder : {}, webViewBorderStyle]} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabled and isDarkMode is redundant here
|
||
const selectedStyle = useAnimatedStyle(() => { | ||
const selected = selectedItemId?.value === uniqueId || variant === 'homePanel'; | ||
return { | ||
// eslint-disable-next-line no-nested-ternary | ||
backgroundColor: selected ? (isDarkMode ? globalColors.white10 : '#FBFCFD') : 'transparent', | ||
backgroundColor: selected ? (isDarkMode ? globalColors.white10 : '#F7F7F9') : 'transparent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think moving random colors like this #F7F7F9
to a constants file is beneficial? You're also using it below so would improve DRY rules too.
- Removed unnecessary isSwitchingTabs (`tabViewGestureState` serves the same purpose) - Removed a wrapper view around each tab and merged most animated tab styles into `animatedWebViewStyle` - In `animatedWebViewStyle`, now passing values to the style generation worklets instead of passing the Shared Values themselves
- Now setting the JS-side active tab index first so it gets a tiny head start (the JS and SV active indexes inform which tab activates and when tab screenshots are shown/hidden) - Now resetting tab switching state *before* updating `activeTabId` and `animatedActiveTabIndex` (instead of after) — this fixes an edge case where the switch animation would occasionally be skipped, if you switched tabs again at the exact moment a previous tab switch ended
Because getTabInfo is stable and the SVs used within getTabInfo weren't visible to the useAnimatedStyle hooks, styles weren't recomputing for changes in getTabInfo's input values — same idea applies to useDerivedValue, useAnimatedReaction prepare functions, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff. No suggested tweaks. Did some manual testing on my iphone w/o issue and was able to walk through your bullet points.
|
||
export const AccountIcon = React.memo(function AccountIcon() { | ||
// return <View style={{ backgroundColor: 'rgba(20, 20, 20, 1)', borderRadius: 22, height: 44, left: -8, width: 44 }} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
APP-1283 Improve shadow performance on webview APP-1329 Make back / forward nav buttons more visible APP-1417 Would be nice to tap out of the edit URL box to leave this page APP-1424 Feature request: add "Close Tab" option to ••• menu APP-1441 Reintegrate canGoBack/Forward APP-1451 Add Home option to ••• menu to allow returning to homepage |
* Browser upgrades (#6269) * Dapp browser upgrades * Remove unneeded whitelisted native text prop * Clean up SwipeNavigator tab bar components * Remove BPA wrapper from GestureHandlerButton Also adds turbo-haptics and an internal scale animation, giving GestureHandlerButton full platform parity * freezeStore → navigationStore * Restructure browser gesture handlers, code cleanup * Make useKeyboardHeight more efficient * TextShadow: Add support for AnimatedText * Remove commented code * Fix lint error * Remove commented code * Force a new WebView when the content process dies Reloading the page by calling reload() on the ref doesn't successfully restart the WebView. This was causing tabs to occasionally become blank after the app sat backgrounded for long enough, and upon returning to the app they'd be stuck. This change forces a new WebView by providing a new key, which should resolve the issue. * Minor gesture cleanup * Add common gesture options to GestureHandlerButton * Bump packages * Fix manual activation bug in RNGH Fixes a bug that exists with manually activated gestures where when the app returns to the foreground, the first interaction with the manually activated handler doesn't trigger any events * Fix type issue in react-native-view-shot RN was complaining that this iOS code was not Android compliant * Only render WebViewBorder on iOS, misc. cleanup * Adjust ScrollView/tabs hierarchy, props cleanup * Bump Skia * Remove activeTabInfo.value.tabId No longer needed as there's a dedicated activeTabId Shared Value * Make tab switching lighter, add getTabInfo helper A few tab switching styles were applied for all tabs when tab switching, when only the active tab and the tabs to the left and right need full-size tab styles * Smooth out height animations * Clean up scripts, clamp tab height * Clean up WebView handlers * Improve tab animation performance - Removed unnecessary isSwitchingTabs (`tabViewGestureState` serves the same purpose) - Removed a wrapper view around each tab and merged most animated tab styles into `animatedWebViewStyle` - In `animatedWebViewStyle`, now passing values to the style generation worklets instead of passing the Shared Values themselves * Make screenshot flicker less likely, improve tab switching reset - Now setting the JS-side active tab index first so it gets a tiny head start (the JS and SV active indexes inform which tab activates and when tab screenshots are shown/hidden) - Now resetting tab switching state *before* updating `activeTabId` and `animatedActiveTabIndex` (instead of after) — this fixes an edge case where the switch animation would occasionally be skipped, if you switched tabs again at the exact moment a previous tab switch ended * Make isNewIndexValid a boolean * Fix bad worklet pattern Because getTabInfo is stable and the SVs used within getTabInfo weren't visible to the useAnimatedStyle hooks, styles weren't recomputing for changes in getTabInfo's input values — same idea applies to useDerivedValue, useAnimatedReaction prepare functions, etc. * revert third party positions enabled (#6298) * chain badges * Swaps deeplink (#6178) * fix branch branch is blocking some vpns, when trying to open deeplinks while connected to a vpn it would fail to connect to branch servers and return an empty params object, not undefined, empty `params: {}`, in turn making the app ignore the deeplink and not open it * aaa * aaaaaa * remove unused imports * fix type * ops * better validations * opsi inverted the conditions * revert pbxproj changes * setFromWallet * fix typo & code style * remove uncessary stuff --------- Co-authored-by: Matthew Wall <[email protected]> * add eth rewards to claimables and make it discoverable by watchers --------- Co-authored-by: Christian Baroni <[email protected]> Co-authored-by: Kane Thomas <[email protected]> Co-authored-by: gregs <[email protected]> Co-authored-by: Matthew Wall <[email protected]>
* progress * progress * progress * testing * progress * progress * crosschain quote working * claim + crosschainswap rap worked * raps logic is done * delete v2 * cleanup * working on dropdowns * little dropdown refactor * useDropdownMenu hook * refactoring * working on dropdown * basically done with ui refactor * fixes * claim as x is working * context work * progress * gas * enormous refactor, need to fix some things * gas fixes * pretty sure i fixed quotes * functional * wrapping things up * cleaning up * fixes * more fixes * fix formatting * lint * gas and quote state fixes * rm logs * error messages * error messages + i18n * fix bug that allowed button press w/o token/chain selected * disable watched wallets * error logging in executeClaim * i18n * slippage * add comments to transaction context * comments * rainbow fee * adjust rainbow fee * gas improvements * forgot to undo this * fix gas race condition * fix swap data assetToSell bug * rm comment * improve error logging in raps * nit * temp, merging develop * fix gas estimation * rm unused imports * rm console log * rm dai, wbtc, add usdc * fix quote amount + fix gas estimation throttling * rename txState to gasState * more gas fixes * network icons for dropdown menu * fix populateSwap util and some other minor things * fix analyticsId * fix scenario where user does not have native asset for gas calculations * fix context menu ordering on android * fix gas estimation * undo obsolete change * fix analytics * Claimables followups (#6301) * Browser upgrades (#6269) * Dapp browser upgrades * Remove unneeded whitelisted native text prop * Clean up SwipeNavigator tab bar components * Remove BPA wrapper from GestureHandlerButton Also adds turbo-haptics and an internal scale animation, giving GestureHandlerButton full platform parity * freezeStore → navigationStore * Restructure browser gesture handlers, code cleanup * Make useKeyboardHeight more efficient * TextShadow: Add support for AnimatedText * Remove commented code * Fix lint error * Remove commented code * Force a new WebView when the content process dies Reloading the page by calling reload() on the ref doesn't successfully restart the WebView. This was causing tabs to occasionally become blank after the app sat backgrounded for long enough, and upon returning to the app they'd be stuck. This change forces a new WebView by providing a new key, which should resolve the issue. * Minor gesture cleanup * Add common gesture options to GestureHandlerButton * Bump packages * Fix manual activation bug in RNGH Fixes a bug that exists with manually activated gestures where when the app returns to the foreground, the first interaction with the manually activated handler doesn't trigger any events * Fix type issue in react-native-view-shot RN was complaining that this iOS code was not Android compliant * Only render WebViewBorder on iOS, misc. cleanup * Adjust ScrollView/tabs hierarchy, props cleanup * Bump Skia * Remove activeTabInfo.value.tabId No longer needed as there's a dedicated activeTabId Shared Value * Make tab switching lighter, add getTabInfo helper A few tab switching styles were applied for all tabs when tab switching, when only the active tab and the tabs to the left and right need full-size tab styles * Smooth out height animations * Clean up scripts, clamp tab height * Clean up WebView handlers * Improve tab animation performance - Removed unnecessary isSwitchingTabs (`tabViewGestureState` serves the same purpose) - Removed a wrapper view around each tab and merged most animated tab styles into `animatedWebViewStyle` - In `animatedWebViewStyle`, now passing values to the style generation worklets instead of passing the Shared Values themselves * Make screenshot flicker less likely, improve tab switching reset - Now setting the JS-side active tab index first so it gets a tiny head start (the JS and SV active indexes inform which tab activates and when tab screenshots are shown/hidden) - Now resetting tab switching state *before* updating `activeTabId` and `animatedActiveTabIndex` (instead of after) — this fixes an edge case where the switch animation would occasionally be skipped, if you switched tabs again at the exact moment a previous tab switch ended * Make isNewIndexValid a boolean * Fix bad worklet pattern Because getTabInfo is stable and the SVs used within getTabInfo weren't visible to the useAnimatedStyle hooks, styles weren't recomputing for changes in getTabInfo's input values — same idea applies to useDerivedValue, useAnimatedReaction prepare functions, etc. * revert third party positions enabled (#6298) * chain badges * Swaps deeplink (#6178) * fix branch branch is blocking some vpns, when trying to open deeplinks while connected to a vpn it would fail to connect to branch servers and return an empty params object, not undefined, empty `params: {}`, in turn making the app ignore the deeplink and not open it * aaa * aaaaaa * remove unused imports * fix type * ops * better validations * opsi inverted the conditions * revert pbxproj changes * setFromWallet * fix typo & code style * remove uncessary stuff --------- Co-authored-by: Matthew Wall <[email protected]> * add eth rewards to claimables and make it discoverable by watchers --------- Co-authored-by: Christian Baroni <[email protected]> Co-authored-by: Kane Thomas <[email protected]> Co-authored-by: gregs <[email protected]> Co-authored-by: Matthew Wall <[email protected]> * fix hook usage * lint * wallet screen fix * dont throw errors in rap creation * remove claimable asset from dropdown if network is not compatible * rm unnecessary useCallback dep * show wallet error alert if can't load wallet * fix approval target --------- Co-authored-by: Christian Baroni <[email protected]> Co-authored-by: Kane Thomas <[email protected]> Co-authored-by: gregs <[email protected]> Co-authored-by: Matthew Wall <[email protected]>
Fixes APP-1283
Fixes APP-1329
Fixes APP-1417
Fixes APP-1424
Fixes APP-1441
Fixes APP-1451
Fixes APP-1480
What changed (plus any additional context for devs)
ScreenRecording_11-25-2024.14.mov
New Gesture System
gestureManager
Simultaneous
gesture that contains both a manually activatedPan
gesture and theNative
scroll gesture. TheNative
gesture is connected to anAnimated.ScrollView
.Animated.View
that animates to match the aggregate height of the open tabscurrentlyOpenTabIds
andscrollViewOffset
are used to build a map of the tab grid layout. The “map” is necessary because the gesture handlers have no direct connection to the tab views themselves (see: gestureUtils, tabHitTest).Pan
gesture then makes the decision of whether it’s a scroll, tap, or tab close interaction, based on the touch data.Pan
gesture deactivates, and theNative
gesture is allowed to activate, taking over gesture handling until all pointers are off the screenPan
gesture and deactivates theNative
gesture until the end of the interactiongestureScale
andgestureX
values are controlled via an entry inactiveTabCloseGestures
(SharedValue<Record<TabId, TabCloseGesture | undefined>>
)Tab Switching Gestures
New Forward/Back Navigation
canGoBack
andcanGoForward
are now tracked in the browser store within each tab’sTabData
(forward/back state isn’t persisted)GestureHandlerButton
ButtonPressAnimation
wrapper that was used for the button scale animation and haptic feedback on iOSGestureHandlerButton
now does everythingButtonPressAnimation
doesButtonPressAnimation
Gesture
configuration options, e.g.,blocksExternalGesture
,requireExternalGestureToFail
,simultaneousWithExternalGesture
Bug Fixes
WKWebView
has a built-inunderPageBackgroundColor
property which is less error-prone than our background color detection script — that property is now sent through the WebView messaging system to the RN side where it’s applied via animated style. This resolves background color issues on iOS on sites like Foundation. For Android we’ll need to tweak the existing script.onContentProcessDidTerminate
(iOS) oronRenderProcessGone
(Android). Previously when this occurred, we were simply reloading the page by callingreload()
on the WebView ref, which didn't successfully restart the WebView. This was allowing tabs to occasionally become blank after the app sat backgrounded for long enough, and upon returning to the app they'd be stuck. Now when the WebView process dies, itskey
is updated to force a new WebView instance, which allows the page to reload.source
prop possibly being stale. Issue and fix detailed here.Performance
useAnimatedReaction
dependency arrays where only values in the prepare function need to be reacted to (empty dependency array = reacts only to prepare function values)lastActiveHomepageTab
Shared Value. This was previously causing some stutters when switching between homepage tabs due to the homepage re-renders being poorly timed.Additional Improvements
Code Cleanup
types.ts
setTimeout
activeTabIndex
always points to a valid tabuseSmoothScrollView
— no longer needed as in the new structure, the ScrollView isn’t subject to any heavy React-level changes in its childrenMisc.
AnimatedText
inTextShadow
height
andwidth
props onBox
to allow plain numbersnavigationStore
which exposes basic navigation state with Shared Value equivalents:activeRoute
activeSwipeRoute
animatedActiveRoute
← Shared ValueanimatedActiveSwipeRoute
← Shared Valueyarn postinstall
step inyarn setup
to avoid redundant runsPackage Upgrades
(All tested on iOS and Android)
patch
patch
minor
minor
minor
minor
patch
patch
minor
minor
minor
major
minor
patch