feat(direct): use compact native phone layout for new chat to keep form fitted under the on-screen keyboard
This commit is contained in:
parent
212d3e3482
commit
b5ea37d57a
1 changed files with 36 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useEffect } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { Box, Icon, IconButton, Icons, Scroll } from 'folds';
|
||||
import { Box, Icon, IconButton, Icons, Scroll, Text, config } from 'folds';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import { getDirectCreateSearchParams } from '../../pathSearchParam';
|
||||
|
|
@ -18,11 +18,13 @@ import {
|
|||
} from '../../../components/page';
|
||||
import { BackRouteHandler } from '../../../components/BackRouteHandler';
|
||||
import { CreateChat } from '../../../features/create-chat';
|
||||
import { isNativePlatform } from '../../../utils/capacitor';
|
||||
|
||||
export function DirectCreate() {
|
||||
const { t } = useTranslation();
|
||||
const mx = useMatrixClient();
|
||||
const screenSize = useScreenSizeContext();
|
||||
const native = isNativePlatform();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
|
@ -39,6 +41,39 @@ export function DirectCreate() {
|
|||
}
|
||||
}, [mx, navigate, directs, userId]);
|
||||
|
||||
// Native phone (Capacitor + Mobile screen): compact layout — title goes into
|
||||
// the back-arrow header, form sits directly below with light padding, no
|
||||
// oversized hero whitespace. The on-screen keyboard otherwise pushed the
|
||||
// centered hero layout into a visibly long scrollable area. Native tablets,
|
||||
// desktop, and web (any size) keep the original hero-section layout.
|
||||
if (native && screenSize === ScreenSize.Mobile) {
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader balance outlined={false}>
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<BackRouteHandler>
|
||||
{(onBack) => (
|
||||
<IconButton onClick={onBack}>
|
||||
<Icon src={Icons.ArrowLeft} />
|
||||
</IconButton>
|
||||
)}
|
||||
</BackRouteHandler>
|
||||
<Text size="H4" truncate>
|
||||
{t('Direct.create_chat')}
|
||||
</Text>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes">
|
||||
<Scroll size="0" hideTrack visibility="Hover">
|
||||
<Box style={{ padding: config.space.S400 }}>
|
||||
<CreateChat defaultUserId={userId} />
|
||||
</Box>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
{screenSize === ScreenSize.Mobile && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue