about summary refs log tree commit diff
path: root/src/view/com/pager/FeedsTabBar.web.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-04-15 10:15:30 -0700
committerGitHub <noreply@github.com>2023-04-15 10:15:30 -0700
commit91fadadb5848404bc47b69879bbc38a9011a0c62 (patch)
tree57f6b085b2a81bb33441c7107bd02b89187aec8e /src/view/com/pager/FeedsTabBar.web.tsx
parenta79dcd3d3890b2b705cb1e687cf0f31e109fbf74 (diff)
downloadvoidsky-91fadadb5848404bc47b69879bbc38a9011a0c62.tar.zst
Fix web home feed sizing and related issues (close #432) (#475)
* Fix web home feed sizing (close #432)

* Fix lint

* Fix positioning of profile not found error

* Fix load latest on mobile

* Fix overflow issues on mobile web (visible in postthread)

* Fix bottom pad on mobile web

* Remove old comment
Diffstat (limited to 'src/view/com/pager/FeedsTabBar.web.tsx')
-rw-r--r--src/view/com/pager/FeedsTabBar.web.tsx58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/view/com/pager/FeedsTabBar.web.tsx b/src/view/com/pager/FeedsTabBar.web.tsx
index 5cee2fd6d..d80b140ce 100644
--- a/src/view/com/pager/FeedsTabBar.web.tsx
+++ b/src/view/com/pager/FeedsTabBar.web.tsx
@@ -1,30 +1,76 @@
 import React from 'react'
+import {Animated, StyleSheet} from 'react-native'
 import {observer} from 'mobx-react-lite'
 import {TabBar} from 'view/com/pager/TabBar'
-import {CenteredView} from 'view/com/util/Views'
 import {RenderTabBarFnProps} from 'view/com/pager/Pager'
+import {useStores} from 'state/index'
 import {usePalette} from 'lib/hooks/usePalette'
+import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
 import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
 import {FeedsTabBar as FeedsTabBarMobile} from './FeedsTabBarMobile'
 
 export const FeedsTabBar = observer(
-  (props: RenderTabBarFnProps & {onPressSelected: () => void}) => {
-    const pal = usePalette('default')
+  (
+    props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
+  ) => {
     const {isDesktop} = useWebMediaQueries()
-
     if (!isDesktop) {
       return <FeedsTabBarMobile {...props} />
+    } else {
+      return <FeedsTabBarDesktop {...props} />
     }
+  },
+)
+
+const FeedsTabBarDesktop = observer(
+  (
+    props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void},
+  ) => {
+    const store = useStores()
+    const pal = usePalette('default')
+    const interp = useAnimatedValue(0)
 
+    React.useEffect(() => {
+      Animated.timing(interp, {
+        toValue: store.shell.minimalShellMode ? 1 : 0,
+        duration: 100,
+        useNativeDriver: true,
+        isInteraction: false,
+      }).start()
+    }, [interp, store.shell.minimalShellMode])
+    const transform = {
+      transform: [
+        {translateX: '-50%'},
+        {translateY: Animated.multiply(interp, -100)},
+      ],
+    }
     return (
-      <CenteredView>
+      // @ts-ignore the type signature for transform wrong here, translateX and translateY need to be in separate objects -prf
+      <Animated.View style={[pal.view, styles.tabBar, transform]}>
         <TabBar
           {...props}
           items={['Following', "What's hot"]}
           indicatorPosition="bottom"
           indicatorColor={pal.colors.link}
         />
-      </CenteredView>
+      </Animated.View>
     )
   },
 )
+
+const styles = StyleSheet.create({
+  tabBar: {
+    position: 'absolute',
+    zIndex: 1,
+    left: '50%',
+    width: 640,
+    top: 0,
+    flexDirection: 'row',
+    alignItems: 'center',
+    paddingHorizontal: 18,
+  },
+  tabBarAvi: {
+    marginTop: 1,
+    marginRight: 18,
+  },
+})