From bf1641d03aa91037f0b197e9685fbcc195857196 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 11 Jan 2024 14:46:03 -0600 Subject: [PATCH] Improvements to web modal, exiting still broken --- src/alf/atoms.ts | 3 ++ src/view/com/Dialog/index.web.tsx | 74 +++++++++++++++++-------------- src/view/screens/DebugNew.tsx | 1 + 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/alf/atoms.ts b/src/alf/atoms.ts index c142f5f716..15972ce67d 100644 --- a/src/alf/atoms.ts +++ b/src/alf/atoms.ts @@ -4,6 +4,9 @@ export const atoms = { /* * Positioning */ + fixed: { + position: 'fixed', + }, absolute: { position: 'absolute', }, diff --git a/src/view/com/Dialog/index.web.tsx b/src/view/com/Dialog/index.web.tsx index 3d1a267ceb..ea5e309da0 100644 --- a/src/view/com/Dialog/index.web.tsx +++ b/src/view/com/Dialog/index.web.tsx @@ -1,9 +1,9 @@ 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 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 {Portal} from '#/view/com/Portal' import {Button} from '#/view/com/Button' @@ -86,20 +86,21 @@ export function Outer({ onPress={close}> {isVisible && ( @@ -109,30 +110,13 @@ export function Outer({ style={[ a.w_full, a.z_20, + a.justify_center, + a.align_center, { - maxWidth: 600, - paddingTop: gtMobile ? ('10vh' as DimensionValue) : 0, + minHeight: web('calc(90vh - 36px)') || undefined, }, ]}> - true} - onTouchEnd={stopPropagation}> - - {isVisible ? ( - - {children} - - ) : ( - - )} - - + {isVisible ? children : null} @@ -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 {gtMobile} = useBreakpoints() return ( - - {props.children} - + + 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} + + ) } diff --git a/src/view/screens/DebugNew.tsx b/src/view/screens/DebugNew.tsx index 24538bcb33..b6bd1f2c89 100644 --- a/src/view/screens/DebugNew.tsx +++ b/src/view/screens/DebugNew.tsx @@ -343,6 +343,7 @@ function Dialogs() { accessibilityHint="Open basic dialog"> Close basic dialog +