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/booking/booking_detail.dart';

import '../../model/booking_detail/booking_detail_model.dart';

class BookingDetailtPresenter extends BasePresenter<BookingDetail> {
  final formkey = GlobalKey<FormState>();
  Api _api;
  String type = '3';
  int getid;
  int vendor_id;
  int store_id;

  ProductModel getmodel;

  BookingDetailtPresenter(State<BookingDetail> state) : super(state);

  getDetail() async {
    print(getid);
    print(store_id);
    print(vendor_id);

    _api = Api<ProductModel>();

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

    if (res.fail == null) {
      if (res.success.status) {
        setState(
          () {
            print("AAAA :${res.success}");
            getmodel = res.success;

          },
        );
      }
    } 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();
//    }
//  }
}
