123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:lszlgl/base/base_lifecycle_state.dart';
- import 'package:lszlgl/model/rsp/user_rsp.dart';
- import 'package:lszlgl/service/user_service.dart';
- import 'package:lszlgl/utils/sp_utils.dart';
- import 'package:lszlgl/widget/button.dart';
- import 'package:lszlgl/widget/card_item.dart';
- /// 账号管理
- class AccountManagePage extends StatefulWidget {
- const AccountManagePage({Key? key}) : super(key: key);
- @override
- State<AccountManagePage> createState() => _AccountManagePageState();
- }
- class _AccountManagePageState extends BaseLifecycleState<AccountManagePage> {
- UserRsp? user;
- void startChangePwd() {
- MyRouter.startChangePwd();
- }
- void onLogout() {
- SPUtils.getInstance().remove('accountpwd');
- UserService.get().logout();
- }
- @override
- void onInit() {
- user = UserService.get().getUser();
- }
- @override
- Widget build(BuildContext context) {
- return myScaffold(child: buildBody());
- }
- Widget buildBody() {
- return Column(
- children: [
- myAppBar(title: '账号管理'),
- buildList(),
- const SizedBox(height: 32),
- MyButton(
- '退出登录',
- onTap: onLogout,
- gradient: const LinearGradient(colors: [Color(0xFF3BD2E5), Color(0xFF247AF8)]),
- margin: const EdgeInsets.symmetric(horizontal: 24),
- ),
- ],
- );
- }
- Widget buildList() {
- return Container(
- margin: const EdgeInsets.symmetric(horizontal: 14),
- clipBehavior: Clip.hardEdge,
- decoration: const BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(10))),
- child: Column(
- children: [
- CardItemWidget(
- '头像',
- rightChild: buildAvatar(),
- bottomLine: true,
- ),
- CardItemWidget(
- '单位名称',
- rightText: user?.dept?.name ?? '',
- bottomLine: true,
- ),
- CardItemWidget(
- '姓名',
- rightText: user?.nickname ?? '',
- bottomLine: true,
- ),
- CardItemWidget(
- '账号',
- rightText: user?.username ?? '',
- bottomLine: true,
- ),
- CardItemWidget(
- '修改密码',
- trailing: Image.asset(imgItemArrowRight, height: 16),
- onTap: startChangePwd,
- ),
- ],
- ),
- );
- }
- Widget buildAvatar() {
- return Container(
- width: 48,
- height: 48,
- clipBehavior: Clip.antiAlias,
- decoration: const BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(200))),
- child: CachedNetworkImage(
- fit: BoxFit.cover,
- imageUrl: user?.avatar ?? '',
- placeholder: (_, __) => const Center(child: CircularProgressIndicator()),
- errorWidget: (context, url, error) => const Center(child: Icon(Icons.error, color: Colors.grey)),
- ),
- );
- }
- }
|