1 Star 0 Fork 1

hendyyou/react-native-hooks-basic

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.tsx 907 Bytes
一键复制 编辑 原始数据 按行查看 历史
第十人i 提交于 2020-04-21 17:24 . init
/**
* 适配安卓IOS刘海屏、异形屏方案
*/
import React, {useEffect, useState} from 'react';
import {Platform, SafeAreaView, NativeModules, StatusBar} from 'react-native';
import Navigation from './navigation';
// TODO 待完成 安卓异形屏适配
const App = () => {
const {StatusBarManager} = NativeModules;
const [statusBarHeight, setStatusBarHeight] = useState();
// 获取状态栏高度
const getHeight = () => {
let statusBarHeight;
if (Platform.OS === 'ios') {
StatusBarManager.getHeight((height: number) => {
statusBarHeight = height;
});
} else {
statusBarHeight = StatusBar.currentHeight;
setStatusBarHeight(statusBarHeight);
}
};
// 初始化加载一次
useEffect(() => {
getHeight();
}, []);
return (
<SafeAreaView style={{flex: 1}}>
<Navigation />
</SafeAreaView>
);
};
export default App;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hendyyou/react-native-hooks-basic.git
git@gitee.com:hendyyou/react-native-hooks-basic.git
hendyyou
react-native-hooks-basic
react-native-hooks-basic
master

搜索帮助