my_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'my_page/revise_password_page.dart';
  4. import 'package:flutter_picker/flutter_picker.dart';
  5. import 'dart:convert';
  6. import '../showDialog.dart';
  7. import '../login_page.dart';
  8. class MyPage extends StatefulWidget {
  9. final Widget child;
  10. MyPage({
  11. Key key,
  12. this.child
  13. }): super(key: key);
  14. _MyPageState createState() => _MyPageState();
  15. }
  16. class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
  17. bool check = false;
  18. @override
  19. bool get wantKeepAlive => true;
  20. String _siteName = "请选择站点";
  21. @override
  22. void initState() {
  23. // TODO: implement initState
  24. super.initState();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return Container(
  29. child: Scaffold(
  30. appBar: AppBar(
  31. elevation: 0,
  32. title: Text('我的',
  33. style: TextStyle(
  34. fontSize: ScreenUtil.getInstance().setSp(36)
  35. ), ),
  36. centerTitle: true,
  37. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  38. actions: < Widget > [
  39. IconButton(
  40. icon: Icon(Icons.arrow_forward, color: Colors.white, )
  41. )
  42. ],
  43. ),
  44. body: Container(
  45. color: Color.fromRGBO(246, 246, 254, 1),
  46. child: Column(
  47. children: < Widget > [
  48. _avatarWidget(),
  49. _funWrapWidget(check, context),
  50. ],
  51. ),
  52. ),
  53. )
  54. );
  55. }
  56. Widget _avatarWidget() {
  57. return Container(
  58. color: Color.fromRGBO(64, 98, 254, 1),
  59. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(59), 0, ScreenUtil.getInstance().setHeight(67), ),
  60. child: Column(
  61. children: < Widget > [
  62. Center(
  63. child: Padding(
  64. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setWidth(24), ),
  65. child: ClipOval(
  66. child: Image.asset('lib/images/icon_logo.png',
  67. fit: BoxFit.cover,
  68. width: ScreenUtil.getInstance().setWidth(120),
  69. height: ScreenUtil.getInstance().setWidth(120), ),
  70. )
  71. )
  72. ),
  73. Center(child: Text('Alisa Lin', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(255, 255, 255, 1)), ), )
  74. ],
  75. ),
  76. );
  77. }
  78. Widget _funWrapWidget(bool check, BuildContext context) {
  79. return Container(
  80. padding: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(20)),
  81. child: Column(
  82. children: < Widget > [
  83. _switchSite(context),
  84. _passWordWidget(),
  85. _linkPrint(check),
  86. _quitWidget(context)
  87. ],
  88. ),
  89. );
  90. }
  91. Widget _switchSite(BuildContext context) {
  92. return InkWell(
  93. child: Container(
  94. height: ScreenUtil.getInstance().setHeight(90),
  95. color: Colors.white,
  96. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  97. child: Column(
  98. children: < Widget > [
  99. Expanded(
  100. child: Center(
  101. child: Row(
  102. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  103. children: < Widget > [
  104. Expanded(
  105. child: Row(
  106. mainAxisAlignment: MainAxisAlignment.start,
  107. children: < Widget > [
  108. Padding(
  109. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(22)),
  110. child: Image.asset('lib/images/icon_zhandianss.png',
  111. width: ScreenUtil.getInstance().setWidth(30),
  112. height: ScreenUtil.getInstance().setHeight(34),
  113. )
  114. ),
  115. Text('站点切换', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  116. ],
  117. ),
  118. ),
  119. Expanded(
  120. child: Row(
  121. mainAxisAlignment: MainAxisAlignment.end,
  122. children: < Widget > [
  123. Text(_siteName, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)), ),
  124. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1))
  125. ],
  126. ),
  127. ),
  128. ],
  129. ),
  130. ),
  131. ),
  132. Expanded(
  133. flex: 0,
  134. child: _underLine(),
  135. )
  136. ],
  137. )
  138. ),
  139. onTap: () {
  140. // showDialog < Null > (
  141. // context: context, //BuildContext对象
  142. // barrierDismissible: false,
  143. // builder: (BuildContext context) {
  144. // return SiteDialog( //调用对话框
  145. // );
  146. // });
  147. showPickerModal(context);
  148. },
  149. );
  150. }
  151. showPickerModal(BuildContext context) {
  152. new Picker(
  153. adapter: PickerDataAdapter < String > (pickerdata: new JsonDecoder().convert('["回龙观","草桥","丰台"]')),
  154. height: ScreenUtil.getInstance().setHeight(450),
  155. confirmText: '确定',
  156. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  157. cancelText: '取消',
  158. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  159. headercolor: Color.fromRGBO(245, 245, 245, 1),
  160. itemExtent: ScreenUtil.getInstance().setHeight(80),
  161. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  162. changeToFirst: true,
  163. hideHeader: false,
  164. onConfirm: (Picker picker, List value) {
  165. print(value.toString());
  166. print(picker.adapter);
  167. setState(() {
  168. _siteName = picker.adapter.text + '站点';
  169. });
  170. }
  171. ).showModal(this.context); //_scaffoldKey.currentState);
  172. }
  173. Widget _underLine() {
  174. return Container(
  175. height: ScreenUtil.getInstance().setHeight(1),
  176. color: Color.fromRGBO(223, 223, 223, 1),
  177. );
  178. }
  179. Widget _passWordWidget() {
  180. return
  181. GestureDetector(
  182. child: Container(
  183. height: ScreenUtil.getInstance().setHeight(90),
  184. color: Colors.white,
  185. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  186. child: Column(
  187. children: < Widget > [
  188. Expanded(
  189. child: Center(
  190. child: Row(
  191. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  192. children: < Widget > [
  193. Expanded(
  194. child: Row(
  195. mainAxisAlignment: MainAxisAlignment.start,
  196. children: < Widget > [
  197. Padding(
  198. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(22)),
  199. child: Image.asset('lib/images/icon_mimas.png',
  200. width: ScreenUtil.getInstance().setWidth(30),
  201. height: ScreenUtil.getInstance().setHeight(34),
  202. )
  203. ),
  204. Text('修改密码', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  205. ],
  206. ),
  207. ),
  208. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1))
  209. ],
  210. ),
  211. ),
  212. )
  213. ],
  214. )
  215. ),
  216. onTap: () {
  217. Navigator.push(context, MaterialPageRoute(builder: (context) {
  218. return RevisePasswordPage();
  219. }));
  220. },
  221. );
  222. }
  223. Widget _linkPrint(bool check) {
  224. return Container(
  225. height: ScreenUtil.getInstance().setHeight(90),
  226. color: Colors.white,
  227. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  228. margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(20)),
  229. child: Column(
  230. children: < Widget > [
  231. Expanded(
  232. child: Center(
  233. child: Row(
  234. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  235. children: < Widget > [
  236. Expanded(
  237. child: Row(
  238. mainAxisAlignment: MainAxisAlignment.start,
  239. children: < Widget > [
  240. Padding(
  241. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(22)),
  242. child: Image.asset('lib/images/icon_dayinji.png',
  243. width: ScreenUtil.getInstance().setWidth(30),
  244. height: ScreenUtil.getInstance().setHeight(34),
  245. )
  246. ),
  247. Text('打印机连接', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  248. ],
  249. ),
  250. ),
  251. Switch(
  252. value: this.check,
  253. activeColor: Colors.blue,
  254. onChanged: (bool val) {
  255. print("val:${val}");
  256. this.setState(() {
  257. this.check = val;
  258. });
  259. print('check:${this.check}');
  260. },
  261. )
  262. ],
  263. ),
  264. ),
  265. )
  266. ],
  267. )
  268. );
  269. }
  270. Widget _quitWidget(BuildContext context) {
  271. return InkWell(
  272. child: Container(
  273. height: ScreenUtil.getInstance().setHeight(90),
  274. color: Colors.white,
  275. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  276. margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(20)),
  277. child: Column(
  278. children: < Widget > [
  279. Expanded(
  280. child: Center(
  281. child: Row(
  282. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  283. children: < Widget > [
  284. Text('退出', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  285. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1))
  286. ],
  287. ),
  288. ),
  289. )
  290. ],
  291. )
  292. ),
  293. onTap: (){
  294. showDialog < Null > (
  295. context: context, //BuildContext对象
  296. barrierDismissible: false,
  297. builder: (BuildContext context) {
  298. return new LoadingDialog( //调用对话框
  299. text:'确认退出?',childCallback: (val){
  300. if(val){
  301. Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
  302. return LoginPage();
  303. }));
  304. }else{
  305. return;
  306. }
  307. },
  308. );
  309. });
  310. },
  311. );
  312. }
  313. }
  314. // //打印机弹出层
  315. // class PrintDialog extends Dialog {
  316. // PrintDialog({
  317. // Key key,
  318. // }): super(key: key);
  319. // }