my_page.dart 9.8 KB

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