import 'package:cs_resources/generated/assets.dart';
import 'package:flutter/cupertino.dart';
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
import 'package:plugin_platform/engine/toast/toast_engine.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shared/utils/color_utils.dart';
import 'package:shared/utils/log_utils.dart';
import 'package:widgets/my_text_view.dart';
import '../../components/bottomDialog.dart';
import './property_ioan_state.dart';

part 'property_ioan_vm.g.dart';

@riverpod
class PropertyIoanVm extends _$PropertyIoanVm {
  PropertyIoanState initState() {
    return PropertyIoanState(
        lowestFloatingRate: "3.79%",
        lowestFixedRate: "2.48%",
        othersOfferingPic: "",
        othersOfferingInfoList: [
          {
            "floating": "3.08%",
            "fixed": "3.79%",
          },
          {
            "floating": "3.08%",
            "fixed": "3.79%",
          }
        ],
        offerTextInfoList: [
            {
              "title": "New HomeLoans",
              "icon": Assets.propertyNewHomeLoans,
              "iconWidth": 46.0,
              "iconHeight": 42.5
            },
            {
              "title": "Refinancing",
              "icon": Assets.propertyRefinancing,
              "iconWidth": 37.0,
              "iconHeight": 41.5
            },
            {
              "title": "Home EquityLoans",
              "icon": Assets.propertyHomeEquityLoans,
              "iconWidth": 41.5,
              "iconHeight": 42.5
            },
            {
              "title": "ConveyancingLawyer",
              "icon": Assets.propertyConveyancingLawyer,
              "iconWidth": 42.0,
              "iconHeight": 42.0
            },
            {
              "title": "Approval in Principle",
              "icon": Assets.propertyApproval,
              "iconWidth": 41.0,
              "iconHeight": 39.0
            },
            {
              "title": "OverseasHome Loan",
              "icon": Assets.propertyOverseasHomeLoan,
              "iconWidth": 36.0,
              "iconHeight": 39.0
            }
        ]
    );
  }

  @override
  PropertyIoanState build(){
    // 引入数据仓库
    // propertyIoanRepository = ref.read(propertyIoanRepositoryProvider);
    // 初始化状态
    PropertyIoanState state = initState();
    // 初始化列表数据
    return state;
  }

  requestQuoteConfirmAction(){
    Log.d("点击了确定");
    DialogEngine.dismiss(tag: "requestQuote");
  }

  requestQuoteCancelAction(){
    Log.d("点击了取消");
  }

  handlerRequestQuote(BuildContext context) async {
    Log.d("点击了请求报价");
    ToastEngine.show("暂未开放");
    await DialogEngine.show(
      tag: "requestQuote",
      position: DialogPosition.bottom,
      widget: BottomDialog(
        confirmAction: requestQuoteConfirmAction,
        cancelAction: requestQuoteCancelAction,
        messageBuilder: (context) {
          return Container(
            padding: const EdgeInsets.only(left: 15,right: 15),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                MyTextView(
                  "Submit Request?",
                  textColor: ColorUtils.string2Color('#000000'),
                  textAlign: TextAlign.left,
                  fontWeight: FontWeight.w500,
                  fontSize: 21,
                  // maxLines: 5,
                  marginBottom: 20,
                ),
                MyTextView(
                  "A mortgage specialist will be incontact to help you compare theatest housing loan rates and tosecure the best package that suitsyour need",
                  textColor: ColorUtils.string2Color('#666666'),
                  textAlign: TextAlign.left,
                  // maxLines: 5,
                ),
                MyTextView(
                  "This is a complementary servicebrought to you by YY Home",
                  textColor: ColorUtils.string2Color('#666666'),
                  textAlign: TextAlign.left,
                  // maxLines: 5,
                  marginTop: 15,
                ),
              ]
            )
          );
        },
      ),
    );
  }
}