mirror of
https://github.com/makecindy/cindy.git
synced 2026-12-03 21:49:46 +08:00
冲突处理原则:远端已删除的(自动化管理)跟远端;远端重做的组件(模型选择、 目标面板、伙伴资料等)以远端结构为准,再补回统一按压反馈;首页标题宽度采用 远端算法;抽屉保留账号头新布局,随远端移除「加入共享任务」入口并通过远端 Android 独立窗口测试;设备列表保留分组结构,采用远端图标滑动操作。 Signed-off-by: kirozeng <kirozeng@gmail.com>
142 lines
4.3 KiB
TypeScript
142 lines
4.3 KiB
TypeScript
import { Stack } from "expo-router";
|
|
import { useTranslation } from 'react-i18next';
|
|
import { QuietSyncIndicator } from '@/components/QuietSyncIndicator';
|
|
import type { ReactNode } from "react";
|
|
import { Platform, StyleSheet, View } from "react-native";
|
|
import type { Edge } from "react-native-safe-area-context";
|
|
import { Text } from "@/components/AppText";
|
|
import {
|
|
MainWindowActionButton,
|
|
ScreenBackButton,
|
|
ScreenHeader,
|
|
type MainWindowAction,
|
|
} from "@/components/MobilePrimitives";
|
|
import {
|
|
fontWeight,
|
|
typeScale,
|
|
useTheme,
|
|
useThemedStyles,
|
|
type ThemeColors,
|
|
} from "@/theme";
|
|
import { lineHeight } from "@/theme/tokens";
|
|
|
|
/**
|
|
* 简单页在 iOS 打开系统导航栏;Android 继续自绘 ScreenHeader(外观走安卓)。
|
|
* 不变量:顶栏只放单行 title。iOS UINavigationBar 的 compact 标题槽没有
|
|
* eyebrow / subtitle,Android 的交互与信息跟随 iOS,同样不显示。
|
|
*/
|
|
export function usesNativeStackHeader(): boolean {
|
|
return Platform.OS === "ios";
|
|
}
|
|
|
|
/** iOS 系统顶栏已吃掉顶部安全区,根 SafeAreaView 不要再垫 top。 */
|
|
export function simpleScreenSafeAreaEdges(): readonly Edge[] | undefined {
|
|
return Platform.OS === "ios" ? ["left", "right", "bottom"] : undefined;
|
|
}
|
|
|
|
/**
|
|
* 整页滚动的简单页(配合 `<SimpleStackHeader scrollEdge />`):iOS 上内容铺到透明顶栏
|
|
* 和底部指示条下面,由滚动视图自己让出上下安全区,系统柔和边缘替代硬分界。
|
|
*/
|
|
export function simpleScrollScreenSafeAreaEdges(): readonly Edge[] | undefined {
|
|
return Platform.OS === "ios" ? ["left", "right"] : undefined;
|
|
}
|
|
|
|
export const simpleScrollInsetProps = Platform.OS === "ios"
|
|
? { automaticallyAdjustsScrollIndicatorInsets: true, contentInsetAdjustmentBehavior: "automatic" as const }
|
|
: {};
|
|
|
|
export function SimpleStackHeader({
|
|
action,
|
|
right,
|
|
backTestID,
|
|
onBack,
|
|
title,
|
|
titleTestID,
|
|
syncing,
|
|
scrollEdge = false,
|
|
}: {
|
|
action?: MainWindowAction;
|
|
right?: ReactNode;
|
|
backTestID?: string;
|
|
/**
|
|
* @deprecated 两端都不渲染(iOS 系统顶栏无此槽,Android 跟随 iOS)。
|
|
* 仅为存量调用点保留类型兼容;新代码不要传,需要的信息放进页面内容。
|
|
*/
|
|
eyebrow?: string;
|
|
onBack?: () => void;
|
|
/** @deprecated 同 eyebrow:两端都不渲染,仅保留类型兼容。 */
|
|
subtitle?: string | null;
|
|
title: string;
|
|
titleTestID?: string;
|
|
syncing?: boolean;
|
|
/** 页面根部是整页滚动视图时打开;配套使用 simpleScrollScreenSafeAreaEdges / simpleScrollInsetProps。 */
|
|
scrollEdge?: boolean;
|
|
}) {
|
|
const { colors } = useTheme();
|
|
const { t } = useTranslation();
|
|
const styles = useThemedStyles(makeNativeTitleStyles);
|
|
|
|
if (!usesNativeStackHeader()) {
|
|
return (
|
|
<ScreenHeader
|
|
action={action}
|
|
right={right}
|
|
backTestID={backTestID}
|
|
onBack={onBack}
|
|
title={title}
|
|
titleTestID={titleTestID}
|
|
syncing={syncing}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Stack.Screen
|
|
options={{
|
|
headerShown: true,
|
|
headerShadowVisible: false,
|
|
headerBackVisible: false,
|
|
headerStyle: { backgroundColor: scrollEdge ? "transparent" : colors.surface },
|
|
headerTransparent: scrollEdge,
|
|
scrollEdgeEffects: scrollEdge
|
|
? { bottom: "soft", left: "hidden", right: "hidden", top: "soft" }
|
|
: undefined,
|
|
headerTintColor: colors.textPrimary,
|
|
headerTitle: () => (
|
|
<View style={styles.wrap} testID={titleTestID}>
|
|
<Text numberOfLines={1} style={styles.title}>
|
|
{title}
|
|
</Text>
|
|
{syncing !== undefined ? <QuietSyncIndicator active={syncing} /> : null}
|
|
</View>
|
|
),
|
|
headerRight: right ? () => right : action
|
|
? () => <MainWindowActionButton action={action} density="compact" />
|
|
: undefined,
|
|
}}
|
|
/>
|
|
{onBack ? <Stack.Toolbar placement="left">
|
|
<Stack.Toolbar.Button icon="chevron.backward" onPress={onBack} accessibilityLabel={t('shared.back')} />
|
|
</Stack.Toolbar> : null}
|
|
</>
|
|
);
|
|
}
|
|
|
|
const makeNativeTitleStyles = (colors: ThemeColors) =>
|
|
StyleSheet.create({
|
|
wrap: {
|
|
flexDirection: 'row',
|
|
alignItems: "center",
|
|
maxWidth: 220,
|
|
},
|
|
title: {
|
|
flexShrink: 1,
|
|
color: colors.textPrimary,
|
|
fontSize: typeScale.body,
|
|
fontWeight: fontWeight.semibold,
|
|
lineHeight: lineHeight.body,
|
|
},
|
|
});
|