yarn add git+https://github.com/25juan/react-native-utils.git
import { FillToAspectRatio } from "react-native-utils";
<FillToAspectRatio>
<RNCamera { ...cameraProps }/>
</FillToAspectRatio
import { Text,View } from "react-native" ;
import { StyleUtils } from "react-native-utils";
<View style={{ fontSize:StyleUtils.getAutoSize(50) }}>
<Text style={{ fontSize:StyleUtils.getTextSize(14) }}/>
</View
import React, { Component, lazy, Suspense } from "react";
import { Text,View } from "react-native" ;
import { Dialog,RNDialog } from "react-native-utils";
let Navigation = lazy(() => import("./navigation"));
// 这儿通过 Suspense动态加载组件,等待Dialog渲染完成之后,
// Navigation组件里面才能调用对话框组件API
class App extends React.Component{
componentDidMount(){
// 调用弹框
RNDialog
.Alert
.showAlert({
title:'消息',
content:"",
buttons:[{
text:"取消",
props:{}}]
}).then(idex=>alert(`${idex}`)) ;
// Picker 框调用
RNDialog
.Picker
.showPicker({
title:'消息',
data:[{
title:"成都"
},{
title:"北京"
}]
}).then(obj=>console.log(obj));
// Toast 调用
RNDialog
.Toast
.show("Toast 调用成功");
// Loading 调用
RNDialog
.Loading
.show("数据加载中");
// Loading 调用
RNDialog
.FlatListPicker
.show([{ label:"22",id:22 },{ label:"11",id:11 }]
,[11]).then(result=>{
console.log(result);
});
// AlertInput 调用
RNDialog.AlertInput.showAlert({
title:"修改",
content:"修改您的昵称",
inputProps:{
multiline:true,
style:{
height:50
}
}
}).then((obj)=>{
console.log(obj)
})
}
render() {
return (
<>
<Suspense fallback={<Loading />}>
<Navigation
ref={navigator => {
NavigationService.setTopLevelNavigator(navigator);
}}/>
</Suspense>
<Dialog />
</>
);
}
}