/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-05-25 15:00:21
 * @LastEditTime : 2023-06-15 15:45:33
 * @Description  : Do not edit
 */
/*
 * @Author: WuWei
 * @Date: 2020-06-16 17:11:25
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-07-09 10:25:36
 * @Description:
 */

import 'package:app_package/app_package.dart';
import 'package:flutter/widgets.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import '../models/search_car_detail.dart';
import '../impl/searchindex_service_impl.dart';

class SearchCarDetailStore with ChangeNotifier {
  final BuildContext context;
  late Map args;

  SearchCarDetailStore(this.context) {
    args =
        ModalRoute.of(context)!.settings.arguments as Map<dynamic, dynamic>? ??
            {};
  }

  final scorllViewKey = GlobalKey<WisScrollViewState>();

  /// 车辆类型 [carType]
  final Map carType = {
    'smallCar': '小型汽车',
    'mediumCar': '中型汽车',
    'largeCar': '大型汽车',
    'motorcycle': '摩托车',
    'electricBike': '电动自行车',
    'tricycle': '三轮车'
  };

  final Map residentType = {
    'selfOwner': '独立产权人',
    'jointOwner': '共有产权人',
    'tenant': '租户',
    'relatives': '亲属',
    'enterprise': '企事业单位'
  };

  final Map parkType = {
    'titleParking': '产权车位',
    'publicParking': '公共车位',
    'defenseParking': '人防车位',
    'parkingCard': '停车卡',
    'storageRoom': '储藏间',
  };

  final Map parkStatus = {
    'sold': '已售',
    'rented': '已租',
    'vacant': '空置',
    'personal': '自用',
    'waitSales': '待售',
    'waitRent': '待租',
    'tempStop': '临停'
  };

  SearchCarDetailModel? carDetail;
  final communityGlobalStore = GetIt.I.get<CommunityGlobalStore>();

  ///从储存中取出的当前小区 拿出来可能是空
  CommunityModel? get currentCommunity => communityGlobalStore.data;

  Future getCarDetail({required id, bool isLoad = true}) async {
    if (id == null) return;
    late Map<String, dynamic> params = {'carId': id};
    var res = await SearchIndexServiceImpl.instance!.getCarDetail({...params});
    carDetail = res.data ?? SearchCarDetailModel();
    notifyListeners();
  }
}
