property_ioan_vm.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
  6. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  7. import 'package:riverpod_annotation/riverpod_annotation.dart';
  8. import 'package:shared/utils/color_utils.dart';
  9. import 'package:shared/utils/log_utils.dart';
  10. import 'package:widgets/load_state_layout.dart';
  11. import 'package:widgets/my_text_view.dart';
  12. import 'package:widgets/widget_export.dart';
  13. import 'package:widgets/dialog/dialog_content_wrap.dart';
  14. import './property_ioan_state.dart';
  15. part 'property_ioan_vm.g.dart';
  16. @riverpod
  17. class PropertyIoanVm extends _$PropertyIoanVm {
  18. bool _needShowPlaceholder = false; //是否展示LoadingView
  19. // Refresh 控制器
  20. final EasyRefreshController refreshController = EasyRefreshController(
  21. controlFinishRefresh: true, //允许刷新
  22. controlFinishLoad: true, //允许加载
  23. );
  24. PropertyIoanState initState() {
  25. return PropertyIoanState(
  26. lowestFloatingRate: "3.79%",
  27. lowestFixedRate: "2.48%",
  28. othersOfferingPic: "",
  29. othersOfferingInfoList: [
  30. {
  31. "floating": "3.08%",
  32. "fixed": "3.79%",
  33. },
  34. {
  35. "floating": "3.08%",
  36. "fixed": "3.79%",
  37. }
  38. ],
  39. offerTextInfoList: [
  40. {"title": S.current.new_homeLoans, "icon": Assets.propertyNewHomeLoans, "iconWidth": 46.0, "iconHeight": 42.5},
  41. {"title": S.current.refinancing, "icon": Assets.propertyRefinancing, "iconWidth": 37.0, "iconHeight": 41.5},
  42. {"title": S.current.home_equity_loans, "icon": Assets.propertyHomeEquityLoans, "iconWidth": 41.5, "iconHeight": 42.5},
  43. {"title": S.current.conveyancing_lawyer, "icon": Assets.propertyConveyancingLawyer, "iconWidth": 42.0, "iconHeight": 42.0},
  44. {"title": S.current.approval_in_principle, "icon": Assets.propertyApproval, "iconWidth": 41.0, "iconHeight": 39.0},
  45. {"title": S.current.overseas_home_loan, "icon": Assets.propertyOverseasHomeLoan, "iconWidth": 36.0, "iconHeight": 39.0}
  46. ],
  47. );
  48. }
  49. @override
  50. PropertyIoanState build() {
  51. // 引入数据仓库
  52. // propertyIoanRepository = ref.read(propertyIoanRepositoryProvider);
  53. // 初始化状态
  54. PropertyIoanState state = initState();
  55. // 初始化列表数据
  56. return state;
  57. }
  58. //刷新页面状态
  59. void changeLoadingState(LoadState loadState, String? errorMsg) {
  60. state = state.copyWith(loadingState: loadState, errorMessage: errorMsg);
  61. }
  62. // 重试请求
  63. Future retryRequest() async {
  64. _needShowPlaceholder = true;
  65. featchData();
  66. }
  67. // 初始化页面数据
  68. initPageData() {
  69. Log.d("----property_news_vm-----initPageData");
  70. featchData();
  71. }
  72. Future featchData() async {
  73. await Future.delayed(const Duration(milliseconds: 1500));
  74. //更新展示的状态
  75. changeLoadingState(LoadState.State_Success, null);
  76. // 最后赋值
  77. _needShowPlaceholder = false;
  78. }
  79. requestQuoteConfirmAction() {
  80. Log.d("点击了确定");
  81. DialogEngine.dismiss(tag: "requestQuote");
  82. }
  83. requestQuoteCancelAction() {
  84. Log.d("点击了取消");
  85. }
  86. handlerRequestQuote(BuildContext context) async {
  87. Log.d("点击了请求报价");
  88. // ToastEngine.show("暂未开放");
  89. await DialogEngine.show(
  90. tag: "requestQuote",
  91. position: DialogPosition.bottom,
  92. widget: DialogContentWrap(
  93. confirmAction: requestQuoteConfirmAction,
  94. cancelAction: requestQuoteCancelAction,
  95. messageBuilder: (context) {
  96. return Container(
  97. padding: const EdgeInsets.only(left: 15, right: 15),
  98. child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
  99. MyTextView(
  100. "Submit Request?",
  101. textColor: context.appColors.textBlack,
  102. textAlign: TextAlign.left,
  103. fontWeight: FontWeight.w500,
  104. fontSize: 21,
  105. // maxLines: 5,
  106. marginBottom: 20,
  107. ),
  108. MyTextView(
  109. "A mortgage specialist will be incontact to help you compare theatest housing loan rates and tosecure the best package that suitsyour need",
  110. textColor: ColorUtils.string2Color('#666666'),
  111. textAlign: TextAlign.left,
  112. // maxLines: 5,
  113. ),
  114. MyTextView(
  115. "This is a complementary servicebrought to you by YY Home",
  116. textColor: ColorUtils.string2Color('#666666'),
  117. textAlign: TextAlign.left,
  118. // maxLines: 5,
  119. marginTop: 15,
  120. ),
  121. ]));
  122. },
  123. ),
  124. );
  125. }
  126. }