import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:sport/provider/lib/provider_widget.dart'; import 'package:sport/provider/lib/view_state_lifecycle.dart'; import 'package:sport/provider/shop_model.dart'; import 'package:sport/widgets/appbar.dart'; import 'package:sport/widgets/error.dart'; import 'package:sport/widgets/space.dart'; class ShopDetailPage extends StatefulWidget { @override State createState() { return _ShopDetailPageState(); } } class _ShopDetailPageState extends ViewStateLifecycle { Widget _buildListItem(String name, String create, int score) { return Padding( padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 12.0), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "$name", style: TextStyle(fontSize: 16.0, color: Color(0xff333333)), ), Space( height: 5.0, ), Text( "$create", style: TextStyle(color: Color(0xff999999), fontSize: 12.0), ) ], ), Text(score > 0 ? "+$score 积分" : "-$score 积分", style: TextStyle( fontSize: 16.0, color: score < 0 ? Theme.of(context).accentColor : Color(0xffFF5B1D), )), ], ), Space( height: 10, ), Divider(), ], )); } @override Widget build(BuildContext context) { return Scaffold( appBar: buildAppBar(context, title: "积分明细"), backgroundColor: Colors.white, body: ProviderWidget( model: model, onModelReady: (v) => v.refresh(), builder: (_, model, __) { return CustomScrollView(slivers: [ if (model.isIdle) SliverList( delegate: SliverChildBuilderDelegate( (context, index) { return _buildListItem( model.scoreList[index].detail ??"", model.scoreList[index].createdAt ??"", model.scoreList[index].score ??0); }, childCount: model.scoreList.length, ), ), if (model.isEmpty) SliverFillRemaining( child: Center( child: RequestErrorWidget( null, msg: "暂无明细~", assets: RequestErrorWidget.ASSETS_NO_INVITATION, ), ), ), ]); }, )); } @override ScoreModel createModel() { return new ScoreModel(); } }