1359f51feS猫头猫import React, {memo} from 'react'; 2e2257bd6S猫头猫import {StyleSheet, View} from 'react-native'; 3bf6e62f2S猫头猫import rpx from '@/utils/rpx'; 4bf6e62f2S猫头猫import {DrawerContentScrollView} from '@react-navigation/drawer'; 5b882a19dS猫头猫import {Button, Card} from 'react-native-paper'; 619dc08ecS猫头猫import ListItem from '@/components/base/listItem'; 7e7fa3837S猫头猫import {ROUTE_PATH, useNavigate} from '@/entry/router'; 819dc08ecS猫头猫import ThemeText from '@/components/base/themeText'; 919dc08ecS猫头猫import PageBackground from '@/components/base/pageBackground'; 10c7676810S猫头猫import DeviceInfo from 'react-native-device-info'; 119cd1998bS猫头猫import NativeUtils from '@/native/utils'; 12e2257bd6S猫头猫import MusicQueue from '@/core/musicQueue'; 13359f51feS猫头猫import {useTimingClose} from '@/utils/timingClose'; 14*c15039e2S猫头猫 15359f51feS猫头猫import timeformat from '@/utils/timeformat'; 16*c15039e2S猫头猫import {showPanel} from '@/components/panels/usePanel'; 17bf6e62f2S猫头猫 18359f51feS猫头猫const ITEM_HEIGHT = rpx(108); 19f7a931fdS猫头猫function HomeDrawer(props: any) { 20e7fa3837S猫头猫 const navigate = useNavigate(); 21bf6e62f2S猫头猫 function navigateToSetting(settingType: string) { 22e7fa3837S猫头猫 navigate(ROUTE_PATH.SETTING, { 23bf6e62f2S猫头猫 type: settingType, 24bf6e62f2S猫头猫 }); 25bf6e62f2S猫头猫 } 263ee62d1bS猫头猫 273ee62d1bS猫头猫 const basicSetting = [ 283ee62d1bS猫头猫 { 293ee62d1bS猫头猫 icon: 'cog-outline', 303ee62d1bS猫头猫 title: '基本设置', 313ee62d1bS猫头猫 onPress: () => { 323ee62d1bS猫头猫 navigateToSetting('basic'); 333ee62d1bS猫头猫 }, 343ee62d1bS猫头猫 }, 353ee62d1bS猫头猫 { 363ee62d1bS猫头猫 icon: 'language-javascript', 373ee62d1bS猫头猫 title: '插件设置', 383ee62d1bS猫头猫 onPress: () => { 393ee62d1bS猫头猫 navigateToSetting('plugin'); 403ee62d1bS猫头猫 }, 413ee62d1bS猫头猫 }, 423ee62d1bS猫头猫 { 433ee62d1bS猫头猫 icon: 'tshirt-v-outline', 443ee62d1bS猫头猫 title: '主题设置', 453ee62d1bS猫头猫 onPress: () => { 463ee62d1bS猫头猫 navigateToSetting('theme'); 473ee62d1bS猫头猫 }, 483ee62d1bS猫头猫 }, 49359f51feS猫头猫 ] as const; 50359f51feS猫头猫 51359f51feS猫头猫 const otherSetting = [ 523ee62d1bS猫头猫 { 533ee62d1bS猫头猫 icon: 'backup-restore', 543ee62d1bS猫头猫 title: '备份与恢复', 55dec7a5f8S猫头猫 onPress: () => { 56dec7a5f8S猫头猫 navigateToSetting('backup'); 57dec7a5f8S猫头猫 }, 583ee62d1bS猫头猫 }, 590cffb46aS猫头猫 { 600cffb46aS猫头猫 icon: 'information-outline', 610cffb46aS猫头猫 title: '关于', 620cffb46aS猫头猫 onPress: () => { 630cffb46aS猫头猫 navigateToSetting('about'); 640cffb46aS猫头猫 }, 650cffb46aS猫头猫 }, 663ee62d1bS猫头猫 ] as const; 673ee62d1bS猫头猫 68bf6e62f2S猫头猫 return ( 6965fc5a50S猫头猫 <> 704060c00aS猫头猫 <PageBackground /> 714060c00aS猫头猫 <DrawerContentScrollView {...[props]} style={style.scrollWrapper}> 72bf6e62f2S猫头猫 <View style={style.header}> 73dec7a5f8S猫头猫 <ThemeText fontSize="appbar" fontWeight="bold"> 74dec7a5f8S猫头猫 {DeviceInfo.getApplicationName()} 75dec7a5f8S猫头猫 </ThemeText> 76b882a19dS猫头猫 {/* <IconButton icon={'qrcode-scan'} size={rpx(36)} /> */} 77bf6e62f2S猫头猫 </View> 78bf6e62f2S猫头猫 <Card style={style.card}> 79bf6e62f2S猫头猫 <Card.Title 808b51f01aS猫头猫 title={ 81dec7a5f8S猫头猫 <ThemeText fontSize="description">设置</ThemeText> 824060c00aS猫头猫 } 834060c00aS猫头猫 /> 84dec7a5f8S猫头猫 <Card.Content style={style.cardContent}> 853ee62d1bS猫头猫 {basicSetting.map(item => ( 86bf6e62f2S猫头猫 <ListItem 87359f51feS猫头猫 itemHeight={ITEM_HEIGHT} 88359f51feS猫头猫 key={item.title} 89359f51feS猫头猫 left={{ 90359f51feS猫头猫 icon: { 91359f51feS猫头猫 name: item.icon, 92359f51feS猫头猫 size: 'normal', 93359f51feS猫头猫 fontColor: 'normal', 94359f51feS猫头猫 }, 95359f51feS猫头猫 width: rpx(48), 96359f51feS猫头猫 }} 97359f51feS猫头猫 title={item.title} 98359f51feS猫头猫 onPress={item.onPress} 99359f51feS猫头猫 /> 100359f51feS猫头猫 ))} 101359f51feS猫头猫 </Card.Content> 102359f51feS猫头猫 </Card> 103359f51feS猫头猫 <Card style={style.card}> 104359f51feS猫头猫 <Card.Title 105359f51feS猫头猫 title={ 106359f51feS猫头猫 <ThemeText fontSize="description">其他</ThemeText> 107359f51feS猫头猫 } 108359f51feS猫头猫 /> 109359f51feS猫头猫 <Card.Content style={style.cardContent}> 110359f51feS猫头猫 <CountDownItem /> 111359f51feS猫头猫 {otherSetting.map(item => ( 112359f51feS猫头猫 <ListItem 113359f51feS猫头猫 itemHeight={ITEM_HEIGHT} 1143ee62d1bS猫头猫 key={item.title} 1153ee62d1bS猫头猫 left={{ 1163ee62d1bS猫头猫 icon: { 1173ee62d1bS猫头猫 name: item.icon, 1183ee62d1bS猫头猫 size: 'normal', 1193ee62d1bS猫头猫 fontColor: 'normal', 1203ee62d1bS猫头猫 }, 1213ee62d1bS猫头猫 width: rpx(48), 1223ee62d1bS猫头猫 }} 1233ee62d1bS猫头猫 title={item.title} 1244060c00aS猫头猫 onPress={item.onPress} 1254060c00aS猫头猫 /> 1263ee62d1bS猫头猫 ))} 127bf6e62f2S猫头猫 </Card.Content> 128bf6e62f2S猫头猫 </Card> 129bf6e62f2S猫头猫 <View style={style.bottom}> 130bf6e62f2S猫头猫 <Button 131e2257bd6S猫头猫 onPress={async () => { 132e2257bd6S猫头猫 await MusicQueue.reset(); 133e2257bd6S猫头猫 NativeUtils.exitApp(); 134bf6e62f2S猫头猫 }}> 135e2257bd6S猫头猫 <ThemeText>退出</ThemeText> 136bf6e62f2S猫头猫 </Button> 137bf6e62f2S猫头猫 </View> 138bf6e62f2S猫头猫 </DrawerContentScrollView> 13965fc5a50S猫头猫 </> 140bf6e62f2S猫头猫 ); 141bf6e62f2S猫头猫} 142bf6e62f2S猫头猫 143f7a931fdS猫头猫export default memo(HomeDrawer, () => true); 144f7a931fdS猫头猫 145bf6e62f2S猫头猫const style = StyleSheet.create({ 146bf6e62f2S猫头猫 wrapper: { 147bf6e62f2S猫头猫 flex: 1, 148bf6e62f2S猫头猫 backgroundColor: '#999999', 149bf6e62f2S猫头猫 }, 150bf6e62f2S猫头猫 scrollWrapper: { 151bf6e62f2S猫头猫 paddingTop: rpx(12), 152bf6e62f2S猫头猫 }, 153bf6e62f2S猫头猫 154bf6e62f2S猫头猫 header: { 15594b17902S猫头猫 height: rpx(120), 156bf6e62f2S猫头猫 width: '100%', 157bf6e62f2S猫头猫 flexDirection: 'row', 158bf6e62f2S猫头猫 justifyContent: 'space-between', 159bf6e62f2S猫头猫 alignItems: 'center', 16094b17902S猫头猫 marginLeft: rpx(24), 161bf6e62f2S猫头猫 }, 162bf6e62f2S猫头猫 card: { 163bf6e62f2S猫头猫 backgroundColor: '#eeeeee22', 164359f51feS猫头猫 marginBottom: rpx(24), 165bf6e62f2S猫头猫 }, 166dec7a5f8S猫头猫 cardContent: { 1674060c00aS猫头猫 paddingHorizontal: 0, 168dec7a5f8S猫头猫 }, 169bf6e62f2S猫头猫 bottom: { 170bf6e62f2S猫头猫 height: rpx(100), 171bf6e62f2S猫头猫 flexDirection: 'row', 172bf6e62f2S猫头猫 alignItems: 'center', 173bf6e62f2S猫头猫 justifyContent: 'flex-end', 174bf6e62f2S猫头猫 }, 175359f51feS猫头猫 /** 倒计时 */ 176359f51feS猫头猫 countDownText: { 177359f51feS猫头猫 height: ITEM_HEIGHT, 178359f51feS猫头猫 textAlignVertical: 'center', 179359f51feS猫头猫 }, 180bf6e62f2S猫头猫}); 181359f51feS猫头猫 182359f51feS猫头猫function _CountDownItem() { 183359f51feS猫头猫 const countDown = useTimingClose(); 184359f51feS猫头猫 185359f51feS猫头猫 return ( 186359f51feS猫头猫 <ListItem 187359f51feS猫头猫 title="定时关闭" 188359f51feS猫头猫 onPress={() => { 189359f51feS猫头猫 showPanel('TimingClose'); 190359f51feS猫头猫 }} 191359f51feS猫头猫 left={{ 192359f51feS猫头猫 icon: { 193359f51feS猫头猫 name: 'timer-outline', 194359f51feS猫头猫 size: 'normal', 195359f51feS猫头猫 fontColor: 'normal', 196359f51feS猫头猫 }, 197359f51feS猫头猫 width: rpx(48), 198359f51feS猫头猫 }} 199359f51feS猫头猫 itemHeight={ITEM_HEIGHT} 200359f51feS猫头猫 right={() => ( 201359f51feS猫头猫 <ThemeText style={style.countDownText} fontSize="subTitle"> 202359f51feS猫头猫 {countDown ? timeformat(countDown) : ''} 203359f51feS猫头猫 </ThemeText> 204359f51feS猫头猫 )} 205359f51feS猫头猫 /> 206359f51feS猫头猫 ); 207359f51feS猫头猫} 208359f51feS猫头猫 209359f51feS猫头猫const CountDownItem = memo(_CountDownItem, () => true); 210