import { Ionicons } from '@expo/vector-icons';
import { useRouter } from 'expo-router';
import {
ActivityIndicator,
Pressable,
ScrollView,
StyleSheet,
Switch,
Text,
TextInput,
View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useDndSetting } from '../../../src/hooks';
import { colors , spacing } from '../../../src/theme';
/* ===================== 子组件:顶部导航 ===================== */
function Header({ onBack }: { onBack: () => void }) {
return (
勿扰模式
);
}
/* ===================== 子组件:时间输入行 ===================== */
function TimeRow({
label,
value,
onChange,
}: {
label: string;
value: string;
onChange: (text: string) => void;
}) {
return (
{label}
);
}
/* ===================== 页面 ===================== */
export default function DndSettingScreen() {
const router = useRouter();
const { setting, loading, error, refresh, update } = useDndSetting();
if (loading) {
return (
);
}
if (error || !setting) {
return (
router.back()} />
加载失败,请重试
重试
);
}
return (
router.back()} />
{setting.blockedCount}
累计拦截的通知条数
基础设置
开启勿扰模式
update({ enabled: next })}
trackColor={{ false: colors.border, true: colors.primaryBorder }}
thumbColor={setting.enabled ? colors.primary : colors.white}
/>
update({ startTime: text })}
/>
update({ endTime: text })}
/>
高级设置
允许重要通知穿透
面试邀约等与企业的重要沟通仍会提醒你
update({ allowUrgent: next })}
trackColor={{ false: colors.border, true: colors.primaryBorder }}
thumbColor={setting.allowUrgent ? colors.primary : colors.white}
/>
开启勿扰模式后,{setting.startTime} 至 {setting.endTime} 期间的非重要通知将被静音。你仍可在「企业沟通」中查看错过的消息。
);
}
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: colors.pageBg,
},
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: spacing.card,
height: 48,
backgroundColor: colors.white,
borderBottomWidth: 1,
borderBottomColor: colors.borderLight,
},
headerBtn: {
width: 40,
height: 40,
alignItems: 'center',
justifyContent: 'center',
},
headerTitle: {
flex: 1,
textAlign: 'center',
fontSize: 17,
fontWeight: '700',
color: colors.textPrimary,
},
scroll: {
flex: 1,
},
content: {
padding: spacing.card,
paddingBottom: 24,
},
stateBox: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
gap: 12,
},
stateText: {
marginTop: 12,
fontSize: 14,
color: colors.textSecondary,
},
retryBtn: {
marginTop: 16,
paddingHorizontal: 24,
paddingVertical: spacing.card,
borderRadius: 18,
backgroundColor: colors.primaryBtn,
},
retryText: {
fontSize: 13,
fontWeight: '600',
color: colors.white,
},
statCard: {
borderRadius: spacing.card,
padding: spacing.card,
alignItems: 'center',
marginBottom: 8,
},
statValue: {
fontSize: 32,
fontWeight: '800',
},
statLabel: {
marginTop: 4,
fontSize: 13,
color: colors.textSecondary,
},
section: {
marginBottom: 16,
},
sectionTitle: {
fontSize: 14,
fontWeight: '700',
color: colors.textPrimary,
marginBottom: 10,
},
card: {
backgroundColor: colors.white,
borderRadius: spacing.card,
overflow: 'hidden',
},
row: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 14,
paddingVertical: 14,
},
rowBorder: {
borderBottomWidth: 1,
borderBottomColor: colors.borderLight,
},
rowBody: {
flex: 1,
marginRight: 12,
},
rowTitle: {
fontSize: 15,
fontWeight: '600',
color: colors.textPrimary,
},
rowDesc: {
marginTop: 3,
fontSize: 12,
lineHeight: 16,
color: colors.textSecondary,
},
timeInput: {
minWidth: 64,
textAlign: 'right',
fontSize: 15,
fontWeight: '600',
color: colors.primary,
paddingVertical: 4,
paddingHorizontal: spacing.card,
},
noteCard: {
flexDirection: 'row',
alignItems: 'flex-start',
backgroundColor: colors.white,
borderRadius: spacing.card,
padding: spacing.card,
gap: 8,
},
noteText: {
flex: 1,
fontSize: 12,
lineHeight: 18,
color: colors.textSecondary,
},
});