Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sheets] [Pt. 14] Portaling behaviors for nested dialogs #5588

Merged
merged 76 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5a98ea6
Include ghost hook to statically export fonts (#5553)
estrattonbailey Oct 1, 2024
801cb62
close all dialogs
haileyok Oct 1, 2024
a17892d
remove a bunch of to-be-useless stuff
haileyok Oct 1, 2024
3971254
remove `Dialog.Handle` uses
haileyok Oct 1, 2024
64f849b
rm handle component
haileyok Oct 1, 2024
6dec099
type
haileyok Oct 1, 2024
d0149a9
get scrollview working
haileyok Oct 1, 2024
40030ba
tidy
haileyok Oct 1, 2024
0b55acd
bump
haileyok Oct 1, 2024
368a9df
bump gesture handler
haileyok Oct 1, 2024
a4c7e2f
tweak types
haileyok Oct 1, 2024
e1ccacc
add props back
haileyok Oct 1, 2024
b900ac6
update types
haileyok Oct 2, 2024
baf1923
update other dialog views
haileyok Oct 2, 2024
a3737f0
replace all buttons with `BottomSheetButton`
haileyok Oct 2, 2024
e2f8e7c
fix type
haileyok Oct 2, 2024
81906df
wizard remove buttons
haileyok Oct 2, 2024
cdfdf49
fix
haileyok Oct 2, 2024
8bd6b2d
fix embed consent
haileyok Oct 2, 2024
65bfd89
buttons in account switcher
haileyok Oct 2, 2024
87c83dd
custom bottom sheet link
haileyok Oct 2, 2024
5a60190
nesting support
haileyok Oct 2, 2024
f251a43
Add intent/verify-email to go server (#5554)
estrattonbailey Oct 2, 2024
3569873
Tweak verify email dialog (#5555)
estrattonbailey Oct 2, 2024
1a7885b
Add suspense boundary in onboarding (#5556)
estrattonbailey Oct 2, 2024
d4b8401
android support
haileyok Oct 2, 2024
1ca6d36
fix type
haileyok Oct 2, 2024
a444fc5
import order (#5571)
haileyok Oct 2, 2024
3972d3d
Ignore built files (#5572)
estrattonbailey Oct 2, 2024
4059668
Make reply prompt more subtle on desktop (#5569)
mozzius Oct 2, 2024
b5a5113
simplify pressable changes
haileyok Oct 2, 2024
349b8b7
rm
haileyok Oct 2, 2024
1ea82c3
rename for clairity
haileyok Oct 2, 2024
f558eb6
fix other buttons in dialogs
haileyok Oct 2, 2024
f365ae0
tweak
haileyok Oct 2, 2024
ca0888c
more fixes
haileyok Oct 2, 2024
43eb47f
Merge remote-tracking branch 'origin/main' into hailey/dialogs-pt10
haileyok Oct 2, 2024
13c9c79
move files around (#5576)
mozzius Oct 2, 2024
c2dac85
Delete messages NUX (#5574)
mozzius Oct 2, 2024
1357ac3
bump
haileyok Oct 2, 2024
3fabcc2
revert some changes
haileyok Oct 2, 2024
1ad73e1
Merge remote-tracking branch 'origin/hailey/dialogs-pt1' into hailey/…
haileyok Oct 2, 2024
b0c0aee
custom bottom sheet link
haileyok Oct 2, 2024
84d32e3
simplify pressable changes
haileyok Oct 2, 2024
5fe4ee9
rm
haileyok Oct 2, 2024
839d6dc
rename for clairity
haileyok Oct 2, 2024
1d5a3ef
tweak
haileyok Oct 2, 2024
6d7b54c
fix namE
haileyok Oct 2, 2024
10cb87b
use context to pick default pressable component
haileyok Oct 2, 2024
431f1ff
adjust
haileyok Oct 2, 2024
fee2468
Merge branch 'hailey/dialogs-pt7-rework' into hailey/dialogs-pt8
haileyok Oct 2, 2024
bb33aa0
revert all the button import changes
haileyok Oct 3, 2024
67e4d77
revert all the changes that are not needed'
haileyok Oct 3, 2024
7ef51ac
Merge branch 'hailey/dialogs-pt8' into hailey/dialogs-pt9
haileyok Oct 3, 2024
1bda59c
Merge branch 'hailey/dialogs-pt9' into hailey/dialogs-pt10
haileyok Oct 3, 2024
5c36d8c
remove unused type
haileyok Oct 3, 2024
24bebec
Merge remote-tracking branch 'origin/main' into hailey/dialogs-pt10
haileyok Oct 3, 2024
d007151
move into repo
haileyok Oct 3, 2024
2ac8308
lint
haileyok Oct 3, 2024
52532fb
add config
haileyok Oct 3, 2024
2b98055
update type imports
haileyok Oct 3, 2024
7ee865f
fix import
haileyok Oct 3, 2024
7489a70
add event to ios
haileyok Oct 3, 2024
0ce5d44
simplify logic
haileyok Oct 3, 2024
b6adc93
ensure event fires on open
haileyok Oct 3, 2024
086dde7
log
haileyok Oct 3, 2024
83d1c38
Allow default PressableComponent override
estrattonbailey Oct 3, 2024
639a7ea
fix accessibility
haileyok Oct 3, 2024
8295c23
before spread
haileyok Oct 3, 2024
b64a294
clean
haileyok Oct 3, 2024
97c5053
implement keyboard handling
haileyok Oct 3, 2024
1c14991
rm now useless components
haileyok Oct 3, 2024
6f23676
create portaling props
haileyok Oct 3, 2024
a07ca8b
portal up delete dialog
haileyok Oct 3, 2024
f49f00f
simplify type
haileyok Oct 3, 2024
bdafef8
merge
haileyok Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/bottom-sheet/src/BottomSheet.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ export interface BottomSheetViewProps {
onStateChange?: (
event: NativeSyntheticEvent<{state: BottomSheetState}>,
) => void
onAttemptDismiss?: (event: NativeSyntheticEvent<object>) => void
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"react-native-get-random-values": "~1.11.0",
"react-native-image-crop-picker": "0.41.2",
"react-native-ios-context-menu": "^1.15.3",
"react-native-keyboard-controller": "^1.12.1",
"react-native-keyboard-controller": "^1.14.0",
"react-native-mmkv": "^2.12.2",
"react-native-pager-view": "6.2.3",
"react-native-picker-select": "^9.1.3",
Expand Down
74 changes: 30 additions & 44 deletions src/components/Dialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useImperativeHandle} from 'react'
import {StyleProp, TextInput, View, ViewStyle} from 'react-native'
import {GestureHandlerRootView, ScrollView} from 'react-native-gesture-handler'
import {KeyboardAwareScrollView} from 'react-native-keyboard-controller'
import {useSafeAreaInsets} from 'react-native-safe-area-context'

import {logger} from '#/logger'
Expand All @@ -15,7 +16,7 @@ import {
DialogOuterProps,
} from '#/components/Dialog/types'
import {createInput} from '#/components/forms/TextField'
import {Portal} from '#/components/Portal'
import {Portal as DefaultPortal} from '#/components/Portal'
import {
BottomSheetSnapPoint,
BottomSheetView,
Expand All @@ -33,26 +34,7 @@ export function Outer({
onClose,
nativeOptions,
testID,
}: React.PropsWithChildren<DialogOuterProps>) {
return (
<Portal>
<OuterWithoutPortal
control={control}
onClose={onClose}
nativeOptions={nativeOptions}
testID={testID}>
{children}
</OuterWithoutPortal>
</Portal>
)
}

export function OuterWithoutPortal({
children,
control,
onClose,
nativeOptions,
testID,
Portal = DefaultPortal,
}: React.PropsWithChildren<DialogOuterProps>) {
const t = useTheme()
const ref = React.useRef<BottomSheetView>(null)
Expand Down Expand Up @@ -118,26 +100,28 @@ export function OuterWithoutPortal({
const Wrapper = isIOS ? View : GestureHandlerRootView

return (
<Context.Provider value={context}>
<BottomSheetView
ref={ref}
topInset={30}
bottomInset={insets.bottom}
onSnapPointChange={e => {
setSnapPoint(e.nativeEvent.snapPoint)
}}
onStateChange={e => {
if (e.nativeEvent.state === 'closed') {
onCloseAnimationComplete()
}
}}
cornerRadius={20}
{...nativeOptions}>
<Wrapper testID={testID} style={[t.atoms.bg]}>
{children}
</Wrapper>
</BottomSheetView>
</Context.Provider>
<Portal>
<Context.Provider value={context}>
<BottomSheetView
ref={ref}
topInset={30}
bottomInset={insets.bottom}
onSnapPointChange={e => {
setSnapPoint(e.nativeEvent.snapPoint)
}}
onStateChange={e => {
if (e.nativeEvent.state === 'closed') {
onCloseAnimationComplete()
}
}}
cornerRadius={20}
{...nativeOptions}>
<Wrapper testID={testID} style={[t.atoms.bg]}>
{children}
</Wrapper>
</BottomSheetView>
</Context.Provider>
</Portal>
)
}

Expand All @@ -162,13 +146,15 @@ export const ScrollableInner = React.forwardRef<ScrollView, DialogInnerProps>(
const insets = useSafeAreaInsets()
const {nativeSnapPoint} = useDialogContext()
return (
<ScrollView
<KeyboardAwareScrollView
style={[a.px_xl, style]}
ref={ref}
bounces={nativeSnapPoint === BottomSheetSnapPoint.Full}>
bounces={nativeSnapPoint === BottomSheetSnapPoint.Full}
bottomOffset={30}
ScrollViewComponent={ScrollView}>
{children}
<View style={{height: insets.bottom + a.pt_5xl.paddingTop}} />
</ScrollView>
</KeyboardAwareScrollView>
)
},
)
Expand Down
2 changes: 2 additions & 0 deletions src/components/Dialog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
} from 'react-native'

import {ViewStyleProp} from '#/alf'
import {PortalComponent} from '#/components/Portal'
import {BottomSheetViewProps} from '../../../modules/bottom-sheet'
import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types'

Expand Down Expand Up @@ -58,6 +59,7 @@ export type DialogOuterProps = {
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
webOptions?: {}
testID?: string
Portal?: PortalComponent
}

type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T
Expand Down
31 changes: 0 additions & 31 deletions src/components/KeyboardControllerPadding.android.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions src/components/KeyboardControllerPadding.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type ComponentMap = {
[id: string]: Component
}

export type PortalComponent = ({children}: {children?: React.ReactNode}) => null

export function createPortalGroup() {
const Context = React.createContext<ContextType>({
outlet: null,
Expand Down
22 changes: 8 additions & 14 deletions src/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {GestureResponderEvent, View} from 'react-native'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {isNative} from '#/platform/detection'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Button, ButtonColor, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {PortalComponent} from '#/components/Portal'
import {Text} from '#/components/Typography'

export {
Expand All @@ -26,11 +26,11 @@ export function Outer({
children,
control,
testID,
withoutPortal,
Portal,
}: React.PropsWithChildren<{
control: Dialog.DialogControlProps
testID?: string
withoutPortal?: boolean
Portal?: PortalComponent
}>) {
const {gtMobile} = useBreakpoints()
const titleId = React.useId()
Expand All @@ -41,11 +41,8 @@ export function Outer({
[titleId, descriptionId],
)

const Wrapper =
withoutPortal && isNative ? Dialog.OuterWithoutPortal : Dialog.Outer

return (
<Wrapper control={control} testID={testID}>
<Dialog.Outer control={control} testID={testID} Portal={Portal}>
<Context.Provider value={context}>
<Dialog.ScrollableInner
accessibilityLabelledBy={titleId}
Expand All @@ -56,7 +53,7 @@ export function Outer({
{children}
</Dialog.ScrollableInner>
</Context.Provider>
</Wrapper>
</Dialog.Outer>
)
}

Expand Down Expand Up @@ -185,7 +182,7 @@ export function Basic({
onConfirm,
confirmButtonColor,
showCancel = true,
withoutPortal,
Portal,
}: React.PropsWithChildren<{
control: Dialog.DialogOuterProps['control']
title: string
Expand All @@ -202,13 +199,10 @@ export function Basic({
onConfirm: (e: GestureResponderEvent) => void
confirmButtonColor?: ButtonColor
showCancel?: boolean
withoutPortal?: boolean
Portal?: PortalComponent
}>) {
return (
<Outer
control={control}
testID="confirmModal"
withoutPortal={withoutPortal}>
<Outer control={control} testID="confirmModal" Portal={Portal}>
<TitleText>{title}</TitleText>
<DescriptionText>{description}</DescriptionText>
<Actions>
Expand Down
4 changes: 0 additions & 4 deletions src/components/ReportDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {AppBskyLabelerDefs} from '@atproto/api'
import {atoms as a} from '#/alf'
import * as Dialog from '#/components/Dialog'
import {useDelayedLoading} from '#/components/hooks/useDelayedLoading'
import {useOnKeyboardDidShow} from '#/components/hooks/useOnKeyboard'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'
import {SelectLabelerView} from './SelectLabelerView'
Expand All @@ -39,9 +38,6 @@ function ReportDialogInner(props: ReportDialogProps) {
const isLoading = useDelayedLoading(500, isLabelerLoading)

const ref = React.useRef<ScrollView>(null)
useOnKeyboardDidShow(() => {
ref.current?.scrollToEnd({animated: true})
})

return (
<Dialog.ScrollableInner label={_(msg`Report dialog`)} ref={ref}>
Expand Down
Loading
Loading