put dropdown in fullscreenoverlay on iOS (#4284)

zio/stable
Samuel Newman 2024-05-30 16:06:59 +03:00 committed by GitHub
parent 16925baf8d
commit 8feb2ab449
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 26 deletions

View File

@ -1,27 +1,28 @@
import React, {useCallback, useMemo} from 'react' import React, {useCallback, useMemo} from 'react'
import {StyleSheet, Keyboard} from 'react-native' import {Keyboard, StyleSheet} from 'react-native'
import { import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import {Text} from 'view/com/util/text/Text' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useModalControls} from '#/state/modals'
import {
hasPostLanguage,
toPostLanguages,
useLanguagePrefs,
useLanguagePrefsApi,
} from '#/state/preferences/languages'
import {usePalette} from 'lib/hooks/usePalette'
import {isNative} from 'platform/detection'
import { import {
DropdownButton, DropdownButton,
DropdownItem, DropdownItem,
DropdownItemButton, DropdownItemButton,
} from 'view/com/util/forms/DropdownButton' } from 'view/com/util/forms/DropdownButton'
import {usePalette} from 'lib/hooks/usePalette' import {Text} from 'view/com/util/text/Text'
import {isNative} from 'platform/detection'
import {codeToLanguageName} from '../../../../locale/helpers' import {codeToLanguageName} from '../../../../locale/helpers'
import {useModalControls} from '#/state/modals'
import {
useLanguagePrefs,
useLanguagePrefsApi,
toPostLanguages,
hasPostLanguage,
} from '#/state/preferences/languages'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
export function SelectLangBtn() { export function SelectLangBtn() {
const pal = usePalette('default') const pal = usePalette('default')

View File

@ -2,6 +2,7 @@ import React, {PropsWithChildren, useMemo, useRef} from 'react'
import { import {
Dimensions, Dimensions,
GestureResponderEvent, GestureResponderEvent,
Platform,
StyleProp, StyleProp,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
@ -10,18 +11,20 @@ import {
View, View,
ViewStyle, ViewStyle,
} from 'react-native' } from 'react-native'
import {IconProp} from '@fortawesome/fontawesome-svg-core'
import RootSiblings from 'react-native-root-siblings' import RootSiblings from 'react-native-root-siblings'
import {FullWindowOverlay} from 'react-native-screens'
import {IconProp} from '@fortawesome/fontawesome-svg-core'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {HITSLOP_10} from 'lib/constants'
import {usePalette} from 'lib/hooks/usePalette'
import {colors} from 'lib/styles'
import {useTheme} from 'lib/ThemeContext'
import {isWeb} from 'platform/detection'
import {Text} from '../text/Text' import {Text} from '../text/Text'
import {Button, ButtonType} from './Button' import {Button, ButtonType} from './Button'
import {colors} from 'lib/styles'
import {usePalette} from 'lib/hooks/usePalette'
import {useTheme} from 'lib/ThemeContext'
import {HITSLOP_10} from 'lib/constants'
import {useLingui} from '@lingui/react'
import {msg} from '@lingui/macro'
import {isWeb} from 'platform/detection'
const ESTIMATED_BTN_HEIGHT = 50 const ESTIMATED_BTN_HEIGHT = 50
const ESTIMATED_SEP_HEIGHT = 16 const ESTIMATED_SEP_HEIGHT = 16
@ -239,7 +242,7 @@ const DropdownItems = ({
// - (On mobile) be buttons by default, accept `label` and `nativeID` // - (On mobile) be buttons by default, accept `label` and `nativeID`
// props, and always have an explicit label // props, and always have an explicit label
return ( return (
<> <Wrapper>
{/* This TouchableWithoutFeedback renders the background so if the user clicks outside, the dropdown closes */} {/* This TouchableWithoutFeedback renders the background so if the user clicks outside, the dropdown closes */}
<TouchableWithoutFeedback <TouchableWithoutFeedback
onPress={onOuterPress} onPress={onOuterPress}
@ -304,10 +307,17 @@ const DropdownItems = ({
return null return null
})} })}
</View> </View>
</> </Wrapper>
) )
} }
// on iOS, due to formSheet presentation style, we need to render the overlay
// as a full screen overlay
const Wrapper = Platform.select({
ios: FullWindowOverlay,
default: ({children}) => <>{children}</>,
})
function isSep(item: DropdownItem): item is DropdownItemSeparator { function isSep(item: DropdownItem): item is DropdownItemSeparator {
return 'sep' in item && item.sep return 'sep' in item && item.sep
} }

View File

@ -1,15 +1,16 @@
import React from 'react' import React from 'react'
import {StyleSheet, View} from 'react-native' import {StyleSheet, View} from 'react-native'
import Animated, {FadeIn, FadeInDown, FadeOut} from 'react-native-reanimated' import Animated, {FadeIn, FadeInDown, FadeOut} from 'react-native-reanimated'
import {ComposePost} from '../com/composer/Composer'
import {useComposerState} from 'state/shell/composer' import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock' import {useComposerState} from 'state/shell/composer'
import { import {
EmojiPicker, EmojiPicker,
EmojiPickerState, EmojiPickerState,
} from 'view/com/composer/text-input/web/EmojiPicker.web' } from 'view/com/composer/text-input/web/EmojiPicker.web'
import {ComposePost} from '../com/composer/Composer'
const BOTTOM_BAR_HEIGHT = 61 const BOTTOM_BAR_HEIGHT = 61