property_sale_page.dart 4.6 KB

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