123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 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<StatefulWidget> createState() {
- return _ShopDetailPageState();
- }
- }
- class _ShopDetailPageState
- extends ViewStateLifecycle<ShopDetailPage, ScoreModel> {
- Widget _buildListItem(String name, String create, int score) {
- return Padding(
- padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 12.0),
- child: Column(
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- 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<ScoreModel>(
- 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();
- }
- }
|