Skip to content

Commit

Permalink
💄 style: Fix safeare in mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Sep 27, 2023
1 parent 31201b4 commit 2adfb04
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 49 deletions.
Binary file added public/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-maskable-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-maskable-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 21 additions & 6 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,38 @@
"display": "fullscreen",
"icons": [
{
"src": "https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/android-chrome-192x192.png",
"src": "/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
"type": "image/png",
"purpose": "any"
},
{
"src": "/icons/icon-maskable-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/android-chrome-512x512.png",
"src": "/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
"type": "image/png",
"purpose": "any"
},
{
"src": "/icons/icon-maskable-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"id": "/",
"name": "LobeChat",
"orientation": "portrait",
"scope": "/",
"screenshots": [
{
"src": "https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/og-960x720.png",
"sizes": "960x720",
"src": "https://registry.npmmirror.com/@lobehub/assets-favicons/1.4.0/files/assets/og-960x540.png",
"sizes": "960x540",
"type": "image/png"
}
],
Expand Down
22 changes: 18 additions & 4 deletions src/app/chat/features/Conversation/ChatList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChatList, RenderMessage } from '@lobehub/ui';
import { createStyles } from 'antd-style';
import isEqual from 'fast-deep-equal';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
Expand All @@ -15,10 +16,22 @@ import FunctionCall from './Plugins/FunctionCall';
import PluginMessage from './Plugins/PluginMessage';
import SkeletonList from './SkeletonList';

const List = () => {
const useStyles = createStyles(({ css, responsive, cx, stylish }) =>
cx(
stylish.noScrollbar,
css`
overflow-x: hidden;
${responsive.mobile} {
width: 100vw;
}
`,
),
);

const List = memo(() => {
const init = useSessionChatInit();
const { t } = useTranslation('common');

const { styles } = useStyles();
const data = useSessionStore(chatSelectors.currentChatsWithGuideMessage, isEqual);

const [
Expand Down Expand Up @@ -83,6 +96,7 @@ const List = () => {

return (
<ChatList
className={styles}
data={data}
enableHistoryCount={enableHistoryCount}
historyCount={historyCount}
Expand Down Expand Up @@ -120,6 +134,6 @@ const List = () => {
type={displayMode || 'chat'}
/>
);
};
});

export default memo(List);
export default List;
36 changes: 21 additions & 15 deletions src/app/chat/features/Conversation/Input/ActionBar/ActionRight.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { ActionIcon } from '@lobehub/ui';
import { Popconfirm } from 'antd';
import { useResponsive } from 'antd-style';
import { Eraser } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { useSessionStore } from '@/store/session';

import SaveTopic from '../Footer/SaveTopic';

const ActionsRight = memo(() => {
const { t } = useTranslation('setting');
const [clearMessage] = useSessionStore((s) => [s.clearMessage, s.updateAgentConfig]);

const { mobile } = useResponsive();
return (
<Popconfirm
cancelText={t('cancel', { ns: 'common' })}
okButtonProps={{ danger: true }}
okText={t('ok', { ns: 'common' })}
onConfirm={() => clearMessage()}
placement={'topRight'}
title={t('confirmClearCurrentMessages', { ns: 'common' })}
>
<ActionIcon
icon={Eraser}
placement={'bottom'}
title={t('clearCurrentMessages', { ns: 'common' })}
/>
</Popconfirm>
<>
{mobile && <SaveTopic />}
<Popconfirm
cancelText={t('cancel', { ns: 'common' })}
okButtonProps={{ danger: true }}
okText={t('ok', { ns: 'common' })}
onConfirm={() => clearMessage()}
placement={'topRight'}
title={t('confirmClearCurrentMessages', { ns: 'common' })}
>
<ActionIcon
icon={Eraser}
placement={'bottom'}
title={t('clearCurrentMessages', { ns: 'common' })}
/>
</Popconfirm>
</>
);
});

Expand Down
25 changes: 24 additions & 1 deletion src/app/chat/features/Conversation/Input/Mobile.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
import { createStyles } from 'antd-style';
import { ReactNode, memo } from 'react';

import SafeSpacing from '@/components/SafeSpacing';
import { CHAT_TEXTAREA_HEIGHT_MOBILE } from '@/const/layoutTokens';

const useStyles = createStyles(
({ css, token }) => css`
position: fixed;
right: 0;
bottom: 0;
left: 0;
width: 100vw;
background: ${token.colorBgLayout};
`,
);

interface ChatInputMobileLayoutProps {
children: ReactNode;
expand?: boolean;
}

const ChatInputMobileLayout = memo<ChatInputMobileLayoutProps>(({ children }) => {
return <div>{children}</div>;
const { styles } = useStyles();
return (
<>
<SafeSpacing height={CHAT_TEXTAREA_HEIGHT_MOBILE} mobile position={'bottom'} />
<div className={styles}>{children}</div>
</>
);
});

export default ChatInputMobileLayout;
2 changes: 1 addition & 1 deletion src/app/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
import Conversation from './features/Conversation';
import Header from './features/Header';
import SideBar from './features/Sidebar';
import DesktopLayout from './layout.desktop';
import MobileLayout from './layout.mobile';
import DesktopLayout from './layout.pc';

const Chat = memo(() => {
const { mobile } = useResponsive();
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/chat/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useSessionStore } from '@/store/session';
import { agentSelectors } from '@/store/session/selectors';
import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';

import DesktopLayout from './layout.desktop';
import MobileLayout from './layout.mobile';
import DesktopLayout from './layout.pc';

const EditPage = memo(() => {
const { mobile } = useResponsive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Flexbox } from 'react-layout-kit';
import SafeSpacing from '@/components/SafeSpacing';
import { HEADER_HEIGHT } from '@/const/layoutTokens';

import ChatLayout from '../layout.pc';
import ChatLayout from '../layout.desktop';
import Header from './features/Header';

const DesktopLayout = memo<PropsWithChildren>(({ children }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/market/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';

import AgentCard from './features/AgentCard';
import AgentSearchBar from './features/AgentSearchBar';
import DesktopLayout from './layout.desktop';
import MobileLayout from './layout.mobile';
import DesktopLayout from './layout.pc';

const Market = memo(() => {
const { t } = useTranslation('common');
Expand Down
File renamed without changes.
17 changes: 3 additions & 14 deletions src/app/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ const title = genSiteHeadTitle();
const description = pkg.description;
const metadata: Metadata = {
appleWebApp: {
startupImage: [
'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/splash-750x1624.png',
{
media: '(device-width: 768px) and (device-height: 1024px)',
url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/splash-2048x2732.png',
},
],
statusBarStyle: 'black-translucent',
title: title,
},
Expand All @@ -23,10 +16,6 @@ const metadata: Metadata = {
apple:
'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/apple-touch-icon.png',
icon: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/favicon-32x32.png',
other: {
rel: 'mask-icon',
url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/safari-pinned-tab.svg',
},
shortcut:
'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/favicon.ico',
},
Expand All @@ -37,13 +26,13 @@ const metadata: Metadata = {
{
alt: title,
height: 360,
url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/og-480x360.png',
url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/1.4.0/files/assets/og-480x270.png',
width: 480,
},
{
alt: title,
height: 720,
url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/og-960x720.png',
url: 'https://registry.npmmirror.com/@lobehub/assets-favicons/1.4.0/files/assets/og-960x540.png',
width: 960,
},
],
Expand All @@ -57,7 +46,7 @@ const metadata: Metadata = {
{ color: '#fff', media: '(prefers-color-scheme: light)' },
{ color: '#000', media: '(prefers-color-scheme: dark)' },
],
title: genSiteHeadTitle(),
title: title,
viewport: {
initialScale: 1,
maximumScale: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/app/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { useSwitchSideBarOnInit } from '@/store/global';
import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';

import Settings from './features/Settings';
import DesktopLayout from './layout.desktop';
import MobileLayout from './layout.mobile';
import DesktopLayout from './layout.pc';

const Setting = memo(() => {
const { mobile } = useResponsive();
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/welcome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';

import Banner from './features/Banner';
import Footer from './features/Footer';
import Layout from './layout.desktop';
import Mobile from './layout.mobile';
import Layout from './layout.pc';

const Welcome = memo(() => {
const { mobile } = useResponsive();
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/welcome/layout.mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const WelcomeLayout = memo<PropsWithChildren>(({ children }) => {
<AppMobileLayout
navBar={<MobileNavBar center={<Logo type={'text'} />} />}
showTabBar
style={{ background: theme.colorBgContainer }}
style={{ background: theme.colorBgLayout }}
>
{children}
</AppMobileLayout>
Expand Down
1 change: 1 addition & 0 deletions src/const/layoutTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const HEADER_HEIGHT = 64;
export const MOBILE_NABBAR_HEIGHT = 44;
export const MOBILE_TABBAR_HEIGHT = 48;
export const CHAT_TEXTAREA_HEIGHT = 200;
export const CHAT_TEXTAREA_HEIGHT_MOBILE = 180;
export const CHAT_SIDEBAR_WIDTH = 280;
export const MARKET_SIDEBAR_WIDTH = 400;
export const FOLDER_WIDTH = 256;
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useIsPWA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ export const useIsPWA = () => {
const [isPWA, setIsPWA] = useState(false);

useEffect(() => {
const isInStandaloneMode = () =>
'standalone' in window.navigator && window.navigator['standalone'];
const isInStandaloneMode = () => window.matchMedia('(display-mode: standalone)').matches;
if (isInStandaloneMode()) {
setIsPWA(true);
}
Expand Down

0 comments on commit 2adfb04

Please sign in to comment.