56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:rogapp/pages/index/index_controller.dart';
|
|
import 'package:rogapp/routes/app_pages.dart';
|
|
import 'package:rogapp/services/destination_service.dart';
|
|
import 'package:rogapp/services/maxtrix_service.dart';
|
|
|
|
class DestinationController extends GetxController {
|
|
|
|
|
|
List<dynamic> destinations = <dynamic>[].obs;
|
|
Map<String, dynamic> matrix = {};
|
|
|
|
final IndexController indexController = Get.find<IndexController>();
|
|
|
|
@override
|
|
void onInit() {
|
|
PopulateDestinations();
|
|
super.onInit();
|
|
}
|
|
|
|
void PopulateDestinations(){
|
|
if(indexController.currentUser.isNotEmpty){
|
|
int user_id = indexController.currentUser[0]["user"]["id"] as int;
|
|
//print(user_id);
|
|
DestinationService.getDestinations(user_id).then((value){
|
|
|
|
MatrixService.getDestinations(value).then((mat){
|
|
print(mat);
|
|
matrix = mat;
|
|
|
|
destinations.clear();
|
|
destinations = value;
|
|
|
|
});
|
|
|
|
//var val = value[2]["location"]["id"];
|
|
//print("-----current destinations ----- ${val}");
|
|
});
|
|
}
|
|
else{
|
|
Get.toNamed(AppPages.LOGIN);
|
|
}
|
|
}
|
|
|
|
void makeOrder(BuildContext context, int action_id, int order, String dir){
|
|
DestinationService.updateOrder(action_id, order, dir).then((value){
|
|
//print("----action value----${value}");
|
|
PopulateDestinations();
|
|
});
|
|
|
|
}
|
|
|
|
} |