property_sale_page.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import 'package:cpt_property/modules/property/page/property_page.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:auto_route/auto_route.dart';
  4. import 'package:hooks_riverpod/hooks_riverpod.dart';
  5. import 'package:router/ext/auto_router_extensions.dart';
  6. import 'package:shared/utils/log_utils.dart';
  7. import 'package:shared/utils/color_utils.dart';
  8. import 'package:widgets/ext/ex_widget.dart';
  9. import 'package:widgets/my_load_image.dart';
  10. import 'package:widgets/widget_export.dart';
  11. import 'package:cs_resources/generated/assets.dart';
  12. import '../../../router/page/property_page_router.dart';
  13. import '../vm/property_sale_vm.dart';
  14. @RoutePage()
  15. class PropertySalePage extends HookConsumerWidget {
  16. const PropertySalePage({Key? key}) : super(key: key);
  17. //启动当前页面
  18. static void startInstance({BuildContext? context}) {
  19. if (context != null) {
  20. context.router.push(const PropertySalePageRoute());
  21. } else {
  22. appRouter.push(const PropertySalePageRoute());
  23. }
  24. }
  25. Widget _buildItemLeftSection(BuildContext context,WidgetRef ref, item, _vm) {
  26. return Container(
  27. // color: Colors.blue,
  28. child:
  29. Text(item['title'],
  30. style: const TextStyle(fontSize: 16.0, color: Colors.black, fontWeight: FontWeight.w400), // 设置字体大小
  31. ),
  32. ).marginOnly(right: 17.5);
  33. }
  34. Widget _buildItemRightSection(BuildContext context,WidgetRef ref, item, _vm) {
  35. return Container(
  36. color: Colors.white,
  37. child: TextButton(
  38. onPressed: (){},
  39. style: TextButton.styleFrom(
  40. foregroundColor: Colors.black,
  41. backgroundColor: ColorUtils.string2Color('#EFF3FF'), // 背景颜色
  42. minimumSize: const Size(91.5, 44), // 最小宽度和高度
  43. padding: const EdgeInsets.symmetric(horizontal: 11.0, vertical: 14), // 内边距
  44. shape: RoundedRectangleBorder(
  45. borderRadius: BorderRadius.circular(5), // 圆角
  46. side: BorderSide(
  47. color: ColorUtils.string2Color('#EFF3FF'),
  48. width: 1.0,
  49. ), // 边框
  50. ),
  51. ),
  52. child: Text(item['price']),
  53. ),
  54. );
  55. }
  56. // listitem
  57. Widget _buildSaleItem(BuildContext context,WidgetRef ref, item, _vm) {
  58. return Container(
  59. // color: Colors.red,
  60. child: Row(
  61. mainAxisAlignment: MainAxisAlignment.center,
  62. crossAxisAlignment: CrossAxisAlignment.center,
  63. mainAxisSize: MainAxisSize.max,
  64. children: [
  65. Container(
  66. width: MediaQuery.of(context).size.width - 30,
  67. height: 100,
  68. margin: const EdgeInsets.only(left: 15,right: 15,top: 12.5),
  69. child: Row(
  70. mainAxisAlignment: MainAxisAlignment.start,
  71. crossAxisAlignment: CrossAxisAlignment.center,
  72. children: [
  73. Expanded(child: _buildItemLeftSection(context, ref, item, _vm)),
  74. Container(
  75. width: 100,
  76. child: _buildItemRightSection(context, ref, item, _vm),
  77. // child: TextButton(onPressed: (){}, child: Text("fdsfds")),
  78. ),
  79. ],
  80. ),
  81. ).constrained(
  82. minHeight: 117.5,
  83. ),
  84. ],
  85. ).onTap((){
  86. // 去详情
  87. _vm.goNewsDetail(item);
  88. }),
  89. ).border(color: ColorUtils.string2Color('C9C9C9FF'), bottom: 0.5);
  90. }
  91. // list
  92. Widget _buildSaleList(BuildContext context, WidgetRef ref, _vm) {
  93. List itemsList = _vm.state.list.toList();
  94. return ListView.builder(
  95. itemCount: itemsList.length,
  96. itemBuilder: (context, index) {
  97. return _buildSaleItem(context, ref, itemsList[index], _vm);
  98. },
  99. );
  100. }
  101. @override
  102. Widget build(BuildContext context, WidgetRef ref) {
  103. final _vm = ref.read(propertySaleVmProvider.notifier);
  104. return Scaffold(
  105. // appBar: AppBar(title: Text("资产")),
  106. body: Container(
  107. child: EasyRefresh(
  108. // 上拉加载
  109. onLoad: () async{
  110. Log.d("----onLoad");
  111. _vm.onLoadData();
  112. },
  113. // 下拉刷新
  114. onRefresh: () async{
  115. Log.d("----onRefresh");
  116. _vm.refreshListData();
  117. },
  118. child: Container(
  119. color: Colors.white,
  120. margin: const EdgeInsets.only(top: 5),
  121. child: _buildSaleList(context, ref, _vm)
  122. ),
  123. )
  124. ),
  125. );
  126. }
  127. }