update to init loading

This commit is contained in:
Mohamed Nouffer
2023-01-03 12:00:28 +05:30
parent f8a79842e3
commit d56ed36be5
4 changed files with 18 additions and 6 deletions

View File

@ -514,13 +514,19 @@ class DestinationController extends GetxController {
void onReady() {
Get.toNamed(AppPages.LOGIN)!.then((value){
if(indexController.currentUser.length > 0) {
Get.toNamed(AppPages.INITIAL);
LocationService.getLocationsExt().then((value) {
String _token = indexController.currentUser[0]["token"];
indexController.switchPage(AppPages.INITIAL);
LocationService.getLocationsExt(_token).then((value) {
if(value != null){
print("--- loc ext is - ${value} ----");
LatLngBounds bnds = LatLngBounds(LatLng(value[1], value[0]), LatLng(value[3], value[2]));
print("--- bnds is - ${bnds} ----");
indexController.mapController!.fitBounds(bnds); //.centerZoomFitBounds(bnds);
indexController.mapController!.fitBounds(
bnds,
);
indexController.currentBound.clear();
indexController.currentBound.add(bnds);
indexController.loadLocationsBound();
}
});
}

View File

@ -31,9 +31,11 @@ class AuthService{
static Future<Map<String, dynamic>> login(String email, String password) async {
print("------- in logged email ${email} pwd ${password} ###### --------");
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/login/';
print("------- in logged url ${url} ###### --------");
//String url = 'http://localhost:8100/api/login/';
final http.Response response = await http.post(
Uri.parse(url),

View File

@ -76,15 +76,19 @@ class LocationService{
return null;
}
static Future<List<dynamic>?> getLocationsExt() async {
static Future<List<dynamic>?> getLocationsExt(String token) async {
List<dynamic> ext = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/locsext/';
//String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id;
final response = await http.get(Uri.parse(url),
final response = await http.post(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
},
body: jsonEncode(<String, String>{
'token': token,
})
);
if (response.statusCode == 200) {

View File

@ -5,7 +5,7 @@ class ConstValues{
static const container_svr = "http://container.intranet.sumasen.net:8100";
static const server_uri = "https://rogaining.sumasen.net";
static const dev_server = "http://localhost:8100";
static const dev_ip_server = "http://192.168.1.10:8100";
static const dev_ip_server = "http://192.168.8.100:8100";
static const dev_home_ip_server = "http://172.20.10.9:8100";
static String currentServer(){