property_ioan_vm.dart 5.5 KB

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