1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
react-native-wechat/example/App.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-07-31 14:47:29 +08:00
import React, { Component } from 'react';
2020-08-01 18:05:40 +08:00
import { Platform, SafeAreaView, StyleSheet, Text, View } from 'react-native';
2020-08-01 19:44:52 +08:00
import Wechat from '@uiw/react-native-wechat';
2020-07-31 14:47:29 +08:00
2020-08-01 18:05:40 +08:00
export default class App extends Component {
2020-07-31 14:47:29 +08:00
state = {
2020-08-01 19:59:12 +08:00
isInstall: false,
isWXAppSupportApi: false,
2020-07-31 14:47:29 +08:00
};
2020-08-01 19:44:52 +08:00
async componentDidMount() {
const isInstall = await Wechat.isWXAppInstalled();
2020-08-01 19:59:12 +08:00
const isWXAppSupportApi = await Wechat.isWXAppSupportApi();
this.setState({
isInstall, isWXAppSupportApi
});
2020-07-31 14:47:29 +08:00
}
render() {
2020-08-01 19:59:12 +08:00
const { isInstall, isWXAppSupportApi } = this.state;
2020-07-31 14:47:29 +08:00
return (
2020-08-01 18:05:40 +08:00
<SafeAreaView style={{ flex: 1 }}>
<View style={styles.container}>
<Text style={styles.welcome}>Wechat Example</Text>
2020-08-01 19:59:12 +08:00
<Text>
<Text style={styles.instructions}>
<Text style={{color: isInstall ? 'green' : 'red'}}>{isInstall ? '有' : '没有'}</Text>
</Text>
<Text style={styles.instructions}>
当前微信的版本<Text style={{color: isWXAppSupportApi ? 'green' : 'red'}}>{isWXAppSupportApi ? '支持' : '不支持'}</Text> OpenApi
</Text>
</Text>
2020-08-01 18:05:40 +08:00
</View>
</SafeAreaView>
2020-07-31 14:47:29 +08:00
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
2020-08-01 18:05:40 +08:00
// justifyContent: 'center',
2020-07-31 14:47:29 +08:00
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});