Blame view

lib/pages/user/information/user_information_page.dart 4.98 KB
da82bd70   Key   feat: user_inform...
1
2
3
4
5
6
7
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
  import 'package:flutter_screenutil/flutter_screenutil.dart';
  import 'package:wow_english/common/core/assets_const.dart';
  import 'package:wow_english/common/core/user_util.dart';
  import 'package:wow_english/common/widgets/we_app_bar.dart';
  import 'package:wow_english/models/user_entity.dart';
49e626e9   Key   feat: log_util.dart
8
  import 'package:wow_english/pages/user/bloc/user_bloc.dart';
c948a9ea   liangchengyou   feat:个人信息更改模块功能
9
  import 'package:wow_english/route/route.dart';
da82bd70   Key   feat: user_inform...
10
  import 'package:wow_english/utils/image_util.dart';
c9df43c8   Key   feat: 修改个人信息、接口
11
  import 'package:wow_english/utils/log_util.dart';
da82bd70   Key   feat: user_inform...
12
  
49e626e9   Key   feat: log_util.dart
13
  import '../modify/modify_user_information_page.dart';
da82bd70   Key   feat: user_inform...
14
15
16
17
18
19
  
  class UserInformationPage extends StatelessWidget {
    const UserInformationPage({super.key});
  
    @override
    Widget build(BuildContext context) {
80aafd80   biao   修复 新用户修改年龄页面显示nul...
20
21
22
      return BlocBuilder<UserBloc, UserState>(builder: (context, state) {
        return _UserInformationContentView();
      });
da82bd70   Key   feat: user_inform...
23
24
25
    }
  }
  
da82bd70   Key   feat: user_inform...
26
  class _UserInformationContentView extends StatelessWidget {
c9df43c8   Key   feat: 修改个人信息、接口
27
28
    void _openModifyPage(BuildContext context, ModifyUserInformationType type) {
      Log.d('_openModifyPage($type)');
c948a9ea   liangchengyou   feat:个人信息更改模块功能
29
      ModifyUserInformationPage.push(context, type);
49e626e9   Key   feat: log_util.dart
30
31
    }
  
da82bd70   Key   feat: user_inform...
32
33
34
35
36
    @override
    Widget build(BuildContext context) {
      UserEntity user = UserUtil.getUser()!;
      return Scaffold(
        backgroundColor: Colors.white,
49e626e9   Key   feat: log_util.dart
37
38
39
        appBar: const WEAppBar(
          titleText: "个人信息",
        ),
da82bd70   Key   feat: user_inform...
40
        body: SingleChildScrollView(
80aafd80   biao   修复 新用户修改年龄页面显示nul...
41
42
          padding:
              EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h),
da82bd70   Key   feat: user_inform...
43
44
          child: Column(
            children: [
49e626e9   Key   feat: log_util.dart
45
              _buildContentRow(
da82bd70   Key   feat: user_inform...
46
47
48
                  '头像',
                  CircleAvatar(
                    radius: 22.5.r,
49e626e9   Key   feat: log_util.dart
49
                    backgroundColor: const Color(0xFF140C10),
da82bd70   Key   feat: user_inform...
50
51
                    child: CircleAvatar(
                      radius: 21.r,
80aafd80   biao   修复 新用户修改年龄页面显示nul...
52
53
                      backgroundImage:
                          ImageUtil.getImageProviderOnDefault(user.avatarUrl),
da82bd70   Key   feat: user_inform...
54
                    ),
c948a9ea   liangchengyou   feat:个人信息更改模块功能
55
                  ),
80aafd80   biao   修复 新用户修改年龄页面显示nul...
56
57
                  onTap: () => pushNamed(AppRouteName.userAvatar,
                      arguments: {'pageType': '1'})),
da82bd70   Key   feat: user_inform...
58
              11.verticalSpace,
49e626e9   Key   feat: log_util.dart
59
              _buildContentRow(
da82bd70   Key   feat: user_inform...
60
61
62
63
64
65
66
67
                  '名字',
                  Text(
                    user.name,
                    style: TextStyle(
                      fontWeight: FontWeight.w500,
                      color: const Color(0xFF333333),
                      fontSize: 21.sp,
                    ),
49e626e9   Key   feat: log_util.dart
68
                  ),
80aafd80   biao   修复 新用户修改年龄页面显示nul...
69
70
                  onTap: () =>
                      _openModifyPage(context, ModifyUserInformationType.name)),
da82bd70   Key   feat: user_inform...
71
              11.verticalSpace,
49e626e9   Key   feat: log_util.dart
72
              _buildContentRow(
da82bd70   Key   feat: user_inform...
73
74
                  '年龄',
                  Text(
80aafd80   biao   修复 新用户修改年龄页面显示nul...
75
                    (user.age ?? 0).toString(),
da82bd70   Key   feat: user_inform...
76
77
78
79
80
                    style: TextStyle(
                      fontWeight: FontWeight.w500,
                      color: const Color(0xFF333333),
                      fontSize: 21.sp,
                    ),
23b46e8e   Key   feat: 修改个人信息性别
81
                  ),
80aafd80   biao   修复 新用户修改年龄页面显示nul...
82
83
                  onTap: () =>
                      _openModifyPage(context, ModifyUserInformationType.age)),
da82bd70   Key   feat: user_inform...
84
              11.verticalSpace,
49e626e9   Key   feat: log_util.dart
85
              _buildContentRow(
da82bd70   Key   feat: user_inform...
86
87
88
89
90
91
92
93
                  '性别',
                  Text(
                    user.getGenderString(),
                    style: TextStyle(
                      fontWeight: FontWeight.w500,
                      color: const Color(0xFF333333),
                      fontSize: 21.sp,
                    ),
23b46e8e   Key   feat: 修改个人信息性别
94
                  ),
80aafd80   biao   修复 新用户修改年龄页面显示nul...
95
96
                  onTap: () =>
                      _openModifyPage(context, ModifyUserInformationType.gender)),
da82bd70   Key   feat: user_inform...
97
              11.verticalSpace,
49e626e9   Key   feat: log_util.dart
98
              _buildContentRow(
da82bd70   Key   feat: user_inform...
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
                '账号',
                Text(
                  user.phoneNum,
                  style: TextStyle(
                    fontWeight: FontWeight.w500,
                    color: const Color(0xFF999999),
                    fontSize: 21.sp,
                  ),
                ),
                isHideEndIcon: true,
              ),
            ],
          ),
        ),
      );
    }
  
80aafd80   biao   修复 新用户修改年龄页面显示nul...
116
117
    Widget _buildContentRow(String filedName, Widget contentWidget,
        {bool isHideEndIcon = false, Function()? onTap}) {
da82bd70   Key   feat: user_inform...
118
119
120
      return GestureDetector(
          onTap: onTap,
          child: Container(
80aafd80   biao   修复 新用户修改年龄页面显示nul...
121
122
            padding:
                EdgeInsets.only(left: 16.w, right: 16.w, top: 18.h, bottom: 18.h),
da82bd70   Key   feat: user_inform...
123
124
            decoration: BoxDecoration(
                image: DecorationImage(
80aafd80   biao   修复 新用户修改年龄页面显示nul...
125
126
127
                    image: ImageUtil.getImageProviderOnDefault(
                        AssetsConst.bgUserInformationText),
                    fit: BoxFit.fill)),
da82bd70   Key   feat: user_inform...
128
129
130
131
132
133
134
135
136
137
138
139
            child: Row(children: [
              Text(
                filedName,
                style: TextStyle(
                  fontWeight: FontWeight.w700,
                  color: const Color(0xFF999999),
                  fontSize: 21.sp,
                ),
              ),
              32.horizontalSpace,
              Expanded(
                  child: Container(
80aafd80   biao   修复 新用户修改年龄页面显示nul...
140
141
142
                alignment: Alignment.centerLeft,
                child: contentWidget,
              )),
da82bd70   Key   feat: user_inform...
143
144
145
146
147
148
149
150
              Offstage(
                offstage: isHideEndIcon,
                child: Image.asset(AssetsConst.icNext, width: 20.w, height: 25.h),
              )
            ]),
          ));
    }
  }