Skip to content

Commit 372f7d1

Browse files
committed
zxt 发送定位
1 parent 92445c6 commit 372f7d1

7 files changed

Lines changed: 44 additions & 13 deletions

File tree

‎android/app/build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ android {
160160
}
161161

162162
dependencies {
163+
compile project(':react-native-amap-geolocation')
163164
compile project(':react-native-maps')
164165
api project(':react-native-splash-screen')
165166
api project(':react-native-fs')

‎android/app/src/main/java/com/supermap/itablet/MainApplication.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.supermap.imb.lic.LicConfig;
66
import com.facebook.react.ReactApplication;
7+
import cn.qiuxiang.react.geolocation.AMapGeolocationPackage;
78
import com.airbnb.android.react.maps.MapsPackage;
89
import org.devio.rn.splashscreen.SplashScreenReactPackage;
910
import com.github.yamill.orientation.OrientationPackage;
@@ -30,6 +31,7 @@ public boolean getUseDeveloperSupport() {
3031
protected List<ReactPackage> getPackages() {
3132
return Arrays.<ReactPackage>asList(
3233
new MainReactPackage(),
34+
new AMapGeolocationPackage(),
3335
new MapsPackage(),
3436
new OrientationPackage(),
3537
new RNFSPackage(),

‎android/settings.gradle‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
rootProject.name = 'iTablet'
2+
include ':react-native-amap-geolocation'
3+
project(':react-native-amap-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-amap-geolocation/lib/android')
24
include ':react-native-maps'
35
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
46
include ':react-native-splash-screen'

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"react": "16.6.0-alpha.8af6728",
3434
"react-native": "0.57.4",
3535
"react-native-actionsheet": "^2.4.2",
36+
"react-native-amap-geolocation": "^0.3.2",
3637
"react-native-camera-roll-picker": "^1.2.3",
3738
"react-native-color-picker": "^0.4.0",
3839
"react-native-fs": "^2.13.3",

‎src/containers/tabs/Friend/Chat/Chat.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ class Chat extends React.Component {
541541
<GiftedChat
542542
placeholder="message..."
543543
messages={this.state.messages}
544+
showAvatarForEveryMessage={false}
544545
onSend={this.onSend}
545546
loadEarlier={this.state.loadEarlier}
546547
onLoadEarlier={this.onLoadEarlier}
@@ -645,12 +646,14 @@ class Chat extends React.Component {
645646
wrapperStyle={{
646647
left: {
647648
//对方的气泡
649+
marginTop: scaleSize(1),
648650
backgroundColor: 'white',
649651
overflow: 'hidden',
650652
borderRadius: scaleSize(10),
651653
},
652654
right: {
653655
//我方的气泡
656+
marginTop: scaleSize(1),
654657
backgroundColor: 'blue',
655658
overflow: 'hidden',
656659
borderRadius: scaleSize(10),

‎src/containers/tabs/Friend/Chat/CustomActions.js‎

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ import { SOnlineService } from 'imobile_for_reactnative'
1818
import { scaleSize } from '../../../../utils/screen'
1919
import NavigationService from '../../../NavigationService'
2020
import { Const } from '../../../../constants'
21-
22-
var GeolocationIOS = require('Geolocation')
23-
24-
import { Geolocation } from "react-native-amap-geolocation"
25-
26-
21+
var Geolocation = undefined
22+
if(Platform.OS === 'ios'){
23+
var GeolocationIOS = require('Geolocation')
24+
}else{
25+
import("react-native-amap-geolocation").then(result => {
26+
Geolocation = result.default.Geolocation
27+
})
28+
}
2729

2830
// eslint-disable-next-line no-unused-vars
2931
const ICONS = context => [
@@ -88,23 +90,37 @@ export default class CustomActions extends React.Component {
8890
if(Platform.OS === 'android'){
8991
Geolocation.init({
9092
ios: "9bd6c82e77583020a73ef1af59d0c759",
91-
android: "043b24fe18785f33c491705ffe5b6935",
93+
android: "078057f0e29931c173ad8ec02284a897",
9294
}).then(()=>{
9395
Geolocation.setOptions({
9496
interval: 8000,
9597
distanceFilter: 20,
9698
})
9799
Geolocation.addLocationListener(location => {
98-
GeoLocation.stop()
100+
Geolocation.stop()
99101
console.log(location)
102+
SOnlineService.reverseGeocoding(
103+
location.longitude,
104+
location.latitude,
105+
{
106+
onResult: result => {
107+
this.props.sendCallBack(3, {
108+
address: result,
109+
longitude: location.longitude,
110+
latitude: location.latitude,
111+
})
112+
// alert(result)
113+
},
114+
},
115+
)
100116
})
101117
})
102118
}
103119
}
104120
componentWillUnmount() {
105121
if (Platform.OS === 'android') {
106-
GeoLocation.removeLocationListener();
107-
GeoLocation.stop()
122+
// Geolocation.removeLocationListener();
123+
Geolocation.stop()
108124
}
109125
}
110126
setModalVisible(visible = false) {
@@ -201,7 +217,7 @@ export default class CustomActions extends React.Component {
201217
},
202218
)
203219
}else{
204-
GeoLocation.start()
220+
Geolocation.start()
205221
}
206222
}
207223
}

‎src/containers/tabs/Friend/Chat/CustomView.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ export default class CustomView extends React.Component {
4343
: [styles.fileContainer, styles.fileContainerRight]
4444
}
4545
>
46-
<Text style={styles.fileName}>
46+
<Text style={this.props.position === 'left'
47+
? styles.fileName : [styles.fileName, {color: 'white'}]}
48+
>
4749
{this.props.currentMessage.message.message.fileName}
4850
</Text>
49-
<Text style={styles.fileSize}>{fileSizeText}</Text>
51+
<Text style={this.props.position === 'left'
52+
? styles.fileSize : [styles.fileSize, {color: 'white'}]}
53+
>
54+
{fileSizeText}
55+
</Text>
5056
</View>
5157
)
5258
}

0 commit comments

Comments
 (0)