|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:gsy_github_app_flutter/common/model/Repository.dart'; |
| 3 | +import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart'; |
| 4 | +import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart'; |
| 5 | +import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart'; |
| 6 | +import 'package:gsy_github_app_flutter/widget/GSYIConText.dart'; |
| 7 | +import 'package:gsy_github_app_flutter/widget/GSYUserIconWidget.dart'; |
| 8 | + |
| 9 | + |
| 10 | +class DemoItem extends StatelessWidget { |
| 11 | + |
| 12 | + DemoItem() : super(); |
| 13 | + |
| 14 | + ///返回一个居中带图标和文本的Item |
| 15 | + _getBottomItem(IconData icon, String text) { |
| 16 | + ///充满 Row 横向的布局 |
| 17 | + return new Expanded( |
| 18 | + flex: 1, |
| 19 | + |
| 20 | + ///居中显示 |
| 21 | + child: new Center( |
| 22 | + ///横向布局 |
| 23 | + child: new Row( |
| 24 | + ///主轴居中,即是横向居中 |
| 25 | + mainAxisAlignment: MainAxisAlignment.center, |
| 26 | + |
| 27 | + ///大小按照最大充满 |
| 28 | + mainAxisSize: MainAxisSize.max, |
| 29 | + |
| 30 | + ///竖向也居中 |
| 31 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 32 | + children: <Widget>[ |
| 33 | + ///一个星星图标 |
| 34 | + new Icon( |
| 35 | + icon, |
| 36 | + size: 16.0, |
| 37 | + color: Colors.grey, |
| 38 | + ), |
| 39 | + |
| 40 | + ///间隔 |
| 41 | + new Padding(padding: new EdgeInsets.all(5.0)), |
| 42 | + |
| 43 | + ///显示数量文本 |
| 44 | + new Text( |
| 45 | + text, |
| 46 | + style: new TextStyle(color: Colors.grey, fontSize: 14.0), |
| 47 | + overflow: TextOverflow.ellipsis, |
| 48 | + maxLines: 1, |
| 49 | + ), |
| 50 | + ], |
| 51 | + ), |
| 52 | + ), |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + @override |
| 57 | + Widget build(BuildContext context) { |
| 58 | + return new Container( |
| 59 | + ///卡片包装 |
| 60 | + child: new Card( |
| 61 | + ///增加点击效果 |
| 62 | + child: new FlatButton( |
| 63 | + onPressed: (){print("点击了哦");}, |
| 64 | + child: new Padding( |
| 65 | + padding: new EdgeInsets.only(left: 0.0, top: 10.0, right: 10.0, bottom: 10.0), |
| 66 | + child: new Column( |
| 67 | + mainAxisSize: MainAxisSize.min, |
| 68 | + children: <Widget>[ |
| 69 | + ///文本描述 |
| 70 | + new Container( |
| 71 | + child: new Text( |
| 72 | + "这是一点描述", |
| 73 | + style: TextStyle( |
| 74 | + color: Color(GSYColors.subTextColor), |
| 75 | + fontSize: 14.0, |
| 76 | + ), |
| 77 | + ///最长三行,超过 ... 显示 |
| 78 | + maxLines: 3, |
| 79 | + overflow: TextOverflow.ellipsis, |
| 80 | + ), |
| 81 | + margin: new EdgeInsets.only(top: 6.0, bottom: 2.0), |
| 82 | + alignment: Alignment.topLeft), |
| 83 | + new Padding(padding: EdgeInsets.all(10.0)), |
| 84 | + |
| 85 | + ///三个平均分配的横向图标文字 |
| 86 | + new Row( |
| 87 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 88 | + children: <Widget>[ |
| 89 | + _getBottomItem(Icons.star, "1000"), |
| 90 | + _getBottomItem(Icons.link, "1000"), |
| 91 | + _getBottomItem(Icons.subject, "1000"), |
| 92 | + ], |
| 93 | + ), |
| 94 | + ], |
| 95 | + ), |
| 96 | + ))), |
| 97 | + ); |
| 98 | + } |
| 99 | +} |
0 commit comments