property_ioan_page.dart 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. import 'package:cpt_property/components/bottomDialog.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:auto_route/auto_route.dart';
  6. import 'package:flutter_hooks/flutter_hooks.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  9. import 'package:router/ext/auto_router_extensions.dart';
  10. import 'package:shared/utils/color_utils.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:widgets/load_state_layout.dart';
  13. import 'package:widgets/my_button.dart';
  14. import 'package:widgets/my_load_image.dart';
  15. import 'package:widgets/my_text_view.dart';
  16. import '../../../router/page/property_page_router.dart';
  17. import 'property_ioan_vm.dart';
  18. @RoutePage()
  19. class PropertyIoanPage extends HookConsumerWidget {
  20. const PropertyIoanPage({Key? key}) : super(key: key);
  21. //启动当前页面
  22. static void startInstance({BuildContext? context}) {
  23. if (context != null) {
  24. context.router.push(const PropertyIoanPageRoute());
  25. } else {
  26. appRouter.push(const PropertyIoanPageRoute());
  27. }
  28. }
  29. Widget _buildContentTopAdviceSection(BuildContext context,WidgetRef ref, _vm){
  30. return Column(
  31. children: [
  32. MyTextView(
  33. "YY Home",
  34. textColor: ColorUtils.string2Color('#000000'),
  35. fontSize: 27,
  36. isFontMedium: true,
  37. textAlign: TextAlign.center,
  38. ),
  39. MyTextView(
  40. "Find the best home loan for you",
  41. textColor: ColorUtils.string2Color('#000000'),
  42. fontSize: 16,
  43. isFontRegular: true,
  44. marginBottom: 14,
  45. textAlign: TextAlign.center,
  46. ),
  47. Container(
  48. width: double.infinity,
  49. height: 210,
  50. decoration: BoxDecoration(
  51. borderRadius: BorderRadius.circular(0),
  52. color: ColorUtils.string2Color('#FEFEFE'),
  53. image: const DecorationImage(
  54. image: AssetImage('packages/cs_resources/${Assets.propertyHomeLoanBg}'), // 使用包中的资源
  55. fit: BoxFit.cover,
  56. ),
  57. ),
  58. child: Column(
  59. children: [
  60. MyTextView(
  61. "YY Home exclusive rates:",
  62. textColor: ColorUtils.string2Color('#FEFEFE'),
  63. fontSize: 15,
  64. boxWidth: 237,
  65. boxHeight: 35,
  66. alignment: Alignment.center,
  67. textAlign: TextAlign.center,
  68. marginTop: 5.5,
  69. backgroundColor: ColorUtils.string2Color('#4161D0')
  70. ),
  71. Expanded(
  72. child: Row(
  73. mainAxisAlignment: MainAxisAlignment.center,
  74. children: [
  75. Container(
  76. width: 105,
  77. height: 105,
  78. padding: const EdgeInsets.all(5),
  79. color: ColorUtils.string2Color('#4161D0'),
  80. child: Column(
  81. mainAxisAlignment: MainAxisAlignment.center,
  82. crossAxisAlignment: CrossAxisAlignment.center,
  83. children: [
  84. MyTextView(
  85. _vm.state.lowestFloatingRate,
  86. textColor: ColorUtils.string2Color('#FEFEFE'),
  87. fontSize: 30,
  88. ),
  89. MyTextView(
  90. "Lowest Floating Rate",
  91. textColor: ColorUtils.string2Color('#FEFEFE'),
  92. fontSize: 14,
  93. textAlign: TextAlign.center,
  94. ),
  95. ]
  96. )
  97. ),
  98. Container(
  99. width: 105,
  100. height: 105,
  101. padding: const EdgeInsets.all(5),
  102. color: ColorUtils.string2Color('#4161D0'),
  103. margin: const EdgeInsets.only(left: 18),
  104. child: Column(
  105. mainAxisAlignment: MainAxisAlignment.center,
  106. crossAxisAlignment: CrossAxisAlignment.center,
  107. children: [
  108. MyTextView(
  109. _vm.state.lowestFixedRate,
  110. textColor: ColorUtils.string2Color('#FEFEFE'),
  111. fontSize: 30,
  112. ),
  113. MyTextView(
  114. "Lowest Floating Rate",
  115. textColor: ColorUtils.string2Color('#FEFEFE'),
  116. fontSize: 14,
  117. textAlign: TextAlign.center,
  118. ),
  119. ]
  120. )
  121. ),
  122. ],
  123. ),
  124. ),
  125. ],
  126. ),
  127. ),
  128. MyTextView(
  129. "Check out what others are offering:",
  130. textColor: ColorUtils.string2Color('#FEFEFE'),
  131. fontSize: 15,
  132. boxWidth: double.infinity,
  133. boxHeight: 40.5,
  134. alignment: Alignment.center,
  135. textAlign: TextAlign.center,
  136. backgroundColor: ColorUtils.string2Color('#4161D0'),
  137. ),
  138. const SizedBox(height: 20),
  139. Row(
  140. mainAxisAlignment: MainAxisAlignment.start,
  141. children: [
  142. MyLoadImage(
  143. Assets.propertyAdvicePic,
  144. width: 132,
  145. // height: 122.5,
  146. ),
  147. Expanded(
  148. child: Container(
  149. // color: Colors.red,
  150. padding: const EdgeInsets.only(left: 50,right: 20),
  151. child: Column(
  152. // mainAxisAlignment: MainAxisAlignment.end,
  153. crossAxisAlignment: CrossAxisAlignment.start,
  154. children: [
  155. Row(
  156. mainAxisAlignment: MainAxisAlignment.center,
  157. children: [
  158. MyTextView(
  159. "Floating",
  160. textColor: ColorUtils.string2Color('#000000'),
  161. fontSize: 14,
  162. textAlign: TextAlign.center,
  163. ),
  164. MyTextView(
  165. "Fixed",
  166. textColor: ColorUtils.string2Color('#000000'),
  167. fontSize: 14,
  168. textAlign: TextAlign.center,
  169. marginLeft: 50.5,
  170. ),
  171. ],
  172. ),
  173. // const SizedBox(height: 10),
  174. Expanded(child: Column(
  175. mainAxisAlignment: MainAxisAlignment.center,
  176. children: [
  177. Row(
  178. mainAxisAlignment: MainAxisAlignment.center,
  179. children: [
  180. MyTextView(
  181. "3.08%",
  182. textColor: ColorUtils.string2Color('#000000'),
  183. fontSize: 16,
  184. textAlign: TextAlign.center,
  185. isFontMedium: true,
  186. marginLeft: 15,
  187. ),
  188. MyTextView(
  189. "2.50%",
  190. textColor: ColorUtils.string2Color('#000000'),
  191. fontSize: 16,
  192. textAlign: TextAlign.center,
  193. isFontMedium: true,
  194. marginLeft: 50.5,
  195. ),
  196. ],
  197. ),
  198. Row(
  199. mainAxisAlignment: MainAxisAlignment.center,
  200. children: [
  201. MyTextView(
  202. "3.08%",
  203. textColor: ColorUtils.string2Color('#000000'),
  204. fontSize: 16,
  205. textAlign: TextAlign.center,
  206. isFontMedium: true,
  207. marginLeft: 15,
  208. ),
  209. MyTextView(
  210. "2.50%",
  211. textColor: ColorUtils.string2Color('#000000'),
  212. fontSize: 16,
  213. textAlign: TextAlign.center,
  214. isFontMedium: true,
  215. marginLeft: 50.5,
  216. ),
  217. ],
  218. ).marginOnly(top: 15),
  219. Row(
  220. mainAxisAlignment: MainAxisAlignment.center,
  221. children: [
  222. MyTextView(
  223. "3.08%",
  224. textColor: ColorUtils.string2Color('#000000'),
  225. fontSize: 16,
  226. textAlign: TextAlign.center,
  227. isFontMedium: true,
  228. marginLeft: 15,
  229. ),
  230. MyTextView(
  231. "2.50%",
  232. textColor: ColorUtils.string2Color('#000000'),
  233. fontSize: 16,
  234. textAlign: TextAlign.center,
  235. isFontMedium: true,
  236. marginLeft: 47.5,
  237. ),
  238. ],
  239. ).marginOnly(top: 15),
  240. ],
  241. ))
  242. ],
  243. ),
  244. ),
  245. ),
  246. ],
  247. ).constrained(height: 160),
  248. ],
  249. );
  250. }
  251. Widget _buildContentMiddleTextSection(BuildContext context,WidgetRef ref, _vm) {
  252. return Column(
  253. children: [
  254. MyTextView(
  255. "The right advice to help you choose the best package in the market!",
  256. textColor: ColorUtils.string2Color('#000000'),
  257. fontSize: 18,
  258. isFontMedium: true,
  259. marginTop: 20,
  260. marginBottom: 20,
  261. textAlign: TextAlign.center,
  262. ),
  263. MyTextView(
  264. "-No Hidden Fees, We Are Out ToHelp You!-Interest Savings With Lowest RatesGuarantee-One-Stop Access to All The BanksPackages",
  265. textColor: ColorUtils.string2Color('#000000'),
  266. fontSize: 15,
  267. textAlign: TextAlign.center,
  268. marginBottom: 20,
  269. ),
  270. ],
  271. );
  272. }
  273. Widget _buildContentOfferSection(BuildContext context,WidgetRef ref, _vm) {
  274. final offerTextInfoList = _vm.state.offerTextInfoList.map((value) => value).toList();
  275. return Container(
  276. width: double.infinity,
  277. child: Column(
  278. children: [
  279. MyTextView(
  280. "What do we offer?",
  281. textColor: ColorUtils.string2Color('#000000'),
  282. fontSize: 18,
  283. isFontMedium: true,
  284. marginTop: 16.5,
  285. marginBottom: 16.5,
  286. ),
  287. Wrap(
  288. children: List.generate(offerTextInfoList.length, (index){
  289. return Container(
  290. width: MediaQuery.of(context).size.width / 2 - 100,
  291. margin: const EdgeInsets.only(right: 15,bottom: 15),
  292. padding: const EdgeInsets.only(left: 15,right: 15,top:15,bottom:15,),
  293. // decoration: BoxDecoration(
  294. // borderRadius: BorderRadius.circular(10),
  295. // color: ColorUtils.string2Color('#F5F5F5'),
  296. // ),
  297. child: Column(
  298. children: [
  299. MyLoadImage(
  300. offerTextInfoList[index]["icon"],
  301. width: offerTextInfoList[index]["iconWidth"],
  302. height: offerTextInfoList[index]["iconHeight"],
  303. ),
  304. const SizedBox(height: 13,),
  305. MyTextView(
  306. offerTextInfoList[index]["title"],
  307. fontSize: 15,
  308. textColor: ColorUtils.string2Color('#000000'),
  309. textAlign: TextAlign.center,
  310. ),
  311. ]
  312. ),
  313. );
  314. }),
  315. ),
  316. ]
  317. ),
  318. );
  319. }
  320. Widget _buildContentBottomPartnersSection(BuildContext context,WidgetRef ref, _vm) {
  321. return Column(
  322. mainAxisAlignment: MainAxisAlignment.center,
  323. crossAxisAlignment: CrossAxisAlignment.center,
  324. children: [
  325. MyTextView(
  326. "Our Partners",
  327. textColor: ColorUtils.string2Color('#000000'),
  328. fontSize: 18,
  329. isFontMedium: true,
  330. marginBottom: 16.5,
  331. ),
  332. MyLoadImage(Assets.propertyOurPartners,),
  333. ],
  334. );
  335. }
  336. Widget _buildCotentBox(BuildContext context,WidgetRef ref, _vm) {
  337. return Column(
  338. children: [
  339. _buildContentTopAdviceSection(context, ref, _vm),
  340. const SizedBox(height: 15,),
  341. _buildContentMiddleTextSection(context, ref, _vm),
  342. const SizedBox(height: 15,),
  343. _buildContentOfferSection(context, ref, _vm),
  344. const SizedBox(height: 15,),
  345. _buildContentBottomPartnersSection(context, ref, _vm),
  346. ],
  347. );
  348. }
  349. @override
  350. Widget build(BuildContext context, WidgetRef ref) {
  351. final _vm = ref.read(propertyIoanVmProvider.notifier);
  352. final state = ref.watch(propertyIoanVmProvider);
  353. useEffect((){
  354. _vm.initPageData();
  355. return () {};
  356. }, []);
  357. return Scaffold(
  358. backgroundColor: ColorUtils.string2Color("#F2F3F6"),
  359. // appBar: AppBar(title: Text("资产")),
  360. body: Column(
  361. children: [
  362. Expanded(
  363. child: LoadStateLayout(
  364. state: state.loadingState,
  365. errorMessage: state.errorMessage,
  366. errorRetry: () {
  367. _vm.retryRequest();
  368. },
  369. successWidget: SingleChildScrollView(
  370. scrollDirection: Axis.vertical,
  371. physics: const BouncingScrollPhysics(),
  372. clipBehavior: Clip.none,
  373. child: Padding(
  374. padding: const EdgeInsets.only(left: 15,right: 15,top: 15),
  375. child: _buildCotentBox(context, ref, _vm),
  376. )
  377. ),
  378. )
  379. ),
  380. Visibility(
  381. visible: state.loadingState == LoadState.State_Success,
  382. child: Container(
  383. height: 50,
  384. color: ColorUtils.string2Color('#4161D0'),
  385. child: Row(
  386. mainAxisAlignment: MainAxisAlignment.center,
  387. children: [
  388. // MyLoadImage(Assets.propertyIoanItemBg,width: 60,height: 50,),
  389. const SizedBox(width: 10,),
  390. MyTextView(
  391. "Request a Quote",
  392. fontSize: 16,
  393. textColor: Colors.white,
  394. isFontMedium: true,
  395. ),
  396. ],
  397. ),
  398. ).onTap((){
  399. _vm.handlerRequestQuote(context);
  400. }),
  401. )
  402. ],
  403. ),
  404. );
  405. }
  406. }