11import 'package:flutter/material.dart' ;
22import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
3+ import 'package:efox_flutter/store/index.dart' show Store, UserModel;
4+ import 'package:efox_flutter/store/objects/flutter_ui_issues.dart' show IssuesContent;
35
46class Index extends StatefulWidget {
57 @override
@@ -17,9 +19,102 @@ class _IndexState extends State<Index> {
1719 AppLocalizations .$t ('title_comment' )
1820 ),
1921 ),
20- body: Center (
21- child: Text ('评论' ),
22- ),
22+ body: Container (
23+ padding: EdgeInsets .fromLTRB (16.0 , 0 ,16.0 , 0 ),
24+ child: _CommentList (context),
25+ )
26+ );
27+ }
28+
29+ Widget _CommentList (BuildContext context){
30+ return Store .connect <UserModel >(
31+ builder: (context, child, model) {
32+ if (model.flutter_ui_issues!= null && model.flutter_ui_issues.issuesContent!= null && model.flutter_ui_issues.issuesContent.length!= 0 ) {
33+ return ListView .builder (
34+ itemCount: model.flutter_ui_issues.issuesContent.length,
35+ itemBuilder: (context, index) {
36+ return _CommentCard (context, model.flutter_ui_issues.issuesContent[index]);
37+ },
38+ );
39+ } else {
40+ return Center (
41+ child: Text ('loading....' ),
42+ );
43+ }
44+ }
45+ );
46+ }
47+
48+ Widget _CommentCard (BuildContext context, IssuesContent issuesContent) {
49+ return Card (
50+ elevation: 4.0 ,
51+ child: Stack (
52+ alignment: Alignment .topCenter,
53+ children: < Widget > [
54+ Column (
55+ crossAxisAlignment: CrossAxisAlignment .start,
56+ children: < Widget > [
57+ AspectRatio (
58+ aspectRatio: 16 / 9 ,
59+ child: ClipRRect (
60+ borderRadius: BorderRadius .only (
61+ topLeft: Radius .circular (6.0 ),
62+ topRight: Radius .circular (6.0 ),
63+ bottomLeft: Radius .circular (6.0 ),
64+ bottomRight: Radius .circular (6.0 )
65+ ),
66+ child: Image .network (
67+ issuesContent.user.avatarUrl?? 'http://thumb10.jfcdns.com/2018-06/bce5b10ae530f530.png' ,
68+ fit: BoxFit .cover,
69+ ),
70+ ),
71+ ),
72+ Container (
73+ padding: EdgeInsets .fromLTRB (20.0 , 20 , 20 , 0 ),
74+ child: Text (
75+ '${issuesContent .title != '' ? issuesContent .title : '无标题' } #${issuesContent .number }' ,
76+ style: Theme .of (context).textTheme.title,
77+ ),
78+ ),
79+ Container (
80+ padding: EdgeInsets .fromLTRB (20.0 , 10 , 20 , 0 ),
81+ child: Column (
82+ children: < Widget > [
83+ Text (
84+ '创建时间:${issuesContent .createdAt }' ,
85+ style: TextStyle (color: Colors .black54, fontSize: 12 )
86+ ),
87+ Text (
88+ '更新时间:${issuesContent .updatedAt }' ,
89+ style: TextStyle (color: Colors .black54, fontSize: 12 )
90+ )
91+ ],
92+ )
93+ ),
94+ Container (
95+ padding: EdgeInsets .fromLTRB (20.0 , 10 , 20 , 20.0 ),
96+ child: Text (
97+ issuesContent.body,
98+ // != '' ?issuesContent.body:'无主体内容'
99+ style: Theme .of (context).textTheme.subhead
100+ ),
101+ )
102+ ],
103+ ),
104+ Positioned (
105+ top: 10 ,
106+ left: 10 ,
107+ child: Text (
108+ issuesContent.user.login,
109+ style: TextStyle (
110+ color: Theme .of (context).primaryColor,
111+ fontWeight: FontWeight .bold,
112+ fontSize: 20
113+ ),
114+ ),
115+ )
116+ ],
117+ )
23118 );
24119 }
25120}
0 commit comments