1359f51feS猫头猫import React, {memo} from 'react'; 2*13cebe63S猫头猫import {StyleSheet, View, BackHandler, Platform} from 'react-native'; 3bf6e62f2S猫头猫import rpx from '@/utils/rpx'; 4bf6e62f2S猫头猫import {DrawerContentScrollView} from '@react-navigation/drawer'; 51119c2eaS猫头猫import ListItem from '@/components/base/listItem'; 6e7fa3837S猫头猫import {ROUTE_PATH, useNavigate} from '@/entry/router'; 719dc08ecS猫头猫import ThemeText from '@/components/base/themeText'; 819dc08ecS猫头猫import PageBackground from '@/components/base/pageBackground'; 9c7676810S猫头猫import DeviceInfo from 'react-native-device-info'; 109cd1998bS猫头猫import NativeUtils from '@/native/utils'; 11359f51feS猫头猫import {useTimingClose} from '@/utils/timingClose'; 12359f51feS猫头猫import timeformat from '@/utils/timeformat'; 13c15039e2S猫头猫import {showPanel} from '@/components/panels/usePanel'; 141119c2eaS猫头猫import Divider from '@/components/base/divider'; 155500cea7S猫头猫import TrackPlayer from '@/core/trackPlayer'; 16a22fe20fS猫头猫import deviceInfoModule from 'react-native-device-info'; 17a22fe20fS猫头猫import {checkUpdateAndShowResult} from '@/hooks/useCheckUpdate'; 18bf6e62f2S猫头猫 19359f51feS猫头猫const ITEM_HEIGHT = rpx(108); 20f7a931fdS猫头猫function HomeDrawer(props: any) { 21e7fa3837S猫头猫 const navigate = useNavigate(); 22bf6e62f2S猫头猫 function navigateToSetting(settingType: string) { 23e7fa3837S猫头猫 navigate(ROUTE_PATH.SETTING, { 24bf6e62f2S猫头猫 type: settingType, 25bf6e62f2S猫头猫 }); 26bf6e62f2S猫头猫 } 273ee62d1bS猫头猫 283ee62d1bS猫头猫 const basicSetting = [ 293ee62d1bS猫头猫 { 303ee62d1bS猫头猫 icon: 'cog-outline', 313ee62d1bS猫头猫 title: '基本设置', 323ee62d1bS猫头猫 onPress: () => { 333ee62d1bS猫头猫 navigateToSetting('basic'); 343ee62d1bS猫头猫 }, 353ee62d1bS猫头猫 }, 363ee62d1bS猫头猫 { 373ee62d1bS猫头猫 icon: 'language-javascript', 38b3a3a048S猫头猫 title: '插件管理', 393ee62d1bS猫头猫 onPress: () => { 403ee62d1bS猫头猫 navigateToSetting('plugin'); 413ee62d1bS猫头猫 }, 423ee62d1bS猫头猫 }, 433ee62d1bS猫头猫 { 443ee62d1bS猫头猫 icon: 'tshirt-v-outline', 453ee62d1bS猫头猫 title: '主题设置', 463ee62d1bS猫头猫 onPress: () => { 473ee62d1bS猫头猫 navigateToSetting('theme'); 483ee62d1bS猫头猫 }, 493ee62d1bS猫头猫 }, 50359f51feS猫头猫 ] as const; 51359f51feS猫头猫 52359f51feS猫头猫 const otherSetting = [ 533ee62d1bS猫头猫 { 543ee62d1bS猫头猫 icon: 'backup-restore', 553ee62d1bS猫头猫 title: '备份与恢复', 56dec7a5f8S猫头猫 onPress: () => { 57dec7a5f8S猫头猫 navigateToSetting('backup'); 58dec7a5f8S猫头猫 }, 593ee62d1bS猫头猫 }, 60*13cebe63S猫头猫 ]; 61*13cebe63S猫头猫 62*13cebe63S猫头猫 if (Platform.OS === 'android') { 63*13cebe63S猫头猫 otherSetting.push({ 6409528755S猫头猫 icon: 'cellphone-key', 6509528755S猫头猫 title: '权限管理', 6609528755S猫头猫 onPress: () => { 6709528755S猫头猫 navigate(ROUTE_PATH.PERMISSIONS); 6809528755S猫头猫 }, 69*13cebe63S猫头猫 }); 70*13cebe63S猫头猫 } 713ee62d1bS猫头猫 72bf6e62f2S猫头猫 return ( 7365fc5a50S猫头猫 <> 744060c00aS猫头猫 <PageBackground /> 754060c00aS猫头猫 <DrawerContentScrollView {...[props]} style={style.scrollWrapper}> 76bf6e62f2S猫头猫 <View style={style.header}> 77dec7a5f8S猫头猫 <ThemeText fontSize="appbar" fontWeight="bold"> 78dec7a5f8S猫头猫 {DeviceInfo.getApplicationName()} 79dec7a5f8S猫头猫 </ThemeText> 80b882a19dS猫头猫 {/* <IconButton icon={'qrcode-scan'} size={rpx(36)} /> */} 81bf6e62f2S猫头猫 </View> 821119c2eaS猫头猫 <View style={style.card}> 83a22fe20fS猫头猫 <ListItem withHorizonalPadding heightType="smallest"> 841119c2eaS猫头猫 <ListItem.ListItemText 851119c2eaS猫头猫 fontSize="subTitle" 861119c2eaS猫头猫 fontWeight="bold"> 871119c2eaS猫头猫 设置 881119c2eaS猫头猫 </ListItem.ListItemText> 891119c2eaS猫头猫 </ListItem> 903ee62d1bS猫头猫 {basicSetting.map(item => ( 91bf6e62f2S猫头猫 <ListItem 921119c2eaS猫头猫 withHorizonalPadding 93359f51feS猫头猫 key={item.title} 941119c2eaS猫头猫 onPress={item.onPress}> 951119c2eaS猫头猫 <ListItem.ListItemIcon 961119c2eaS猫头猫 icon={item.icon} 971119c2eaS猫头猫 width={rpx(48)} 98359f51feS猫头猫 /> 991119c2eaS猫头猫 <ListItem.Content title={item.title} /> 1001119c2eaS猫头猫 </ListItem> 101359f51feS猫头猫 ))} 1021119c2eaS猫头猫 </View> 1031119c2eaS猫头猫 <View style={style.card}> 104a22fe20fS猫头猫 <ListItem withHorizonalPadding heightType="smallest"> 1051119c2eaS猫头猫 <ListItem.ListItemText 1061119c2eaS猫头猫 fontSize="subTitle" 1071119c2eaS猫头猫 fontWeight="bold"> 1081119c2eaS猫头猫 其他 1091119c2eaS猫头猫 </ListItem.ListItemText> 1101119c2eaS猫头猫 </ListItem> 111359f51feS猫头猫 <CountDownItem /> 112359f51feS猫头猫 {otherSetting.map(item => ( 113359f51feS猫头猫 <ListItem 1141119c2eaS猫头猫 withHorizonalPadding 1153ee62d1bS猫头猫 key={item.title} 1161119c2eaS猫头猫 onPress={item.onPress}> 1171119c2eaS猫头猫 <ListItem.ListItemIcon 1181119c2eaS猫头猫 icon={item.icon} 1191119c2eaS猫头猫 width={rpx(48)} 1204060c00aS猫头猫 /> 1211119c2eaS猫头猫 <ListItem.Content title={item.title} /> 1221119c2eaS猫头猫 </ListItem> 1233ee62d1bS猫头猫 ))} 1241119c2eaS猫头猫 </View> 1251119c2eaS猫头猫 126a22fe20fS猫头猫 <View style={style.card}> 127a22fe20fS猫头猫 <ListItem withHorizonalPadding heightType="smallest"> 128a22fe20fS猫头猫 <ListItem.ListItemText 129a22fe20fS猫头猫 fontSize="subTitle" 130a22fe20fS猫头猫 fontWeight="bold"> 131a22fe20fS猫头猫 软件 132a22fe20fS猫头猫 </ListItem.ListItemText> 133a22fe20fS猫头猫 </ListItem> 134a22fe20fS猫头猫 135a22fe20fS猫头猫 <ListItem 136a22fe20fS猫头猫 withHorizonalPadding 137a22fe20fS猫头猫 key={'update'} 138a22fe20fS猫头猫 onPress={() => { 139a22fe20fS猫头猫 checkUpdateAndShowResult(true); 140a22fe20fS猫头猫 }}> 141a22fe20fS猫头猫 <ListItem.ListItemIcon 142a22fe20fS猫头猫 icon={'update'} 143a22fe20fS猫头猫 width={rpx(48)} 144a22fe20fS猫头猫 /> 145a22fe20fS猫头猫 <ListItem.Content title="检查更新" /> 146a22fe20fS猫头猫 <ListItem.ListItemText 147a22fe20fS猫头猫 position="right" 148a22fe20fS猫头猫 fontSize="subTitle"> 1496f57784cS猫头猫 {`当前版本: ${deviceInfoModule.getVersion()}`} 150a22fe20fS猫头猫 </ListItem.ListItemText> 151a22fe20fS猫头猫 </ListItem> 152a22fe20fS猫头猫 <ListItem 153a22fe20fS猫头猫 withHorizonalPadding 154a22fe20fS猫头猫 key={'about'} 155a22fe20fS猫头猫 onPress={() => { 156a22fe20fS猫头猫 navigateToSetting('about'); 157a22fe20fS猫头猫 }}> 158a22fe20fS猫头猫 <ListItem.ListItemIcon 159a22fe20fS猫头猫 icon={'information-outline'} 160a22fe20fS猫头猫 width={rpx(48)} 161a22fe20fS猫头猫 /> 162a22fe20fS猫头猫 <ListItem.Content 163a22fe20fS猫头猫 title={`关于 ${deviceInfoModule.getApplicationName()}`} 164a22fe20fS猫头猫 /> 165a22fe20fS猫头猫 </ListItem> 166a22fe20fS猫头猫 </View> 167a22fe20fS猫头猫 1681119c2eaS猫头猫 <Divider /> 1691119c2eaS猫头猫 <ListItem 1701119c2eaS猫头猫 withHorizonalPadding 1716bdd7a42S猫头猫 onPress={() => { 1726bdd7a42S猫头猫 // 仅安卓生效 1736bdd7a42S猫头猫 BackHandler.exitApp(); 1746bdd7a42S猫头猫 }}> 1750be848bcS猫头猫 <ListItem.ListItemIcon 1760be848bcS猫头猫 icon={'home-outline'} 1770be848bcS猫头猫 width={rpx(48)} 1780be848bcS猫头猫 /> 1796bdd7a42S猫头猫 <ListItem.Content title={'返回桌面'} /> 1806bdd7a42S猫头猫 </ListItem> 1816bdd7a42S猫头猫 <ListItem 1826bdd7a42S猫头猫 withHorizonalPadding 183e2257bd6S猫头猫 onPress={async () => { 1845500cea7S猫头猫 await TrackPlayer.reset(); 185e2257bd6S猫头猫 NativeUtils.exitApp(); 186bf6e62f2S猫头猫 }}> 1871119c2eaS猫头猫 <ListItem.ListItemIcon icon={'power'} width={rpx(48)} /> 1881119c2eaS猫头猫 <ListItem.Content title={'退出应用'} /> 1891119c2eaS猫头猫 </ListItem> 190bf6e62f2S猫头猫 </DrawerContentScrollView> 19165fc5a50S猫头猫 </> 192bf6e62f2S猫头猫 ); 193bf6e62f2S猫头猫} 194bf6e62f2S猫头猫 195f7a931fdS猫头猫export default memo(HomeDrawer, () => true); 196f7a931fdS猫头猫 197bf6e62f2S猫头猫const style = StyleSheet.create({ 198bf6e62f2S猫头猫 wrapper: { 199bf6e62f2S猫头猫 flex: 1, 200bf6e62f2S猫头猫 backgroundColor: '#999999', 201bf6e62f2S猫头猫 }, 202bf6e62f2S猫头猫 scrollWrapper: { 203bf6e62f2S猫头猫 paddingTop: rpx(12), 204bf6e62f2S猫头猫 }, 205bf6e62f2S猫头猫 206bf6e62f2S猫头猫 header: { 20794b17902S猫头猫 height: rpx(120), 208bf6e62f2S猫头猫 width: '100%', 209bf6e62f2S猫头猫 flexDirection: 'row', 210bf6e62f2S猫头猫 justifyContent: 'space-between', 211bf6e62f2S猫头猫 alignItems: 'center', 21294b17902S猫头猫 marginLeft: rpx(24), 213bf6e62f2S猫头猫 }, 214bf6e62f2S猫头猫 card: { 215359f51feS猫头猫 marginBottom: rpx(24), 216bf6e62f2S猫头猫 }, 217dec7a5f8S猫头猫 cardContent: { 2184060c00aS猫头猫 paddingHorizontal: 0, 219dec7a5f8S猫头猫 }, 2201119c2eaS猫头猫 221359f51feS猫头猫 /** 倒计时 */ 222359f51feS猫头猫 countDownText: { 223359f51feS猫头猫 height: ITEM_HEIGHT, 224359f51feS猫头猫 textAlignVertical: 'center', 225359f51feS猫头猫 }, 226bf6e62f2S猫头猫}); 227359f51feS猫头猫 228359f51feS猫头猫function _CountDownItem() { 229359f51feS猫头猫 const countDown = useTimingClose(); 230359f51feS猫头猫 231359f51feS猫头猫 return ( 232359f51feS猫头猫 <ListItem 2331119c2eaS猫头猫 withHorizonalPadding 234359f51feS猫头猫 onPress={() => { 235359f51feS猫头猫 showPanel('TimingClose'); 2361119c2eaS猫头猫 }}> 2371119c2eaS猫头猫 <ListItem.ListItemIcon icon="timer-outline" width={rpx(48)} /> 2381119c2eaS猫头猫 <ListItem.Content title="定时关闭" /> 2391119c2eaS猫头猫 <ListItem.ListItemText position="right" fontSize="subTitle"> 240359f51feS猫头猫 {countDown ? timeformat(countDown) : ''} 2411119c2eaS猫头猫 </ListItem.ListItemText> 2421119c2eaS猫头猫 </ListItem> 243359f51feS猫头猫 ); 244359f51feS猫头猫} 245359f51feS猫头猫 246359f51feS猫头猫const CountDownItem = memo(_CountDownItem, () => true); 247