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'; 15*5500cea7S猫头猫import TrackPlayer from '@/core/trackPlayer'; 16bf6e62f2S猫头猫 17359f51feS猫头猫const ITEM_HEIGHT = rpx(108); 18f7a931fdS猫头猫function HomeDrawer(props: any) { 19e7fa3837S猫头猫 const navigate = useNavigate(); 20bf6e62f2S猫头猫 function navigateToSetting(settingType: string) { 21e7fa3837S猫头猫 navigate(ROUTE_PATH.SETTING, { 22bf6e62f2S猫头猫 type: settingType, 23bf6e62f2S猫头猫 }); 24bf6e62f2S猫头猫 } 253ee62d1bS猫头猫 263ee62d1bS猫头猫 const basicSetting = [ 273ee62d1bS猫头猫 { 283ee62d1bS猫头猫 icon: 'cog-outline', 293ee62d1bS猫头猫 title: '基本设置', 303ee62d1bS猫头猫 onPress: () => { 313ee62d1bS猫头猫 navigateToSetting('basic'); 323ee62d1bS猫头猫 }, 333ee62d1bS猫头猫 }, 343ee62d1bS猫头猫 { 353ee62d1bS猫头猫 icon: 'language-javascript', 36b3a3a048S猫头猫 title: '插件管理', 373ee62d1bS猫头猫 onPress: () => { 383ee62d1bS猫头猫 navigateToSetting('plugin'); 393ee62d1bS猫头猫 }, 403ee62d1bS猫头猫 }, 413ee62d1bS猫头猫 { 423ee62d1bS猫头猫 icon: 'tshirt-v-outline', 433ee62d1bS猫头猫 title: '主题设置', 443ee62d1bS猫头猫 onPress: () => { 453ee62d1bS猫头猫 navigateToSetting('theme'); 463ee62d1bS猫头猫 }, 473ee62d1bS猫头猫 }, 48359f51feS猫头猫 ] as const; 49359f51feS猫头猫 50359f51feS猫头猫 const otherSetting = [ 513ee62d1bS猫头猫 { 523ee62d1bS猫头猫 icon: 'backup-restore', 533ee62d1bS猫头猫 title: '备份与恢复', 54dec7a5f8S猫头猫 onPress: () => { 55dec7a5f8S猫头猫 navigateToSetting('backup'); 56dec7a5f8S猫头猫 }, 573ee62d1bS猫头猫 }, 580cffb46aS猫头猫 { 590cffb46aS猫头猫 icon: 'information-outline', 600cffb46aS猫头猫 title: '关于', 610cffb46aS猫头猫 onPress: () => { 620cffb46aS猫头猫 navigateToSetting('about'); 630cffb46aS猫头猫 }, 640cffb46aS猫头猫 }, 653ee62d1bS猫头猫 ] as const; 663ee62d1bS猫头猫 67bf6e62f2S猫头猫 return ( 6865fc5a50S猫头猫 <> 694060c00aS猫头猫 <PageBackground /> 704060c00aS猫头猫 <DrawerContentScrollView {...[props]} style={style.scrollWrapper}> 71bf6e62f2S猫头猫 <View style={style.header}> 72dec7a5f8S猫头猫 <ThemeText fontSize="appbar" fontWeight="bold"> 73dec7a5f8S猫头猫 {DeviceInfo.getApplicationName()} 74dec7a5f8S猫头猫 </ThemeText> 75b882a19dS猫头猫 {/* <IconButton icon={'qrcode-scan'} size={rpx(36)} /> */} 76bf6e62f2S猫头猫 </View> 771119c2eaS猫头猫 <View style={style.card}> 781119c2eaS猫头猫 <ListItem withHorizonalPadding heightType="small"> 791119c2eaS猫头猫 <ListItem.ListItemText 801119c2eaS猫头猫 fontSize="subTitle" 811119c2eaS猫头猫 fontWeight="bold"> 821119c2eaS猫头猫 设置 831119c2eaS猫头猫 </ListItem.ListItemText> 841119c2eaS猫头猫 </ListItem> 853ee62d1bS猫头猫 {basicSetting.map(item => ( 86bf6e62f2S猫头猫 <ListItem 871119c2eaS猫头猫 withHorizonalPadding 88359f51feS猫头猫 key={item.title} 891119c2eaS猫头猫 onPress={item.onPress}> 901119c2eaS猫头猫 <ListItem.ListItemIcon 911119c2eaS猫头猫 icon={item.icon} 921119c2eaS猫头猫 width={rpx(48)} 93359f51feS猫头猫 /> 941119c2eaS猫头猫 <ListItem.Content title={item.title} /> 951119c2eaS猫头猫 </ListItem> 96359f51feS猫头猫 ))} 971119c2eaS猫头猫 </View> 981119c2eaS猫头猫 <View style={style.card}> 991119c2eaS猫头猫 <ListItem withHorizonalPadding heightType="small"> 1001119c2eaS猫头猫 <ListItem.ListItemText 1011119c2eaS猫头猫 fontSize="subTitle" 1021119c2eaS猫头猫 fontWeight="bold"> 1031119c2eaS猫头猫 其他 1041119c2eaS猫头猫 </ListItem.ListItemText> 1051119c2eaS猫头猫 </ListItem> 106359f51feS猫头猫 <CountDownItem /> 107359f51feS猫头猫 {otherSetting.map(item => ( 108359f51feS猫头猫 <ListItem 1091119c2eaS猫头猫 withHorizonalPadding 1103ee62d1bS猫头猫 key={item.title} 1111119c2eaS猫头猫 onPress={item.onPress}> 1121119c2eaS猫头猫 <ListItem.ListItemIcon 1131119c2eaS猫头猫 icon={item.icon} 1141119c2eaS猫头猫 width={rpx(48)} 1154060c00aS猫头猫 /> 1161119c2eaS猫头猫 <ListItem.Content title={item.title} /> 1171119c2eaS猫头猫 </ListItem> 1183ee62d1bS猫头猫 ))} 1191119c2eaS猫头猫 </View> 1201119c2eaS猫头猫 1211119c2eaS猫头猫 <Divider /> 1221119c2eaS猫头猫 <ListItem 1231119c2eaS猫头猫 withHorizonalPadding 1246bdd7a42S猫头猫 onPress={() => { 1256bdd7a42S猫头猫 // 仅安卓生效 1266bdd7a42S猫头猫 BackHandler.exitApp(); 1276bdd7a42S猫头猫 }}> 1280be848bcS猫头猫 <ListItem.ListItemIcon 1290be848bcS猫头猫 icon={'home-outline'} 1300be848bcS猫头猫 width={rpx(48)} 1310be848bcS猫头猫 /> 1326bdd7a42S猫头猫 <ListItem.Content title={'返回桌面'} /> 1336bdd7a42S猫头猫 </ListItem> 1346bdd7a42S猫头猫 <ListItem 1356bdd7a42S猫头猫 withHorizonalPadding 136e2257bd6S猫头猫 onPress={async () => { 137*5500cea7S猫头猫 await TrackPlayer.reset(); 138e2257bd6S猫头猫 NativeUtils.exitApp(); 139bf6e62f2S猫头猫 }}> 1401119c2eaS猫头猫 <ListItem.ListItemIcon icon={'power'} width={rpx(48)} /> 1411119c2eaS猫头猫 <ListItem.Content title={'退出应用'} /> 1421119c2eaS猫头猫 </ListItem> 143bf6e62f2S猫头猫 </DrawerContentScrollView> 14465fc5a50S猫头猫 </> 145bf6e62f2S猫头猫 ); 146bf6e62f2S猫头猫} 147bf6e62f2S猫头猫 148f7a931fdS猫头猫export default memo(HomeDrawer, () => true); 149f7a931fdS猫头猫 150bf6e62f2S猫头猫const style = StyleSheet.create({ 151bf6e62f2S猫头猫 wrapper: { 152bf6e62f2S猫头猫 flex: 1, 153bf6e62f2S猫头猫 backgroundColor: '#999999', 154bf6e62f2S猫头猫 }, 155bf6e62f2S猫头猫 scrollWrapper: { 156bf6e62f2S猫头猫 paddingTop: rpx(12), 157bf6e62f2S猫头猫 }, 158bf6e62f2S猫头猫 159bf6e62f2S猫头猫 header: { 16094b17902S猫头猫 height: rpx(120), 161bf6e62f2S猫头猫 width: '100%', 162bf6e62f2S猫头猫 flexDirection: 'row', 163bf6e62f2S猫头猫 justifyContent: 'space-between', 164bf6e62f2S猫头猫 alignItems: 'center', 16594b17902S猫头猫 marginLeft: rpx(24), 166bf6e62f2S猫头猫 }, 167bf6e62f2S猫头猫 card: { 168359f51feS猫头猫 marginBottom: rpx(24), 169bf6e62f2S猫头猫 }, 170dec7a5f8S猫头猫 cardContent: { 1714060c00aS猫头猫 paddingHorizontal: 0, 172dec7a5f8S猫头猫 }, 1731119c2eaS猫头猫 174359f51feS猫头猫 /** 倒计时 */ 175359f51feS猫头猫 countDownText: { 176359f51feS猫头猫 height: ITEM_HEIGHT, 177359f51feS猫头猫 textAlignVertical: 'center', 178359f51feS猫头猫 }, 179bf6e62f2S猫头猫}); 180359f51feS猫头猫 181359f51feS猫头猫function _CountDownItem() { 182359f51feS猫头猫 const countDown = useTimingClose(); 183359f51feS猫头猫 184359f51feS猫头猫 return ( 185359f51feS猫头猫 <ListItem 1861119c2eaS猫头猫 withHorizonalPadding 187359f51feS猫头猫 onPress={() => { 188359f51feS猫头猫 showPanel('TimingClose'); 1891119c2eaS猫头猫 }}> 1901119c2eaS猫头猫 <ListItem.ListItemIcon icon="timer-outline" width={rpx(48)} /> 1911119c2eaS猫头猫 <ListItem.Content title="定时关闭" /> 1921119c2eaS猫头猫 <ListItem.ListItemText position="right" fontSize="subTitle"> 193359f51feS猫头猫 {countDown ? timeformat(countDown) : ''} 1941119c2eaS猫头猫 </ListItem.ListItemText> 1951119c2eaS猫头猫 </ListItem> 196359f51feS猫头猫 ); 197359f51feS猫头猫} 198359f51feS猫头猫 199359f51feS猫头猫const CountDownItem = memo(_CountDownItem, () => true); 200