property_ioan_page.dart 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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/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: context.appColors.textBlack,
  35. fontSize: 27,
  36. isFontMedium: true,
  37. textAlign: TextAlign.center,
  38. ),
  39. MyTextView(
  40. S.current.find_best_loan,
  41. textColor: context.appColors.textBlack,
  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. S.current.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. S.current.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. S.current.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. S.current.other_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: 20,right: 20),
  151. child: Column(
  152. // mainAxisAlignment: MainAxisAlignment.end,
  153. crossAxisAlignment: CrossAxisAlignment.start,
  154. children: [
  155. Row(
  156. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  157. children: [
  158. MyTextView(
  159. S.current.floating_rate,
  160. textColor: context.appColors.textBlack,
  161. fontSize: 14,
  162. textAlign: TextAlign.center,
  163. ),
  164. MyTextView(
  165. S.current.fixed_rate,
  166. textColor: context.appColors.textBlack,
  167. fontSize: 14,
  168. textAlign: TextAlign.center,
  169. ),
  170. ],
  171. ),
  172. // const SizedBox(height: 10),
  173. Expanded(child: Column(
  174. mainAxisAlignment: MainAxisAlignment.center,
  175. children: [
  176. Row(
  177. mainAxisAlignment: MainAxisAlignment.center,
  178. children: [
  179. MyTextView(
  180. "3.08%",
  181. textColor: context.appColors.textBlack,
  182. fontSize: 16,
  183. textAlign: TextAlign.center,
  184. isFontMedium: true,
  185. marginLeft: 15,
  186. ),
  187. MyTextView(
  188. "2.50%",
  189. textColor: context.appColors.textBlack,
  190. fontSize: 16,
  191. textAlign: TextAlign.center,
  192. isFontMedium: true,
  193. marginLeft: 50.5,
  194. ),
  195. ],
  196. ),
  197. Row(
  198. mainAxisAlignment: MainAxisAlignment.center,
  199. children: [
  200. MyTextView(
  201. "3.08%",
  202. textColor: context.appColors.textBlack,
  203. fontSize: 16,
  204. textAlign: TextAlign.center,
  205. isFontMedium: true,
  206. marginLeft: 15,
  207. ),
  208. MyTextView(
  209. "2.50%",
  210. textColor: context.appColors.textBlack,
  211. fontSize: 16,
  212. textAlign: TextAlign.center,
  213. isFontMedium: true,
  214. marginLeft: 50.5,
  215. ),
  216. ],
  217. ).marginOnly(top: 15),
  218. Row(
  219. mainAxisAlignment: MainAxisAlignment.center,
  220. children: [
  221. MyTextView(
  222. "3.08%",
  223. textColor: context.appColors.textBlack,
  224. fontSize: 16,
  225. textAlign: TextAlign.center,
  226. isFontMedium: true,
  227. marginLeft: 15,
  228. ),
  229. MyTextView(
  230. "2.50%",
  231. textColor: context.appColors.textBlack,
  232. fontSize: 16,
  233. textAlign: TextAlign.center,
  234. isFontMedium: true,
  235. marginLeft: 47.5,
  236. ),
  237. ],
  238. ).marginOnly(top: 15),
  239. ],
  240. ))
  241. ],
  242. ),
  243. ),
  244. ),
  245. ],
  246. ).constrained(height: 160),
  247. ],
  248. );
  249. }
  250. Widget _buildContentMiddleTextSection(BuildContext context,WidgetRef ref, _vm) {
  251. return Column(
  252. children: [
  253. MyTextView(
  254. S.current.choose_best_package,
  255. textColor: context.appColors.textBlack,
  256. fontSize: 18,
  257. isFontMedium: true,
  258. marginTop: 20,
  259. marginBottom: 20,
  260. textAlign: TextAlign.center,
  261. ),
  262. MyTextView(
  263. S.current.text_no_hidden_fees,
  264. textColor: context.appColors.textBlack,
  265. fontSize: 15,
  266. textAlign: TextAlign.center,
  267. marginBottom: 20,
  268. ),
  269. ],
  270. );
  271. }
  272. Widget _buildContentOfferSection(BuildContext context,WidgetRef ref, _vm) {
  273. final offerTextInfoList = _vm.state.offerTextInfoList.map((value) => value).toList();
  274. return Container(
  275. width: double.infinity,
  276. child: Column(
  277. children: [
  278. MyTextView(
  279. S.current.what_do_we_offer,
  280. textColor: context.appColors.textBlack,
  281. fontSize: 18,
  282. isFontMedium: true,
  283. marginTop: 16.5,
  284. marginBottom: 16.5,
  285. ),
  286. Wrap(
  287. children: List.generate(offerTextInfoList.length, (index){
  288. return Container(
  289. width: MediaQuery.of(context).size.width / 2 - 30,
  290. margin: const EdgeInsets.only(right: 15,bottom: 15),
  291. padding: const EdgeInsets.only(left: 15,right: 15,top:15,bottom:15,),
  292. // decoration: BoxDecoration(
  293. // borderRadius: BorderRadius.circular(10),
  294. // color: ColorUtils.string2Color('#F5F5F5'),
  295. // ),
  296. child: Column(
  297. children: [
  298. MyLoadImage(
  299. offerTextInfoList[index]["icon"],
  300. width: offerTextInfoList[index]["iconWidth"],
  301. height: offerTextInfoList[index]["iconHeight"],
  302. ),
  303. const SizedBox(height: 13,),
  304. MyTextView(
  305. offerTextInfoList[index]["title"],
  306. fontSize: 15,
  307. textColor: context.appColors.textBlack,
  308. textAlign: TextAlign.center,
  309. ),
  310. ]
  311. ),
  312. );
  313. }),
  314. ),
  315. ]
  316. ),
  317. );
  318. }
  319. Widget _buildContentBottomPartnersSection(BuildContext context,WidgetRef ref, _vm) {
  320. return Column(
  321. mainAxisAlignment: MainAxisAlignment.center,
  322. crossAxisAlignment: CrossAxisAlignment.center,
  323. children: [
  324. MyTextView(
  325. S.current.our_partners,
  326. textColor: context.appColors.textBlack,
  327. fontSize: 18,
  328. isFontMedium: true,
  329. marginBottom: 16.5,
  330. ),
  331. MyLoadImage(Assets.propertyOurPartners,),
  332. ],
  333. );
  334. }
  335. Widget _buildCotentBox(BuildContext context,WidgetRef ref, _vm) {
  336. return Column(
  337. children: [
  338. _buildContentTopAdviceSection(context, ref, _vm),
  339. const SizedBox(height: 15,),
  340. _buildContentMiddleTextSection(context, ref, _vm),
  341. const SizedBox(height: 15,),
  342. _buildContentOfferSection(context, ref, _vm),
  343. const SizedBox(height: 15,),
  344. _buildContentBottomPartnersSection(context, ref, _vm),
  345. ],
  346. );
  347. }
  348. @override
  349. Widget build(BuildContext context, WidgetRef ref) {
  350. final _vm = ref.read(propertyIoanVmProvider.notifier);
  351. final state = ref.watch(propertyIoanVmProvider);
  352. useEffect((){
  353. _vm.initPageData();
  354. return () {};
  355. }, []);
  356. return Scaffold(
  357. backgroundColor: ColorUtils.string2Color("#F2F3F6"),
  358. // appBar: AppBar(title: Text("资产")),
  359. body: Column(
  360. children: [
  361. Expanded(
  362. child: LoadStateLayout(
  363. state: state.loadingState,
  364. errorMessage: state.errorMessage,
  365. errorRetry: () {
  366. _vm.retryRequest();
  367. },
  368. successWidget: SingleChildScrollView(
  369. scrollDirection: Axis.vertical,
  370. physics: const BouncingScrollPhysics(),
  371. clipBehavior: Clip.none,
  372. child: Padding(
  373. padding: const EdgeInsets.only(left: 15,right: 15,top: 15),
  374. child: _buildCotentBox(context, ref, _vm),
  375. )
  376. ),
  377. )
  378. ),
  379. // Visibility(
  380. // visible: state.loadingState == LoadState.State_Success,
  381. // child: Container(
  382. // height: 50,
  383. // color: ColorUtils.string2Color('#4161D0'),
  384. // child: Row(
  385. // mainAxisAlignment: MainAxisAlignment.center,
  386. // children: [
  387. // // MyLoadImage(Assets.propertyIoanItemBg,width: 60,height: 50,),
  388. // const SizedBox(width: 10,),
  389. // MyTextView(
  390. // "Request a Quote",
  391. // fontSize: 16,
  392. // textColor: Colors.white,
  393. // isFontMedium: true,
  394. // ),
  395. // ],
  396. // ),
  397. // ).onTap((){
  398. // _vm.handlerRequestQuote(context);
  399. // }),
  400. // )
  401. ],
  402. ),
  403. );
  404. }
  405. }