修复进入播放详情歌词界面后的屏幕常亮不会被取消的问题

This commit is contained in:
lyswhut 2021-05-22 16:20:45 +08:00
parent aac3f0581c
commit 57e57f3724
6 changed files with 32 additions and 21 deletions

View File

@ -1,11 +1,3 @@
### 新增
- 新增通过歌单链接打开歌单的功能
### 优化
- 切换到播放详情歌词界面时将阻止屏幕息屏
### 修复 ### 修复
- 修复一个导致崩溃日志写入文件前会导致APP崩溃的莫名其妙问题 - 修复进入播放详情歌词界面后的屏幕常亮不会被取消的问题

View File

@ -12,3 +12,5 @@ global.allList = null
global.globalObj = null global.globalObj = null
global.listScrollPosition = {} global.listScrollPosition = {}
global.listSort = {} global.listSort = {}
global.isScreenKeepAwake = false

View File

@ -42,8 +42,6 @@ export default memo(() => {
// const imgWidth = useMemo(() => layout.width * 0.75, [layout.width]) // const imgWidth = useMemo(() => layout.width * 0.75, [layout.width])
const handleScrollToActive = useCallback((index = lineRef.current) => { const handleScrollToActive = useCallback((index = lineRef.current) => {
screenkeepAwake()
if (scrollViewRef.current && linesRef.current.length) { if (scrollViewRef.current && linesRef.current.length) {
scrollViewRef.current.scrollToIndex({ scrollViewRef.current.scrollToIndex({
index, index,
@ -51,10 +49,6 @@ export default memo(() => {
viewPosition: 0.4, viewPosition: 0.4,
}) })
} }
return () => {
screenUnkeepAwake()
}
}, []) }, [])
const handleScrollBeginDrag = () => { const handleScrollBeginDrag = () => {

View File

@ -9,13 +9,20 @@ import { useGetter, useDispatch } from '@/store'
import PagerView from 'react-native-pager-view' import PagerView from 'react-native-pager-view'
import Pic from './Pic' import Pic from './Pic'
import Lyric from './Lyric' import Lyric from './Lyric'
import { screenkeepAwake, screenUnkeepAwake } from '@/utils/utils'
// global.iskeep = false
export default memo(() => { export default memo(() => {
const theme = useGetter('common', 'theme') const theme = useGetter('common', 'theme')
const [pageIndex, setPageIndex] = useState(0) const [pageIndex, setPageIndex] = useState(0)
const onPageSelected = useCallback(({ nativeEvent }) => { const onPageSelected = useCallback(({ nativeEvent }) => {
setPageIndex(nativeEvent.position) setPageIndex(nativeEvent.position)
if (nativeEvent.position == 1) {
screenkeepAwake()
} else {
screenUnkeepAwake()
}
}, []) }, [])
const pic = useMemo(() => <Pic />, []) const pic = useMemo(() => <Pic />, [])

View File

@ -9,6 +9,7 @@ import { compareVer } from '@/utils'
// import { setMaxCache } from '@/plugins/player/utils' // import { setMaxCache } from '@/plugins/player/utils'
import { showVersionModal } from '@/navigation' import { showVersionModal } from '@/navigation'
import { VERSION_STATUS } from '@/config/constant' import { VERSION_STATUS } from '@/config/constant'
import { screenUnkeepAwake } from '@/utils/utils'
export const TYPES = { export const TYPES = {
updateSetting: null, updateSetting: null,
@ -107,10 +108,16 @@ export const setComponentId = data => ({
type: TYPES.setComponentId, type: TYPES.setComponentId,
payload: data, payload: data,
}) })
export const removeComponentId = id => ({ export const removeComponentId = id => (dispatch, getState) => {
type: TYPES.removeComponentId, const { common } = getState()
payload: id, if (common.componentIds.playDetail == id) {
}) screenUnkeepAwake()
}
dispatch({
type: TYPES.removeComponentId,
payload: id,
})
}
export const setNavActiveIndex = index => ({ export const setNavActiveIndex = index => ({
type: TYPES.setNavActiveIndex, type: TYPES.setNavActiveIndex,

View File

@ -9,5 +9,14 @@ export const getSupportedAbis = UtilsModule.getSupportedAbis
export const installApk = (filePath, fileProviderAuthority) => UtilsModule.installApk(filePath, fileProviderAuthority) export const installApk = (filePath, fileProviderAuthority) => UtilsModule.installApk(filePath, fileProviderAuthority)
export const screenkeepAwake = UtilsModule.screenkeepAwake export const screenkeepAwake = () => {
export const screenUnkeepAwake = UtilsModule.screenUnkeepAwake if (global.isScreenKeepAwake) return
global.isScreenKeepAwake = true
UtilsModule.screenkeepAwake()
}
export const screenUnkeepAwake = () => {
// console.log('screenUnkeepAwake')
if (!global.isScreenKeepAwake) return
global.isScreenKeepAwake = false
UtilsModule.screenUnkeepAwake()
}