my_page.dart 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'my_page/revise_password_page.dart';
  4. class MyPage extends StatefulWidget {
  5. final Widget child;
  6. MyPage({
  7. Key key,
  8. this.child
  9. }): super(key: key);
  10. _MyPageState createState() => _MyPageState();
  11. }
  12. class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin{
  13. bool check = false;
  14. @override
  15. bool get wantKeepAlive => true;
  16. @override
  17. Widget build(BuildContext context) {
  18. return Container(
  19. child: Scaffold(
  20. appBar: AppBar(
  21. elevation: 0,
  22. title: Text('我的',
  23. style: TextStyle(
  24. fontSize: ScreenUtil.getInstance().setSp(36)
  25. ), ),
  26. centerTitle: true,
  27. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  28. ),
  29. body: Container(
  30. color: Color.fromRGBO(246, 246, 254, 1),
  31. child: Column(
  32. children: < Widget > [
  33. _avatarWidget(),
  34. _funWrapWidget(check)
  35. ],
  36. ),
  37. ),
  38. )
  39. );
  40. }
  41. Widget _avatarWidget() {
  42. return Container(
  43. color: Color.fromRGBO(64, 98, 254, 1),
  44. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(59), 0, ScreenUtil.getInstance().setHeight(67), ),
  45. child: Column(
  46. children: < Widget > [
  47. Center(
  48. child: Padding(
  49. padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setWidth(24), ),
  50. child: ClipOval(
  51. 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',
  52. fit: BoxFit.cover,
  53. width: ScreenUtil.getInstance().setWidth(120),
  54. height: ScreenUtil.getInstance().setWidth(120), ),
  55. )
  56. )
  57. ),
  58. Center(child: Text('Alisa Lin', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(255, 255, 255, 1)), ), )
  59. ],
  60. ),
  61. );
  62. }
  63. Widget _funWrapWidget(bool check) {
  64. return Container(
  65. padding: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(20)),
  66. child: Column(
  67. children: < Widget > [
  68. _switchSite(),
  69. _passWordWidget(),
  70. _linkPrint(check)
  71. ],
  72. ),
  73. );
  74. }
  75. Widget _switchSite() {
  76. return Container(
  77. height: ScreenUtil.getInstance().setHeight(90),
  78. color: Colors.white,
  79. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  80. child: Column(
  81. children: < Widget > [
  82. Expanded(
  83. child: Center(
  84. child: Row(
  85. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  86. children: < Widget > [
  87. Expanded(
  88. child: Row(
  89. mainAxisAlignment: MainAxisAlignment.start,
  90. children: < Widget > [
  91. Padding(
  92. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(22)),
  93. child: Image.asset('lib/images/icon_zhandianss.png',
  94. width: ScreenUtil.getInstance().setWidth(30),
  95. height: ScreenUtil.getInstance().setHeight(34),
  96. )
  97. ),
  98. Text('站点切换', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  99. ],
  100. ),
  101. ),
  102. Expanded(
  103. child: Row(
  104. mainAxisAlignment: MainAxisAlignment.end,
  105. children: < Widget > [
  106. Text('大兴站点', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)), ),
  107. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1))
  108. ],
  109. ),
  110. ),
  111. ],
  112. ),
  113. ),
  114. ),
  115. Expanded(
  116. flex: 0,
  117. child: _underLine(),
  118. )
  119. ],
  120. )
  121. );
  122. }
  123. Widget _underLine() {
  124. return Container(
  125. height: ScreenUtil.getInstance().setHeight(1),
  126. color: Color.fromRGBO(223, 223, 223, 1),
  127. );
  128. }
  129. Widget _passWordWidget() {
  130. return
  131. GestureDetector(
  132. child: Container(
  133. height: ScreenUtil.getInstance().setHeight(90),
  134. color: Colors.white,
  135. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  136. child: Column(
  137. children: < Widget > [
  138. Expanded(
  139. child: Center(
  140. child: Row(
  141. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  142. children: < Widget > [
  143. Expanded(
  144. child: Row(
  145. mainAxisAlignment: MainAxisAlignment.start,
  146. children: < Widget > [
  147. Padding(
  148. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(22)),
  149. child: Image.asset('lib/images/icon_mimas.png',
  150. width: ScreenUtil.getInstance().setWidth(30),
  151. height: ScreenUtil.getInstance().setHeight(34),
  152. )
  153. ),
  154. Text('修改密码', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  155. ],
  156. ),
  157. ),
  158. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1))
  159. ],
  160. ),
  161. ),
  162. )
  163. ],
  164. )
  165. ),
  166. onTap: () {
  167. Navigator.push(context, MaterialPageRoute(builder: (context) {
  168. return RevisePasswordPage();
  169. }));
  170. },
  171. );
  172. }
  173. Widget _linkPrint(bool check) {
  174. return Container(
  175. height: ScreenUtil.getInstance().setHeight(90),
  176. color: Colors.white,
  177. padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
  178. margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(20)),
  179. child: Column(
  180. children: < Widget > [
  181. Expanded(
  182. child: Center(
  183. child: Row(
  184. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  185. children: < Widget > [
  186. Expanded(
  187. child: Row(
  188. mainAxisAlignment: MainAxisAlignment.start,
  189. children: < Widget > [
  190. Padding(
  191. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(22)),
  192. child: Image.asset('lib/images/icon_dayinji.png',
  193. width: ScreenUtil.getInstance().setWidth(30),
  194. height: ScreenUtil.getInstance().setHeight(34),
  195. )
  196. ),
  197. Text('打印机连接', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  198. ],
  199. ),
  200. ),
  201. Switch(
  202. value: this.check,
  203. activeColor: Colors.blue,
  204. onChanged: (bool val) {
  205. print("val:${val}");
  206. this.setState(() {
  207. this.check = val;
  208. });
  209. print('check:${this.check}');
  210. },
  211. )
  212. ],
  213. ),
  214. ),
  215. )
  216. ],
  217. )
  218. );
  219. }
  220. }