Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mobile-full-screen-pages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sable: patch
---

Render the global modals (search, create room, create space, bug report) as full-screen pages on mobile instead of centered modals.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0",
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0",
"@choochmeque/tauri-plugin-notifications-api": "0.5.0-rc.11",
"@choochmeque/tauri-plugin-sharekit-api": "0.4.0-rc.5",
"@fontsource-variable/nunito": "5.2.7",
"@fontsource/space-mono": "5.2.9",
"@noble/hashes": "^2.2.0",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugi
"push-notifications",
] }
tauri-plugin-edge-to-edge = { git = "https://github.com/SableClient/tauri-plugin-edge-to-edge.git", rev = "33c6116c27be28c06df5a9d02231ecc5fdeb93c5" }
tauri-plugin-sharekit = { git = "https://github.com/Choochmeque/tauri-plugin-sharekit", rev = "9f2b4c5d8a4f0ab910d900ba234ed8bae0ab854b" }

[target.'cfg(target_os = "ios")'.dependencies]
objc2 = "0.6"
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/capabilities/mobile.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"core:window:allow-set-badge-count",
"deep-link:default",
"edge-to-edge:default",
"notifications:default"
"notifications:default",
"sharekit:default"
]
}
4 changes: 3 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ pub fn run() {
.plugin(tauri_plugin_dialog::init());

#[cfg(mobile)]
let builder = builder.plugin(tauri_plugin_edge_to_edge::init());
let builder = builder
.plugin(tauri_plugin_edge_to_edge::init())
.plugin(tauri_plugin_sharekit::init());

#[cfg(target_os = "android")]
let builder = builder.plugin(tauri_plugin_android_fs::init());
Expand Down
9 changes: 6 additions & 3 deletions src/app/components/Modal500.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { render } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { ScreenSize, ScreenSizeProvider } from '$hooks/useScreenSize';
import { Modal500 } from './Modal500';

describe('Modal500', () => {
it('does not throw when rendered without tabbable children', () => {
expect(() =>
render(
<Modal500 requestClose={vi.fn<() => void>()}>
<div>Empty modal content</div>
</Modal500>
<ScreenSizeProvider value={ScreenSize.Desktop}>
<Modal500 requestClose={vi.fn<() => void>()}>
<div>Empty modal content</div>
</Modal500>
</ScreenSizeProvider>
)
).not.toThrow();
});
Expand Down
24 changes: 24 additions & 0 deletions src/app/components/Modal500.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
import { useRef } from 'react';
import FocusTrap from 'focus-trap-react';
import { Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
import { stopPropagation } from '$utils/keyboard';

type Modal500Props = {
Expand All @@ -10,6 +11,29 @@ type Modal500Props = {
};
export function Modal500({ requestClose, children }: Modal500Props) {
const modalRef = useRef<HTMLDivElement | null>(null);
const screenSize = useScreenSizeContext();

if (screenSize === ScreenSize.Mobile) {
return (
<Overlay open>
<FocusTrap
focusTrapOptions={{
initialFocus: false,
escapeDeactivates: stopPropagation,
onDeactivate: requestClose,
}}
>
<div
ref={modalRef}
tabIndex={-1}
style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column' }}
>
{children}
</div>
</FocusTrap>
</Overlay>
);
}

return (
<Overlay open backdrop={<OverlayBackdrop />}>
Expand Down
5 changes: 3 additions & 2 deletions src/app/components/page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ type PageRootProps = {
rail?: ReactNode;
bottomNav?: ReactNode;
children: ReactNode;
mobileDrawer?: boolean;
};

export function PageRoot({ nav, rail, bottomNav, children }: PageRootProps) {
export function PageRoot({ nav, rail, bottomNav, children, mobileDrawer = true }: PageRootProps) {
const screenSize = useScreenSizeContext();
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
const isMobile = screenSize === ScreenSize.Mobile;

if (isMobile && mobileGestures) {
if (isMobile && mobileGestures && mobileDrawer) {
return (
<Box grow="Yes" className={ContainerColor({ variant: 'Background' })}>
<MobileNavDrawer nav={nav} rail={rail} bottomNav={bottomNav}>
Expand Down
57 changes: 57 additions & 0 deletions src/app/components/page/SettingsSectionPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { ReactNode } from 'react';
import { Box, IconButton, Text } from 'folds';
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
import { ArrowLeft, composerIcon, X } from '$components/icons/phosphor';
import { Page, PageHeader } from './Page';
import { SettingsSectionBody, SettingsSectionHeader } from './style.css';

type SettingsSectionPageProps = {
title: ReactNode;
requestBack?: () => void;
requestClose: () => void;
titleAs?: 'h1' | 'h2' | 'h3' | 'span' | 'div';
backLabel?: string;
actionLabel?: string;
children?: ReactNode;
};

export function SettingsSectionPage({
title,
requestBack,
requestClose,
titleAs,
backLabel,
actionLabel,
children,
}: SettingsSectionPageProps) {
const screenSize = useScreenSizeContext();
const closeLabel = actionLabel ?? 'Close';
const showBack = screenSize === ScreenSize.Mobile && requestBack;

return (
<Page>
<PageHeader className={SettingsSectionHeader}>
<Box grow="Yes" gap="200">
<Box grow="Yes" alignItems="Center" gap="200">
{showBack && (
<IconButton aria-label={backLabel ?? 'Back'} onClick={requestBack} variant="Surface">
{composerIcon(ArrowLeft)}
</IconButton>
)}
<Text size="H4" as={titleAs} truncate>
{title}
</Text>
</Box>
<Box shrink="No">
<IconButton aria-label={closeLabel} onClick={requestClose} variant="Surface">
{composerIcon(X)}
</IconButton>
</Box>
</Box>
</PageHeader>
<Box grow="Yes" className={SettingsSectionBody}>
{children}
</Box>
</Page>
);
}
1 change: 1 addition & 0 deletions src/app/components/page/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './Page';
export * from './SettingsSectionPage';
20 changes: 19 additions & 1 deletion src/app/components/page/style.css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { style } from '@vanilla-extract/css';
import { globalStyle, style } from '@vanilla-extract/css';
import type { RecipeVariants } from '@vanilla-extract/recipes';
import { recipe } from '@vanilla-extract/recipes';
import { DefaultReset, color, config, toRem } from 'folds';
Expand Down Expand Up @@ -123,3 +123,21 @@ export const PageContentCenter = style([
margin: 'auto',
},
]);

export const SettingsSectionBody = style({
width: '100%',
maxWidth: toRem(800),
marginInline: 'auto',
});

globalStyle(`${SettingsSectionBody} *`, {
scrollbarWidth: 'none',
});
globalStyle(`${SettingsSectionBody} *::-webkit-scrollbar`, {
display: 'none',
});

export const SettingsSectionHeader = style({
paddingLeft: config.space.S300,
paddingRight: config.space.S200,
});
21 changes: 21 additions & 0 deletions src/app/components/user-profile/UserChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { getMxIdServer } from '$utils/mxIdHelper';
import { useCloseUserRoomProfile } from '$state/hooks/userRoomProfile';
import { stopPropagation } from '$utils/keyboard';
import { copyToClipboard } from '$utils/dom';
import { shareText } from '$utils/share';
import { getExploreServerPath } from '$pages/pathUtils';
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
import { factoryRoomIdByAtoZ } from '$utils/sort';
Expand Down Expand Up @@ -300,6 +301,26 @@ export function ShareChip({
>
<Text size="B300">Copy User Link</Text>
</MenuItem>
<MenuItem
fill="None"
size="300"
radii="300"
className={css.UserHeroMenuItem}
style={heroMenuItemStyle(
{
backgroundColor: menuItemBg,
color: textColor,
},
chipHoverBrightness
)}
onClick={async () => {
const shared = await shareText(getMatrixToUser(userId));
if (shared) setCopied();
close();
}}
>
<Text size="B300">Share User Link</Text>
</MenuItem>
</Box>
</div>
</Menu>
Expand Down
Loading
Loading