mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-05-23 22:37:41 +08:00
优化进入动画
This commit is contained in:
parent
20daea8e71
commit
09af301209
@ -138,6 +138,17 @@ export function pushPlayDetailScreen(componentId, id) {
|
|||||||
duration: 300,
|
duration: 300,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'pageIndicator',
|
||||||
|
alpha: {
|
||||||
|
from: 0, // We don't declare 'to' value as that is the element's current alpha value, here we're essentially animating from 0 to 1
|
||||||
|
duration: 300,
|
||||||
|
},
|
||||||
|
translationX: {
|
||||||
|
from: -16, // Animate translationY from 16dp to 0dp
|
||||||
|
duration: 300,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'player',
|
id: 'player',
|
||||||
alpha: {
|
alpha: {
|
||||||
|
@ -2,21 +2,27 @@ import React, { memo, useMemo, useState, useEffect } from 'react'
|
|||||||
import { View, Image, StyleSheet } from 'react-native'
|
import { View, Image, StyleSheet } from 'react-native'
|
||||||
import { useGetter, useDispatch } from '@/store'
|
import { useGetter, useDispatch } from '@/store'
|
||||||
import { useLayout } from '@/utils/hooks'
|
import { useLayout } from '@/utils/hooks'
|
||||||
|
import { useNavigationComponentDidAppear } from '@/navigation'
|
||||||
|
|
||||||
export default memo(() => {
|
export default memo(({ componentId }) => {
|
||||||
const playMusicInfo = useGetter('player', 'playMusicInfo')
|
const playMusicInfo = useGetter('player', 'playMusicInfo')
|
||||||
const theme = useGetter('common', 'theme')
|
const theme = useGetter('common', 'theme')
|
||||||
const { onLayout, ...layout } = useLayout()
|
const { onLayout, ...layout } = useLayout()
|
||||||
|
const [animated, setAnimated] = useState(false)
|
||||||
|
|
||||||
const musicInfo = useMemo(() => {
|
const musicInfo = useMemo(() => {
|
||||||
return (playMusicInfo && playMusicInfo.musicInfo) || {}
|
return (playMusicInfo && playMusicInfo.musicInfo) || {}
|
||||||
}, [playMusicInfo])
|
}, [playMusicInfo])
|
||||||
|
|
||||||
|
useNavigationComponentDidAppear(componentId, () => {
|
||||||
|
setAnimated(true)
|
||||||
|
})
|
||||||
|
|
||||||
const imgWidth = Math.max(layout.width * 0.8, 100)
|
const imgWidth = Math.max(layout.width * 0.8, 100)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container} onLayout={onLayout}>
|
<View style={styles.container} onLayout={onLayout}>
|
||||||
<View style={{ ...styles.content }}>
|
<View style={{ ...styles.content, elevation: animated ? 3 : 0 }}>
|
||||||
<Image source={{ uri: musicInfo.img }} nativeID={`pic${musicInfo.songmid}Dest`} progressiveRenderingEnabled={true} borderRadius={2} style={{
|
<Image source={{ uri: musicInfo.img }} nativeID={`pic${musicInfo.songmid}Dest`} progressiveRenderingEnabled={true} borderRadius={2} style={{
|
||||||
...styles.img,
|
...styles.img,
|
||||||
backgroundColor: theme.primary,
|
backgroundColor: theme.primary,
|
||||||
@ -36,7 +42,7 @@ const styles = StyleSheet.create({
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
elevation: 3,
|
// elevation: 3,
|
||||||
backgroundColor: 'rgba(0,0,0,0)',
|
backgroundColor: 'rgba(0,0,0,0)',
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ const LyricPage = ({ activeIndex }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// global.iskeep = false
|
// global.iskeep = false
|
||||||
export default memo(() => {
|
export default memo(({ componentId }) => {
|
||||||
const theme = useGetter('common', 'theme')
|
const theme = useGetter('common', 'theme')
|
||||||
const [pageIndex, setPageIndex] = useState(0)
|
const [pageIndex, setPageIndex] = useState(0)
|
||||||
|
|
||||||
@ -49,13 +49,13 @@ export default memo(() => {
|
|||||||
style={styles.pagerView}
|
style={styles.pagerView}
|
||||||
>
|
>
|
||||||
<View collapsable={false} style={styles.pageStyle}>
|
<View collapsable={false} style={styles.pageStyle}>
|
||||||
<Pic />
|
<Pic componentId={componentId} />
|
||||||
</View>
|
</View>
|
||||||
<View collapsable={false} style={styles.pageStyle}>
|
<View collapsable={false} style={styles.pageStyle}>
|
||||||
<LyricPage activeIndex={pageIndex} />
|
<LyricPage activeIndex={pageIndex} />
|
||||||
</View>
|
</View>
|
||||||
</PagerView>
|
</PagerView>
|
||||||
<View style={styles.pageIndicator}>
|
<View style={styles.pageIndicator} nativeID="pageIndicator">
|
||||||
<View style={{ ...styles.pageIndicatorItem, backgroundColor: pageIndex == 0 ? theme.secondary20 : theme.normal60 }}></View>
|
<View style={{ ...styles.pageIndicatorItem, backgroundColor: pageIndex == 0 ? theme.secondary20 : theme.normal60 }}></View>
|
||||||
<View style={{ ...styles.pageIndicatorItem, backgroundColor: pageIndex == 1 ? theme.secondary20 : theme.normal60 }}></View>
|
<View style={{ ...styles.pageIndicatorItem, backgroundColor: pageIndex == 1 ? theme.secondary20 : theme.normal60 }}></View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -4,10 +4,10 @@ import { useGetter, useDispatch } from '@/store'
|
|||||||
|
|
||||||
import Player from './Player'
|
import Player from './Player'
|
||||||
|
|
||||||
export default () => {
|
export default ({ componentId }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Player />
|
<Player componentId={componentId} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,6 @@ export default (props) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
window.width > window.height ? <Landscape /> : <Portrait />
|
window.width > window.height ? <Landscape /> : <Portrait componentId={props.componentId} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user