account_manage_page.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:lszlgl/base/base_state.dart';
  5. import 'package:lszlgl/page/login/login_page.dart';
  6. import 'package:lszlgl/page/user_center/change_pwd_page.dart';
  7. import 'package:lszlgl/widget/button.dart';
  8. import 'package:lszlgl/widget/card_item.dart';
  9. /// 账号管理
  10. class AccountManagePage extends StatefulWidget {
  11. const AccountManagePage({Key? key}) : super(key: key);
  12. @override
  13. State<AccountManagePage> createState() => _AccountManagePageState();
  14. }
  15. class _AccountManagePageState extends BaseState<AccountManagePage> {
  16. String userAvatar = 'https://gd-hbimg.huaban.com/4105629c1e4204e2296515d1784f407c903024e7b9ce-Gs4d6A_fw658webp';
  17. void startChangePwd() {
  18. MyRouter.startChangePwd();
  19. }
  20. void onLogout() {
  21. MyRouter.startLogin(popAll: true);
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return myScaffold(child: buildBody());
  26. }
  27. Widget buildBody() {
  28. return Column(
  29. children: [
  30. myAppBar(title: '账号管理'),
  31. buildList(),
  32. const SizedBox(height: 40),
  33. MyButton(
  34. '退出登录',
  35. onTap: onLogout,
  36. gradient: const LinearGradient(colors: [Color(0xFF3BD2E5), Color(0xFF247AF8)]),
  37. margin: const EdgeInsets.symmetric(horizontal: 24),
  38. ),
  39. ],
  40. );
  41. }
  42. Widget buildList() {
  43. return Container(
  44. margin: const EdgeInsets.symmetric(horizontal: 14),
  45. clipBehavior: Clip.hardEdge,
  46. decoration: const BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(10))),
  47. child: Column(
  48. children: [
  49. CardItemWidget(
  50. '头像',
  51. rightChild: buildAvatar(),
  52. bottomLine: true,
  53. ),
  54. const CardItemWidget(
  55. '单位名称',
  56. rightText: '****',
  57. bottomLine: true,
  58. ),
  59. const CardItemWidget(
  60. '姓名',
  61. rightText: '****',
  62. bottomLine: true,
  63. ),
  64. const CardItemWidget(
  65. '账号',
  66. rightText: '手机号',
  67. bottomLine: true,
  68. ),
  69. const CardItemWidget(
  70. '检验监测能力',
  71. rightText: '****',
  72. bottomLine: true,
  73. ),
  74. CardItemWidget(
  75. '修改密码',
  76. trailing: Image.asset(imgItemArrowRight, height: 16),
  77. onTap: startChangePwd,
  78. ),
  79. ],
  80. ),
  81. );
  82. }
  83. Widget buildAvatar() {
  84. return Container(
  85. width: 48,
  86. height: 48,
  87. clipBehavior: Clip.antiAlias,
  88. decoration: const BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(200))),
  89. child: CachedNetworkImage(
  90. fit: BoxFit.cover,
  91. imageUrl: userAvatar,
  92. placeholder: (_, __) => const Center(child: CircularProgressIndicator()),
  93. errorWidget: (context, url, error) => const Center(child: Icon(Icons.error)),
  94. ),
  95. );
  96. }
  97. }