diff --git a/package-lock.json b/package-lock.json index 6eb344a..eaa9d41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lx-music-mobile", - "version": "0.9.2", + "version": "0.10.0-beta2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3572,6 +3572,11 @@ "merge-options": "^3.0.4" } }, + "@react-native-clipboard/clipboard": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@react-native-clipboard/clipboard/-/clipboard-1.9.0.tgz", + "integrity": "sha512-O/ohFq1CAQLfoNc376Z3W6gvVcCJlje5AVk0JhsI8Q40hn+NXAWCnOM1bEePfC0uDMtp0/RCK6FotUvkQ6c4Zw==" + }, "@react-native-community/checkbox": { "version": "0.5.9", "resolved": "https://registry.npmmirror.com/@react-native-community/checkbox/download/@react-native-community/checkbox-0.5.9.tgz", diff --git a/package.json b/package.json index 5ae3ceb..c4fe9b6 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "homepage": "https://github.com/lyswhut/lx-music-mobile#readme", "dependencies": { "@react-native-async-storage/async-storage": "^1.15.14", + "@react-native-clipboard/clipboard": "^1.9.0", "@react-native-community/checkbox": "^0.5.9", "@react-native-community/slider": "^4.1.12", "buffer": "^6.0.3", diff --git a/publish/changeLog.md b/publish/changeLog.md index 29c3713..4ced3f4 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -4,6 +4,7 @@ - 新增播放详情页歌词字体大小调整设置,可在详情页右上角的按钮进行调整 - 新增同步服务地址历史列表功能 - 横屏播放详情页新增评论入口 +- 我的列表歌曲三个点的菜单新增复制歌曲名 ### 优化 diff --git a/src/lang/en_us.json b/src/lang/en_us.json index dc7fab0..0bb02b5 100644 --- a/src/lang/en_us.json +++ b/src/lang/en_us.json @@ -18,6 +18,7 @@ "comment_title": "{{name}}-{{singer}}'s comment", "confirm": "Confirm", "copy_name": "Copy name", + "copy_name_tip": "Copied", "create_new_folder": "Create new folder", "create_new_folder_error_tip": "The name entered is invalid", "create_new_folder_tip": "Please enter a new folder name", diff --git a/src/lang/zh_cn.json b/src/lang/zh_cn.json index 4fe8e75..205f35c 100644 --- a/src/lang/zh_cn.json +++ b/src/lang/zh_cn.json @@ -18,6 +18,7 @@ "comment_title": "{{name}} - {{singer}} 的评论", "confirm": "确认", "copy_name": "复制歌曲名", + "copy_name_tip": "已复制", "create_new_folder": "新建文件夹", "create_new_folder_error_tip": "输入的名称不合法", "create_new_folder_tip": "请输入新文件夹名", diff --git a/src/screens/Home/List/index.js b/src/screens/Home/List/index.js index 94c617f..02ca6c7 100644 --- a/src/screens/Home/List/index.js +++ b/src/screens/Home/List/index.js @@ -1,4 +1,4 @@ -import React, { useMemo, useCallback, memo, useRef, useState, useEffect } from 'react' +import React, { useMemo, useCallback, useRef, useState, useEffect } from 'react' import { View, Text, StyleSheet, FlatList } from 'react-native' import { useGetter, useDispatch } from '@/store' @@ -10,7 +10,7 @@ import Button from '@/components/common/Button' import ExitMultipleModeBar from './components/ExitMultipleModeBar' import MyList from './components/MyList' import ListItem from './components/ListItem' -import { getListScrollPosition, saveListScrollPosition, toast } from '@/utils/tools' +import { getListScrollPosition, saveListScrollPosition, clipboardWriteText, toast } from '@/utils/tools' import { useTranslation } from '@/plugins/i18n' import { LIST_ITEM_HEIGHT } from '@/config/constant' import MusicPositionModal from './components/MusicPositionModal' @@ -34,6 +34,7 @@ const List = () => { const playListInfoRef = useRef(playListInfo) const activeListId = useGetter('common', 'prevSelectListId') const activeListIdRef = useRef(activeListId) + const downloadFileName = useGetter('common', 'downloadFileName') const [buttonPosition, setButtonPosition] = useState({ w: 0, h: 0, x: 0, y: 0 }) const selectedDataRef = useRef({ data: null, index: -1 }) const flatListRef = useRef() @@ -166,15 +167,11 @@ const List = () => { return [ { action: 'play', label: t('play') }, { action: 'playLater', label: t('play_later') }, - // { action: 'copyName', label: t('copy_name') }, - // { action: 'download', label: '下载' }, - // { action: 'add', label: t('add_to') }, - // { action: 'move', label: '移动到...' }, // { action: 'download', label: '下载' }, { action: 'add', label: t('add_to') }, { action: 'move', label: t('move_to') }, + { action: 'copyName', label: t('copy_name') }, { action: 'changePosition', label: t('change_position') }, - // { action: 'move', label: '移动到...' }, { action: 'remove', label: t('delete') }, ] }, [t]) @@ -204,8 +201,6 @@ const List = () => { setTempPlayList([{ listId: activeListIdRef.current, musicInfo: selectedDataRef.current.data }]) } break - // case 'copyName': - // break case 'add': isMoveRef.current = false selectedListRef.current.length @@ -218,6 +213,11 @@ const List = () => { ? setVisibleMusicMultiAddModal(true) : setVisibleMusicAddModal(true) break + case 'copyName': + clipboardWriteText(downloadFileName.replace('歌名', selectedDataRef.current.data.name) + .replace('歌手', selectedDataRef.current.data.singer)) + toast(t('copy_name_tip')) + break case 'changePosition': setVIsibleMusicPosition(true) break @@ -232,7 +232,7 @@ const List = () => { default: break } - }, [handleCancelMultiSelect, handlePlay, removeListItem, removeListMultiItem, setTempPlayList]) + }, [downloadFileName, handleCancelMultiSelect, handlePlay, removeListItem, removeListMultiItem, setTempPlayList]) const handleScroll = useCallback(({ nativeEvent }) => { saveListScrollPosition(currentListRef.current.id, nativeEvent.contentOffset.y) diff --git a/src/utils/tools.js b/src/utils/tools.js index 84c9894..3f79649 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -1,5 +1,6 @@ import { Platform, NativeModules, ToastAndroid, BackHandler, Linking, Dimensions, Alert } from 'react-native' import ExtraDimensions from 'react-native-extra-dimensions-android' +import Clipboard from '@react-native-clipboard/clipboard' import { getData, setData, getAllKeys, removeData, removeDataMultiple, setDataMultiple, getDataMultiple } from '@/plugins/storage' import { storageDataPrefix } from '@/config' import { throttle } from './index' @@ -313,6 +314,10 @@ export const confirmDialog = ({ }) } +export const clipboardWriteText = str => { + Clipboard.setString(str) +} + export { deviceLanguage, }