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
8f83046cdb
commit
f3ac526b51
@ -5,3 +5,7 @@
|
|||||||
### 优化
|
### 优化
|
||||||
|
|
||||||
- 更新设置界面菜单布局
|
- 更新设置界面菜单布局
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
- 修复歌单排序列表滚动重置问题
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { forwardRef, useImperativeHandle, useMemo, useState } from 'react'
|
import React, { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react'
|
||||||
import { ScrollView, TouchableOpacity } from 'react-native'
|
import { ScrollView, TouchableOpacity } from 'react-native'
|
||||||
import songlistState, { type SortInfo, type Source } from '@/store/songlist/state'
|
import songlistState, { type SortInfo, type Source } from '@/store/songlist/state'
|
||||||
import { useI18n } from '@/lang'
|
import { useI18n } from '@/lang'
|
||||||
@ -20,9 +20,11 @@ export default forwardRef<SortTabType, SortTabProps>(({ onSortChange }, ref) =>
|
|||||||
const [activeId, setActiveId] = useState<SortInfo['id']>('')
|
const [activeId, setActiveId] = useState<SortInfo['id']>('')
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
|
const scrollViewRef = useRef<ScrollView>(null)
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
setSource(source, activeTab) {
|
setSource(source, activeTab) {
|
||||||
|
scrollViewRef.current?.scrollTo({ x: 0 })
|
||||||
setSortList(songlistState.sortList[source] as SortInfo[])
|
setSortList(songlistState.sortList[source] as SortInfo[])
|
||||||
setActiveId(activeTab)
|
setActiveId(activeTab)
|
||||||
},
|
},
|
||||||
@ -38,7 +40,7 @@ export default forwardRef<SortTabType, SortTabProps>(({ onSortChange }, ref) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.container} keyboardShouldPersistTaps={'always'} horizontal={true}>
|
<ScrollView ref={scrollViewRef} style={styles.container} keyboardShouldPersistTaps={'always'} horizontal>
|
||||||
{
|
{
|
||||||
sorts.map(s => (
|
sorts.map(s => (
|
||||||
<TouchableOpacity style={styles.button} onPress={() => { handleSortChange(s.id) }} key={s.id}>
|
<TouchableOpacity style={styles.button} onPress={() => { handleSortChange(s.id) }} key={s.id}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user