property_ioan_vm.dart 5.4 KB

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