
import 'package:farmer_client/pages/machinery/map/widgets/detail.dart';
import 'package:farmer_client/widgets/layout/BasicPage.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../models/entities/CardInfo.dart';
import '../../../services/homeAPI.dart';

class MachineryMapPage extends BasicPage {
  String markId = '';
  String marKm = '';
  final machineryInfoContent = Rx<CardInfo>(CardInfo());//全部详情
  // 响应预约事件
  void handleClick() {
    // Get.toNamed("/machineryDetail");
    Get.toNamed('/orderConfirmation',arguments: {'item':machineryInfoContent()});

  }

  @override
  void beforeShow() {
    // TODO: implement onMounted
    super.beforeShow();
    if (Get.arguments['id'] != null) {
      markId = Get.arguments['id'];
      marKm = Get.arguments['km'];
      print(marKm);
      getMachineryInfo(markId, '122.08400000000002,37.421998333333335', true).then((value) {
        machineryInfoContent(CardInfo.fromJson(value));

      });

    }
    print("----show----map page--------------");
  }

  @override
  void beforeHide() {
    // TODO: implement beforeHide
    super.beforeHide();
    print("-----hide---map page--------------");
  }

  @override
  Widget builder(BuildContext context) {
    naviTitle = "查看地图";
    return Obx(()=>page(context: context, handleClick: handleClick,item: machineryInfoContent(),km: marKm));
  }
  
}

