调整播放栏布局

This commit is contained in:
lyswhut 2021-12-21 13:04:37 +08:00
parent 4bc78fd840
commit 47a169e7f5
11 changed files with 119 additions and 62 deletions

View File

@ -12,6 +12,8 @@
- 支持PC端同步功能添加对列表顺序调整的控制确保手动调整位置后的列表与不同的电脑同步时列表位置不会被还原 - 支持PC端同步功能添加对列表顺序调整的控制确保手动调整位置后的列表与不同的电脑同步时列表位置不会被还原
- 调整横屏下的导航栏、播放详情页布局,提高屏幕空间利用率并使其更易操作 - 调整横屏下的导航栏、播放详情页布局,提高屏幕空间利用率并使其更易操作
- 调整歌单类别、我的列表弹出层界面 - 调整歌单类别、我的列表弹出层界面
- 播放栏移除上一曲按钮,将多出来的空间加给播放、下一曲按钮
- 现在点击、长按播放栏歌曲标题也可以进入详情页、定位当前播放歌曲了
### 修复 ### 修复

View File

@ -34,7 +34,7 @@ const Header = ({ componentId }) => {
const theme = useGetter('common', 'theme') const theme = useGetter('common', 'theme')
return ( return (
<View style={{ ...styles.container, borderRightColor: theme.borderColor }}> <View style={{ ...styles.container, borderRightColor: theme.borderColor, backgroundColor: theme.primary }}>
{/* <View style={styles.left}> */} {/* <View style={styles.left}> */}
{menus.map((item, index) => <HeaderItem info={item} index={index} key={item.id} onPress={setNavActiveIndex} />)} {menus.map((item, index) => <HeaderItem info={item} index={index} key={item.id} onPress={setNavActiveIndex} />)}
{/* </View> {/* </View>

View File

@ -200,7 +200,7 @@ const styles = StyleSheet.create({
container: { container: {
flexGrow: 1, flexGrow: 1,
flexShrink: 1, flexShrink: 1,
backgroundColor: '#fff', // backgroundColor: '#fff',
}, },
pagerView: { pagerView: {
flex: 1, flex: 1,

View File

@ -8,7 +8,7 @@ import { STATUS } from '@/store/modules/player'
export default () => { export default () => {
const playStatus = useGetter('player', 'status') const playStatus = useGetter('player', 'status')
const playNext = useDispatch('player', 'playNext') const playNext = useDispatch('player', 'playNext')
const playPrev = useDispatch('player', 'playPrev') // const playPrev = useDispatch('player', 'playPrev')
// const playMusicInfo = useGetter('player', 'playMusicInfo') // const playMusicInfo = useGetter('player', 'playMusicInfo')
const pauseMusic = useDispatch('player', 'pauseMusic') const pauseMusic = useDispatch('player', 'pauseMusic')
const playMusic = useDispatch('player', 'playMusic') const playMusic = useDispatch('player', 'playMusic')
@ -22,11 +22,11 @@ export default () => {
// setPlayNextMode(playNextModes[index] || '') // setPlayNextMode(playNextModes[index] || '')
// }, [setPlayNextMode, togglePlayMethod, playNextModes]) // }, [setPlayNextMode, togglePlayMethod, playNextModes])
const btnPrev = useMemo(() => ( // const btnPrev = useMemo(() => (
<TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playPrev}> // <TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playPrev}>
<Icon name='prevMusic' style={{ color: theme.secondary10 }} size={20} /> // <Icon name='prevMusic' style={{ color: theme.secondary10 }} size={20} />
</TouchableOpacity> // </TouchableOpacity>
), [playPrev, theme]) // ), [playPrev, theme])
const togglePlay = useCallback(playStatus => { const togglePlay = useCallback(playStatus => {
switch (playStatus) { switch (playStatus) {
@ -45,12 +45,12 @@ export default () => {
}, []) }, [])
const btnPlay = useMemo(() => ( const btnPlay = useMemo(() => (
<TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={() => togglePlay(playStatus)}> <TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={() => togglePlay(playStatus)}>
<Icon name={playStatus == STATUS.playing ? 'pause' : 'play'} style={{ color: theme.secondary10 }} size={20} /> <Icon name={playStatus == STATUS.playing ? 'pause' : 'play'} style={{ color: theme.secondary10 }} size={24} />
</TouchableOpacity> </TouchableOpacity>
), [playStatus, theme, togglePlay]) ), [playStatus, theme, togglePlay])
const btnNext = useMemo(() => ( const btnNext = useMemo(() => (
<TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playNext}> <TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playNext}>
<Icon name='nextMusic' style={{ color: theme.secondary10 }} size={20} /> <Icon name='nextMusic' style={{ color: theme.secondary10 }} size={24} />
</TouchableOpacity> </TouchableOpacity>
), [playNext, theme]) ), [playNext, theme])
@ -62,7 +62,7 @@ export default () => {
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
*/} */}
{btnPrev} {/* {btnPrev} */}
{btnPlay} {btnPlay}
{btnNext} {btnNext}
</> </>
@ -72,8 +72,8 @@ export default () => {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
cotrolBtn: { cotrolBtn: {
width: 32, width: 50,
height: 32, height: 50,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',

View File

@ -1,18 +1,52 @@
import React, { useCallback, memo, useMemo, useEffect } from 'react' import React, { useCallback, memo, useMemo, useEffect } from 'react'
import { Text, StyleSheet } from 'react-native' import { Text, StyleSheet, TouchableOpacity } from 'react-native'
import { useGetter, useDispatch } from '@/store' import { useGetter, useDispatch } from '@/store'
import { navigations } from '@/navigation'
import { LIST_ID_PLAY_TEMP, LIST_ID_PLAY_LATER, NAV_VIEW_NAMES } from '@/config/constant'
export default () => { export default () => {
const theme = useGetter('common', 'theme')
const downloadFileName = useGetter('common', 'downloadFileName')
const playMusicInfo = useGetter('player', 'playMusicInfo') const playMusicInfo = useGetter('player', 'playMusicInfo')
const theme = useGetter('common', 'theme')
const setNavActiveIndex = useDispatch('common', 'setNavActiveIndex')
const setPrevSelectListId = useDispatch('common', 'setPrevSelectListId')
const setJumpPosition = useDispatch('list', 'setJumpPosition')
// const { t } = useTranslation()
const componentIds = useGetter('common', 'componentIds')
const musicInfo = useMemo(() => {
return (playMusicInfo && playMusicInfo.musicInfo) || {}
}, [playMusicInfo])
const handlePress = useCallback(() => {
// console.log('')
// console.log(playMusicInfo)
if (!playMusicInfo) return
navigations.pushPlayDetailScreen(componentIds.home, musicInfo.songmid)
// toast(t('play_detail_todo_tip'), 'long')
}, [componentIds.home, musicInfo, playMusicInfo])
const handleLongPress = useCallback(() => {
if (!playMusicInfo || playMusicInfo.listId == LIST_ID_PLAY_TEMP || playMusicInfo.listId == LIST_ID_PLAY_LATER) return
setNavActiveIndex(NAV_VIEW_NAMES.list)
setPrevSelectListId(playMusicInfo.listId)
global.requestAnimationFrame(() => {
setJumpPosition(true)
})
}, [playMusicInfo, setJumpPosition, setNavActiveIndex, setPrevSelectListId])
const downloadFileName = useGetter('common', 'downloadFileName')
const title = useMemo(() => {
let title = '^-^' let title = '^-^'
if (playMusicInfo && playMusicInfo.musicInfo) { if (playMusicInfo && playMusicInfo.musicInfo) {
title = downloadFileName.replace('歌手', playMusicInfo.musicInfo.singer).replace('歌名', playMusicInfo.musicInfo.name) title = downloadFileName.replace('歌手', playMusicInfo.musicInfo.singer).replace('歌名', playMusicInfo.musicInfo.name)
} }
return title
}, [downloadFileName, playMusicInfo])
// console.log(playMusicInfo) // console.log(playMusicInfo)
return <Text style={{ width: '100%', fontSize: 14, color: theme.normal }} numberOfLines={1}>{title}</Text> return (
<TouchableOpacity onLongPress={handleLongPress} onPress={handlePress} activeOpacity={0.7} >
<Text style={{ width: '100%', fontSize: 14, color: theme.normal }} numberOfLines={1}>{title}</Text>
</TouchableOpacity>
)
} }
// const Singer = () => { // const Singer = () => {
// const playMusicInfo = useGetter('player', 'playMusicInfo') // const playMusicInfo = useGetter('player', 'playMusicInfo')

View File

@ -18,7 +18,7 @@ export default memo(() => {
const playerComponent = useMemo(() => ( const playerComponent = useMemo(() => (
<View style={{ ...styles.container, backgroundColor: theme.primary, borderTopColor: theme.secondary10 }}> <View style={{ ...styles.container, backgroundColor: theme.primary }}>
<View style={styles.left} elevation={1}><Pic /></View> <View style={styles.left} elevation={1}><Pic /></View>
<View style={styles.center}> <View style={styles.center}>
<View style={{ ...styles.row, justifyContent: 'space-between', fontSize: 12 }}> <View style={{ ...styles.row, justifyContent: 'space-between', fontSize: 12 }}>
@ -45,14 +45,17 @@ const styles = StyleSheet.create({
// paddingTop: progressContentPadding, // paddingTop: progressContentPadding,
// marginTop: -progressContentPadding, // marginTop: -progressContentPadding,
// backgroundColor: 'rgba(0, 0, 0, .1)', // backgroundColor: 'rgba(0, 0, 0, .1)',
borderTopWidth: BorderWidths.normal2, // borderTopWidth: BorderWidths.normal2,
paddingTop: 5, paddingTop: 5,
paddingBottom: 5, paddingBottom: 5,
paddingLeft: 5, paddingLeft: 5,
// backgroundColor: AppColors.primary, // backgroundColor: AppColors.primary,
// backgroundColor: 'red', // backgroundColor: 'red',
borderTopLeftRadius: 6,
borderTopRightRadius: 6,
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
elevation: 10,
}, },
left: { left: {
borderRadius: 3, borderRadius: 3,

View File

@ -23,7 +23,7 @@ const Landscape = (props) => {
<StatusBar backgroundColor="rgba(0,0,0,0)" barStyle="dark-content" translucent={true} /> <StatusBar backgroundColor="rgba(0,0,0,0)" barStyle="dark-content" translucent={true} />
<View style={{ ...styles.container, backgroundColor: props.theme.primary }}> <View style={{ ...styles.container, backgroundColor: props.theme.primary }}>
<HeaderLandscape componentId={props.componentId} /> <HeaderLandscape componentId={props.componentId} />
<View style={{ flex: 1, flexDirection: 'column', height: '100%' }}> <View style={{ flex: 1, flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
{/* <Aside /> */} {/* <Aside /> */}
<Main /> <Main />
<FooterPlayer /> <FooterPlayer />

View File

@ -8,7 +8,7 @@ import { STATUS } from '@/store/modules/player'
export default () => { export default () => {
const playStatus = useGetter('player', 'status') const playStatus = useGetter('player', 'status')
const playNext = useDispatch('player', 'playNext') const playNext = useDispatch('player', 'playNext')
const playPrev = useDispatch('player', 'playPrev') // const playPrev = useDispatch('player', 'playPrev')
// const playMusicInfo = useGetter('player', 'playMusicInfo') // const playMusicInfo = useGetter('player', 'playMusicInfo')
const pauseMusic = useDispatch('player', 'pauseMusic') const pauseMusic = useDispatch('player', 'pauseMusic')
const playMusic = useDispatch('player', 'playMusic') const playMusic = useDispatch('player', 'playMusic')
@ -22,11 +22,11 @@ export default () => {
// setPlayNextMode(playNextModes[index] || '') // setPlayNextMode(playNextModes[index] || '')
// }, [setPlayNextMode, togglePlayMethod, playNextModes]) // }, [setPlayNextMode, togglePlayMethod, playNextModes])
const btnPrev = useMemo(() => ( // const btnPrev = useMemo(() => (
<TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playPrev}> // <TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playPrev}>
<Icon name='prevMusic' style={{ color: theme.secondary10 }} size={20} /> // <Icon name='prevMusic' style={{ color: theme.secondary10 }} size={20} />
</TouchableOpacity> // </TouchableOpacity>
), [playPrev, theme]) // ), [playPrev, theme])
const togglePlay = useCallback(playStatus => { const togglePlay = useCallback(playStatus => {
switch (playStatus) { switch (playStatus) {
@ -45,12 +45,12 @@ export default () => {
}, []) }, [])
const btnPlay = useMemo(() => ( const btnPlay = useMemo(() => (
<TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={() => togglePlay(playStatus)}> <TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={() => togglePlay(playStatus)}>
<Icon name={playStatus == STATUS.playing ? 'pause' : 'play'} style={{ color: theme.secondary10 }} size={20} /> <Icon name={playStatus == STATUS.playing ? 'pause' : 'play'} style={{ color: theme.secondary10 }} size={24} />
</TouchableOpacity> </TouchableOpacity>
), [playStatus, theme, togglePlay]) ), [playStatus, theme, togglePlay])
const btnNext = useMemo(() => ( const btnNext = useMemo(() => (
<TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playNext}> <TouchableOpacity style={{ ...styles.cotrolBtn }} activeOpacity={0.5} onPress={playNext}>
<Icon name='nextMusic' style={{ color: theme.secondary10 }} size={20} /> <Icon name='nextMusic' style={{ color: theme.secondary10 }} size={24} />
</TouchableOpacity> </TouchableOpacity>
), [playNext, theme]) ), [playNext, theme])
@ -62,7 +62,7 @@ export default () => {
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
*/} */}
{btnPrev} {/* {btnPrev} */}
{btnPlay} {btnPlay}
{btnNext} {btnNext}
</> </>
@ -72,8 +72,8 @@ export default () => {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
cotrolBtn: { cotrolBtn: {
width: 32, width: 50,
height: 32, height: 50,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',

View File

@ -1,17 +1,11 @@
import React, { useCallback, memo, useMemo, useEffect, useState } from 'react' import React, { useCallback, memo, useMemo, useEffect, useState } from 'react'
import { View, Text, StyleSheet, Image, TouchableOpacity } from 'react-native' import { Image, TouchableOpacity } from 'react-native'
import { useGetter, useDispatch } from '@/store' import { useGetter, useDispatch } from '@/store'
import { toast } from '@/utils/tools'
import { useTranslation } from '@/plugins/i18n'
import { LIST_ID_PLAY_TEMP, LIST_ID_PLAY_LATER, NAV_VIEW_NAMES } from '@/config/constant'
import { navigations } from '@/navigation' import { navigations } from '@/navigation'
export default () => { export default () => {
const playMusicInfo = useGetter('player', 'playMusicInfo') const playMusicInfo = useGetter('player', 'playMusicInfo')
const theme = useGetter('common', 'theme') const theme = useGetter('common', 'theme')
const setNavActiveIndex = useDispatch('common', 'setNavActiveIndex')
const setPrevSelectListId = useDispatch('common', 'setPrevSelectListId')
const setJumpPosition = useDispatch('list', 'setJumpPosition')
// const { t } = useTranslation() // const { t } = useTranslation()
const componentIds = useGetter('common', 'componentIds') const componentIds = useGetter('common', 'componentIds')
const musicInfo = useMemo(() => { const musicInfo = useMemo(() => {
@ -25,17 +19,17 @@ export default () => {
// toast(t('play_detail_todo_tip'), 'long') // toast(t('play_detail_todo_tip'), 'long')
}, [componentIds.home, musicInfo, playMusicInfo]) }, [componentIds.home, musicInfo, playMusicInfo])
const handleLongPress = useCallback(() => { // const handleLongPress = useCallback(() => {
if (!playMusicInfo || playMusicInfo.listId == LIST_ID_PLAY_TEMP || playMusicInfo.listId == LIST_ID_PLAY_LATER) return // if (!playMusicInfo || playMusicInfo.listId == LIST_ID_PLAY_TEMP || playMusicInfo.listId == LIST_ID_PLAY_LATER) return
setNavActiveIndex(NAV_VIEW_NAMES.list) // setNavActiveIndex(NAV_VIEW_NAMES.list)
setPrevSelectListId(playMusicInfo.listId) // setPrevSelectListId(playMusicInfo.listId)
global.requestAnimationFrame(() => { // global.requestAnimationFrame(() => {
setJumpPosition(true) // setJumpPosition(true)
}) // })
}, [playMusicInfo, setJumpPosition, setNavActiveIndex, setPrevSelectListId]) // }, [playMusicInfo, setJumpPosition, setNavActiveIndex, setPrevSelectListId])
const component = useMemo(() => ( const component = useMemo(() => (
<TouchableOpacity onLongPress={handleLongPress} onPress={handlePress} activeOpacity={0.7} > <TouchableOpacity onPress={handlePress} activeOpacity={0.7} >
<Image source={{ uri: musicInfo.img }} nativeID={`pic${musicInfo.songmid}`} progressiveRenderingEnabled={true} borderRadius={2} style={{ <Image source={{ uri: musicInfo.img }} nativeID={`pic${musicInfo.songmid}`} progressiveRenderingEnabled={true} borderRadius={2} style={{
// ...styles.playInfoImg, // ...styles.playInfoImg,
backgroundColor: theme.primary, backgroundColor: theme.primary,
@ -43,7 +37,7 @@ export default () => {
height: 48, height: 48,
}} /> }} />
</TouchableOpacity> </TouchableOpacity>
), [handleLongPress, handlePress, musicInfo, theme]) ), [handlePress, musicInfo, theme])
return component return component
} }

View File

@ -1,18 +1,39 @@
import React, { useCallback, memo, useMemo, useEffect } from 'react' import React, { useCallback, memo, useMemo, useEffect } from 'react'
import { Text, StyleSheet } from 'react-native' import { Text, StyleSheet, TouchableOpacity } from 'react-native'
import { useGetter, useDispatch } from '@/store' import { useGetter, useDispatch } from '@/store'
import { navigations } from '@/navigation'
export default () => { export default () => {
const theme = useGetter('common', 'theme')
const downloadFileName = useGetter('common', 'downloadFileName')
const playMusicInfo = useGetter('player', 'playMusicInfo') const playMusicInfo = useGetter('player', 'playMusicInfo')
const theme = useGetter('common', 'theme')
// const { t } = useTranslation()
const componentIds = useGetter('common', 'componentIds')
const musicInfo = useMemo(() => {
return (playMusicInfo && playMusicInfo.musicInfo) || {}
}, [playMusicInfo])
const handlePress = useCallback(() => {
// console.log('')
// console.log(playMusicInfo)
if (!playMusicInfo) return
navigations.pushPlayDetailScreen(componentIds.home, musicInfo.songmid)
// toast(t('play_detail_todo_tip'), 'long')
}, [componentIds.home, musicInfo, playMusicInfo])
const downloadFileName = useGetter('common', 'downloadFileName')
const title = useMemo(() => {
let title = '^-^' let title = '^-^'
if (playMusicInfo && playMusicInfo.musicInfo) { if (playMusicInfo && playMusicInfo.musicInfo) {
title = downloadFileName.replace('歌手', playMusicInfo.musicInfo.singer).replace('歌名', playMusicInfo.musicInfo.name) title = downloadFileName.replace('歌手', playMusicInfo.musicInfo.singer).replace('歌名', playMusicInfo.musicInfo.name)
} }
return title
}, [downloadFileName, playMusicInfo])
// console.log(playMusicInfo) // console.log(playMusicInfo)
return <Text style={{ width: '100%', fontSize: 14, color: theme.normal }} numberOfLines={1}>{title}</Text> return (
<TouchableOpacity onPress={handlePress} activeOpacity={0.7} >
<Text style={{ width: '100%', fontSize: 14, color: theme.normal }} numberOfLines={1}>{title}</Text>
</TouchableOpacity>
)
} }
// const Singer = () => { // const Singer = () => {
// const playMusicInfo = useGetter('player', 'playMusicInfo') // const playMusicInfo = useGetter('player', 'playMusicInfo')

View File

@ -18,7 +18,7 @@ export default memo(() => {
const playerComponent = useMemo(() => ( const playerComponent = useMemo(() => (
<View style={{ ...styles.container, backgroundColor: theme.primary, borderTopColor: theme.secondary10 }}> <View style={{ ...styles.container, backgroundColor: theme.primary }}>
<View style={styles.left} elevation={1}><Pic /></View> <View style={styles.left} elevation={1}><Pic /></View>
<View style={styles.center}> <View style={styles.center}>
<View style={{ ...styles.row, justifyContent: 'space-between', fontSize: 12 }}> <View style={{ ...styles.row, justifyContent: 'space-between', fontSize: 12 }}>
@ -45,14 +45,17 @@ const styles = StyleSheet.create({
// paddingTop: progressContentPadding, // paddingTop: progressContentPadding,
// marginTop: -progressContentPadding, // marginTop: -progressContentPadding,
// backgroundColor: 'rgba(0, 0, 0, .1)', // backgroundColor: 'rgba(0, 0, 0, .1)',
borderTopWidth: BorderWidths.normal2, // borderTopWidth: BorderWidths.normal2,
paddingTop: 5, paddingTop: 5,
paddingBottom: 5, paddingBottom: 5,
paddingLeft: 5, paddingLeft: 5,
// backgroundColor: AppColors.primary, // backgroundColor: AppColors.primary,
// backgroundColor: 'red', // backgroundColor: 'red',
borderTopLeftRadius: 6,
borderTopRightRadius: 6,
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
elevation: 10,
}, },
left: { left: {
borderRadius: 3, borderRadius: 3,