mine_page.dart 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. Image.asset(
  60. "assets/images/head.jpg",
  61. width: 150,
  62. height: 150,
  63. ),
  64. const SizedBox(
  65. height: 10,
  66. ),
  67. Container(
  68. width: _size.width * 0.9,
  69. height: _size.width * 0.4,
  70. decoration: BoxDecoration(
  71. color: Colors.white,
  72. borderRadius: BorderRadius.circular(20)),
  73. child: Column(
  74. crossAxisAlignment: CrossAxisAlignment.start,
  75. children: [
  76. Container(
  77. child: Text(
  78. "更多",
  79. style: TextStyle(
  80. fontSize: 20, fontWeight: FontWeight.bold),
  81. ),
  82. margin: EdgeInsets.only(left: 10, top: 5),
  83. ),
  84. Row(
  85. children: [
  86. Expanded(
  87. child: InkWell(
  88. onTap: () {
  89. goSetting();
  90. },
  91. child: Column(
  92. children: [
  93. SizedBox(
  94. height: 10,
  95. ),
  96. Image.asset("assets/images/setting.png"),
  97. const SizedBox(
  98. height: 10,
  99. ),
  100. const Text("设置")
  101. ],
  102. ),
  103. ),
  104. ),
  105. Expanded(
  106. child: InkWell(
  107. onTap: () {
  108. aboutUs();
  109. },
  110. child: Column(
  111. children: [
  112. SizedBox(
  113. height: 10,
  114. ),
  115. Image.asset("assets/images/about.png"),
  116. const SizedBox(
  117. height: 10,
  118. ),
  119. const Text("关于我们")
  120. ],
  121. ),
  122. ),
  123. ),
  124. ],
  125. ),
  126. ],
  127. ),
  128. ),
  129. SizedBox(
  130. height: 50,
  131. ),
  132. Container(
  133. width: 150,
  134. child: InkWell(
  135. onTap: () {
  136. logout();
  137. },
  138. child: Container(
  139. width: double.infinity,
  140. height: 50,
  141. padding: EdgeInsets.only(right: 20, left: 20),
  142. decoration: BoxDecoration(
  143. gradient: const LinearGradient(colors: [
  144. ThemeColor.loignColor,
  145. ThemeColor.loignColor
  146. ]),
  147. borderRadius: BorderRadius.circular(10),
  148. boxShadow: const [
  149. BoxShadow(
  150. offset: Offset(1.0, 5.0),
  151. color: ThemeColor.loignColor,
  152. blurRadius: 5.0,
  153. )
  154. ]),
  155. child: const Center(
  156. child: Text(
  157. "退出登录",
  158. style: TextStyle(fontSize: 20, color: Colors.white),
  159. ),
  160. ),
  161. ),
  162. ),
  163. ),
  164. ],
  165. ),
  166. ),
  167. ),
  168. );
  169. }
  170. @override
  171. void initState() {
  172. super.initState();
  173. }
  174. void getUserInfo(String token) {}
  175. void logout() async {
  176. var sharedPreferences = await SharedPreferences.getInstance();
  177. String token = sharedPreferences.getString("token");
  178. try {
  179. bool logoutResult = await LoginDao.logout(token);
  180. if (logoutResult) {
  181. AppUtil.buildToast("退出成功!");
  182. Navigator.of(context).pushNamed(Routes.loginPage);
  183. } else {
  184. AppUtil.buildToast("退出异常,检测网络");
  185. }
  186. } catch (e) {
  187. AppUtil.buildToast("退出异常" + e.toString());
  188. }
  189. }
  190. void aboutUs() {
  191. AppUtil.buildToast("\"关于我们\"推出中..");
  192. }
  193. void goSetting() {
  194. AppUtil.buildToast("\"设置\"推出中..");
  195. }
  196. }