1359f51feS猫头猫import React, {memo} from 'react'; 26bdd7a42S猫头猫import {StyleSheet, View, BackHandler} 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*09528755S猫头猫 { 61*09528755S猫头猫 icon: 'cellphone-key', 62*09528755S猫头猫 title: '权限管理', 63*09528755S猫头猫 onPress: () => { 64*09528755S猫头猫 navigate(ROUTE_PATH.PERMISSIONS); 65*09528755S猫头猫 }, 66*09528755S猫头猫 }, 673ee62d1bS猫头猫 ] as const; 683ee62d1bS猫头猫 69bf6e62f2S猫头猫 return ( 7065fc5a50S猫头猫 <> 714060c00aS猫头猫 <PageBackground /> 724060c00aS猫头猫 <DrawerContentScrollView {...[props]} style={style.scrollWrapper}> 73bf6e62f2S猫头猫 <View style={style.header}> 74dec7a5f8S猫头猫 <ThemeText fontSize="appbar" fontWeight="bold"> 75dec7a5f8S猫头猫 {DeviceInfo.getApplicationName()} 76dec7a5f8S猫头猫 </ThemeText> 77b882a19dS猫头猫 {/* <IconButton icon={'qrcode-scan'} size={rpx(36)} /> */} 78bf6e62f2S猫头猫 </View> 791119c2eaS猫头猫 <View style={style.card}> 80a22fe20fS猫头猫 <ListItem withHorizonalPadding heightType="smallest"> 811119c2eaS猫头猫 <ListItem.ListItemText 821119c2eaS猫头猫 fontSize="subTitle" 831119c2eaS猫头猫 fontWeight="bold"> 841119c2eaS猫头猫 设置 851119c2eaS猫头猫 </ListItem.ListItemText> 861119c2eaS猫头猫 </ListItem> 873ee62d1bS猫头猫 {basicSetting.map(item => ( 88bf6e62f2S猫头猫 <ListItem 891119c2eaS猫头猫 withHorizonalPadding 90359f51feS猫头猫 key={item.title} 911119c2eaS猫头猫 onPress={item.onPress}> 921119c2eaS猫头猫 <ListItem.ListItemIcon 931119c2eaS猫头猫 icon={item.icon} 941119c2eaS猫头猫 width={rpx(48)} 95359f51feS猫头猫 /> 961119c2eaS猫头猫 <ListItem.Content title={item.title} /> 971119c2eaS猫头猫 </ListItem> 98359f51feS猫头猫 ))} 991119c2eaS猫头猫 </View> 1001119c2eaS猫头猫 <View style={style.card}> 101a22fe20fS猫头猫 <ListItem withHorizonalPadding heightType="smallest"> 1021119c2eaS猫头猫 <ListItem.ListItemText 1031119c2eaS猫头猫 fontSize="subTitle" 1041119c2eaS猫头猫 fontWeight="bold"> 1051119c2eaS猫头猫 其他 1061119c2eaS猫头猫 </ListItem.ListItemText> 1071119c2eaS猫头猫 </ListItem> 108359f51feS猫头猫 <CountDownItem /> 109359f51feS猫头猫 {otherSetting.map(item => ( 110359f51feS猫头猫 <ListItem 1111119c2eaS猫头猫 withHorizonalPadding 1123ee62d1bS猫头猫 key={item.title} 1131119c2eaS猫头猫 onPress={item.onPress}> 1141119c2eaS猫头猫 <ListItem.ListItemIcon 1151119c2eaS猫头猫 icon={item.icon} 1161119c2eaS猫头猫 width={rpx(48)} 1174060c00aS猫头猫 /> 1181119c2eaS猫头猫 <ListItem.Content title={item.title} /> 1191119c2eaS猫头猫 </ListItem> 1203ee62d1bS猫头猫 ))} 1211119c2eaS猫头猫 </View> 1221119c2eaS猫头猫 123a22fe20fS猫头猫 <View style={style.card}> 124a22fe20fS猫头猫 <ListItem withHorizonalPadding heightType="smallest"> 125a22fe20fS猫头猫 <ListItem.ListItemText 126a22fe20fS猫头猫 fontSize="subTitle" 127a22fe20fS猫头猫 fontWeight="bold"> 128a22fe20fS猫头猫 软件 129a22fe20fS猫头猫 </ListItem.ListItemText> 130a22fe20fS猫头猫 </ListItem> 131a22fe20fS猫头猫 132a22fe20fS猫头猫 <ListItem 133a22fe20fS猫头猫 withHorizonalPadding 134a22fe20fS猫头猫 key={'update'} 135a22fe20fS猫头猫 onPress={() => { 136a22fe20fS猫头猫 checkUpdateAndShowResult(true); 137a22fe20fS猫头猫 }}> 138a22fe20fS猫头猫 <ListItem.ListItemIcon 139a22fe20fS猫头猫 icon={'update'} 140a22fe20fS猫头猫 width={rpx(48)} 141a22fe20fS猫头猫 /> 142a22fe20fS猫头猫 <ListItem.Content title="检查更新" /> 143a22fe20fS猫头猫 <ListItem.ListItemText 144a22fe20fS猫头猫 position="right" 145a22fe20fS猫头猫 fontSize="subTitle"> 1466f57784cS猫头猫 {`当前版本: ${deviceInfoModule.getVersion()}`} 147a22fe20fS猫头猫 </ListItem.ListItemText> 148a22fe20fS猫头猫 </ListItem> 149a22fe20fS猫头猫 <ListItem 150a22fe20fS猫头猫 withHorizonalPadding 151a22fe20fS猫头猫 key={'about'} 152a22fe20fS猫头猫 onPress={() => { 153a22fe20fS猫头猫 navigateToSetting('about'); 154a22fe20fS猫头猫 }}> 155a22fe20fS猫头猫 <ListItem.ListItemIcon 156a22fe20fS猫头猫 icon={'information-outline'} 157a22fe20fS猫头猫 width={rpx(48)} 158a22fe20fS猫头猫 /> 159a22fe20fS猫头猫 <ListItem.Content 160a22fe20fS猫头猫 title={`关于 ${deviceInfoModule.getApplicationName()}`} 161a22fe20fS猫头猫 /> 162a22fe20fS猫头猫 </ListItem> 163a22fe20fS猫头猫 </View> 164a22fe20fS猫头猫 1651119c2eaS猫头猫 <Divider /> 1661119c2eaS猫头猫 <ListItem 1671119c2eaS猫头猫 withHorizonalPadding 1686bdd7a42S猫头猫 onPress={() => { 1696bdd7a42S猫头猫 // 仅安卓生效 1706bdd7a42S猫头猫 BackHandler.exitApp(); 1716bdd7a42S猫头猫 }}> 1720be848bcS猫头猫 <ListItem.ListItemIcon 1730be848bcS猫头猫 icon={'home-outline'} 1740be848bcS猫头猫 width={rpx(48)} 1750be848bcS猫头猫 /> 1766bdd7a42S猫头猫 <ListItem.Content title={'返回桌面'} /> 1776bdd7a42S猫头猫 </ListItem> 1786bdd7a42S猫头猫 <ListItem 1796bdd7a42S猫头猫 withHorizonalPadding 180e2257bd6S猫头猫 onPress={async () => { 1815500cea7S猫头猫 await TrackPlayer.reset(); 182e2257bd6S猫头猫 NativeUtils.exitApp(); 183bf6e62f2S猫头猫 }}> 1841119c2eaS猫头猫 <ListItem.ListItemIcon icon={'power'} width={rpx(48)} /> 1851119c2eaS猫头猫 <ListItem.Content title={'退出应用'} /> 1861119c2eaS猫头猫 </ListItem> 187bf6e62f2S猫头猫 </DrawerContentScrollView> 18865fc5a50S猫头猫 </> 189bf6e62f2S猫头猫 ); 190bf6e62f2S猫头猫} 191bf6e62f2S猫头猫 192f7a931fdS猫头猫export default memo(HomeDrawer, () => true); 193f7a931fdS猫头猫 194bf6e62f2S猫头猫const style = StyleSheet.create({ 195bf6e62f2S猫头猫 wrapper: { 196bf6e62f2S猫头猫 flex: 1, 197bf6e62f2S猫头猫 backgroundColor: '#999999', 198bf6e62f2S猫头猫 }, 199bf6e62f2S猫头猫 scrollWrapper: { 200bf6e62f2S猫头猫 paddingTop: rpx(12), 201bf6e62f2S猫头猫 }, 202bf6e62f2S猫头猫 203bf6e62f2S猫头猫 header: { 20494b17902S猫头猫 height: rpx(120), 205bf6e62f2S猫头猫 width: '100%', 206bf6e62f2S猫头猫 flexDirection: 'row', 207bf6e62f2S猫头猫 justifyContent: 'space-between', 208bf6e62f2S猫头猫 alignItems: 'center', 20994b17902S猫头猫 marginLeft: rpx(24), 210bf6e62f2S猫头猫 }, 211bf6e62f2S猫头猫 card: { 212359f51feS猫头猫 marginBottom: rpx(24), 213bf6e62f2S猫头猫 }, 214dec7a5f8S猫头猫 cardContent: { 2154060c00aS猫头猫 paddingHorizontal: 0, 216dec7a5f8S猫头猫 }, 2171119c2eaS猫头猫 218359f51feS猫头猫 /** 倒计时 */ 219359f51feS猫头猫 countDownText: { 220359f51feS猫头猫 height: ITEM_HEIGHT, 221359f51feS猫头猫 textAlignVertical: 'center', 222359f51feS猫头猫 }, 223bf6e62f2S猫头猫}); 224359f51feS猫头猫 225359f51feS猫头猫function _CountDownItem() { 226359f51feS猫头猫 const countDown = useTimingClose(); 227359f51feS猫头猫 228359f51feS猫头猫 return ( 229359f51feS猫头猫 <ListItem 2301119c2eaS猫头猫 withHorizonalPadding 231359f51feS猫头猫 onPress={() => { 232359f51feS猫头猫 showPanel('TimingClose'); 2331119c2eaS猫头猫 }}> 2341119c2eaS猫头猫 <ListItem.ListItemIcon icon="timer-outline" width={rpx(48)} /> 2351119c2eaS猫头猫 <ListItem.Content title="定时关闭" /> 2361119c2eaS猫头猫 <ListItem.ListItemText position="right" fontSize="subTitle"> 237359f51feS猫头猫 {countDown ? timeformat(countDown) : ''} 2381119c2eaS猫头猫 </ListItem.ListItemText> 2391119c2eaS猫头猫 </ListItem> 240359f51feS猫头猫 ); 241359f51feS猫头猫} 242359f51feS猫头猫 243359f51feS猫头猫const CountDownItem = memo(_CountDownItem, () => true); 244