|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter/cupertino.dart'; |
| 3 | + |
| 4 | +enum LoadType { |
| 5 | + loading, |
| 6 | + noData, |
| 7 | + dot, |
| 8 | +} |
| 9 | + |
| 10 | +class LoadMore extends StatelessWidget { |
| 11 | + LoadMore({Key key, this.type = LoadType.noData}) : super(key: key); |
| 12 | + |
| 13 | + final LoadType type; |
| 14 | + @override |
| 15 | + Widget build(BuildContext context) { |
| 16 | + double screenWidth = MediaQuery.of(context).size.width; |
| 17 | + return Row( |
| 18 | + mainAxisAlignment: MainAxisAlignment.center, |
| 19 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 20 | + children: <Widget>[ |
| 21 | + Container( |
| 22 | + width: screenWidth * 0.65, |
| 23 | + margin: const EdgeInsets.symmetric(vertical: 15), |
| 24 | + child: Row( |
| 25 | + children: <Widget>[ |
| 26 | + Expanded( |
| 27 | + child: Divider( |
| 28 | + height: 1, |
| 29 | + )), |
| 30 | + Padding( |
| 31 | + padding: const EdgeInsets.symmetric(horizontal: 5), |
| 32 | + child: Row( |
| 33 | + children: <Widget>[ |
| 34 | + Offstage( |
| 35 | + child: CupertinoActivityIndicator(), |
| 36 | + offstage: type != LoadType.loading, |
| 37 | + ), |
| 38 | + type == LoadType.dot |
| 39 | + ? Container( |
| 40 | + width: 4, |
| 41 | + height: 4, |
| 42 | + child: Text(""), |
| 43 | + decoration: BoxDecoration( |
| 44 | + color: Color(0xFFE5E5E5), |
| 45 | + borderRadius: BorderRadius.all(Radius.circular(2)) |
| 46 | + ), |
| 47 | + ) |
| 48 | + : Text(type == LoadType.loading ? "正在加载" : "暂无数据",style: TextStyle(fontSize: 14),), |
| 49 | + ], |
| 50 | + ), |
| 51 | + ), |
| 52 | + Expanded( |
| 53 | + child: Divider( |
| 54 | + height: 1, |
| 55 | + )), |
| 56 | + ], |
| 57 | + ), |
| 58 | + ) |
| 59 | + ], |
| 60 | + ); |
| 61 | + // TODO: implement build |
| 62 | + return Container( |
| 63 | + child: Row( |
| 64 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 65 | + children: <Widget>[ |
| 66 | + Expanded( |
| 67 | + child: Text(""), |
| 68 | + flex: 4, |
| 69 | + ), |
| 70 | + Expanded( |
| 71 | + flex: 12, |
| 72 | + child: Row( |
| 73 | + children: <Widget>[ |
| 74 | + Expanded(child: Divider()), |
| 75 | + Row( |
| 76 | + children: <Widget>[CupertinoActivityIndicator(), Text("正在加载")], |
| 77 | + ), |
| 78 | + Expanded(child: Divider()), |
| 79 | + ], |
| 80 | + ), |
| 81 | + ), |
| 82 | + Expanded( |
| 83 | + child: Text(""), |
| 84 | + flex: 4, |
| 85 | + ) |
| 86 | + ], |
| 87 | + ), |
| 88 | + ); |
| 89 | + } |
| 90 | +} |
0 commit comments