/*
 * @Author: XianKaiQun
 * @Date: 2020-07-29 11:49:32
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-08-03 15:58:52
 * @Description: 
 */

import 'package:flutter/material.dart';
import 'package:qrcode_package/src/impl/repair_service_impl.dart';
import 'package:qrcode_package/src/models/repair_equipment_detail.dart';

class PrivateRepairDetailStore with ChangeNotifier {
  final BuildContext context, providerContext;
  late Map<String, dynamic> routingArgs;
  PrivateRepairDetailStore(this.context, this.providerContext) {
    routingArgs = (ModalRoute.of(context)?.settings.arguments ??
            new Map<String, dynamic>()) as Map<String, dynamic>? ?? {};
  }
  String? get id => routingArgs['id'];

  ///设备详情
  RepairEquipmentDetailModel? data;

  ///设备详情
  Future getData() async {
    final res = await RepairServiceImpl.instance!.getEquipmentDetail(id);
    data = res.data ?? RepairEquipmentDetailModel();
    notifyListeners();
  }

  ///路由到二级详情
  route2detailItem(String? id) {
    Navigator.pushNamed(context, 'qrcode/repair_detail_item',
        arguments: {'id': id});
  }
}
