Blame view

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