|
|
@@ -0,0 +1,194 @@
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
+import 'package:redux/redux.dart';
|
|
|
+import 'package:flutter_redux/flutter_redux.dart';
|
|
|
+import '../redux/AppState.dart';
|
|
|
+import '../model/UserInfo.dart';
|
|
|
+import 'package:cached_network_image/cached_network_image.dart';
|
|
|
+import '../net/Result.dart';
|
|
|
+import '../net/HttpManager.dart';
|
|
|
+import '../model/CompetitionInfo.dart';
|
|
|
+import '../widget/Competition.dart';
|
|
|
+
|
|
|
+class Competitions extends StatefulWidget {
|
|
|
+ @override
|
|
|
+ State<StatefulWidget> createState() => _CompetitionState();
|
|
|
+}
|
|
|
+
|
|
|
+class _CompetitionState extends State<Competitions> {
|
|
|
+ List<CompetitionInfo> competitionInfoList = [];
|
|
|
+
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ Future.delayed(Duration.zero, () {
|
|
|
+ _getCompetitions();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return StoreConnector<AppState, UserInfo>(
|
|
|
+ converter: (Store store) => store.state.userInfo,
|
|
|
+ builder: (context, userInfo) => Material(
|
|
|
+ child: CupertinoPageScaffold(
|
|
|
+ backgroundColor: Color(0xFF0E1D32),
|
|
|
+ child: SizedBox(
|
|
|
+ width: double.infinity,
|
|
|
+ child: Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+ color: Color(0xff293354),
|
|
|
+ child: SafeArea(
|
|
|
+ child: SizedBox(
|
|
|
+ width: double.infinity,
|
|
|
+ height: 60,
|
|
|
+ child: Container(
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+ child: ClipOval(
|
|
|
+ child: Builder(
|
|
|
+ builder: (context) {
|
|
|
+ return Material(
|
|
|
+ child: InkWell(
|
|
|
+ child: CachedNetworkImage(
|
|
|
+ imageUrl: userInfo.icon,
|
|
|
+ width: 42,
|
|
|
+ height: 42,
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ Scaffold.of(context).openDrawer();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ margin: EdgeInsets.only(left: 15),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Container(
|
|
|
+ height: 42,
|
|
|
+ margin: EdgeInsets.only(left: 8),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ userInfo.username,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ color: Colors.white,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ '最强王者',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Color(0xFFFC9A3B),
|
|
|
+ fontSize: 13,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.fromLTRB(10, 0, 15, 0),
|
|
|
+ child: InkWell(
|
|
|
+ child: Container(
|
|
|
+ width: 62,
|
|
|
+ height: 32,
|
|
|
+ color: Color(0xFFE56B45),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 6),
|
|
|
+ child: Image.asset(
|
|
|
+ 'images/icon_qiandao.png',
|
|
|
+ width: 20,
|
|
|
+ height: 20,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 2),
|
|
|
+ child: Text(
|
|
|
+ '签到',
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14,
|
|
|
+ color: Colors.white,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onTap: () {},
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: RefreshIndicator(
|
|
|
+ child: Container(
|
|
|
+ width: double.infinity,
|
|
|
+ child: SingleChildScrollView(
|
|
|
+ physics: AlwaysScrollableScrollPhysics(),
|
|
|
+ padding: EdgeInsets.only(bottom: 7),
|
|
|
+ child: Flex(
|
|
|
+ direction: Axis.vertical,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
+ children: buidChildren(),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onRefresh: () {
|
|
|
+ return _getCompetitions();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Widget> buidChildren() {
|
|
|
+ List<Widget> list = [];
|
|
|
+ list.add(Padding(
|
|
|
+ padding: EdgeInsets.fromLTRB(15, 10, 15, 7),
|
|
|
+ child: Image.asset(
|
|
|
+ 'images/text_saishiliebiao.png',
|
|
|
+ fit: BoxFit.contain,
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+ competitionInfoList.forEach((competitionInfo) {
|
|
|
+ list.add(Competition(competitionInfo));
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ Future<void> _getCompetitions() async {
|
|
|
+ Result res = await HttpManager.get('competition/all', data: {'status': 1});
|
|
|
+ if (res.success) {
|
|
|
+ List<CompetitionInfo> list = [];
|
|
|
+ for (var item in res.data) {
|
|
|
+ list.add(CompetitionInfo.fromJson(item));
|
|
|
+ }
|
|
|
+ setState(() {
|
|
|
+ competitionInfoList = list;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|