[Chat] Improve gate (#10359)
This commit is contained in:
@@ -3,7 +3,7 @@ import {type GestureResponderEvent, View} from 'react-native'
|
|||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {atoms as a, useTheme, type ViewStyleProp, web} from '#/alf'
|
import {atoms as a, type TextStyleProp, useTheme, web} from '#/alf'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
type ButtonColor,
|
type ButtonColor,
|
||||||
@@ -34,6 +34,8 @@ export function Outer({
|
|||||||
control,
|
control,
|
||||||
testID,
|
testID,
|
||||||
nativeOptions,
|
nativeOptions,
|
||||||
|
webOptions,
|
||||||
|
onClose,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
testID?: string
|
testID?: string
|
||||||
@@ -41,6 +43,13 @@ export function Outer({
|
|||||||
* Native-specific options for the prompt. Extends `BottomSheetViewProps`
|
* Native-specific options for the prompt. Extends `BottomSheetViewProps`
|
||||||
*/
|
*/
|
||||||
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
|
nativeOptions?: Omit<BottomSheetViewProps, 'children'>
|
||||||
|
/**
|
||||||
|
* Web-specific options for the prompt
|
||||||
|
*/
|
||||||
|
webOptions?: {
|
||||||
|
onBackgroundPress?: (e: GestureResponderEvent) => void
|
||||||
|
}
|
||||||
|
onClose?: () => void
|
||||||
}>) {
|
}>) {
|
||||||
const titleId = useId()
|
const titleId = useId()
|
||||||
const descriptionId = useId()
|
const descriptionId = useId()
|
||||||
@@ -54,7 +63,8 @@ export function Outer({
|
|||||||
<Dialog.Outer
|
<Dialog.Outer
|
||||||
control={control}
|
control={control}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
webOptions={{alignCenter: true}}
|
onClose={onClose}
|
||||||
|
webOptions={{alignCenter: true, ...webOptions}}
|
||||||
nativeOptions={{preventExpansion: true, ...nativeOptions}}>
|
nativeOptions={{preventExpansion: true, ...nativeOptions}}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Context.Provider value={context}>
|
<Context.Provider value={context}>
|
||||||
@@ -72,7 +82,7 @@ export function Outer({
|
|||||||
export function TitleText({
|
export function TitleText({
|
||||||
children,
|
children,
|
||||||
style,
|
style,
|
||||||
}: React.PropsWithChildren<ViewStyleProp>) {
|
}: React.PropsWithChildren<TextStyleProp>) {
|
||||||
const {titleId} = useContext(Context)
|
const {titleId} = useContext(Context)
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
@@ -93,14 +103,21 @@ export function TitleText({
|
|||||||
export function DescriptionText({
|
export function DescriptionText({
|
||||||
children,
|
children,
|
||||||
selectable,
|
selectable,
|
||||||
}: React.PropsWithChildren<{selectable?: boolean}>) {
|
style,
|
||||||
|
}: React.PropsWithChildren<{selectable?: boolean} & TextStyleProp>) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {descriptionId} = useContext(Context)
|
const {descriptionId} = useContext(Context)
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
nativeID={descriptionId}
|
nativeID={descriptionId}
|
||||||
selectable={selectable}
|
selectable={selectable}
|
||||||
style={[a.text_md, a.leading_snug, t.atoms.text_contrast_high, a.pb_lg]}>
|
style={[
|
||||||
|
a.text_md,
|
||||||
|
a.leading_snug,
|
||||||
|
t.atoms.text_contrast_high,
|
||||||
|
a.pb_lg,
|
||||||
|
style,
|
||||||
|
]}>
|
||||||
{children}
|
{children}
|
||||||
</Text>
|
</Text>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {useCallback, useEffect, useMemo, useState} from 'react'
|
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {type LayoutChangeEvent, View} from 'react-native'
|
import {type LayoutChangeEvent, View} from 'react-native'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {moderateProfile} from '@atproto/api'
|
import {moderateProfile} from '@atproto/api'
|
||||||
@@ -319,7 +319,10 @@ function GroupChatGate() {
|
|||||||
ax.features.GroupChatsHasBeenReleased,
|
ax.features.GroupChatsHasBeenReleased,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const isAlreadyGoingBackRef = useRef(false)
|
||||||
const onGoBack = () => {
|
const onGoBack = () => {
|
||||||
|
if (isAlreadyGoingBackRef.current) return
|
||||||
|
isAlreadyGoingBackRef.current = true
|
||||||
if (navigation.canGoBack()) {
|
if (navigation.canGoBack()) {
|
||||||
navigation.goBack()
|
navigation.goBack()
|
||||||
} else {
|
} else {
|
||||||
@@ -330,27 +333,29 @@ function GroupChatGate() {
|
|||||||
return (
|
return (
|
||||||
<Prompt.Outer
|
<Prompt.Outer
|
||||||
control={groupChatGateDialogControl}
|
control={groupChatGateDialogControl}
|
||||||
|
onClose={onGoBack}
|
||||||
nativeOptions={{preventDismiss: true, preventExpansion: true}}
|
nativeOptions={{preventDismiss: true, preventExpansion: true}}
|
||||||
testID="groupChatGateDialog">
|
testID="groupChatGateDialog">
|
||||||
<Prompt.Content>
|
<Prompt.Content>
|
||||||
<View style={[a.w_full, a.align_center, a.py_2xl]}>
|
<View style={[a.w_full, a.align_center, a.py_3xl]}>
|
||||||
<Text style={{fontSize: 48}} emoji>
|
<Text style={{fontSize: 72}} emoji>
|
||||||
🐴
|
🐴
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Prompt.TitleText>
|
<Prompt.TitleText style={[a.text_center]}>
|
||||||
{hasBeenReleased ? (
|
{hasBeenReleased ? (
|
||||||
<Trans>Group chats are now available</Trans>
|
<Trans>Group chats are now available</Trans>
|
||||||
) : (
|
) : (
|
||||||
<Trans>Group chats are not yet available</Trans>
|
<Trans>Group chats are not yet available</Trans>
|
||||||
)}
|
)}
|
||||||
</Prompt.TitleText>
|
</Prompt.TitleText>
|
||||||
<Prompt.DescriptionText>
|
<Prompt.DescriptionText style={[a.text_center]}>
|
||||||
{hasBeenReleased ? (
|
{hasBeenReleased ? (
|
||||||
<Trans>Update your app to the latest version to join in!</Trans>
|
<Trans>Update your app to the latest version to join in!</Trans>
|
||||||
) : (
|
) : (
|
||||||
<Trans>
|
<Trans>
|
||||||
This feature isn't available to you yet. Please check back later.
|
Hold your horses! This feature isn't available to you yet. Please
|
||||||
|
check back later.
|
||||||
</Trans>
|
</Trans>
|
||||||
)}
|
)}
|
||||||
</Prompt.DescriptionText>
|
</Prompt.DescriptionText>
|
||||||
|
|||||||
Reference in New Issue
Block a user