property_rent_page.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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_rent_vm.dart';
  14. @RoutePage()
  15. class PropertyRentPage extends HookConsumerWidget {
  16. const PropertyRentPage({Key? key}) : super(key: key);
  17. //启动当前页面
  18. static void startInstance({BuildContext? context}) {
  19. if (context != null) {
  20. context.router.push(const PropertyRentPageRoute());
  21. } else {
  22. appRouter.push(const PropertyRentPageRoute());
  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(71, 30), // 最小宽度和高度
  43. padding: const EdgeInsets.symmetric(horizontal: 17.5, vertical: 7.5), // 内边距
  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: Container(
  53. height: 44,
  54. child: Column(
  55. mainAxisAlignment: MainAxisAlignment.center,
  56. children: [
  57. Text(
  58. item['price'],
  59. style: const TextStyle(
  60. fontSize: 17, // 字体大小
  61. fontWeight: FontWeight.bold, // 字体粗细
  62. ),
  63. ),
  64. Text(
  65. item['unit'],
  66. style: const TextStyle(
  67. fontSize: 12, // 字体大小
  68. fontWeight: FontWeight.normal, // 字体粗细
  69. ),
  70. ),
  71. ],
  72. ),
  73. ),
  74. ),
  75. );
  76. }
  77. // listitem
  78. Widget _buildRentItem(BuildContext context,WidgetRef ref, item, _vm) {
  79. return Container(
  80. // color: Colors.red,
  81. child: Row(
  82. mainAxisAlignment: MainAxisAlignment.center,
  83. crossAxisAlignment: CrossAxisAlignment.center,
  84. mainAxisSize: MainAxisSize.max,
  85. children: [
  86. Container(
  87. width: MediaQuery.of(context).size.width - 30,
  88. height: 100,
  89. margin: const EdgeInsets.only(left: 15,right: 15,top: 12.5),
  90. child: Row(
  91. mainAxisAlignment: MainAxisAlignment.start,
  92. crossAxisAlignment: CrossAxisAlignment.center,
  93. children: [
  94. Expanded(child: _buildItemLeftSection(context, ref, item, _vm)),
  95. Container(
  96. width: 100,
  97. child: _buildItemRightSection(context, ref, item, _vm),
  98. ),
  99. ],
  100. ),
  101. ).constrained(
  102. minHeight: 117.5,
  103. ),
  104. ],
  105. ).onTap((){
  106. // 去详情
  107. _vm.goNewsDetail(item);
  108. }),
  109. ).border(color: ColorUtils.string2Color('C9C9C9FF'), bottom: 0.5);
  110. }
  111. // list
  112. Widget _buildRentList(BuildContext context, WidgetRef ref, _vm) {
  113. List itemsList = _vm.state.list.toList();
  114. return ListView.builder(
  115. itemCount: itemsList.length,
  116. itemBuilder: (context, index) {
  117. return _buildRentItem(context, ref, itemsList[index], _vm);
  118. },
  119. );
  120. }
  121. @override
  122. Widget build(BuildContext context, WidgetRef ref) {
  123. final _vm = ref.read(propertyRentVmProvider.notifier);
  124. return Scaffold(
  125. // appBar: AppBar(title: Text("资产")),
  126. body: Container(
  127. child: EasyRefresh(
  128. // 上拉加载
  129. onLoad: () async{
  130. Log.d("----onLoad");
  131. _vm.onLoadData();
  132. },
  133. // 下拉刷新
  134. onRefresh: () async{
  135. Log.d("----onRefresh");
  136. _vm.refreshListData();
  137. },
  138. child: Container(
  139. color: Colors.white,
  140. margin: const EdgeInsets.only(top: 5),
  141. child: _buildRentList(context, ref, _vm)
  142. ),
  143. )
  144. ),
  145. );
  146. }
  147. }