mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 20:28:55 +08:00
我的列表菜单列表新增“新建列表”菜单
This commit is contained in:
parent
81c8d98508
commit
308ba72f2a
@ -11,6 +11,7 @@
|
|||||||
- 新增启用竖屏首页横向滚动设置,默认开启(原来的行为),如果你不想要竖屏的首页左右滑动则可以关闭此设置(#397)
|
- 新增启用竖屏首页横向滚动设置,默认开启(原来的行为),如果你不想要竖屏的首页左右滑动则可以关闭此设置(#397)
|
||||||
- 新增“使用系统文件选择器”设置,默认启用,启用该选项后,导入备份文件、自定义源等操作将不需要申请存储权限,但可能在某些系统上不可用
|
- 新增“使用系统文件选择器”设置,默认启用,启用该选项后,导入备份文件、自定义源等操作将不需要申请存储权限,但可能在某些系统上不可用
|
||||||
- 播放详情页新增桌面歌词显示/隐藏切换按钮,长按可切换歌词锁定状态
|
- 播放详情页新增桌面歌词显示/隐藏切换按钮,长按可切换歌词锁定状态
|
||||||
|
- 我的列表菜单列表新增“新建列表”菜单
|
||||||
- 添加 Android 5 特别版(版本号包含`android_5`)与墨·状态栏特别版(版本号包含`sl`)的 release 构建
|
- 添加 Android 5 特别版(版本号包含`android_5`)与墨·状态栏特别版(版本号包含`sl`)的 release 构建
|
||||||
|
|
||||||
### 优化
|
### 优化
|
||||||
|
@ -19,6 +19,7 @@ const menuItemWidth = scaleSizeW(110)
|
|||||||
|
|
||||||
|
|
||||||
export interface ListMenuProps {
|
export interface ListMenuProps {
|
||||||
|
onNew: (position: number) => void
|
||||||
onRename: (listInfo: LX.List.UserListInfo) => void
|
onRename: (listInfo: LX.List.UserListInfo) => void
|
||||||
onImport: (listInfo: LX.List.MyListInfo, index: number) => void
|
onImport: (listInfo: LX.List.MyListInfo, index: number) => void
|
||||||
onExport: (listInfo: LX.List.MyListInfo, index: number) => void
|
onExport: (listInfo: LX.List.MyListInfo, index: number) => void
|
||||||
@ -35,6 +36,7 @@ export type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default forwardRef<ListMenuType, ListMenuProps>(({
|
export default forwardRef<ListMenuType, ListMenuProps>(({
|
||||||
|
onNew,
|
||||||
onRename,
|
onRename,
|
||||||
onImport,
|
onImport,
|
||||||
onExport,
|
onExport,
|
||||||
@ -81,6 +83,7 @@ export default forwardRef<ListMenuType, ListMenuProps>(({
|
|||||||
}
|
}
|
||||||
|
|
||||||
setMenus([
|
setMenus([
|
||||||
|
{ action: 'new', label: t('list_create') },
|
||||||
{ action: 'rename', disabled: !rename, label: t('list_rename') },
|
{ action: 'rename', disabled: !rename, label: t('list_rename') },
|
||||||
{ action: 'local_file', disabled: !local_file, label: t('list_select_local_file') },
|
{ action: 'local_file', disabled: !local_file, label: t('list_select_local_file') },
|
||||||
{ action: 'sync', disabled: !sync || !local_file, label: t('list_sync') },
|
{ action: 'sync', disabled: !sync || !local_file, label: t('list_sync') },
|
||||||
@ -94,6 +97,9 @@ export default forwardRef<ListMenuType, ListMenuProps>(({
|
|||||||
const handleMenuPress = ({ action }: typeof menus[number]) => {
|
const handleMenuPress = ({ action }: typeof menus[number]) => {
|
||||||
const selectInfo = selectInfoRef.current
|
const selectInfo = selectInfoRef.current
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case 'new':
|
||||||
|
onNew(Math.max(selectInfo.index - 1, 0))
|
||||||
|
break
|
||||||
case 'rename':
|
case 'rename':
|
||||||
onRename(selectInfo.listInfo as LX.List.UserListInfo)
|
onRename(selectInfo.listInfo as LX.List.UserListInfo)
|
||||||
break
|
break
|
||||||
|
@ -3,7 +3,7 @@ import ConfirmAlert, { type ConfirmAlertType } from '@/components/common/Confirm
|
|||||||
import Text from '@/components/common/Text'
|
import Text from '@/components/common/Text'
|
||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import Input, { type InputType } from '@/components/common/Input'
|
import Input, { type InputType } from '@/components/common/Input'
|
||||||
import { updateUserList } from '@/core/list'
|
import { createUserList, updateUserList } from '@/core/list'
|
||||||
import { createStyle } from '@/utils/tools'
|
import { createStyle } from '@/utils/tools'
|
||||||
import { useTheme } from '@/store/theme/hook'
|
import { useTheme } from '@/store/theme/hook'
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ const NameInput = forwardRef<NameInputType, {}>((props, ref) => {
|
|||||||
},
|
},
|
||||||
setName(text) {
|
setName(text) {
|
||||||
setText(text)
|
setText(text)
|
||||||
setPlaceholder(text)
|
setPlaceholder(text || global.i18n.t('list_create_input_placeholder'))
|
||||||
},
|
},
|
||||||
focus() {
|
focus() {
|
||||||
inputRef.current?.focus()
|
inputRef.current?.focus()
|
||||||
@ -44,6 +44,7 @@ const NameInput = forwardRef<NameInputType, {}>((props, ref) => {
|
|||||||
|
|
||||||
|
|
||||||
export interface ListNameEditType {
|
export interface ListNameEditType {
|
||||||
|
showCreate: (position: number) => void
|
||||||
show: (listInfo: LX.List.UserListInfo) => void
|
show: (listInfo: LX.List.UserListInfo) => void
|
||||||
}
|
}
|
||||||
const initSelectInfo = {}
|
const initSelectInfo = {}
|
||||||
@ -52,20 +53,33 @@ const initSelectInfo = {}
|
|||||||
export default forwardRef<ListNameEditType, {}>((props, ref) => {
|
export default forwardRef<ListNameEditType, {}>((props, ref) => {
|
||||||
const alertRef = useRef<ConfirmAlertType>(null)
|
const alertRef = useRef<ConfirmAlertType>(null)
|
||||||
const nameInputRef = useRef<NameInputType>(null)
|
const nameInputRef = useRef<NameInputType>(null)
|
||||||
|
const [position, setPosition] = useState(0)
|
||||||
const selectedListInfo = useRef<LX.List.UserListInfo>(initSelectInfo as LX.List.UserListInfo)
|
const selectedListInfo = useRef<LX.List.UserListInfo>(initSelectInfo as LX.List.UserListInfo)
|
||||||
const [visible, setVisible] = useState(false)
|
const [visible, setVisible] = useState(false)
|
||||||
|
|
||||||
const handleShow = () => {
|
const handleShow = () => {
|
||||||
alertRef.current?.setVisible(true)
|
alertRef.current?.setVisible(true)
|
||||||
|
const name = position == -1 ? '' : (selectedListInfo.current.name ?? '')
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
nameInputRef.current?.setName(selectedListInfo.current.name ?? '')
|
nameInputRef.current?.setName(name)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
nameInputRef.current?.focus()
|
nameInputRef.current?.focus()
|
||||||
}, 300)
|
}, 300)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
|
showCreate(position) {
|
||||||
|
setPosition(position)
|
||||||
|
if (visible) handleShow()
|
||||||
|
else {
|
||||||
|
setVisible(true)
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
handleShow()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
show(listInfo) {
|
show(listInfo) {
|
||||||
|
setPosition(-1)
|
||||||
selectedListInfo.current = listInfo
|
selectedListInfo.current = listInfo
|
||||||
if (visible) handleShow()
|
if (visible) handleShow()
|
||||||
else {
|
else {
|
||||||
@ -81,7 +95,12 @@ export default forwardRef<ListNameEditType, {}>((props, ref) => {
|
|||||||
let name = nameInputRef.current?.getText() ?? ''
|
let name = nameInputRef.current?.getText() ?? ''
|
||||||
if (!name.length) return
|
if (!name.length) return
|
||||||
if (name.length > 100) name = name.substring(0, 100)
|
if (name.length > 100) name = name.substring(0, 100)
|
||||||
|
if (position == -1) {
|
||||||
void updateUserList([{ ...selectedListInfo.current, name }])
|
void updateUserList([{ ...selectedListInfo.current, name }])
|
||||||
|
} else {
|
||||||
|
const now = Date.now()
|
||||||
|
void createUserList(position, [{ id: `userlist_${now}`, name, locationUpdateTime: now }])
|
||||||
|
}
|
||||||
alertRef.current?.setVisible(false)
|
alertRef.current?.setVisible(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +111,7 @@ export default forwardRef<ListNameEditType, {}>((props, ref) => {
|
|||||||
onConfirm={handleRename}
|
onConfirm={handleRename}
|
||||||
>
|
>
|
||||||
<View style={styles.renameContent}>
|
<View style={styles.renameContent}>
|
||||||
<Text style={{ marginBottom: 5 }}>{global.i18n.t('list_rename_title')}</Text>
|
<Text style={{ marginBottom: 5 }}>{ position == -1 ? global.i18n.t('list_rename_title') : global.i18n.t('list_create')}</Text>
|
||||||
<NameInput ref={nameInputRef} />
|
<NameInput ref={nameInputRef} />
|
||||||
</View>
|
</View>
|
||||||
</ConfirmAlert>
|
</ConfirmAlert>
|
||||||
|
@ -41,6 +41,7 @@ export default () => {
|
|||||||
<ListImportExport ref={listImportExportRef} />
|
<ListImportExport ref={listImportExportRef} />
|
||||||
<ListMenu
|
<ListMenu
|
||||||
ref={listMenuRef}
|
ref={listMenuRef}
|
||||||
|
onNew={index => listNameEditRef.current?.showCreate(index)}
|
||||||
onRename={info => listNameEditRef.current?.show(info)}
|
onRename={info => listNameEditRef.current?.show(info)}
|
||||||
onImport={(info, position) => listImportExportRef.current?.import(info, position)}
|
onImport={(info, position) => listImportExportRef.current?.import(info, position)}
|
||||||
onExport={(info, position) => listImportExportRef.current?.export(info, position)}
|
onExport={(info, position) => listImportExportRef.current?.export(info, position)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user