import 'package:cpt_property/modules/property/page/property_page.dart'; import 'package:flutter/material.dart'; import 'package:auto_route/auto_route.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:router/ext/auto_router_extensions.dart'; import 'package:shared/utils/log_utils.dart'; import 'package:shared/utils/color_utils.dart'; import 'package:widgets/ext/ex_widget.dart'; import 'package:widgets/my_load_image.dart'; import 'package:widgets/my_text_view.dart'; import 'package:widgets/widget_export.dart'; import 'package:cs_resources/generated/assets.dart'; import '../../../router/page/property_page_router.dart'; import '../vm/property_sale_vm.dart'; @RoutePage() class PropertySalePage extends HookConsumerWidget { const PropertySalePage({Key? key}) : super(key: key); //启动当前页面 static void startInstance({BuildContext? context}) { if (context != null) { context.router.push(const PropertySalePageRoute()); } else { appRouter.push(const PropertySalePageRoute()); } } Widget _buildItemLeftSection(BuildContext context,WidgetRef ref, item, _vm) { return Container( // color: Colors.blue, child: MyTextView( item['title'], fontSize: 16, textColor: Colors.black, isFontMedium: true, ), ).marginOnly(right: 17.5); } Widget _buildItemRightSection(BuildContext context,WidgetRef ref, item, _vm) { return Container( color: Colors.white, child: TextButton( onPressed: (){}, style: TextButton.styleFrom( foregroundColor: Colors.black, backgroundColor: ColorUtils.string2Color('#EFF3FF'), // 背景颜色 minimumSize: const Size(91.5, 44), // 最小宽度和高度 padding: const EdgeInsets.symmetric(horizontal: 11.0, vertical: 14), // 内边距 shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), // 圆角 side: BorderSide( color: ColorUtils.string2Color('#EFF3FF'), width: 1.0, ), // 边框 ), ), child:MyTextView( item['price'], fontSize: 17, textColor: Colors.black, isFontMedium: true, ), ), ); } // listitem Widget _buildSaleItem(BuildContext context,WidgetRef ref, item, _vm) { return Container( // color: Colors.red, child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ Container( width: MediaQuery.of(context).size.width - 30, height: 100, margin: const EdgeInsets.only(left: 15,right: 15,top: 12.5), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded(child: _buildItemLeftSection(context, ref, item, _vm)), SizedBox( width: 120, child: _buildItemRightSection(context, ref, item, _vm), ), ], ), ).constrained( minHeight: 117.5, ), ], ).onTap((){ // 去详情 _vm.goNewsDetail(item); }), ).border(color: ColorUtils.string2Color('C9C9C9FF'), bottom: 0.5); } // list Widget _buildSaleList(BuildContext context, WidgetRef ref, _vm) { List itemsList = _vm.state.list.toList(); return ListView.builder( itemCount: itemsList.length, itemBuilder: (context, index) { return _buildSaleItem(context, ref, itemsList[index], _vm); }, ); } @override Widget build(BuildContext context, WidgetRef ref) { final _vm = ref.read(propertySaleVmProvider.notifier); return Scaffold( // appBar: AppBar(title: Text("资产")), body: Container( child: EasyRefresh( // 上拉加载 onLoad: () async{ Log.d("----onLoad"); _vm.onLoadData(); }, // 下拉刷新 onRefresh: () async{ Log.d("----onRefresh"); _vm.refreshListData(); }, child: Container( color: Colors.white, margin: const EdgeInsets.only(top: 5), child: _buildSaleList(context, ref, _vm) ), ) ), ); } }