order_taking_page.dart 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. class OrderTakingPage extends StatefulWidget {
  4. OrderTakingPage({
  5. Key key
  6. }): super(key: key);
  7. _OrderTakingPageState createState() => _OrderTakingPageState();
  8. }
  9. class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
  10. @override
  11. void initState() {
  12. // TODO: implement initState
  13. super.initState();
  14. print("重绘页面");
  15. }
  16. @override
  17. Widget build(BuildContext context) {
  18. super.build(context);
  19. return Container(
  20. child: Scaffold(
  21. appBar: AppBar(
  22. title: Text('接单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  23. centerTitle: true,
  24. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  25. actions: < Widget > [
  26. Container(
  27. child: PopupMenuButton<String>(
  28. icon: Icon(Icons.add_circle_outline),
  29. offset: Offset(0, 60),
  30. padding: EdgeInsets.zero,
  31. //child: IconButton(icon: Image.asset('lib/images/icon_shaixuan.png', scale: 1.8, ),onPressed: (){},),
  32. itemBuilder: (BuildContext context)=><PopupMenuEntry<String>>[
  33. PopupMenuItem<String>(
  34. child:Text("hahahahahh"),
  35. ),
  36. PopupMenuDivider(height: 1.0),
  37. PopupMenuItem<String>(
  38. child:Text("hahahahahh"),
  39. ),
  40. PopupMenuDivider(height: 1.0),
  41. PopupMenuItem<String>(
  42. child:Text("hahahahahh"),
  43. ),
  44. PopupMenuDivider(height: 1.0),
  45. ]
  46. )
  47. ),
  48. ],
  49. ),
  50. body: Container(
  51. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
  52. decoration: BoxDecoration(
  53. color: Color.fromRGBO(246, 246, 254, 1)
  54. ),
  55. child: ListView(
  56. children: < Widget > [
  57. OrderCard(),
  58. OrderCard(),
  59. OrderCard(),
  60. OrderCard(),
  61. ],
  62. ),
  63. )
  64. ),
  65. );
  66. }
  67. @override
  68. bool get wantKeepAlive => true;
  69. }
  70. class OrderCard extends StatefulWidget {
  71. final Widget child;
  72. OrderCard({
  73. Key key,
  74. this.child
  75. }): super(key: key);
  76. _OrderCardState createState() => _OrderCardState();
  77. }
  78. class _OrderCardState extends State < OrderCard > {
  79. @override
  80. Widget build(BuildContext context) {
  81. return Card(
  82. color: Colors.white,
  83. elevation: 3.0,
  84. child: Column(
  85. children: < Widget > [
  86. OrderCardContainer()
  87. ],
  88. ),
  89. );
  90. }
  91. }
  92. class OrderCardContainer extends StatefulWidget {
  93. final Widget child;
  94. OrderCardContainer({
  95. Key key,
  96. this.child
  97. }): super(key: key);
  98. _OrderCardContainerState createState() => _OrderCardContainerState();
  99. }
  100. class _OrderCardContainerState extends State < OrderCardContainer > with SingleTickerProviderStateMixin {
  101. Animation < double > animation;
  102. AnimationController controller;
  103. String str="联系方式";
  104. bool animationStatus =true;
  105. @override
  106. initState() {
  107. super.initState();
  108. controller = new AnimationController(
  109. duration: const Duration(milliseconds: 200), vsync: this);
  110. animation = new Tween(begin: 0.0, end: 230.0).animate(controller);
  111. animation.addStatusListener((status){
  112. if (status == AnimationStatus.completed) {
  113. //动画执行结束时反向执行动画
  114. setState(() {
  115. animationStatus = false;
  116. str="收起";
  117. });
  118. } else if (status == AnimationStatus.dismissed) {
  119. //动画恢复到初始状态时执行动画(正向)
  120. setState(() {
  121. animationStatus=true;
  122. str="联系方式";
  123. });
  124. }
  125. });
  126. }
  127. @override
  128. Widget build(BuildContext context) {
  129. return Container(
  130. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), 0),
  131. child: Column(
  132. children: < Widget > [
  133. orderNoRow(),
  134. orderAddress(),
  135. orderItem('货物名称', '汽车轮胎', 15),
  136. orderItem('货物件数', '2件', 30),
  137. orderCutLine(),
  138. orderBtn(animationStatus,controller,str),
  139. AnimatedOpen(animation: animation)
  140. ],
  141. ),
  142. );
  143. }
  144. dispose() {
  145. //路由销毁时需要释放动画资源
  146. controller.dispose();
  147. super.dispose();
  148. }
  149. }
  150. Widget orderBtn(bool animationStatus,AnimationController controller,String str){
  151. return Container(
  152. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  153. child: Row(
  154. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  155. children: < Widget > [
  156. GestureDetector(
  157. child: Container(
  158. width: ScreenUtil.getInstance().setWidth(100),
  159. height: ScreenUtil.getInstance().setHeight(48),
  160. color: Colors.white,
  161. child: Center(
  162. child: Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1)), ),
  163. )
  164. ),
  165. onTap: () {
  166. if (animationStatus) {
  167. //动画恢复到初始状态时执行动画(正向)
  168. controller.forward();
  169. } else{
  170. //动画执行结束时反向执行动画
  171. controller.reverse();
  172. }
  173. },
  174. ),
  175. GestureDetector(
  176. child: Container(
  177. width: ScreenUtil.getInstance().setWidth(94),
  178. height: ScreenUtil.getInstance().setWidth(48),
  179. decoration: BoxDecoration(
  180. color: Color.fromRGBO(252, 97, 128, 1),
  181. borderRadius: BorderRadius.all(Radius.circular(4.0))
  182. ),
  183. child: Center(
  184. child: Text("接单", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Colors.white), ),
  185. ),
  186. ),
  187. onTap: () {
  188. print("22222");
  189. },
  190. )
  191. ],
  192. )
  193. );
  194. }
  195. class AnimatedOpen extends AnimatedWidget {
  196. AnimatedOpen({
  197. Key key,
  198. Animation < double > animation
  199. }): super(key: key, listenable: animation);
  200. Widget build(BuildContext context) {
  201. final Animation < double > animation = listenable;
  202. return Container(
  203. height: ScreenUtil.getInstance().setHeight(animation.value),
  204. child: orderDetailInfo(),
  205. );
  206. }
  207. }
  208. Widget orderNoRow() { //订单号及时间
  209. return Container(
  210. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  211. child: Row(
  212. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  213. children: < Widget > [
  214. Text("订单号:10893477897899", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
  215. Text("2019/02/24 14:23", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
  216. ],
  217. ),
  218. );
  219. }
  220. Widget orderAddress() { //运送路线
  221. return Container(
  222. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  223. child: Row(children: < Widget > [
  224. Text('朝阳门大阳汽贸 ---> 朝阳门大阳汽贸', style: TextStyle(color: Colors.black, fontSize: ScreenUtil.getInstance().setSp(30)), ),
  225. ], )
  226. );
  227. }
  228. Widget orderItem(String key, String value, int marginBottom) {
  229. return Container(
  230. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
  231. child: Row(children: < Widget > [
  232. Text('${key}:${value}', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
  233. ], )
  234. );
  235. }
  236. Widget orderPhone(String key, String value, int marginBottom) {
  237. return Container(
  238. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
  239. child: Row(children: < Widget > [
  240. Text('${key}:', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
  241. Text('${value}', style: TextStyle(color: Color.fromRGBO(64, 98, 254, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
  242. ], )
  243. );
  244. }
  245. Widget orderCutLine() { //分割线
  246. return Container(
  247. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  248. height: ScreenUtil.getInstance().setHeight(1),
  249. color: Color.fromRGBO(223, 223, 223, 1),
  250. );
  251. }
  252. Widget orderDetailInfo() {//卡片展开信息
  253. return Container(
  254. child: Wrap(
  255. children: < Widget > [
  256. orderCutLine(),
  257. orderPhone('发件电话', '010-8788 6890', 15),
  258. orderItem('发件地址', '北京市朝阳区朝阳门外大街28号', 30),
  259. orderPhone('收件电话', '010-8788 6890', 15),
  260. orderItem('收件地址', '河北省廊坊市香河县东大街29号院18', 30),
  261. ],
  262. )
  263. );
  264. }