send_express_page.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:city_pickers/city_pickers.dart';
  4. class SendExpressPage extends StatefulWidget {
  5. final Widget child;
  6. SendExpressPage({
  7. Key key,
  8. this.child
  9. }): super(key: key);
  10. _SendExpressPageState createState() => _SendExpressPageState();
  11. }
  12. class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
  13. @override
  14. bool get wantKeepAlive => true;
  15. final Map < Object,
  16. String > sendInfo = {
  17. "icon": 'lib/images/icon_send.png',
  18. "title": "发件信息",
  19. "phone": "010-8788 6890",
  20. "code": "345678",
  21. "name": "朝阳门大阳汽贸",
  22. "address": "",
  23. "addressDetail": "朝阳门外大街28号"
  24. };
  25. final Map < Object,
  26. String > getInfo = {
  27. "icon": 'lib/images/icon_shoujian.png',
  28. "title": "收件信息",
  29. "name": "香河汽修厂",
  30. "phone": "010-6734 3426",
  31. "address": "",
  32. "addressDetail": "香河县东大街29号院18栋3单元206"
  33. };
  34. Map < String,
  35. String > _itemInfo = {
  36. "icon": "lib/images/icon_huowu.png",
  37. "title": "货物信息",
  38. "itemName": "汽车轮胎",
  39. "itemNo": "4",
  40. "expressPrice": "15",
  41. "collectionPrice": "15800",
  42. "supportPrice": "5000",
  43. "weight": "600",
  44. "itemDesc": "轮胎请核对数量轮胎请"
  45. };
  46. @override
  47. Widget build(BuildContext context) {
  48. return Container(
  49. child: Scaffold(
  50. appBar: AppBar(
  51. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  52. centerTitle: true,
  53. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  54. // leading: GestureDetector(
  55. // child: Icon(Icons.arrow_back),
  56. // onTap: (){
  57. // Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
  58. // return HomePage();
  59. // }));
  60. // },
  61. // ),
  62. ),
  63. body: Container(
  64. color: Color.fromRGBO(246, 246, 254, 1),
  65. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  66. child: ListView(
  67. children: < Widget > [
  68. _sendInfo(sendInfo,context),
  69. _getInfo(getInfo),
  70. _itemInfoWidget(_itemInfo),
  71. _submitBtn()
  72. ],
  73. ),
  74. ),
  75. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  76. ),
  77. );
  78. }
  79. Widget _sendInfo(Map str,BuildContext context) {
  80. return Container(
  81. color: Colors.white,
  82. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  83. child: Column(
  84. children: < Widget > [
  85. _titleWidget(str['icon'], str['title']),
  86. _underLine(),
  87. _contentWiget('电话', str['phone']),
  88. _contentWiget('企业编码', str['code']),
  89. _contentWiget('企业名称', str['name']),
  90. _cityWiget('城市/区域', str['address'],context),
  91. _lastContentWiget('详细地址', str['addressDetail'])
  92. ],
  93. )
  94. );
  95. }
  96. Widget _getInfo(Map str) {
  97. return Container(
  98. color: Colors.white,
  99. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  100. child: Column(
  101. children: < Widget > [
  102. _titleWidget(str['icon'], str['title']),
  103. _underLine(),
  104. _contentWiget('企业名称', str['name']),
  105. _contentWiget('电话', str['phone']),
  106. _cityWiget('城市/区域', str['address'],context),
  107. _lastContentWiget('详细地址', str['addressDetail'])
  108. ],
  109. )
  110. );
  111. }
  112. Widget _itemInfoWidget(Map _itemInfo) {
  113. return Container(
  114. child: Container(
  115. color: Colors.white,
  116. child: Column(
  117. crossAxisAlignment: CrossAxisAlignment.start,
  118. children: < Widget > [
  119. _titleWidget(_itemInfo['icon'], "货物信息"),
  120. _underLine(),
  121. _contentWiget("货物名称", _itemInfo["itemName"]),
  122. _contentWiget("数量", _itemInfo["itemNo"]),
  123. _contentWiget("运费", _itemInfo["expressPrice"]),
  124. _contentWiget("代收", _itemInfo["collectionPrice"]),
  125. _contentWiget("保价", _itemInfo["supportPrice"]),
  126. _contentWiget("重量", _itemInfo["weight"]),
  127. _descWidget(_itemInfo['itemDesc'])
  128. ],
  129. ),
  130. )
  131. );
  132. }
  133. Widget _titleWidget(String iconUrl, String str) {
  134. return Container(
  135. height: ScreenUtil.getInstance().setHeight(90),
  136. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  137. child: Center(
  138. child: Row(
  139. mainAxisAlignment: MainAxisAlignment.start,
  140. children: < Widget > [
  141. Padding(
  142. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  143. child: Image.asset(
  144. iconUrl,
  145. width: ScreenUtil.getInstance().setWidth(40),
  146. height: ScreenUtil.getInstance().setHeight(40),
  147. )
  148. ),
  149. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  150. ],
  151. ),
  152. ),
  153. );
  154. }
  155. Widget _underLine() {
  156. return Container(
  157. color: Color.fromRGBO(223, 223, 223, 1),
  158. height: ScreenUtil.getInstance().setHeight(1),
  159. );
  160. }
  161. Widget _contentWiget(String key, String value) {
  162. return Padding(
  163. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  164. child: Column(
  165. children: < Widget > [
  166. SizedBox(
  167. height: ScreenUtil.getInstance().setHeight(89),
  168. child: Center(
  169. child: Row(
  170. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  171. children: < Widget > [
  172. Expanded(
  173. flex: 0,
  174. child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  175. ),
  176. Expanded(
  177. child: Row(
  178. mainAxisAlignment: MainAxisAlignment.end,
  179. children: < Widget > [
  180. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  181. SizedBox(
  182. width: ScreenUtil.getInstance().setWidth(500),
  183. child: TextField(
  184. keyboardType: TextInputType.number,
  185. textAlign: TextAlign.end,
  186. decoration: InputDecoration(
  187. border: InputBorder.none
  188. ),
  189. ),
  190. ),
  191. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  192. ],
  193. )
  194. )
  195. ],
  196. ),
  197. )
  198. ),
  199. Expanded(
  200. flex: 0,
  201. child: _underLine()
  202. )
  203. ],
  204. )
  205. );
  206. }
  207. Widget _cityWiget(String key, String value,BuildContext context) {
  208. return
  209. GestureDetector(
  210. child: Padding(
  211. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  212. child: Column(
  213. children: < Widget > [
  214. SizedBox(
  215. height: ScreenUtil.getInstance().setHeight(89),
  216. child: Center(
  217. child: Row(
  218. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  219. children: < Widget > [
  220. Expanded(
  221. flex: 0,
  222. child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  223. ),
  224. Expanded(
  225. child: Row(
  226. mainAxisAlignment: MainAxisAlignment.end,
  227. children: < Widget > [
  228. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  229. SizedBox(
  230. width: ScreenUtil.getInstance().setWidth(500),
  231. child: Text(value,textAlign: TextAlign.end,overflow: TextOverflow.ellipsis,)
  232. ),
  233. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  234. ],
  235. )
  236. )
  237. ],
  238. ),
  239. )
  240. ),
  241. Expanded(
  242. flex: 0,
  243. child: _underLine()
  244. )
  245. ],
  246. )
  247. ),
  248. onTap: (){
  249. getCity(context).then((resp){
  250. setState(() {
  251. this.sendInfo['address'] = resp.provinceName+' '+resp.cityName+' '+' '+resp.areaName;
  252. });
  253. //print(value);
  254. });
  255. },
  256. );
  257. }
  258. Widget _lastContentWiget(String key, String value) {
  259. return Padding(
  260. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  261. child: SizedBox(
  262. height: ScreenUtil.getInstance().setHeight(89),
  263. child: Center(
  264. child: Row(
  265. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  266. children: < Widget > [
  267. Expanded(
  268. flex: 0,
  269. child: Text('${key}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  270. ),
  271. Expanded(
  272. child: Row(
  273. mainAxisAlignment: MainAxisAlignment.end,
  274. children: < Widget > [
  275. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  276. SizedBox(
  277. width: ScreenUtil.getInstance().setWidth(500),
  278. child: TextField(
  279. keyboardType: TextInputType.number,
  280. textAlign: TextAlign.end,
  281. decoration: InputDecoration(
  282. border: InputBorder.none
  283. ),
  284. ),
  285. ),
  286. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  287. ],
  288. )
  289. )
  290. ],
  291. ),
  292. )
  293. )
  294. );
  295. }
  296. Widget _descWidget(String str) {
  297. return
  298. Container(
  299. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  300. //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  301. child: TextField(
  302. maxLines: 3,
  303. decoration: InputDecoration(
  304. border: InputBorder.none,
  305. hintText: "请输入备注内容"
  306. ),
  307. ),
  308. );
  309. }
  310. Widget _submitBtn() {
  311. return GestureDetector(
  312. child: Container(
  313. margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
  314. height: ScreenUtil.getInstance().setHeight(88),
  315. decoration: BoxDecoration(
  316. borderRadius: BorderRadius.all(Radius.circular(4)),
  317. color: Color.fromRGBO(37, 102, 242, 1),
  318. ),
  319. child: Center(
  320. child: Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
  321. ),
  322. ),
  323. onTap: () {
  324. print('提交');
  325. },
  326. );
  327. }
  328. Future getCity(context) async {
  329. Result result = await CityPickers.showCityPicker(
  330. context: context,
  331. );
  332. return result;
  333. }
  334. }