123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import 'package:cpt_notice_board/modules/event_detail/page/event_detail_page.dart';
- import 'package:cpt_notice_board/modules/notice_board/page/notice_board_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/widget_export.dart';
- import 'package:cs_resources/generated/assets.dart';
- import '../../../router/page/notice_board_page_router.dart';
- import '../vm/event_vm.dart';
- @RoutePage()
- class EventPage extends HookConsumerWidget {
- const EventPage({Key? key}) : super(key: key);
- //启动当前页面
- static void startInstance({BuildContext? context}) {
- if (context != null) {
- context.router.push(const EventPageRoute());
- } else {
- appRouter.push(const EventPageRoute());
- }
- }
- Widget _buildItemLeftSection(BuildContext context, WidgetRef ref, item, _vm) {
- return Container(
- // color: Colors.blue,
- child: Text(
- maxLines: 2, // 设置最大行数为2
- overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
- item['title'],
- style: const TextStyle(
- fontSize: 16.0,
- color: Colors.black,
- fontWeight: FontWeight.w700), // 设置字体大小
- ),
- );
- }
- Widget _buildItemRightSection(
- BuildContext context, WidgetRef ref, item, _vm) {
- return Container(
- // color: Colors.green,
- child: Text(
- item['price'],
- style: const TextStyle(
- fontSize: 14.0,
- color: Colors.black,
- fontWeight: FontWeight.w400), // 设置字体大小
- ),
- );
- }
- // listitem
- Widget _buildSaleItem(BuildContext context, WidgetRef ref, item, _vm) {
- return Container(
- decoration: const BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(6.0)),
- boxShadow: [
- BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)
- ],
- ),
- child: Column(
- children: [
- Container(
- width: MediaQuery.of(context).size.width - 30,
- height: 100,
- // margin: const EdgeInsets.only(left: 15, right: 15, top: 12.5),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- _buildItemLeftSection(context, ref, item, _vm)
- .marginOnly(bottom: 5),
- _buildItemRightSection(context, ref, item, _vm),
- ],
- ).paddingOnly(left: 20, right: 20),
- ).constrained(
- minHeight: 117.5,
- ),
- ],
- ).onTap(() {
- // 去详情
- // _vm.goNewsDetail(item['title']);
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => const EventDetailPage()),
- );
- }),
- ).marginOnly(left: 15, bottom: 15, right: 15);
- }
- // 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(eventVmProvider.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: ColorUtils.string2Color('#F2F3F6'),
- padding: const EdgeInsets.only(top: 15),
- child: _buildSaleList(context, ref, _vm)),
- )),
- );
- }
- }
|