Skip to content

Commit

Permalink
start MyPage
Browse files Browse the repository at this point in the history
  • Loading branch information
xujiyou committed Jun 5, 2018
1 parent a5554aa commit 0d98576
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 136 deletions.
4 changes: 4 additions & 0 deletions lib/global_config.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'package:flutter/material.dart';

class GlobalConfig {
static bool dark = true;
static ThemeData themeData = new ThemeData.dark();
static Color searchBackgroundColor = Colors.white10;
static Color cardBackgroundColor = new Color(0xFF222222);
static Color fontColor = Colors.white30;
}
52 changes: 28 additions & 24 deletions lib/home/follow.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'article.dart';
import 'reply_page.dart';
import '../global_config.dart';

class Follow extends StatefulWidget {

Expand All @@ -16,7 +17,7 @@ class _FollowState extends State<Follow> {
if (article.imgUrl == null) {
markWidget = new Text(
article.mark,
style: new TextStyle(height: 1.3, color: Colors.white30)
style: new TextStyle(height: 1.3, color: GlobalConfig.fontColor)
);
} else {
markWidget = new Row(
Expand All @@ -26,7 +27,7 @@ class _FollowState extends State<Follow> {
child: new Container(
child: new Text(
article.mark,
style: new TextStyle(height: 1.3, color: Colors.white30)
style: new TextStyle(height: 1.3, color: GlobalConfig.fontColor)
),
),
),
Expand All @@ -49,7 +50,7 @@ class _FollowState extends State<Follow> {
);
}
return new Container(
color: const Color(0xff222222),
color: GlobalConfig.cardBackgroundColor,
margin: const EdgeInsets.only(top: 5.0, bottom: 5.0),
child: new FlatButton(
onPressed: (){
Expand All @@ -70,15 +71,15 @@ class _FollowState extends State<Follow> {
radius: 11.0
),
),
new Text(" " + article.user + " " + article.action + " · " + article.time, style: new TextStyle(color: Colors.white30))
new Text(" " + article.user + " " + article.action + " · " + article.time, style: new TextStyle(color: GlobalConfig.fontColor))
],
),
padding: const EdgeInsets.only(top: 10.0),
),
new Container(
child: new Text(
article.title,
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0, height: 1.3, color: Colors.white70)
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0, height: 1.3, color: GlobalConfig.dark == true? Colors.white70 : Colors.black)
),
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
alignment: Alignment.topLeft
Expand All @@ -92,10 +93,10 @@ class _FollowState extends State<Follow> {
child: new Row(
children: <Widget>[
new Expanded(
child: new Text(article.agreeNum.toString() + " 赞同 · " + article.commentNum.toString() + "评论", style: new TextStyle(color: Colors.white30))
child: new Text(article.agreeNum.toString() + " 赞同 · " + article.commentNum.toString() + "评论", style: new TextStyle(color: GlobalConfig.fontColor))
),
new PopupMenuButton(
icon: new Icon(Icons.linear_scale, color: Colors.white30,),
icon: new Icon(Icons.linear_scale, color: GlobalConfig.fontColor,),
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new PopupMenuItem<String>(
value: '选项一的值',
Expand Down Expand Up @@ -124,7 +125,7 @@ class _FollowState extends State<Follow> {
Widget billboard() {
return new Container(
margin: const EdgeInsets.only(top: 5.0, bottom: 5.0),
color: const Color(0xff222222),
color: GlobalConfig.cardBackgroundColor,
child: new FlatButton(
onPressed: (){},
child: new Column(
Expand All @@ -138,15 +139,15 @@ class _FollowState extends State<Follow> {
radius: 11.0
),
),
new Text(" 对啊网", style: new TextStyle(color: Colors.white30))
new Text(" 对啊网", style: new TextStyle(color: GlobalConfig.fontColor))
],
),
padding: const EdgeInsets.only(top: 10.0),
),
new Container(
child: new Text(
"考过CPA,非名牌大学也能进名企",
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0, height: 1.3, color: Colors.white70)
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0, height: 1.3, color: GlobalConfig.dark == true? Colors.white70 : Colors.black)
),
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
alignment: Alignment.topLeft
Expand All @@ -170,7 +171,7 @@ class _FollowState extends State<Follow> {
new Container(
child: new Text(
"还在羡慕别人的好工作?免费领取价值1980元的注册会计师课程,为自己充电!",
style: new TextStyle(height: 1.3, color: Colors.white30)
style: new TextStyle(height: 1.3, color: GlobalConfig.fontColor)
),
padding: const EdgeInsets.only(bottom: 8.0)
),
Expand All @@ -179,17 +180,17 @@ class _FollowState extends State<Follow> {
child: new Row(
children: <Widget>[
new Container(
child: new Text("广告", style: new TextStyle(fontSize: 10.0, color: Colors.white30)),
child: new Text("广告", style: new TextStyle(fontSize: 10.0, color: GlobalConfig.fontColor)),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.white30),
border: new Border.all(color: GlobalConfig.fontColor),
borderRadius: new BorderRadius.all(const Radius.circular(2.0)),
),
padding: const EdgeInsets.only(top: 2.0, bottom: 2.0, left: 3.0, right: 3.0)
),
new Expanded(
child: new Text(" 查看详情", style: new TextStyle(color: Colors.white30))
child: new Text(" 查看详情", style: new TextStyle(color: GlobalConfig.fontColor))
),
new Icon(Icons.clear, color: Colors.white30)
new Icon(Icons.clear, color: GlobalConfig.fontColor)
],
),
padding: const EdgeInsets.only(bottom: 10.0),
Expand All @@ -203,15 +204,18 @@ class _FollowState extends State<Follow> {
@override
Widget build(BuildContext context) {
return new SingleChildScrollView(
child: new Column(
children: <Widget>[
wordsCard(articleList[0]),
wordsCard(articleList[1]),
wordsCard(articleList[2]),
billboard(),
wordsCard(articleList[3])
],
),
child: new Container(
margin: const EdgeInsets.only(top: 5.0),
child: new Column(
children: <Widget>[
wordsCard(articleList[0]),
wordsCard(articleList[1]),
wordsCard(articleList[2]),
billboard(),
wordsCard(articleList[3])
],
),
)
);
}
}
12 changes: 6 additions & 6 deletions lib/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class _HomePageState extends State<HomePage> {
},
icon: new Icon(
Icons.search,
color: Colors.white70,
color: GlobalConfig.fontColor,
size: 16.0
),
label: new Text(
"坚果R1摄像头损坏",
style: new TextStyle(color: Colors.white70),
style: new TextStyle(color: GlobalConfig.fontColor),
),
)
),
new Container(
decoration: new BoxDecoration(
border: new BorderDirectional(
start: new BorderSide(color: Colors.white70, width: 1.0)
start: new BorderSide(color: GlobalConfig.fontColor, width: 1.0)
)
),
height: 14.0,
Expand All @@ -59,20 +59,20 @@ class _HomePageState extends State<HomePage> {
},
icon: new Icon(
Icons.border_color,
color: Colors.white70,
color: GlobalConfig.fontColor,
size: 14.0
),
label: new Text(
"提问",
style: new TextStyle(color: Colors.white70),
style: new TextStyle(color: GlobalConfig.fontColor),
),
)
)
],
),
decoration: new BoxDecoration(
borderRadius: const BorderRadius.all(const Radius.circular(4.0)),
color: Colors.white10,
color: GlobalConfig.searchBackgroundColor,
)
);
}
Expand Down
38 changes: 21 additions & 17 deletions lib/home/hot.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'question.dart';
import 'question_page.dart';
import '../global_config.dart';

class Hot extends StatefulWidget{

Expand All @@ -13,9 +14,9 @@ class HotState extends State<Hot>{
Widget hotCard(Question question) {
return new Container(
decoration: new BoxDecoration(
color: const Color(0xff222222),
color: GlobalConfig.cardBackgroundColor,
border: new BorderDirectional(
bottom: new BorderSide(color: Colors.white12, width: 1.0)
bottom: new BorderSide(color: GlobalConfig.dark == true ? Colors.white12 : Colors.black12, width: 1.0)
)
),
child: new FlatButton(
Expand Down Expand Up @@ -61,19 +62,19 @@ class HotState extends State<Hot>{
new Container(
child: new Text(
question.title,
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0, height: 1.1, color: Colors.white70),
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0, height: 1.1, color: GlobalConfig.dark == true ? Colors.white70 : Colors.black),
),
padding: const EdgeInsets.only(bottom: 10.0,right: 4.0),
alignment: Alignment.topLeft,
),
question.mark != null ?
new Container(
child: new Text(question.mark, style: new TextStyle(color: Colors.white30)),
child: new Text(question.mark, style: new TextStyle(color: GlobalConfig.fontColor)),
alignment: Alignment.topLeft,
padding: const EdgeInsets.only(bottom: 8.0,right: 4.0)
) : new Container(),
new Container(
child: new Text(question.hotNum, style: new TextStyle(color: Colors.white30)),
child: new Text(question.hotNum, style: new TextStyle(color: GlobalConfig.fontColor)),
alignment: Alignment.topLeft,
)
],
Expand Down Expand Up @@ -104,18 +105,21 @@ class HotState extends State<Hot>{
@override
Widget build(BuildContext context) {
return new SingleChildScrollView(
child: new Column(
children: <Widget>[
new Container(
margin: const EdgeInsets.only(top: 5.0),
),
hotCard(questionList[0]),
hotCard(questionList[1]),
hotCard(questionList[2]),
hotCard(questionList[3]),
hotCard(questionList[4]),
],
),
child: new Container(
margin: const EdgeInsets.only(top: 5.0),
child: new Column(
children: <Widget>[
new Container(
margin: const EdgeInsets.only(top: 5.0),
),
hotCard(questionList[0]),
hotCard(questionList[1]),
hotCard(questionList[2]),
hotCard(questionList[3]),
hotCard(questionList[4]),
],
),
)
);
}
}
Loading

0 comments on commit 0d98576

Please sign in to comment.