Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 修复 Duo 横屏加号菜单内容裁切

Dash57c34a4ffb25
diff --git a/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx b/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx
index 78adfa8283..c80c16b603 100644
--- a/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx
+++ b/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx
@@ -41,6 +41,8 @@ it('uses a plain list only when requested and preserves form sheets', () => {
} finally { act(() => root.unmount()); }
});
vi.mock('@expo/ui/swift-ui/modifiers', () => ({
+ containerRelativeFrame: vi.fn(() => ({})),
+ onGeometryChange: vi.fn(() => ({})),
...Object.fromEntries(['accessibilityLabel', 'contentShape', 'buttonStyle', 'font', 'foregroundStyle', 'frame', 'padding', 'presentationDetents', 'presentationDragIndicator', 'interactiveDismissDisabled', 'scrollContentBackground', 'listStyle', 'scrollDismissesKeyboard'].map(name => [name, vi.fn(() => ({}))])),
shapes: { rectangle: () => ({}) },
}));
diff --git a/apps/mobile/src/session/ComposerSheet.ios.tsx b/apps/mobile/src/session/ComposerSheet.ios.tsx
index 2b9660b699..e690f89753 100644
--- a/apps/mobile/src/session/ComposerSheet.ios.tsx
+++ b/apps/mobile/src/session/ComposerSheet.ios.tsx
@@ -1,4 +1,5 @@
import { iconSize } from '@/theme';
+import { useState } from 'react';
import { Host } from "@expo/ui";
import {
BottomSheet,
@@ -23,6 +24,8 @@ import {
opacity,
scrollDisabled,
contentShape,
+ containerRelativeFrame,
+ onGeometryChange,
shapes,
buttonStyle,
font,
@@ -66,6 +69,7 @@ export function ComposerSheet({
const { mode, colors } = useTheme();
const { t } = useTranslation();
const { width, height } = useWindowDimensions();
+ const [sheetWidth, setSheetWidth] = useState(0);
// UIKit disables the medium detent in compact-height landscape. Never bind
// selection to an unavailable detent, including after rotating an open sheet.
const landscape = width > height;
@@ -92,7 +96,11 @@ export function ComposerSheet({
>
<VStack
spacing={0}
- modifiers={[frame({ maxWidth: Infinity, maxHeight: Infinity })]}
+ modifiers={[
+ frame({ maxWidth: Infinity, maxHeight: Infinity }),
+ containerRelativeFrame({ axes: 'horizontal' }),
+ onGeometryChange(size => { if (size.width > 0) setSheetWidth(size.width); }),
+ ]}
>
{title || onBack ? <HStack
modifiers={[
@@ -120,9 +128,11 @@ export function ComposerSheet({
]}>{aboveContentTitle}</Text>
) : null}
{aboveContent ? (
+ // Constrain the photo strip to the presented sheet, which can be
+ // narrower than the window on Duo/iPad and in landscape.
<RNHostView matchContents>
- <View style={{ paddingHorizontal: 20, paddingTop: aboveContentTitle ? 0 : 24 }}>
- {aboveContent}
+ <View style={{ width: sheetWidth, paddingHorizontal: 20, paddingTop: aboveContentTitle ? 0 : 24 }}>
+ {sheetWidth > 0 ? aboveContent : null}
</View>
</RNHostView>
) : null}
@@ -146,7 +156,7 @@ export function ComposerSheet({
{nativeRoot.header}
<Form
testID={testID ? `${testID}.list` : undefined}
- modifiers={[scrollContentBackground("hidden")]}
+ modifiers={[containerRelativeFrame({ axes: 'horizontal' }), scrollContentBackground("hidden")]}
>
{nativeRoot.content}
</Form>
@@ -161,7 +171,7 @@ export function ComposerSheet({
{nativeHeader}
<Form
testID={testID}
- modifiers={[scrollContentBackground("hidden")]}
+ modifiers={[containerRelativeFrame({ axes: 'horizontal' }), scrollContentBackground("hidden")]}
>
{children}
</Form>
@@ -170,6 +180,7 @@ export function ComposerSheet({
</ZStack>
) : nativeContent && nativeList ? (
<List testID={testID} modifiers={[
+ containerRelativeFrame({ axes: 'horizontal' }),
listStyle("plain"),
scrollContentBackground("hidden"),
scrollDismissesKeyboard("interactively"),
@@ -178,6 +189,7 @@ export function ComposerSheet({
</List>
) : nativeContent ? (
<Form testID={testID} modifiers={[
+ containerRelativeFrame({ axes: 'horizontal' }),
scrollContentBackground("hidden"),
...(aboveContent ? [padding({ top: -12 })] : []),
]}>