mine_page.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_tracker/dio/login_dao.dart';
  3. import 'package:flutter_tracker/model/config.dart';
  4. import 'package:flutter_tracker/routes/routes.dart';
  5. import 'package:flutter_tracker/utils/app_util.dart';
  6. import 'package:shared_preferences/shared_preferences.dart';
  7. class MinePage extends StatefulWidget {
  8. const MinePage({Key key}) : super(key: key);
  9. @override
  10. _MinePageState createState() => _MinePageState();
  11. }
  12. class _MinePageState extends State<MinePage> {
  13. Size get _size => MediaQuery.of(context).size;
  14. @override
  15. Widget build(BuildContext context) {
  16. return Scaffold(
  17. backgroundColor: Color(0xE6E4E4),
  18. body: SizedBox(
  19. width: _size.width,
  20. child: SingleChildScrollView(
  21. child: Column(
  22. crossAxisAlignment: CrossAxisAlignment.center,
  23. children: [
  24. Container(
  25. width: _size.width,
  26. color: Colors.blue,
  27. child: Column(
  28. crossAxisAlignment: CrossAxisAlignment.center,
  29. children: [
  30. const SizedBox(
  31. height: 50,
  32. ),
  33. // Container(
  34. // height: 100,
  35. // width: 100,
  36. // decoration: BoxDecoration(
  37. // borderRadius: BorderRadius.circular(50)),
  38. // child: Image.asset(
  39. // "assets/images/head.jpg",
  40. // ),
  41. // ),
  42. const Text(
  43. "网小儿",
  44. style: TextStyle(fontSize: 25),
  45. ),
  46. const SizedBox(
  47. height: 10,
  48. ),
  49. const Text("2021-11-25 10:10:10"),
  50. const SizedBox(
  51. height: 10,
  52. )
  53. ],
  54. ),
  55. ),
  56. const SizedBox(
  57. height: 10,
  58. ),
  59. Text("健康状态:"),
  60. Image.asset(
  61. "assets/images/green.jpg",
  62. width: 200,
  63. height: 200,
  64. ),
  65. const SizedBox(
  66. height: 10,
  67. ),
  68. // Container(
  69. // width: _size.width * 0.9,
  70. // height: _size.width * 0.4,
  71. // decoration: BoxDecoration(
  72. // color: Colors.white,
  73. // borderRadius: BorderRadius.circular(20)),
  74. // child: Column(
  75. // crossAxisAlignment: CrossAxisAlignment.start,
  76. // children: [
  77. // Container(
  78. // child: Text(
  79. // "更多",
  80. // style: TextStyle(
  81. // fontSize: 20, fontWeight: FontWeight.bold),
  82. // ),
  83. // margin: EdgeInsets.only(left: 10, top: 5),
  84. // ),
  85. // Row(
  86. // children: [
  87. // Expanded(
  88. // child: InkWell(
  89. // onTap: () {
  90. // goSetting();
  91. // },
  92. // child: Column(
  93. // children: [
  94. // SizedBox(
  95. // height: 10,
  96. // ),
  97. // Image.asset("assets/images/setting.png"),
  98. // const SizedBox(
  99. // height: 10,
  100. // ),
  101. // const Text("设置")
  102. // ],
  103. // ),
  104. // ),
  105. // ),
  106. // Expanded(
  107. // child: InkWell(
  108. // onTap: () {
  109. // aboutUs();
  110. // },
  111. // child: Column(
  112. // children: [
  113. // SizedBox(
  114. // height: 10,
  115. // ),
  116. // Image.asset("assets/images/about.png"),
  117. // const SizedBox(
  118. // height: 10,
  119. // ),
  120. // const Text("关于我们")
  121. // ],
  122. // ),
  123. // ),
  124. // ),
  125. // ],
  126. // ),
  127. // ],
  128. // ),
  129. // ),
  130. SizedBox(
  131. height: 50,
  132. ),
  133. Container(
  134. width: 150,
  135. child: InkWell(
  136. onTap: () {
  137. logout();
  138. },
  139. child: Container(
  140. width: double.infinity,
  141. height: 50,
  142. padding: EdgeInsets.only(right: 20, left: 20),
  143. decoration: BoxDecoration(
  144. gradient: const LinearGradient(colors: [
  145. ThemeColor.loignColor,
  146. ThemeColor.loignColor
  147. ]),
  148. borderRadius: BorderRadius.circular(10),
  149. boxShadow: const [
  150. BoxShadow(
  151. offset: Offset(1.0, 5.0),
  152. color: ThemeColor.loignColor,
  153. blurRadius: 5.0,
  154. )
  155. ]),
  156. child: const Center(
  157. child: Text(
  158. "退出登录",
  159. style: TextStyle(fontSize: 20, color: Colors.white),
  160. ),
  161. ),
  162. ),
  163. ),
  164. ),
  165. ],
  166. ),
  167. ),
  168. ),
  169. );
  170. }
  171. @override
  172. void initState() {
  173. super.initState();
  174. }
  175. void getUserInfo(String token) {
  176. }
  177. void logout() async {
  178. var sharedPreferences = await SharedPreferences.getInstance();
  179. String token = sharedPreferences.getString("token");
  180. try {
  181. bool logoutResult = await LoginDao.logout(token);
  182. if (logoutResult) {
  183. AppUtil.buildToast("退出成功!");
  184. Navigator.of(context).pushNamed(Routes.loginPage);
  185. } else {
  186. AppUtil.buildToast("退出异常,检测网络");
  187. }
  188. } catch (e) {
  189. AppUtil.buildToast("退出异常" + e.toString());
  190. }
  191. }
  192. void aboutUs() {
  193. AppUtil.buildToast("\"关于我们\"推出中..");
  194. }
  195. void goSetting() {
  196. AppUtil.buildToast("\"设置\"推出中..");
  197. }
  198. }