import 'package:domain/entity/paid_service_detail_entity.dart';
import 'package:domain/entity/paid_service_pay_success_info_entity.dart';
import 'package:flutter/cupertino.dart';
import 'package:widgets/load_state_layout.dart';

class ServiceOrderConfirmState {

  double? get totalPrice => cleanServiceToTalCost?? 0.0.toDouble() + extraCost! ?? 0.0.toDouble(); // 总价（包含购买的所有服务的价格 + 加急/节假日/夜间 等的价格总和）
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;
  double? cleanServiceToTalCost;  // 服务项目的总价（不包含加急/节假日/夜间 等的价格）
  double? extraCost; // 额外费用（加急/节假日/夜间 等的额外费用）
  String? visitTime;
  Map<String, Map<String, dynamic>> remarkInfo;
  PaidServiceDetailEntity? datas;

  // 成功支付后的数据
  PaidServicePaySuccessInfoEntity? paidServicePaySuccessInfo;


  ServiceOrderConfirmState({
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    double? cleanServiceToTalCost,
    this.extraCost = 0.0,
    this.visitTime,
    remarkInfo,
    this.datas,
    this.paidServicePaySuccessInfo,
  }): remarkInfo = remarkInfo ?? {
    "remark": {
      'value': '',
      'controller': TextEditingController(),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
  }, cleanServiceToTalCost = cleanServiceToTalCost ?? 0.0;

  ServiceOrderConfirmState copyWith({
    LoadState? loadingState,
    String? errorMessage,
    double? cleanServiceToTalCost,
    double? extraCost,
    String? visitTime,
    Map<String, dynamic>? remarkInfo,
    PaidServiceDetailEntity? datas,
    PaidServicePaySuccessInfoEntity? paidServicePaySuccessInfo,
  }) {
    return ServiceOrderConfirmState(
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      cleanServiceToTalCost: cleanServiceToTalCost ?? this.cleanServiceToTalCost,
      extraCost: extraCost ?? this.extraCost,
      visitTime: visitTime ?? this.visitTime,
      remarkInfo: remarkInfo ?? this.remarkInfo,
      datas: datas ?? this.datas,
    );
  }
}