

Unlike with Header, we need to cap the total distance the component can travel up the screen, to give the effect that the tabs are pinned beneath the NavBar. Similar to the Header, the TabBar must be slid up the screen using translateY. The TabBar should slide up and then pin to the bottom edge of the NavBar.

This transform gives the visual appearance of the Header scrolling with the TabBar and TabViews up and off the page, without actually scrolling the page (more on managing scroll position, and the complexity that comes with that in the implementation details below). Because the top-level Screen container cannot be scrollable, we must simulate the effect that the top of the page is “scrolling” by interpolating the active TabView’s scroll position to a translateY offset for the Header. Because TabViews must be independently scrollable (with their own independent scroll positions), the top-level Screen container cannot be scrollable. One important limitation of React Native is that there are no nested scroll surfaces. This might seem obvious, but getting this right on React Native can be quite challenging.

Interpolation - Maps input ranges to output ranges, typically using a linear interpolation but also supports easing functions.Screen - The top level container component (root level React component).īeyond components we will also be referring to the following terms:.But to keep it simple we just have a title. You often see this with back arrows or other icons up here as well. NavBar This is the top screen navigation.

This can be asset cells, tweets, photos, or any other content.
REACT TABVIEW CODE
However, despite how universal this UX experience has become, behind the scenes it still requires a large lift of complex gestures and state management to get it feeling and performing “just right” for the end user.Īt Coinbase we were able to pull this off for our recent React Native rewrite and wanted to share a little bit more about the UX details that went into this interaction, as well as the code needed to make it happen. if you scroll past the Header on one TabView, switching tabs keeps the global header in the same position, irrespective of tab scroll). It allows you to swipe through the different TabViews, and it treats the overall scroll position intelligently (i.e. It’s a simple tab component, with a scroll-away Header and TabBar that pins to the top of the screen. You see it on things like Instagram, Twitter, Apple Music, AND most recently on the Coinbase prices screen. You’ve probably used this interaction countless times in your day to day life and not spent much time thinking about it. Introduction to the “TabBar” user experience
