Improve dialogs issue (#2941)

* Fix collapse, update backdrop color

* Remove test prop

* Remove debug code
zio/stable
Eric Bailey 2024-02-20 10:04:07 -06:00 committed by GitHub
parent b52a742925
commit 8a169dc6a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 6 deletions

View File

@ -90,6 +90,7 @@ export function Outer({
keyboardBlurBehavior="restore" keyboardBlurBehavior="restore"
topInset={insets.top} topInset={insets.top}
{...sheetOptions} {...sheetOptions}
snapPoints={sheetOptions.snapPoints || ['100%']}
ref={sheet} ref={sheet}
index={openIndex} index={openIndex}
backgroundStyle={{backgroundColor: 'transparent'}} backgroundStyle={{backgroundColor: 'transparent'}}
@ -99,6 +100,7 @@ export function Outer({
appearsOnIndex={0} appearsOnIndex={0}
disappearsOnIndex={-1} disappearsOnIndex={-1}
{...props} {...props}
style={[flatten(props.style), t.atoms.bg_contrast_300]}
/> />
)} )}
handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} handleIndicatorStyle={{backgroundColor: t.palette.primary_500}}
@ -117,7 +119,7 @@ export function Outer({
}, },
]} ]}
/> />
{hasSnapPoints ? children : <View>{children}</View>} {children}
</Context.Provider> </Context.Provider>
</BottomSheet> </BottomSheet>
</Portal> </Portal>

View File

@ -9,7 +9,8 @@ import * as Prompt from '#/components/Prompt'
import {useDialogStateControlContext} from '#/state/dialogs' import {useDialogStateControlContext} from '#/state/dialogs'
export function Dialogs() { export function Dialogs() {
const control = Dialog.useDialogControl() const scrollable = Dialog.useDialogControl()
const basic = Dialog.useDialogControl()
const prompt = Prompt.usePromptControl() const prompt = Prompt.usePromptControl()
const {closeAllDialogs} = useDialogStateControlContext() const {closeAllDialogs} = useDialogStateControlContext()
@ -20,8 +21,31 @@ export function Dialogs() {
color="secondary" color="secondary"
size="small" size="small"
onPress={() => { onPress={() => {
control.open() scrollable.open()
prompt.open() prompt.open()
basic.open()
}}
label="Open basic dialog">
Open all dialogs
</Button>
<Button
variant="outline"
color="secondary"
size="small"
onPress={() => {
scrollable.open()
}}
label="Open basic dialog">
Open scrollable dialog
</Button>
<Button
variant="outline"
color="secondary"
size="small"
onPress={() => {
basic.open()
}} }}
label="Open basic dialog"> label="Open basic dialog">
Open basic dialog Open basic dialog
@ -48,8 +72,17 @@ export function Dialogs() {
</Prompt.Actions> </Prompt.Actions>
</Prompt.Outer> </Prompt.Outer>
<Dialog.Outer control={basic}>
<Dialog.Handle />
<Dialog.Inner label="test">
<H3 nativeID="dialog-title">Dialog</H3>
<P nativeID="dialog-description">A basic dialog</P>
</Dialog.Inner>
</Dialog.Outer>
<Dialog.Outer <Dialog.Outer
control={control} control={scrollable}
nativeOptions={{sheet: {snapPoints: ['100%']}}}> nativeOptions={{sheet: {snapPoints: ['100%']}}}>
<Dialog.Handle /> <Dialog.Handle />
@ -77,9 +110,9 @@ export function Dialogs() {
variant="outline" variant="outline"
color="primary" color="primary"
size="small" size="small"
onPress={() => control.close()} onPress={() => scrollable.close()}
label="Open basic dialog"> label="Open basic dialog">
Close basic dialog Close dialog
</Button> </Button>
</View> </View>
</View> </View>