上移Toast位置避免遮挡播放模式图标 (#603)

* 上移Toast位置避免遮挡播放模式图标

* Update tools.ts

* 添加更新日志

---------

Co-authored-by: momenta\sibo.jia <sibo.jia@momenta.ai>
Co-authored-by: lyswhut <lyswhut@qq.com>
This commit is contained in:
Sibo Jia 2024-10-09 18:09:07 +08:00 committed by GitHub
parent 732edea827
commit 162764290d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
### 优化
- 首次使用的提示窗口可以点击背景或者返回键关闭(#577
- 上移 Toast 位置避免遮挡播放模式图标(#603 @sibojia

View File

@ -116,19 +116,23 @@ export const toast = (message: string, duration: 'long' | 'short' = 'short', pos
break
}
let _position
let offset: number
switch (position) {
case 'top':
_position = ToastAndroid.TOP
offset = 80
break
case 'center':
_position = ToastAndroid.CENTER
offset = 0
break
case 'bottom':
default:
_position = ToastAndroid.BOTTOM
offset = 80
break
}
ToastAndroid.showWithGravity(message, _duration, _position)
ToastAndroid.showWithGravityAndOffset(message, _duration, _position, 0, offset)
}
export const openUrl = async(url: string): Promise<void> => Linking.canOpenURL(url).then(async() => Linking.openURL(url))