Skip to content

Commit

Permalink
重用article_item组件
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjianxiandev committed Apr 8, 2020
1 parent ebf5e86 commit d2af136
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 249 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ build/
.android/
.ios/
.flutter-plugins
.flutter-plugins-dependencies
.gitattributes
.metadata
LICENSE
captures/

4 changes: 2 additions & 2 deletions lib/page/project/project_list_fragment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import 'package:wanandroidflutter/theme/app_theme.dart';
import 'package:wanandroidflutter/utils/collect_event.dart';
import 'package:wanandroidflutter/utils/login_event.dart';
import 'package:wanandroidflutter/utils/loginout_event.dart';
import 'package:wanandroidflutter/widget/article_item.dart';
import 'package:wanandroidflutter/widget/custom_refresh.dart';
import 'package:wanandroidflutter/widget/page_widget.dart';
import 'package:wanandroidflutter/widget/project_item.dart';

class ProjectListFragment extends StatefulWidget {
int _Id;
Expand Down Expand Up @@ -128,7 +128,7 @@ class ProjectListFragmentState extends State<ProjectListFragment>
controller: _scrollController,
itemCount: projectArticleList.length,
itemBuilder: (context, index) {
return ProjectArticleWidget(projectArticleList[index]);
return ArticleWidget(projectArticleList[index]);
})),
),
floatingActionButton: isShowFab ? FloatingActionButton(
Expand Down
76 changes: 65 additions & 11 deletions lib/widget/article_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,57 @@ class _ArticleWidgetState extends State<ArticleWidget> {
)),
],
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
child: !isHighLight(article.title)
? Text("${article.title}",
style: Theme.of(context).textTheme.subtitle)
: Html(
data: article.title,
),
if (article.envelopePic.isEmpty)
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.fromLTRB(0, 15, 0, 0),
child: !isHighLight(article.title)
? Text("${article.title}",
style: Theme.of(context).textTheme.subtitle)
: Html(
data: article.title,
),
),
)
else
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 5,
),
ArticleTitleWidget(article.title),
SizedBox(
height: 2,
),
Text(
article.desc,
style: Theme.of(context).textTheme.caption,
overflow: TextOverflow.ellipsis,
maxLines: 2,
)
],
),
),
SizedBox(
width: 5,
),
Padding(
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
child: Image.network(
article.envelopePic,
height: 60,
width: 60,
fit: BoxFit.cover,
),
)
],
),
),
Row(
children: <Widget>[
Expanded(
Expand Down Expand Up @@ -211,3 +250,18 @@ class _ArticleWidgetState extends State<ArticleWidget> {
}, errorCallBack: (code, msg) {}, context: context);
}
}

class ArticleTitleWidget extends StatelessWidget {
final String title;

ArticleTitleWidget(this.title);

@override
Widget build(BuildContext context) {
return Html(
padding: EdgeInsets.symmetric(vertical: 5),
data: title,
defaultTextStyle: Theme.of(context).textTheme.subtitle,
);
}
}
236 changes: 0 additions & 236 deletions lib/widget/project_item.dart

This file was deleted.

0 comments on commit d2af136

Please sign in to comment.