From 79f807dc4fbcdff12a16fb3fb2af3bb994d2c8c0 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 3 Dec 2024 18:03:43 +0000 Subject: [PATCH] ALF TabBar (#6924) * alf tabbar * reduce indicator height --- src/view/com/pager/TabBar.tsx | 26 ++++++++++------------- src/view/com/pager/TabBar.web.tsx | 35 ++++++++++++++++--------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/view/com/pager/TabBar.tsx b/src/view/com/pager/TabBar.tsx index c19b9366408..b08b364c52b 100644 --- a/src/view/com/pager/TabBar.tsx +++ b/src/view/com/pager/TabBar.tsx @@ -12,9 +12,9 @@ import Animated, { useSharedValue, } from 'react-native-reanimated' -import {usePalette} from '#/lib/hooks/usePalette' -import {PressableWithHover} from '../util/PressableWithHover' -import {Text} from '../util/text/Text' +import {PressableWithHover} from '#/view/com/util/PressableWithHover' +import {atoms as a, useTheme} from '#/alf' +import {Text} from '#/components/Typography' export interface TabBarProps { testID?: string @@ -41,7 +41,7 @@ export function TabBar({ dragProgress, dragState, }: TabBarProps) { - const pal = usePalette('default') + const t = useTheme() const scrollElRef = useAnimatedRef() const syncScrollState = useSharedValue<'synced' | 'unsynced' | 'needs-sync'>( 'synced', @@ -264,7 +264,7 @@ export function TabBar({ return ( - + ) } @@ -336,7 +336,7 @@ function TabBarItem({ onPressItem: (index: number) => void onItemLayout: (index: number, layout: {x: number; width: number}) => void }) { - const pal = usePalette('default') + const t = useTheme() const style = useAnimatedStyle(() => { if (!_WORKLET) { return {opacity: 0.7} @@ -363,15 +363,14 @@ function TabBarItem({ onPressItem(index)} accessibilityRole="tab"> + style={[t.atoms.text, a.text_md, a.font_bold, {lineHeight: 20}]}> {item} @@ -381,9 +380,6 @@ function TabBarItem({ } const styles = StyleSheet.create({ - outer: { - flexDirection: 'row', - }, contentContainer: { backgroundColor: 'transparent', paddingHorizontal: CONTENT_PADDING, diff --git a/src/view/com/pager/TabBar.web.tsx b/src/view/com/pager/TabBar.web.tsx index 4291a053b50..789f88e7532 100644 --- a/src/view/com/pager/TabBar.web.tsx +++ b/src/view/com/pager/TabBar.web.tsx @@ -1,10 +1,9 @@ -import {useCallback, useEffect, useMemo, useRef} from 'react' +import {useCallback, useEffect, useRef} from 'react' import {ScrollView, StyleSheet, View} from 'react-native' -import {usePalette} from '#/lib/hooks/usePalette' -import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' +import {atoms as a, useBreakpoints, useTheme} from '#/alf' +import {Text} from '#/components/Typography' import {PressableWithHover} from '../util/PressableWithHover' -import {Text} from '../util/text/Text' import {DraggableScrollView} from './DraggableScrollView' export interface TabBarProps { @@ -12,6 +11,8 @@ export interface TabBarProps { selectedPage: number items: string[] indicatorColor?: string + backgroundColor?: string + onSelect?: (index: number) => void onPressSelected?: (index: number) => void } @@ -28,15 +29,14 @@ export function TabBar({ onSelect, onPressSelected, }: TabBarProps) { - const pal = usePalette('default') + const t = useTheme() const scrollElRef = useRef(null) const itemRefs = useRef>([]) - const indicatorStyle = useMemo( - () => ({borderBottomColor: indicatorColor || pal.colors.link}), - [indicatorColor, pal], - ) - const {isDesktop, isTablet} = useWebMediaQueries() - const styles = isDesktop || isTablet ? desktopStyles : mobileStyles + const indicatorStyle = { + borderBottomColor: indicatorColor || t.palette.primary_500, + } + const {gtMobile} = useBreakpoints() + const styles = gtMobile ? desktopStyles : mobileStyles useEffect(() => { // On the web, the primary interaction is tapping. @@ -96,7 +96,7 @@ export function TabBar({ return ( (itemRefs.current[i] = node as any)} style={styles.item} - hoverStyle={pal.viewLight} + hoverStyle={t.atoms.bg_contrast_25} onPress={() => onPressItem(i)} accessibilityRole="tab"> {item} @@ -131,7 +132,7 @@ export function TabBar({ ) })} - + ) } @@ -179,7 +180,7 @@ const mobileStyles = StyleSheet.create({ }, itemInner: { paddingBottom: 10, - borderBottomWidth: 3, + borderBottomWidth: 2, borderBottomColor: 'transparent', }, outerBottomBorder: {