import 'package:feelverapp/model/Login/login_model.dart';
import 'package:feelverapp/model/category/category_model.dart';
import 'package:feelverapp/model/editprofile/getprofilemodel.dart';
import 'package:feelverapp/model/home/home_model.dart';
import 'package:feelverapp/model/nearme/nearme_list_model.dart';
import 'package:feelverapp/service/Loading.dart';

import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/service/base_presenter.dart';
import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/util/Accout_util.dart';
import 'package:flutter/material.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'package:feelverapp/ui/shop/shop_Nearby_places.dart';


class ShopNearByPlacePresenter extends BasePresenter<ShopNearbyPlacesPage> {
  final formkey = GlobalKey<FormState>();
  Api _api;
  String type = '3';
  NearMeListModel getmodel ;

  ShopNearByPlacePresenter(State<ShopNearbyPlacesPage> state) : super(state);


  getnearme() async {

    _api = Api<NearMeListModel>();

    var res = await _api.getNearList({});

    if(res.fail == null){
      if(res.success.status){
        setState((){
          print("AAAA :${res.success}");
          getmodel = res.success;
//        print(getmodel.results.data.length);
//          print("getmodel" + getmodel[0].results.data[0].storeName);

        },);
      }
    }else{
      Alert(
          style: AlertStyle(
            animationType: AnimationType.fromTop,
            isCloseButton: false,
          ),
          context: state.context,
          title: "ไม่พบข้อมูล",
          content: Icon(
            Icons.warning,
            color: Colors.orange,
            size: 80,
          ),
          buttons: [
            DialogButton(
              color: Color.fromRGBO(106, 179, 170, 1),
              onPressed: () => Navigator.pop(state.context),
              child: Text(
                "ลองอีกครั้ง",
                style: TextStyle(color: Colors.white, fontSize: 20),
              ),
            )
          ]).show();
    }
  }

//  getnearme() async {
//    _api = Api<NearMeListModel>();
//
//    var res = await _api.getNearList({});
//    print("Hii" + getmodel[0].storeName);
//    print("Hii2" + res.success);
//
//    if (res.fail == null) {
//      setState(() {
//        NearMeListModel model = res.success;
//
////        getmodel = res.success
//      }
//      );
//    } else {
//      Alert(
//          style: AlertStyle(
//            animationType: AnimationType.fromTop,
//            isCloseButton: false,
//          ),
//          context: state.context,
//          title: "ไม่สามารถติดต่อ\nเซิร์ฟเวอร์ได้",
//          content: Icon(
//            Icons.warning,
//            color: Colors.orange,
//            size: 80,
//          ),
//          buttons: [
//            DialogButton(
//              color: Color.fromRGBO(106, 179, 170, 1),
//              onPressed: () => Navigator.pop(state.context),
//              child: Text(
//                "ลองอีกครั้ง",
//                style: TextStyle(color: Colors.white, fontSize: 20),
//              ),
//            )
//          ]).show();
//    }
//  }
}
