import React, { useState } from 'react'; import { IcNavBack } from '../res/icons'; import { useMapGestures } from '../hooks/useMapGestures'; import { useMapBackHandler } from '../hooks/useMapBackHandler'; import { useMapStore } from '../state'; import { useMapStrings } from '../hooks/useMapStrings'; import { localizeMapSettingValue } from '../utils/localizeMapValue'; export const AppDisplayPage: React.FC = () => { const { bindBack, go } = useMapGestures(); const appDisplay = useMapStore((s) => s.settings.appDisplay); const updateAppDisplay = useMapStore((s) => s.updateAppDisplay); const s = useMapStrings(); const [showThemeModal, setShowThemeModal] = useState(false); const [showDistanceModal, setShowDistanceModal] = useState(false); const [showScaleModal, setShowScaleModal] = useState(false); const [showVideoModal, setShowVideoModal] = useState(false); const [tempTheme, setTempTheme] = useState(appDisplay.theme); const [tempVideo, setTempVideo] = useState(appDisplay.videoAutoplay); useMapBackHandler( () => { setShowThemeModal(false); return true; }, { enabled: showThemeModal, priority: 920, scope: 'any' }, ); useMapBackHandler( () => { setShowDistanceModal(false); return true; }, { enabled: showDistanceModal, priority: 920, scope: 'any' }, ); useMapBackHandler( () => { setShowScaleModal(false); return true; }, { enabled: showScaleModal, priority: 920, scope: 'any' }, ); useMapBackHandler( () => { setShowVideoModal(false); return true; }, { enabled: showVideoModal, priority: 920, scope: 'any' }, ); const handleThemeSave = () => { updateAppDisplay('theme', tempTheme); setShowThemeModal(false); }; const handleVideoSave = () => { updateAppDisplay('videoAutoplay', tempVideo); setShowVideoModal(false); }; const handleDistanceSelect = (v: string) => { updateAppDisplay('distanceUnit', v); setShowDistanceModal(false); }; const handleScaleSelect = (v: string) => { updateAppDisplay('scaleBar', v); setShowScaleModal(false); }; const themeOptions = [ { value: '始终采用浅色主题', label: s.theme_light }, { value: '始终采用深色主题', label: s.theme_dark }, { value: '与设备主题背景一致', label: s.theme_device }, ] as const; const distanceOptions = [ { value: '自动', label: s.distance_unit_auto }, { value: '公里', label: s.distance_unit_km }, { value: '英里', label: s.distance_unit_miles }, ] as const; const scaleOptions = [ { value: '缩放时', label: s.scale_bar_on_zoom }, { value: '始终', label: s.scale_bar_always }, ] as const; const videoOptions = [ { value: '自动播放功能已关闭', label: s.video_autoplay_off }, { value: '始终开启自动播放功能', label: s.video_autoplay_always }, { value: '仅在连接到 Wi-Fi 时自动播放', label: s.video_autoplay_wifi }, ] as const; const RadioOption: React.FC<{ label: string; selected: boolean; onSelect: () => void; }> = ({ label, selected, onSelect }) => (