Browse Source

fix(privacy): 修复隐私设置页开关项无入口,7 个页面无法跳转

app/settings/privacy.tsx 的 switch 分支渲染为 View + Switch,未绑定
onPress;而 handlePress(内部 router.push(item.route))只挂在
Pressable 分支上,导致带 route 的开关型条目点击无任何反应。

mock 数据中共 7 条 type: 'switch' 条目挂着 route(real-name /
contact / algo / third-party / location / contacts / dnd),对应
app/settings/privacy/[id].tsx(279 行,覆盖 6 个 slug)与 dnd.tsx
(295 行)两个实页面,运行期完全不可达,违反「有页面出口就一定要
有入口」规范。

对照证据:同组末尾的 keyword-block 是 type: 'value',走 Pressable
分支,其 /settings/privacy/keywords(357 行)可正常进入。这种不对称
证明是漏绑而非设计意图。

修法:仅将左侧文字区包为 Pressable 触发跳转,并补 chevron-forward
提示可点;右侧 Switch 保持独立切换,二者为兄弟节点不嵌套,互不干扰。
无 route 的开关(如「头像公开」)行为不变。
master
doublex001 1 month ago
parent
commit
ee264b644c
  1. 31
      app/settings/privacy.tsx

31
app/settings/privacy.tsx

@ -65,19 +65,29 @@ function SettingRow({
const titleColor = isDanger ? colors.dangerText : colors.textPrimary; const titleColor = isDanger ? colors.dangerText : colors.textPrimary;
const handlePress = () => { const handlePress = () => {
if (item.route) { if (item.route) router.push(item.route);
router.push(item.route);
return;
}
}; };
const rowBody = (
<View style={styles.rowBody}>
<Text style={styles.rowTitle}>{item.title}</Text>
{item.description ? <Text style={styles.rowDesc}>{item.description}</Text> : null}
</View>
);
// 开关型条目:带 route 的(如「勿扰模式」「真实姓名可见性」)点击左侧文字区进详情页,
// 右侧 Switch 保持独立可切换,两者互不干扰。
if (item.type === 'switch') { if (item.type === 'switch') {
return ( return (
<View style={[styles.row, !isLast && styles.rowBorder]}> <View style={[styles.row, !isLast && styles.rowBorder]}>
<View style={styles.rowBody}> {item.route ? (
<Text style={styles.rowTitle}>{item.title}</Text> <Pressable style={styles.rowTapArea} onPress={handlePress} hitSlop={4}>
{item.description ? <Text style={styles.rowDesc}>{item.description}</Text> : null} {rowBody}
</View> <Ionicons name="chevron-forward" size={18} color={colors.textHint} />
</Pressable>
) : (
rowBody
)}
<Switch <Switch
value={item.enabled} value={item.enabled}
onValueChange={(next) => onToggle?.(item.id, next)} onValueChange={(next) => onToggle?.(item.id, next)}
@ -270,6 +280,11 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
marginRight: 12, marginRight: 12,
}, },
rowTapArea: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
rowTitle: { rowTitle: {
fontSize: 15, fontSize: 15,
fontWeight: '600', fontWeight: '600',

Loading…
Cancel
Save