修复横屏歌词字体大小设置不生效的问题,修改歌词行高计算方式

This commit is contained in:
lyswhut 2023-03-24 21:50:18 +08:00
parent 4410cdab53
commit 95071b5415
6 changed files with 21 additions and 16 deletions

View File

@ -7,7 +7,7 @@ import { createStyle } from '@/utils/tools'
import { useTheme } from '@/store/theme/hook' import { useTheme } from '@/store/theme/hook'
import { useSettingValue } from '@/store/setting/hook' import { useSettingValue } from '@/store/setting/hook'
import Text from '@/components/common/Text' import Text from '@/components/common/Text'
import { scaleSizeH, setSpText } from '@/utils/pixelRatio' import { setSpText } from '@/utils/pixelRatio'
// import { screenkeepAwake } from '@/utils/nativeModules/utils' // import { screenkeepAwake } from '@/utils/nativeModules/utils'
// import { log } from '@/utils/log' // import { log } from '@/utils/log'
// import { toast } from '@/utils/tools' // import { toast } from '@/utils/tools'
@ -23,7 +23,7 @@ const LrcLine = memo(({ line, lineNum, activeLine }: {
const theme = useTheme() const theme = useTheme()
const playerPortraitStyle = useSettingValue('playDetail.horizontal.style.lrcFontSize') const playerPortraitStyle = useSettingValue('playDetail.horizontal.style.lrcFontSize')
const textAlign = useSettingValue('playDetail.style.align') const textAlign = useSettingValue('playDetail.style.align')
const lineHeight = scaleSizeH(setSpText(playerPortraitStyle) / 10 * 1.25) const lineHeight = setSpText(playerPortraitStyle / 10) * 1.25
return ( return (
<View style={styles.line}> <View style={styles.line}>
@ -175,8 +175,8 @@ const styles = createStyle({
paddingTop: '80%', paddingTop: '80%',
}, },
line: { line: {
paddingTop: 8, paddingTop: 10,
paddingBottom: 8, paddingBottom: 10,
// opacity: 0, // opacity: 0,
}, },
lineText: { lineText: {

View File

@ -49,7 +49,7 @@ export default memo(() => {
<CommentBtn /> <CommentBtn />
<Btn icon="slider" onPress={showSetting} /> <Btn icon="slider" onPress={showSetting} />
</View> </View>
<SettingPopup ref={popupRef} position="left" /> <SettingPopup ref={popupRef} position="left" direction="horizontal" />
</View> </View>
) )
}) })

View File

@ -7,7 +7,7 @@ import { createStyle } from '@/utils/tools'
import { useTheme } from '@/store/theme/hook' import { useTheme } from '@/store/theme/hook'
import { useSettingValue } from '@/store/setting/hook' import { useSettingValue } from '@/store/setting/hook'
import Text from '@/components/common/Text' import Text from '@/components/common/Text'
import { scaleSizeH, setSpText } from '@/utils/pixelRatio' import { setSpText } from '@/utils/pixelRatio'
// import { screenkeepAwake } from '@/utils/nativeModules/utils' // import { screenkeepAwake } from '@/utils/nativeModules/utils'
// import { log } from '@/utils/log' // import { log } from '@/utils/log'
// import { toast } from '@/utils/tools' // import { toast } from '@/utils/tools'
@ -61,7 +61,7 @@ const LrcLine = memo(({ line, lineNum, activeLine }: {
const theme = useTheme() const theme = useTheme()
const playerPortraitStyle = useSettingValue('playDetail.vertical.style.lrcFontSize') const playerPortraitStyle = useSettingValue('playDetail.vertical.style.lrcFontSize')
const textAlign = useSettingValue('playDetail.style.align') const textAlign = useSettingValue('playDetail.style.align')
const lineHeight = scaleSizeH(setSpText(playerPortraitStyle) / 10 * 1.25) const lineHeight = setSpText(playerPortraitStyle / 10) * 1.25
return ( return (
<View style={styles.line}> <View style={styles.line}>
@ -213,8 +213,8 @@ const styles = createStyle({
paddingTop: '80%', paddingTop: '80%',
}, },
line: { line: {
paddingTop: 8, paddingTop: 10,
paddingBottom: 8, paddingBottom: 10,
// opacity: 0, // opacity: 0,
}, },
lineText: { lineText: {

View File

@ -51,7 +51,7 @@ export default memo(() => {
<Icon name="slider" size={19} /> <Icon name="slider" size={19} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<SettingPopup ref={popupRef} /> <SettingPopup ref={popupRef} direction="vertical" />
</View> </View>
) )
}) })

View File

@ -8,13 +8,15 @@ import SettingPlaybackRate from './settings/SettingPlaybackRate'
import SettingLrcFontSize from './settings/SettingLrcFontSize' import SettingLrcFontSize from './settings/SettingLrcFontSize'
import SettingLrcAlign from './settings/SettingLrcAlign' import SettingLrcAlign from './settings/SettingLrcAlign'
export type SettingPopupProps = Omit<PopupProps, 'children'> export interface SettingPopupProps extends Omit<PopupProps, 'children'> {
direction: 'vertical' | 'horizontal'
}
export interface SettingPopupType { export interface SettingPopupType {
show: () => void show: () => void
} }
export default forwardRef<SettingPopupType, SettingPopupProps>((props, ref) => { export default forwardRef<SettingPopupType, SettingPopupProps>(({ direction, ...props }, ref) => {
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const popupRef = useRef<PopupType>(null) const popupRef = useRef<PopupType>(null)
// console.log('render import export') // console.log('render import export')
@ -41,7 +43,7 @@ export default forwardRef<SettingPopupType, SettingPopupProps>((props, ref) => {
<View onStartShouldSetResponder={() => true}> <View onStartShouldSetResponder={() => true}>
<SettingVolume /> <SettingVolume />
<SettingPlaybackRate /> <SettingPlaybackRate />
<SettingLrcFontSize /> <SettingLrcFontSize direction={direction} />
<SettingLrcAlign /> <SettingLrcAlign />
</View> </View>
</ScrollView> </ScrollView>

View File

@ -10,9 +10,12 @@ import { useI18n } from '@/lang'
import styles from './style' import styles from './style'
const LrcFontSize = () => { const LrcFontSize = ({ direction }: {
direction: 'horizontal' | 'vertical'
}) => {
const theme = useTheme() const theme = useTheme()
const lrcFontSize = useSettingValue('playDetail.vertical.style.lrcFontSize') const settingKey = direction == 'horizontal' ? 'playDetail.horizontal.style.lrcFontSize' : 'playDetail.vertical.style.lrcFontSize'
const lrcFontSize = useSettingValue(settingKey)
const [sliderSize, setSliderSize] = useState(lrcFontSize) const [sliderSize, setSliderSize] = useState(lrcFontSize)
const [isSliding, setSliding] = useState(false) const [isSliding, setSliding] = useState(false)
const t = useI18n() const t = useI18n()
@ -26,7 +29,7 @@ const LrcFontSize = () => {
const handleSlidingComplete: SliderProps['onSlidingComplete'] = value => { const handleSlidingComplete: SliderProps['onSlidingComplete'] = value => {
setSliding(false) setSliding(false)
if (lrcFontSize == value) return if (lrcFontSize == value) return
updateSetting({ 'playDetail.vertical.style.lrcFontSize': value }) updateSetting({ [settingKey]: value })
} }
return ( return (