Improvements to web modal, exiting still broken
This commit is contained in:
@@ -4,6 +4,9 @@ export const atoms = {
|
|||||||
/*
|
/*
|
||||||
* Positioning
|
* Positioning
|
||||||
*/
|
*/
|
||||||
|
fixed: {
|
||||||
|
position: 'fixed',
|
||||||
|
},
|
||||||
absolute: {
|
absolute: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React, {useImperativeHandle} from 'react'
|
import React, {useImperativeHandle} from 'react'
|
||||||
import {View, TouchableWithoutFeedback, DimensionValue} from 'react-native'
|
import {View, TouchableWithoutFeedback, ViewStyle} from 'react-native'
|
||||||
import {FocusScope} from '@tamagui/focus-scope'
|
import {FocusScope} from '@tamagui/focus-scope'
|
||||||
import Animated, {FadeInDown, FadeIn, FadeOut} from 'react-native-reanimated'
|
import Animated, {FadeInDown, FadeIn} from 'react-native-reanimated'
|
||||||
|
|
||||||
import {useTheme, atoms as a, useBreakpoints} from '#/alf'
|
import {useTheme, atoms as a, useBreakpoints, web} from '#/alf'
|
||||||
import {Text} from '#/view/com/Typography'
|
import {Text} from '#/view/com/Typography'
|
||||||
import {Portal} from '#/view/com/Portal'
|
import {Portal} from '#/view/com/Portal'
|
||||||
import {Button} from '#/view/com/Button'
|
import {Button} from '#/view/com/Button'
|
||||||
@@ -86,20 +86,21 @@ export function Outer({
|
|||||||
onPress={close}>
|
onPress={close}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.absolute,
|
web(a.fixed),
|
||||||
a.inset_0,
|
a.inset_0,
|
||||||
a.z_10,
|
a.z_10,
|
||||||
a.flex_row,
|
a.align_center,
|
||||||
a.justify_center,
|
gtMobile ? a.p_lg : a.p_md,
|
||||||
|
{overflowY: 'auto'},
|
||||||
]}>
|
]}>
|
||||||
{isVisible && (
|
{isVisible && (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
entering={FadeIn.duration(150)}
|
entering={FadeIn.duration(150)}
|
||||||
exiting={FadeOut.duration(150)}
|
// exiting={FadeOut.duration(150)}
|
||||||
style={[
|
style={[
|
||||||
a.absolute,
|
web(a.fixed),
|
||||||
a.inset_0,
|
a.inset_0,
|
||||||
t.atoms.bg_contrast_200,
|
t.atoms.bg_contrast_300,
|
||||||
{opacity: 0.8},
|
{opacity: 0.8},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -109,30 +110,13 @@ export function Outer({
|
|||||||
style={[
|
style={[
|
||||||
a.w_full,
|
a.w_full,
|
||||||
a.z_20,
|
a.z_20,
|
||||||
|
a.justify_center,
|
||||||
|
a.align_center,
|
||||||
{
|
{
|
||||||
maxWidth: 600,
|
minHeight: web('calc(90vh - 36px)') || undefined,
|
||||||
paddingTop: gtMobile ? ('10vh' as DimensionValue) : 0,
|
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
<View
|
{isVisible ? children : null}
|
||||||
// @ts-ignore web only -prf
|
|
||||||
onClick={stopPropagation}
|
|
||||||
onStartShouldSetResponder={_ => true}
|
|
||||||
onTouchEnd={stopPropagation}>
|
|
||||||
<FocusScope loop enabled trapped>
|
|
||||||
{isVisible ? (
|
|
||||||
<Animated.View
|
|
||||||
aria-role="dialog"
|
|
||||||
entering={FadeInDown.duration(100)}
|
|
||||||
exiting={FadeOut.duration(100)}
|
|
||||||
style={{width: '100%'}}>
|
|
||||||
{children}
|
|
||||||
</Animated.View>
|
|
||||||
) : (
|
|
||||||
<View />
|
|
||||||
)}
|
|
||||||
</FocusScope>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</TouchableWithoutFeedback>
|
</TouchableWithoutFeedback>
|
||||||
@@ -143,12 +127,34 @@ export function Outer({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Inner(props: React.PropsWithChildren<{}>) {
|
export function Inner({
|
||||||
|
children,
|
||||||
|
style,
|
||||||
|
}: React.PropsWithChildren<{style?: ViewStyle}>) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
const {gtMobile} = useBreakpoints()
|
||||||
return (
|
return (
|
||||||
<View style={[a.relative, a.rounded_md, a.p_xl, t.atoms.bg]}>
|
<FocusScope loop enabled trapped>
|
||||||
{props.children}
|
<Animated.View
|
||||||
</View>
|
aria-role="dialog"
|
||||||
|
// @ts-ignore web only -prf
|
||||||
|
onClick={stopPropagation}
|
||||||
|
onStartShouldSetResponder={_ => true}
|
||||||
|
onTouchEnd={stopPropagation}
|
||||||
|
entering={FadeInDown.duration(100)}
|
||||||
|
// exiting={FadeOut.duration(100)}
|
||||||
|
style={[
|
||||||
|
a.relative,
|
||||||
|
a.rounded_md,
|
||||||
|
a.w_full,
|
||||||
|
gtMobile ? a.p_xl : a.p_lg,
|
||||||
|
t.atoms.bg,
|
||||||
|
{maxWidth: 600},
|
||||||
|
...(Array.isArray(style) ? style : [style || {}]),
|
||||||
|
]}>
|
||||||
|
{children}
|
||||||
|
</Animated.View>
|
||||||
|
</FocusScope>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ function Dialogs() {
|
|||||||
accessibilityHint="Open basic dialog">
|
accessibilityHint="Open basic dialog">
|
||||||
Close basic dialog
|
Close basic dialog
|
||||||
</Button>
|
</Button>
|
||||||
|
<View style={{height: 100}} />
|
||||||
<Button
|
<Button
|
||||||
type="secondary"
|
type="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
Reference in New Issue
Block a user