my_page.dart 11 KB

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