resolving issue about focus on map at first loading

This commit is contained in:
Brice Zele 2020-03-29 09:23:08 +01:00
parent 483283a574
commit 2d41abca6b
11 changed files with 426 additions and 384 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,8 +6,10 @@
"start": "node node_modules/react-native/local-cli/cli.js start", "start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest", "test": "jest",
"postinstall": "node ./fix-android/android-release-fix.js", "postinstall": "node ./fix-android/android-release-fix.js",
"release-build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/ && rm -rf android/app/src/main/res/drawable-* && rm -rf android/app/src/main/res/raw/* && cd android && ./gradlew assembleRelease && cd ..", "release-build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/ && rm -rf android/app/src/main/res/drawable-* && rm -rf android/app/src/main/res/raw/* && cd android && ./gradlew assembleRelease && cd .. && adb install android/app/build/outputs/apk/release/app-release.apk",
"debug-build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ && cd android && ./gradlew assembleDebug && cd .." "debug-build": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ && cd android && ./gradlew assembleDebug && cd .. && adb install android/app/build/outputs/apk/debug/app-debug.apk",
"start-emulator": "emulator -avd Nexus_6P_API_29 -dns-server 8.8.8.8",
"run-android": "cd android && ./gradlew clean && cd .. && react-native run-android"
}, },
"dependencies": { "dependencies": {
"@react-native-community/viewpager": "^3.3.0", "@react-native-community/viewpager": "^3.3.0",

View File

@ -172,13 +172,14 @@ class Home extends BaseScreen {
} }
}) })
this.componentDidAppear();
this.componentDidAppear()
}); });
this.blurListener = navigation.addListener("didBlur", (payload) => { this.blurListener = navigation.addListener("didBlur", (payload) => {
this.componentDidDisappear() this.componentDidDisappear()
}) })
this._retrieveData() this._retrieveData()
//this.toggleSlidingUp(false) //this.toggleSlidingUp(false)
if (this.props.coordinate) return; if (this.props.coordinate) return;
@ -196,6 +197,7 @@ class Home extends BaseScreen {
) )
if (granted === PermissionsAndroid.RESULTS.GRANTED) { if (granted === PermissionsAndroid.RESULTS.GRANTED) {
readUser().then((user) => { readUser().then((user) => {
console.log("MAP READY");
if (user) { if (user) {
if (user.category !== undefined && user.category !== null) { if (user.category !== undefined && user.category !== null) {
const myPosition = { const myPosition = {
@ -227,7 +229,7 @@ class Home extends BaseScreen {
} }
} else { } else {
this.getPosition() this.getPosition();
this.watchLocation(); this.watchLocation();
} }
} }
@ -417,8 +419,6 @@ class Home extends BaseScreen {
if (i.code === shortcountry) { if (i.code === shortcountry) {
this.setState({ indicatif: i.dial_code }) this.setState({ indicatif: i.dial_code })
this.getNetworks(i.dial_code) this.getNetworks(i.dial_code)
} }
} }
@ -524,6 +524,7 @@ class Home extends BaseScreen {
readUser().then((user) => { readUser().then((user) => {
if (user) { if (user) {
if (user.category) { if (user.category) {
this.setState({ user: user }) this.setState({ user: user })
this.setState({ network: user.network }); this.setState({ network: user.network });
@ -538,11 +539,10 @@ class Home extends BaseScreen {
latitudeDelta: 0.03, latitudeDelta: 0.03,
longitudeDelta: 0.01, longitudeDelta: 0.01,
} }
this.setState({ myPosition: myPosition }); this.setState({ myPosition: myPosition });
this.refocusMap(false);
} }
if (this.state.myPosition)
this.refocusMap()
/*if (Platform.OS === 'android') { /*if (Platform.OS === 'android') {
// this.requestCameraPermission(); // this.requestCameraPermission();
} else { } else {
@ -1182,10 +1182,12 @@ class Home extends BaseScreen {
lang={this.state.lang} lang={this.state.lang}
myPosition={this.state.myPosition} myPosition={this.state.myPosition}
onMapReady={() => { onMapReady={() => {
readUser().then((user) => { readUser().then((user) => {
if (user) { if (user) {
this.setState({ user: user }) this.setState({ user: user })
this.setState({ network: user.network }); this.setState({ network: user.network });
if (user.category) { if (user.category) {
this.setState({ loadingDialog: false }) this.setState({ loadingDialog: false })
if (user.category !== "geolocated") { if (user.category !== "geolocated") {
@ -1376,33 +1378,8 @@ class Home extends BaseScreen {
myNetwork={this.state.myNetwork} myNetwork={this.state.myNetwork}
lang={this.state.lang} lang={this.state.lang}
myPosition={this.state.myPosition} myPosition={this.state.myPosition}
onMapReady={() => { onMapReady={Platform.OS === 'android' ? this.onMapReady : null}
readUser().then((user) => { onLayout={Platform.OS === 'ios' ? this.onMapReady : null}
if (user) {
this.setState({ user: user })
this.setState({ network: user.network });
if (user.category) {
this.setState({ loadingDialog: false })
if (user.category !== "geolocated") {
this.showMyMembers();
} else {
if (myPosition.latitude <= 0 && myPosition.longitude <= 0) {
this.props.navigation.push(route.updateinfo);
}
}
} else {
if (Platform.OS === 'android') {
this.requestCameraPermission();
} else {
this.getPosition();
this.watchLocation();
}
}
}
})
}}
needRoad={this.state.needRoad} needRoad={this.state.needRoad}
onNeedRoadReady={(data) => { onNeedRoadReady={(data) => {
this.setState({ showProgress: false }) this.setState({ showProgress: false })
@ -1426,6 +1403,55 @@ class Home extends BaseScreen {
</View> </View>
) )
} }
onMapReady = () => {
readUser().then((user) => {
if (user) {
this.setState({ user: user })
this.setState({ network: user.network });
const myPosition = {
latitude: parseFloat(user.latitude),
longitude: parseFloat(user.longitude)
}
this.mapRef.animateCamera({
center: {
latitude: myPosition.latitude,
longitude: myPosition.longitude
},
pitch: 0,
heading: 0,
altitude: 5,
zoom: 12
}, 1000);
if (user.category) {
this.setState({ loadingDialog: false })
if (user.category !== "geolocated") {
this.showMyMembers();
} else {
if (myPosition.latitude <= 0 && myPosition.longitude <= 0) {
this.props.navigation.push(route.updateinfo);
}
}
} else {
if (Platform.OS === 'android') {
this.requestCameraPermission();
} else {
this.getPosition();
this.watchLocation();
}
}
}
})
.catch((error) => {
console.log(error.message)
});
}
renderTutoOldHome() { renderTutoOldHome() {
return (<View style={{ flex: 1 }}> return (<View style={{ flex: 1 }}>

View File

@ -32,7 +32,8 @@ class IMap extends PureComponent {
isNeedUserFocus: PropTypes.bool, isNeedUserFocus: PropTypes.bool,
onNeedRoadReady: PropTypes.func, onNeedRoadReady: PropTypes.func,
onNeedRoadError: PropTypes.func, onNeedRoadError: PropTypes.func,
onMapReady: PropTypes.func onMapReady: PropTypes.func,
onLayout: PropTypes.func
}; };
static defaultProps = { static defaultProps = {
@ -73,6 +74,7 @@ class IMap extends PureComponent {
mapType={typeMap} mapType={typeMap}
ref={(re) => this.mapview = re} ref={(re) => this.mapview = re}
onMapReady={this.props.onMapReady} onMapReady={this.props.onMapReady}
onLayout={this.props.onLayout}
onRegionChangeComplete={(re) => { this.onRegionChangeOver(re) }}> onRegionChangeComplete={(re) => { this.onRegionChangeOver(re) }}>
{this.state.markers.map((item, index) => { {this.state.markers.map((item, index) => {
return ( return (

View File

@ -13,8 +13,7 @@ import {
const userposi = require('./../../datas/img/png/user_place.png'); const userposi = require('./../../datas/img/png/user_place.png');
const mnetwork = require('./../../datas/img/png/home_network.png'); const mnetwork = require('./../../datas/img/png/home_network.png');
const othernetwork = require('./../../datas/img/png/other_net.png'); const othernetwork = require('./../../datas/img/png/other_net.png');
class IMarker extends PureComponent class IMarker extends PureComponent {
{
constructor(props) { constructor(props) {
super(props) super(props)
const data = this.props.data const data = this.props.data
@ -37,7 +36,7 @@ class IMarker extends PureComponent
longitude: parseFloat(nextProps.data.longitude), longitude: parseFloat(nextProps.data.longitude),
latitude: parseFloat(nextProps.data.latitude), latitude: parseFloat(nextProps.data.latitude),
} }
if (oldCoord.longitude!==coord.longitude || oldCoord.latitude!==coord.latitude) { if (oldCoord.longitude !== coord.longitude || oldCoord.latitude !== coord.latitude) {
if (Platform.OS === 'android') { if (Platform.OS === 'android') {
if (this.markerRef) { if (this.markerRef) {
this.markerRef._component.animateMarkerToCoordinate( this.markerRef._component.animateMarkerToCoordinate(

View File

@ -236,7 +236,8 @@ export class LoginUi extends Component {
} }
for (let i of country) { for (let i of country) {
if (i.code === shortcountry) { if (i.code === shortcountry) {
this.setState({ indicatif: i.dial_code, enterPhone: i.dial_code }) this.setState({ indicatif: i.dial_code, enterPhone: i.dial_code });
console.log("DIAL CODE", i.dial_code);
} }
} }
} else { } else {

View File

@ -4,6 +4,7 @@
"HELP": "Help", "HELP": "Help",
"SIMPLE_USER": "Simple User", "SIMPLE_USER": "Simple User",
"ABOUT": "About us", "ABOUT": "About us",
"ACTION_TREAT_DEMAND": "Treat demand",
"ABOUT_TEXT": "iLink is an application that will facilitate your financial transactions near your location, and give you multiservice points near you.", "ABOUT_TEXT": "iLink is an application that will facilitate your financial transactions near your location, and give you multiservice points near you.",
"GEOLOCATED_USER": "Geo located user", "GEOLOCATED_USER": "Geo located user",
"SUPERVISOR": "Supervisor", "SUPERVISOR": "Supervisor",
@ -103,7 +104,8 @@
"ERROR_FILTER_TEXT": "Problem encountered while filtering.", "ERROR_FILTER_TEXT": "Problem encountered while filtering.",
"YOUR_THERE": "You are here", "YOUR_THERE": "You are here",
"FILTER": "Filter", "FILTER": "Filter",
"QUIT": "Quitter", "QUIT": "Quit",
"QUIT_": "Quit",
"APP_FULLNAME": "Ilink World", "APP_FULLNAME": "Ilink World",
"GUIDE_TITLE": "Welcome to the Guide of", "GUIDE_TITLE": "Welcome to the Guide of",
"GUIDE_USER_SIMPLE": "Guide for a user", "GUIDE_USER_SIMPLE": "Guide for a user",
@ -187,6 +189,7 @@
"SEARCH": "Search", "SEARCH": "Search",
"SEE_VIDEO": "Watch the video", "SEE_VIDEO": "Watch the video",
"SEE_TUTO": "See the tutorial", "SEE_TUTO": "See the tutorial",
"SELECT_NETWORK": "Select your",
"DELETE": "Delete", "DELETE": "Delete",
"FREE": "Available", "FREE": "Available",
"SAVED": "Registered", "SAVED": "Registered",
@ -246,6 +249,8 @@
"TEXT_UPDATE_POSITION_FAILED_2": "Unable to retrieve your location", "TEXT_UPDATE_POSITION_FAILED_2": "Unable to retrieve your location",
"TITLE_ERROR_SURVENU": "An error has occurred!", "TITLE_ERROR_SURVENU": "An error has occurred!",
"TITLE_PROBLE_COME": "A problem has been encountered", "TITLE_PROBLE_COME": "A problem has been encountered",
"TITLE_SUPPRESS_CONFIRM": "Confirm deletion",
"TEXT_SUPPRESS_CONFIRM": "Do you really want to delete this user ?",
"TEXT_ERROR_START_APPLICATION": "An error occurred while starting iLink World, please restart iLink World", "TEXT_ERROR_START_APPLICATION": "An error occurred while starting iLink World, please restart iLink World",
"TEXT_UNABLE_TO_GET_YOUR_POSITION": "Unable to retrieve your location, please make sure your GPS is enabled and restart iLink World", "TEXT_UNABLE_TO_GET_YOUR_POSITION": "Unable to retrieve your location, please make sure your GPS is enabled and restart iLink World",
"RESTART": "REPEAT", "RESTART": "REPEAT",

View File

@ -4,6 +4,7 @@
"HELP": "Aide", "HELP": "Aide",
"SIMPLE_USER": "Utilisateur simple", "SIMPLE_USER": "Utilisateur simple",
"ABOUT": "A Propos", "ABOUT": "A Propos",
"ACTION_TREAT_DEMAND": "Traiter la demande",
"ABOUT_TEXT": "iLink est une application qui facilitera vos transactions financières près de votre position, et vous donne les points multiservices prêt de chez vous.", "ABOUT_TEXT": "iLink est une application qui facilitera vos transactions financières près de votre position, et vous donne les points multiservices prêt de chez vous.",
"GEOLOCATED_USER": "Utilisateur géo-localisé", "GEOLOCATED_USER": "Utilisateur géo-localisé",
"SUPERVISOR": "Superviseur", "SUPERVISOR": "Superviseur",
@ -104,6 +105,7 @@
"YOUR_THERE": "Vous êtes ici", "YOUR_THERE": "Vous êtes ici",
"FILTER": "Filtrer", "FILTER": "Filtrer",
"QUIT": "Quitter", "QUIT": "Quitter",
"QUIT_": "Quitter",
"APP_FULLNAME": "Ilink World", "APP_FULLNAME": "Ilink World",
"GUIDE_TITLE": "Bienvenue dans le Guide de", "GUIDE_TITLE": "Bienvenue dans le Guide de",
"GUIDE_USER_SIMPLE": "Guide pour un utilisateur", "GUIDE_USER_SIMPLE": "Guide pour un utilisateur",
@ -187,6 +189,7 @@
"SEARCH": "Rechercher", "SEARCH": "Rechercher",
"SEE_VIDEO": "Voir la vidéo", "SEE_VIDEO": "Voir la vidéo",
"SEE_TUTO": "Voir le tutoriel", "SEE_TUTO": "Voir le tutoriel",
"SELECT_NETWORK": "Sélectionner votre réseau",
"DELETE": "Supprimer", "DELETE": "Supprimer",
"FREE": "disponibles", "FREE": "disponibles",
"SAVED": "enregistrés", "SAVED": "enregistrés",
@ -246,6 +249,8 @@
"TEXT_UPDATE_POSITION_FAILED_2": "Impossible de recuperer votre position", "TEXT_UPDATE_POSITION_FAILED_2": "Impossible de recuperer votre position",
"TITLE_ERROR_SURVENU": "Une erreur est survenue !", "TITLE_ERROR_SURVENU": "Une erreur est survenue !",
"TITLE_PROBLE_COME": "Un problème a été rencontré", "TITLE_PROBLE_COME": "Un problème a été rencontré",
"TITLE_SUPPRESS_CONFIRM": "Confirmation de suppression",
"TEXT_SUPPRESS_CONFIRM": "Voulez vous vraiment supprimer cet utilisateur ?",
"TEXT_ERROR_START_APPLICATION": "Une erreur est survenue au démarrage de iLink World. Veuillez relancer iLink World", "TEXT_ERROR_START_APPLICATION": "Une erreur est survenue au démarrage de iLink World. Veuillez relancer iLink World",
"TEXT_UNABLE_TO_GET_YOUR_POSITION": "Impossible de recupérez votre position. Veuillez verifier que votre GPS est activé et relancez iLink World", "TEXT_UNABLE_TO_GET_YOUR_POSITION": "Impossible de recupérez votre position. Veuillez verifier que votre GPS est activé et relancez iLink World",
"RESTART": "RECOMMENCER", "RESTART": "RECOMMENCER",

View File

@ -9,7 +9,7 @@ const baseUrl = "https://ilink-app.com/mobilebackend"
//base url agent test //base url agent test
//const baseUrl = "https://ilink-app.com/mobilebackendtest" //const baseUrl = "https://ilink-app.com/mobilebackendtest"
//
export const adhesionUrl = baseUrl + '/interacted/LoginAction.php'; export const adhesionUrl = baseUrl + '/interacted/LoginAction.php';
export const memberActionUrl = baseUrl + '/interacted/MembersAction.php'; export const memberActionUrl = baseUrl + '/interacted/MembersAction.php';
export const networkActionUrl = baseUrl + '/interacted/NetworkAction.php'; export const networkActionUrl = baseUrl + '/interacted/NetworkAction.php';

View File

@ -26,9 +26,11 @@ export const loadMarkers=(position,reseau,distance,page)=>{
return readUser().then((users) => { return readUser().then((users) => {
let user = users; let user = users;
if (user !== undefined) { if (user !== undefined) {
let tag={tag:'location',type:'around', let tag = {
tag: 'location', type: 'around',
page: page, page: page,
id:user.id,position:position,network:reseau,distance:distance} id: user.id, position: position, network: reseau, distance: distance
}
return queryMap(tag) return queryMap(tag)
} }
}) })
@ -45,11 +47,13 @@ export const loadNetwork=(network,userid)=>{
} }
export const getPositionInformation = async (position) => { export const getPositionInformation = async (position) => {
let url = GEOCODDING_URL.concat('?latlng=' + position.latitude + "," + position.longitude + '&key=' + API_KEY); let url = GEOCODDING_URL.concat('?latlng=' + position.latitude + "," + position.longitude + '&key=' + API_KEY);
const data=fetch(url,{ method: 'GET', const data = fetch(url, {
method: 'GET',
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
},}) },
})
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => .then((responseJson) =>
responseJson responseJson
@ -74,13 +78,13 @@ const queryMap= async (data)=>{
}); });
let responseText = await response.text() let responseText = await response.text()
console.log("response= "+responseText) //console.log("response= " + responseText)
try { try {
let responseJson = JSON.parse(responseText) let responseJson = JSON.parse(responseText)
return responseJson; return responseJson;
} catch (e) { } catch (e) {
console.log("erreur="+responseText) //console.log("erreur=" + responseText)
console.log(response) //console.log(response)
throw new Error("Erreur lors de la conversion en json") throw new Error("Erreur lors de la conversion en json")
} }
throw new Error("Erreur lors de la conversion en json") throw new Error("Erreur lors de la conversion en json")

View File

@ -10,8 +10,6 @@ export default class Configuration{
const da = await _getData() const da = await _getData()
if (da) resolve(da) if (da) resolve(da)
else reject(da) else reject(da)
} }
async getCurrentPasValue() { async getCurrentPasValue() {