feat: first commit
This commit is contained in:
36
src/hooks/use-navigation.tsx
Normal file
36
src/hooks/use-navigation.tsx
Normal file
@ -0,0 +1,36 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
import { useRef } from 'react';
|
||||
|
||||
function useNavigation() {
|
||||
const statusBarHeight = useRef(0);
|
||||
const barHeight = useRef(0);
|
||||
|
||||
const systemInfo = Taro.getWindowInfo();
|
||||
if (systemInfo.statusBarHeight) {
|
||||
statusBarHeight.current = systemInfo.statusBarHeight;
|
||||
}
|
||||
|
||||
// #ifndef MP
|
||||
// if (process.env.TARO_ENV !== 'weapp') {
|
||||
// barHeight.current = statusBarHeight.current + (systemInfo.platform === 'android' ? 50 : 40);
|
||||
// }
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
if (process.env.TARO_ENV === 'weapp') {
|
||||
const custom = Taro.getMenuButtonBoundingClientRect();
|
||||
barHeight.current = custom.bottom + custom.top - statusBarHeight.current;
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
// barHeight.current = statusBarHeight.current + systemInfo.titleBarHeight!;
|
||||
// #endif
|
||||
|
||||
return {
|
||||
barHeight,
|
||||
statusBarHeight,
|
||||
};
|
||||
}
|
||||
|
||||
export default useNavigation;
|
Reference in New Issue
Block a user