Add debug to Composer
This commit is contained in:
@@ -37,7 +37,13 @@ export {Outlet} from '#/components/Toast/Portal'
|
|||||||
|
|
||||||
const TOAST_ANIMATION_DURATION = 300
|
const TOAST_ANIMATION_DURATION = 300
|
||||||
|
|
||||||
export function ToastProvider({children}: {children: React.ReactNode}) {
|
export function ToastProvider({
|
||||||
|
children,
|
||||||
|
offsetTop,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode
|
||||||
|
offsetTop?: number
|
||||||
|
}) {
|
||||||
const {top} = useSafeAreaInsets()
|
const {top} = useSafeAreaInsets()
|
||||||
const [toasts, setToasts] = useState<
|
const [toasts, setToasts] = useState<
|
||||||
{
|
{
|
||||||
@@ -96,7 +102,7 @@ export function ToastProvider({children}: {children: React.ReactNode}) {
|
|||||||
a.gap_sm,
|
a.gap_sm,
|
||||||
{
|
{
|
||||||
flexDirection: 'column-reverse',
|
flexDirection: 'column-reverse',
|
||||||
top: top,
|
top: offsetTop ?? top,
|
||||||
left: a.px_lg.paddingLeft,
|
left: a.px_lg.paddingLeft,
|
||||||
right: a.px_lg.paddingLeft,
|
right: a.px_lg.paddingLeft,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmile} from '#/components/icons
|
|||||||
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
||||||
import {LazyQuoteEmbed} from '#/components/Post/Embed/LazyQuoteEmbed'
|
import {LazyQuoteEmbed} from '#/components/Post/Embed/LazyQuoteEmbed'
|
||||||
import * as Prompt from '#/components/Prompt'
|
import * as Prompt from '#/components/Prompt'
|
||||||
|
import {useToast} from '#/components/Toast'
|
||||||
import {Text as NewText} from '#/components/Typography'
|
import {Text as NewText} from '#/components/Typography'
|
||||||
import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet'
|
import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet'
|
||||||
import {
|
import {
|
||||||
@@ -776,6 +777,7 @@ let ComposerPost = React.memo(function ComposerPost({
|
|||||||
: _(msg`Add another post`)
|
: _(msg`Add another post`)
|
||||||
: _(msg`What's up?`)
|
: _(msg`What's up?`)
|
||||||
const discardPromptControl = Prompt.usePromptControl()
|
const discardPromptControl = Prompt.usePromptControl()
|
||||||
|
const {show: showToast} = useToast()
|
||||||
|
|
||||||
const dispatchPost = useCallback(
|
const dispatchPost = useCallback(
|
||||||
(action: PostAction) => {
|
(action: PostAction) => {
|
||||||
@@ -807,6 +809,11 @@ let ComposerPost = React.memo(function ComposerPost({
|
|||||||
|
|
||||||
const onPhotoPasted = useCallback(
|
const onPhotoPasted = useCallback(
|
||||||
async (uri: string) => {
|
async (uri: string) => {
|
||||||
|
showToast({
|
||||||
|
type: 'success',
|
||||||
|
content: _(msg`Pasty wasty`),
|
||||||
|
a11yLabel: _(msg`Pasty wasty`),
|
||||||
|
})
|
||||||
if (uri.startsWith('data:video/') || uri.startsWith('data:image/gif')) {
|
if (uri.startsWith('data:video/') || uri.startsWith('data:image/gif')) {
|
||||||
if (isNative) return // web only
|
if (isNative) return // web only
|
||||||
const [mimeType] = uri.slice('data:'.length).split(';')
|
const [mimeType] = uri.slice('data:'.length).split(';')
|
||||||
@@ -824,7 +831,7 @@ let ComposerPost = React.memo(function ComposerPost({
|
|||||||
onImageAdd([res])
|
onImageAdd([res])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[post.id, onSelectVideo, onImageAdd, _],
|
[post.id, onSelectVideo, onImageAdd, _, showToast],
|
||||||
)
|
)
|
||||||
|
|
||||||
useHideKeyboardOnBackground()
|
useHideKeyboardOnBackground()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {Modal, View} from 'react-native'
|
|||||||
import {useDialogStateControlContext} from '#/state/dialogs'
|
import {useDialogStateControlContext} from '#/state/dialogs'
|
||||||
import {useComposerState} from '#/state/shell/composer'
|
import {useComposerState} from '#/state/shell/composer'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
|
import {Outlet as ToastPortalOutlet, ToastProvider} from '#/components/Toast'
|
||||||
import {ComposePost, useComposerCancelRef} from '../com/composer/Composer'
|
import {ComposePost, useComposerCancelRef} from '../com/composer/Composer'
|
||||||
|
|
||||||
export function Composer({}: {winHeight: number}) {
|
export function Composer({}: {winHeight: number}) {
|
||||||
@@ -32,19 +33,22 @@ export function Composer({}: {winHeight: number}) {
|
|||||||
presentationStyle="pageSheet"
|
presentationStyle="pageSheet"
|
||||||
animationType="slide"
|
animationType="slide"
|
||||||
onRequestClose={() => ref.current?.onPressCancel()}>
|
onRequestClose={() => ref.current?.onPressCancel()}>
|
||||||
<View style={[t.atoms.bg, a.flex_1]}>
|
<ToastProvider offsetTop={a.pt_lg.paddingTop}>
|
||||||
<ComposePost
|
<View style={[t.atoms.bg, a.flex_1]}>
|
||||||
cancelRef={ref}
|
<ComposePost
|
||||||
replyTo={state?.replyTo}
|
cancelRef={ref}
|
||||||
onPost={state?.onPost}
|
replyTo={state?.replyTo}
|
||||||
onPostSuccess={state?.onPostSuccess}
|
onPost={state?.onPost}
|
||||||
quote={state?.quote}
|
onPostSuccess={state?.onPostSuccess}
|
||||||
mention={state?.mention}
|
quote={state?.quote}
|
||||||
text={state?.text}
|
mention={state?.mention}
|
||||||
imageUris={state?.imageUris}
|
text={state?.text}
|
||||||
videoUri={state?.videoUri}
|
imageUris={state?.imageUris}
|
||||||
/>
|
videoUri={state?.videoUri}
|
||||||
</View>
|
/>
|
||||||
|
</View>
|
||||||
|
<ToastPortalOutlet />
|
||||||
|
</ToastProvider>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user