Commit 4d56c432 by CaryaLiu

feat: iOS相关改动

parent bb8bdbef
......@@ -9,6 +9,7 @@
import React, { useState } from 'react';
import {
NativeModules,
NativeEventEmitter,
SafeAreaView,
StyleSheet,
ScrollView,
......@@ -24,6 +25,7 @@ import {
import { BMCUI } from './ui.js'
import CustomerView from './CustomerView.js'
import CustomRoundImageView from './RoundedImage.js'
import MapView from './MapView.js'
import {
Header,
......@@ -33,6 +35,9 @@ import {
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
var ToastManager = NativeModules.ToastManager;
var AlertManager = NativeModules.AlertManager;
async function showConfirmVsCancelPromiseDialog(msg, leftTip, rightTip) {
try {
const {
......@@ -48,8 +53,37 @@ async function showConfirmVsCancelPromiseDialog(msg, leftTip, rightTip) {
}
}
// class App extends React.Component {
// onRegionChange(event) {
// console.log(event.region.latitude)
// }
// render() {
// const region = {
// latitude: 37.48,
// longitue: -122.16,
// latitudeDelta: 0.1,
// longitudeDelta: 0.1,
// };
// return (
// <MapView
// region={region}
// zoomEnabled={false}
// onRegionChange={this.onRegionChange}
// style={{ flex: 1 }}
// />
// );
// }
// }
const App = () => {
var index = 0;
const region = {
latitude: 37.48,
longitue: -122.16,
latitudeDelta: 0.1,
longitudeDelta: 0.1,
};
return (
<>
<StatusBar barStyle="dark-content" />
......@@ -63,7 +97,8 @@ const App = () => {
</View>
)}
<View style={styles.buttonContainer}>
<CustomerView />
<CustomerView style={{height: 80}}/>
<MapView region={region} zoomEnabled={false} style={{ flex: 1, height: 200}} />
</View>
<View style={styles.body}>
<View style={styles.buttonContainer}>
......@@ -93,7 +128,11 @@ const App = () => {
// NativeModules.BMCUI.showWithDuration("你点击了按钮!", NativeModules.BMCUI.SHORT);
// Alert.alert("你点击了按钮");
} else {
Alert.alert("ios undefine");
// Alert.alert("ios undefine");
// NativeModules.ToastManager
var alerts = "alert..." + NativeModules.AlertManager.alertStyleLight;
console.log(alerts)
AlertManager.showAlert("tesss")
}
}}
title="吐司"
......@@ -115,6 +154,7 @@ const App = () => {
// }, true, "你点击了按钮222!", "确定");
} else {
Alert.alert("ios undefine");
}
}}
title="单按钮提示框"
......
......@@ -5,10 +5,12 @@ import {
Image,
TextInput,
DeviceEventEmitter,
NativeEventEmitter,
TouchableHighlight,
TouchableNativeFeedback,
Platform,
Alert
Alert,
NativeModules
} from 'react-native';
import { BMCUI, ImagePicker } from './ui.js'
......@@ -73,6 +75,7 @@ export default class CustomerView extends React.Component {
componentDidMount() {
console.log("CustomerView componentDidMount");
if (Platform.OS == 'android') {
this.eventListener = DeviceEventEmitter.addListener('msg', (a) => {
// alert('收到通知:' + a);
console.log("收到通知:" + a);
......@@ -85,6 +88,12 @@ export default class CustomerView extends React.Component {
console.log("你点击了取确定按钮,结果为:" + result);
});
});
} else {
const alertEmitter = new NativeEventEmitter(NativeModules.AlertManager)
this.subscription = alertEmitter.addListener('msg', (a) => {
console.log("你收到事件" + a.test);
});
}
}
shouldComponentUpdate(nextProps, nextState, nextContext) {
......@@ -98,7 +107,11 @@ export default class CustomerView extends React.Component {
componentWillUnmount() {
console.log("CustomerView componentWillUnmount");
if (Platform.OS == 'android') {
this.eventListener.remove(); // Removes the listener
} else {
this.subscription.remove();
}
}
componentDidCatch(error, errorInfo) {
......
import PropTypes from 'prop-types';
import React from 'react';
import {
requireNativeComponent
} from 'react-native';
class MapView extends React.Component {
_onRegionChange = (event) => {
if (!this.props.onRegionChange) {
return;
}
this.props.onRegionChange(event.nativeEvent);
}
render() {
return (
<RNTMap
{...this.props}
onRegionChange={this._onRegionChange}
/>
);
}
}
MapView.prototypes = {
/**
* A Boolean value that determines whether the user may use pinch
* gestures to zoom in and out of the map.
*/
zoomEnabled: PropTypes.bool,
/**
* 地图要显示的区域。
*
* 区域由中心点坐标和区域范围坐标来定义。
*
*/
region: PropTypes.shape({
/**
* 地图中心点的坐标。
*/
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
/**
* 最小/最大经、纬度间的距离。
*
*/
latitudeDelta: PropTypes.number.isRequired,
longitudeDelta: PropTypes.number.isRequired,
}),
/**
* Callback that is called continuously when the user is dragging the map.
*/
onRegionChange: PropTypes.func,
};
const RNTMap = requireNativeComponent('RNTMap', MapView);
export default MapView;
\ No newline at end of file
ios @ 34c64df5
Subproject commit b7b2f8ccbd271883333f7aaa95186bfd5a0946bc
Subproject commit 34c64df58686624bb36578bba6f101b2745e6693
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment