Skip to content

Commit

Permalink
remove Dialog.Handle uses
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Oct 1, 2024
1 parent a17892d commit 3971254
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 123 deletions.
77 changes: 35 additions & 42 deletions src/components/Dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
DialogOuterProps,
} from '#/components/Dialog/types'
import {createInput} from '#/components/forms/TextField'
import {FullWindowOverlay} from '#/components/FullWindowOverlay'
import {Portal} from '#/components/Portal'

export {useDialogContext, useDialogControl} from '#/components/Dialog/context'
Expand Down Expand Up @@ -93,53 +92,47 @@ export function Outer({
[open, close],
)

React.useEffect(() => {
return () => {
setDialogIsOpen(control.id, false)
}
}, [control.id, setDialogIsOpen])
// @TODO DIALOG REFACTOR - what is this? rm i think?
// React.useEffect(() => {
// return () => {
// setDialogIsOpen(control.id, false)
// }
// }, [control.id, setDialogIsOpen])

const context = React.useMemo(() => ({close}), [close])

return (
isOpen && (
<Portal>
<FullWindowOverlay>
<View
// iOS
accessibilityViewIsModal
style={[a.absolute, a.inset_0]}
testID={testID}
onTouchMove={() => Keyboard.dismiss()}>
<BottomSheet
enablePanDownToClose
keyboardBehavior="interactive"
android_keyboardInputMode="adjustResize"
keyboardBlurBehavior="restore"
topInset={insets.top}
ref={sheet}
backgroundStyle={{backgroundColor: 'transparent'}}
handleIndicatorStyle={{backgroundColor: t.palette.primary_500}}
handleStyle={{display: 'none'}}
onClose={onCloseAnimationComplete}>
<Context.Provider value={context}>
<View
style={[
a.absolute,
a.inset_0,
t.atoms.bg,
{
borderTopLeftRadius: 40,
borderTopRightRadius: 40,
height: Dimensions.get('window').height * 2,
},
]}
/>
{children}
</Context.Provider>
</BottomSheet>
</View>
</FullWindowOverlay>
<View
// iOS
accessibilityViewIsModal
style={[a.absolute, a.inset_0]}
testID={testID}
onTouchMove={() => Keyboard.dismiss()}>
<BottomSheet
topInset={insets.top}
bottomInset={insets.bottom}
ref={sheet}
// handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} // @TODO DIALOG REFACTOR need to add this to lib!
onClose={onCloseAnimationComplete}>
<Context.Provider value={context}>
<View
style={[
a.absolute,
a.inset_0,
t.atoms.bg,
{
borderTopLeftRadius: 40,
borderTopRightRadius: 40,
height: Dimensions.get('window').height * 2,
},
]}
/>
{children}
</Context.Provider>
</BottomSheet>
</View>
</Portal>
)
)
Expand Down
17 changes: 7 additions & 10 deletions src/components/LikesDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React, {useMemo, useCallback} from 'react'
import React, {useCallback, useMemo} from 'react'
import {ActivityIndicator, FlatList, View} from 'react-native'
import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api'

import {useResolveUriQuery} from '#/state/queries/resolve-uri'
import {useLikedByQuery} from '#/state/queries/post-liked-by'
import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger'

import {useLikedByQuery} from '#/state/queries/post-liked-by'
import {useResolveUriQuery} from '#/state/queries/resolve-uri'
import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard'
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
import {atoms as a, useTheme} from '#/alf'
import {Text} from '#/components/Typography'
import * as Dialog from '#/components/Dialog'
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard'
import {Loader} from '#/components/Loader'
import {Text} from '#/components/Typography'

interface LikesDialogProps {
control: Dialog.DialogOuterProps['control']
Expand All @@ -24,8 +23,6 @@ interface LikesDialogProps {
export function LikesDialog(props: LikesDialogProps) {
return (
<Dialog.Outer control={props.control}>
<Dialog.Handle />

<LikesDialogInner {...props} />
</Dialog.Outer>
)
Expand Down
4 changes: 1 addition & 3 deletions src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import flattenReactChildren from 'react-keyed-flatten-children'

import {isNative} from 'platform/detection'
import {isNative} from '#/platform/detection'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
Expand Down Expand Up @@ -85,8 +85,6 @@ export function Outer({

return (
<Dialog.Outer control={context.control}>
<Dialog.Handle />

{/* Re-wrap with context since Dialogs are portal-ed to root */}
<Context.Provider value={context}>
<Dialog.ScrollableInner label="Menu TODO">
Expand Down
7 changes: 3 additions & 4 deletions src/components/NewskieDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {differenceInSeconds} from 'date-fns'

import {HITSLOP_10} from '#/lib/constants'
import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {isNative} from '#/platform/detection'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {HITSLOP_10} from 'lib/constants'
import {sanitizeDisplayName} from 'lib/strings/display-names'
import {useSession} from 'state/session'
import {useSession} from '#/state/session'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
Expand Down Expand Up @@ -78,7 +78,6 @@ export function NewskieDialog({
</Button>

<Dialog.Outer control={control}>
<Dialog.Handle />
<Dialog.ScrollableInner
label={_(msg`New user info dialog`)}
style={[{width: 'auto', maxWidth: 400, minWidth: 200}]}>
Expand Down
2 changes: 0 additions & 2 deletions src/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export function Outer({
return (
<Dialog.Outer control={control} testID={testID}>
<Context.Provider value={context}>
<Dialog.Handle />

<Dialog.ScrollableInner
accessibilityLabelledBy={titleId}
accessibilityDescribedBy={descriptionId}
Expand Down
2 changes: 0 additions & 2 deletions src/components/ReportDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {ReportDialogProps} from './types'
export function ReportDialog(props: ReportDialogProps) {
return (
<Dialog.Outer control={props.control}>
<Dialog.Handle />

<ReportDialogInner {...props} />
</Dialog.Outer>
)
Expand Down
1 change: 0 additions & 1 deletion src/components/StarterPack/QrCodeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export function QrCodeDialog({

return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<Dialog.ScrollableInner
label={_(msg`Create a QR code for a starter pack`)}>
<View style={[a.flex_1, a.align_center, a.gap_5xl]}>
Expand Down
15 changes: 7 additions & 8 deletions src/components/StarterPack/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {AppBskyGraphDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
import {saveImageToMediaLibrary} from '#/lib/media/manip'
import {shareUrl} from '#/lib/sharing'
import {logEvent} from '#/lib/statsig/statsig'
import {getStarterPackOgCard} from '#/lib/strings/starter-pack'
import {logger} from '#/logger'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {saveImageToMediaLibrary} from 'lib/media/manip'
import {shareUrl} from 'lib/sharing'
import {logEvent} from 'lib/statsig/statsig'
import {getStarterPackOgCard} from 'lib/strings/starter-pack'
import {isNative, isWeb} from 'platform/detection'
import * as Toast from 'view/com/util/Toast'
import {isNative, isWeb} from '#/platform/detection'
import * as Toast from '#/view/com/util/Toast'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import {DialogControlProps} from '#/components/Dialog'
Expand Down Expand Up @@ -84,7 +84,6 @@ function ShareDialogInner({

return (
<>
<Dialog.Handle />
<Dialog.ScrollableInner label={_(msg`Share link dialog`)}>
{!imageLoaded || !link ? (
<View style={[a.p_xl, a.align_center]}>
Expand Down
7 changes: 3 additions & 4 deletions src/components/StarterPack/Wizard/WizardEditListDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {BottomSheetFlatListMethods} from '@discord/bottom-sheet'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {useInitialNumToRender} from 'lib/hooks/useInitialNumToRender'
import {isWeb} from 'platform/detection'
import {useSession} from 'state/session'
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import {isWeb} from '#/platform/detection'
import {useSession} from '#/state/session'
import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, native, useTheme, web} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
Expand Down Expand Up @@ -80,7 +80,6 @@ export function WizardEditListDialog({
control={control}
testID="newChatDialog"
nativeOptions={{sheet: {snapPoints: ['95%']}}}>
<Dialog.Handle />
<Dialog.InnerFlatList
ref={listRef}
data={getData()}
Expand Down
2 changes: 0 additions & 2 deletions src/components/TagMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export function TagMenu({
{children}

<Dialog.Outer control={control}>
<Dialog.Handle />

<Dialog.Inner label={_(msg`Tag menu: ${displayTag}`)}>
{isPreferencesLoading ? (
<View style={[a.w_full, a.align_center]}>
Expand Down
1 change: 0 additions & 1 deletion src/components/WhoCanReply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ function WhoCanReplyDialog({
const {_} = useLingui()
return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<Dialog.ScrollableInner
label={_(msg`Dialog: adjust who can interact with this post`)}
style={[{width: 'auto', maxWidth: 400, minWidth: 200}]}>
Expand Down
2 changes: 0 additions & 2 deletions src/components/dialogs/BirthDateSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export function BirthDateSettingsDialog({

return (
<Dialog.Outer control={control}>
<Dialog.Handle />

<Dialog.ScrollableInner label={_(msg`My Birthday`)}>
<View style={[a.gap_sm, a.pb_lg]}>
<Text style={[a.text_2xl, a.font_bold]}>
Expand Down
1 change: 0 additions & 1 deletion src/components/dialogs/Embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type EmbedDialogProps = {
let EmbedDialog = ({control, ...rest}: EmbedDialogProps): React.ReactNode => {
return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<EmbedDialogInner {...rest} />
</Dialog.Outer>
)
Expand Down
2 changes: 0 additions & 2 deletions src/components/dialogs/EmbedConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export function EmbedConsentDialog({

return (
<Dialog.Outer control={control}>
<Dialog.Handle />

<Dialog.ScrollableInner
label={_(msg`External Media`)}
style={[gtMobile ? {width: 'auto', maxWidth: 400} : a.w_full]}>
Expand Down
1 change: 0 additions & 1 deletion src/components/dialogs/GifSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function GifSelectDialog({
control={control}
nativeOptions={{sheet: {snapPoints: ['100%']}}}
onClose={onClose}>
<Dialog.Handle />
<ErrorBoundary renderError={renderErrorBoundary}>
<GifList control={control} onSelectGif={onSelectGif} />
</ErrorBoundary>
Expand Down
1 change: 0 additions & 1 deletion src/components/dialogs/MutedWords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function MutedWordsDialog() {
const {mutedWordsDialogControl: control} = useGlobalDialogsControlContext()
return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<MutedWordsInner />
</Dialog.Outer>
)
Expand Down
2 changes: 0 additions & 2 deletions src/components/dialogs/PostInteractionSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function PostInteractionSettingsControlledDialog({
const {_} = useLingui()
return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<Dialog.ScrollableInner
label={_(msg`Edit post interaction settings`)}
style={[{maxWidth: 500}, a.w_full]}>
Expand Down Expand Up @@ -96,7 +95,6 @@ export function PostInteractionSettingsDialog(
) {
return (
<Dialog.Outer control={props.control}>
<Dialog.Handle />
<PostInteractionSettingsDialogControlledInner {...props} />
</Dialog.Outer>
)
Expand Down
1 change: 0 additions & 1 deletion src/components/dialogs/Signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function SigninDialog() {
const {signinDialogControl: control} = useGlobalDialogsControlContext()
return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<SigninDialogInner control={control} />
</Dialog.Outer>
)
Expand Down
2 changes: 0 additions & 2 deletions src/components/dialogs/SwitchAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export function SwitchAccountDialog({

return (
<Dialog.Outer control={control}>
<Dialog.Handle />

<Dialog.ScrollableInner label={_(msg`Switch Account`)}>
<View style={[a.gap_lg]}>
<Text style={[a.text_2xl, a.font_bold]}>
Expand Down
2 changes: 0 additions & 2 deletions src/components/dialogs/nuxs/NeueTypography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export function NeueTypography() {

return (
<Dialog.Outer control={control} onClose={onClose}>
<Dialog.Handle />

<Dialog.ScrollableInner label={_(msg`Introducing new font settings`)}>
<View style={[a.gap_xl]}>
<View style={[a.gap_md]}>
Expand Down
1 change: 0 additions & 1 deletion src/components/dms/MessagesNUX.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function MessagesNUX() {

return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<DialogInner chatDeclation={profile.associated?.chat} />
</Dialog.Outer>
)
Expand Down
1 change: 0 additions & 1 deletion src/components/dms/ReportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ let ReportDialog = ({
<Dialog.Outer
control={control}
nativeOptions={isAndroid ? {sheet: {snapPoints: ['100%']}} : {}}>
<Dialog.Handle />
<Dialog.ScrollableInner label={_(msg`Report this message`)}>
<DialogInner params={params} />
<Dialog.Close />
Expand Down
1 change: 0 additions & 1 deletion src/components/forms/DateField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export function DateField({
accessibilityHint={accessibilityHint}
/>
<Dialog.Outer control={control} testID={testID}>
<Dialog.Handle />
<Dialog.Inner label={label}>
<View style={a.gap_lg}>
<View style={[a.relative, a.w_full, a.align_center]}>
Expand Down
3 changes: 1 addition & 2 deletions src/components/intents/VerifyEmailIntentDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {useAgent, useSession} from 'state/session'
import {useAgent, useSession} from '#/state/session'
import {atoms as a} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
Expand All @@ -17,7 +17,6 @@ export function VerifyEmailIntentDialog() {

return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<Inner control={control} />
</Dialog.Outer>
)
Expand Down
Loading

0 comments on commit 3971254

Please sign in to comment.