/*
 * @Author: WuWei
 * @Date: 2020-06-17 15:55:37
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-04-06 10:59:11
 * @Description:
 */

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

class SearchParkDetailStore with ChangeNotifier {
  final BuildContext context;
  late Map args;
  final communityGlobalStore = GetIt.I.get<CommunityGlobalStore>();

  SearchParkDetailStore(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': '临停'
  };

  SearchParkDetailModel? parkDetail;

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

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