diff options
author | Ansh <anshnanda10@gmail.com> | 2023-04-09 18:02:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-09 18:02:44 -0700 |
commit | 14c84732106e1db52e6818ac3814c54845ec1226 (patch) | |
tree | c55e07e0e569a2c41ca73fb3420a2c6b08621c4d /src/view/com/util/Selector.tsx | |
parent | 362ea7240d44f130419191e7f726535a77763238 (diff) | |
download | voidsky-14c84732106e1db52e6818ac3814c54845ec1226.tar.zst |
[DRAFT] Android (#424)
* add android & ios folders to .gitignore * delete android and ios dirs * fix android build errors * fix status bar color * fix top cutoff on composer in android * fix weird whitespace issue in post * fix greyed out header android * fix main feed getting cut off android * fix swiping on main feed * fix profile tabs switching on android * A few app.json config items for iOS * Update app.json for bgfetch * make swiping work on android * make splash screen cover * add eas.json * fix image container on android * fix android status bar color * use expo-splash-screen instead of react-native-splash-screen --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/view/com/util/Selector.tsx')
-rw-r--r-- | src/view/com/util/Selector.tsx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/view/com/util/Selector.tsx b/src/view/com/util/Selector.tsx index 5b331dc8d..03db13bd1 100644 --- a/src/view/com/util/Selector.tsx +++ b/src/view/com/util/Selector.tsx @@ -1,4 +1,4 @@ -import React, {createRef, useState, useMemo} from 'react' +import React, {createRef, useState, useMemo, useRef} from 'react' import { Animated, StyleSheet, @@ -24,6 +24,7 @@ export function Selector({ panX: Animated.Value onSelect?: (index: number) => void }) { + const containerRef = useRef<View>(null) const pal = usePalette('default') const [itemLayouts, setItemLayouts] = useState<undefined | Layout[]>( undefined, @@ -68,7 +69,11 @@ export function Selector({ for (let i = 0; i < items.length; i++) { promises.push( new Promise<Layout>(resolve => { - itemRefs[i].current?.measure( + if (!containerRef.current || !itemRefs[i].current) { + return resolve({x: 0, width: 0}) + } + itemRefs[i].current?.measureLayout( + containerRef.current, (x: number, _y: number, width: number) => { resolve({x, width}) }, @@ -86,7 +91,10 @@ export function Selector({ } return ( - <View style={[pal.view, styles.outer]} onLayout={onLayout}> + <View + style={[pal.view, styles.outer]} + onLayout={onLayout} + ref={containerRef}> <Animated.View style={[styles.underline, underlineStyle]} /> {items.map((item, i) => { const selected = i === selectedIndex |