Commit 6778c289bc993e6a593e8a049aa749f06f7921c6

Authored by biao
2 parents d2add4bd 80aafd80

Merge branch 'dev_song_master'

lib/pages/user/information/user_information_page.dart
... ... @@ -17,16 +17,13 @@ class UserInformationPage extends StatelessWidget {
17 17  
18 18 @override
19 19 Widget build(BuildContext context) {
20   - return BlocBuilder<UserBloc, UserState>(
21   - builder: (context,state){
22   - return _UserInformationContentView();
23   - });
  20 + return BlocBuilder<UserBloc, UserState>(builder: (context, state) {
  21 + return _UserInformationContentView();
  22 + });
24 23 }
25 24 }
26 25  
27   -
28 26 class _UserInformationContentView extends StatelessWidget {
29   -
30 27 void _openModifyPage(BuildContext context, ModifyUserInformationType type) {
31 28 Log.d('_openModifyPage($type)');
32 29 ModifyUserInformationPage.push(context, type);
... ... @@ -41,7 +38,8 @@ class _UserInformationContentView extends StatelessWidget {
41 38 titleText: "个人信息",
42 39 ),
43 40 body: SingleChildScrollView(
44   - padding: EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h),
  41 + padding:
  42 + EdgeInsets.only(left: 17.w, right: 17.w, top: 10.h, bottom: 22.h),
45 43 child: Column(
46 44 children: [
47 45 _buildContentRow(
... ... @@ -51,11 +49,12 @@ class _UserInformationContentView extends StatelessWidget {
51 49 backgroundColor: const Color(0xFF140C10),
52 50 child: CircleAvatar(
53 51 radius: 21.r,
54   - backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl),
  52 + backgroundImage:
  53 + ImageUtil.getImageProviderOnDefault(user.avatarUrl),
55 54 ),
56 55 ),
57   - onTap: () => pushNamed(AppRouteName.userAvatar,arguments: {'pageType':'1'})
58   - ),
  56 + onTap: () => pushNamed(AppRouteName.userAvatar,
  57 + arguments: {'pageType': '1'})),
59 58 11.verticalSpace,
60 59 _buildContentRow(
61 60 '名字',
... ... @@ -67,19 +66,21 @@ class _UserInformationContentView extends StatelessWidget {
67 66 fontSize: 21.sp,
68 67 ),
69 68 ),
70   - onTap: () => _openModifyPage(context, ModifyUserInformationType.name)),
  69 + onTap: () =>
  70 + _openModifyPage(context, ModifyUserInformationType.name)),
71 71 11.verticalSpace,
72 72 _buildContentRow(
73 73 '年龄',
74 74 Text(
75   - (user.age??0).toString(),
  75 + (user.age ?? 0).toString(),
76 76 style: TextStyle(
77 77 fontWeight: FontWeight.w500,
78 78 color: const Color(0xFF333333),
79 79 fontSize: 21.sp,
80 80 ),
81 81 ),
82   - onTap: () => _openModifyPage(context, ModifyUserInformationType.age)),
  82 + onTap: () =>
  83 + _openModifyPage(context, ModifyUserInformationType.age)),
83 84 11.verticalSpace,
84 85 _buildContentRow(
85 86 '性别',
... ... @@ -91,7 +92,8 @@ class _UserInformationContentView extends StatelessWidget {
91 92 fontSize: 21.sp,
92 93 ),
93 94 ),
94   - onTap: () => _openModifyPage(context, ModifyUserInformationType.gender)),
  95 + onTap: () =>
  96 + _openModifyPage(context, ModifyUserInformationType.gender)),
95 97 11.verticalSpace,
96 98 _buildContentRow(
97 99 '账号',
... ... @@ -111,14 +113,18 @@ class _UserInformationContentView extends StatelessWidget {
111 113 );
112 114 }
113 115  
114   - Widget _buildContentRow(String filedName, Widget contentWidget, {bool isHideEndIcon = false, Function()? onTap}) {
  116 + Widget _buildContentRow(String filedName, Widget contentWidget,
  117 + {bool isHideEndIcon = false, Function()? onTap}) {
115 118 return GestureDetector(
116 119 onTap: onTap,
117 120 child: Container(
118   - padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 18.h, bottom: 18.h),
  121 + padding:
  122 + EdgeInsets.only(left: 16.w, right: 16.w, top: 18.h, bottom: 18.h),
119 123 decoration: BoxDecoration(
120 124 image: DecorationImage(
121   - image: ImageUtil.getImageProviderOnDefault(AssetsConst.bgUserInformationText), fit: BoxFit.fill)),
  125 + image: ImageUtil.getImageProviderOnDefault(
  126 + AssetsConst.bgUserInformationText),
  127 + fit: BoxFit.fill)),
122 128 child: Row(children: [
123 129 Text(
124 130 filedName,
... ... @@ -131,9 +137,9 @@ class _UserInformationContentView extends StatelessWidget {
131 137 32.horizontalSpace,
132 138 Expanded(
133 139 child: Container(
134   - alignment: Alignment.centerLeft,
135   - child: contentWidget,
136   - )),
  140 + alignment: Alignment.centerLeft,
  141 + child: contentWidget,
  142 + )),
137 143 Offstage(
138 144 offstage: isHideEndIcon,
139 145 child: Image.asset(AssetsConst.icNext, width: 20.w, height: 25.h),
... ...
lib/pages/user/modify/modify_user_information_page.dart
... ... @@ -47,7 +47,7 @@ class ModifyUserInformationPage extends StatelessWidget {
47 47 create: (context) => UserInfoBloc()..add(InitControllerTextEvent(text)),
48 48 child: MultiBlocListener(
49 49 listeners: [
50   - BlocListener<UserBloc,UserState>(listener: (context, state){
  50 + BlocListener<UserBloc, UserState>(listener: (context, state) {
51 51 if (state is UserInfoUpdated) {
52 52 showToast('修改成功');
53 53 popPage();
... ... @@ -64,9 +64,11 @@ class ModifyUserInformationPage extends StatelessWidget {
64 64 onBack: () {
65 65 final bloc = BlocProvider.of<UserInfoBloc>(context);
66 66 if (bloc.isChangeInfo) {
67   - showTwoActionDialog('提示', '确定离开', '继续修改', '您的信息尚未保存',leftTap: (){
  67 + showTwoActionDialog('提示', '确定离开', '继续修改', '您的信息尚未保存',
  68 + leftTap: () {
68 69 popPage();
69   - },rightTap: (){
  70 + popPage();
  71 + }, rightTap: () {
70 72 popPage();
71 73 });
72 74 } else {
... ... @@ -76,75 +78,83 @@ class ModifyUserInformationPage extends StatelessWidget {
76 78 ),
77 79 body: SingleChildScrollView(
78 80 child: Column(
79   - children: [
80   - Padding(
81   - padding: EdgeInsets.only(left: 65.w, right: 55.w, top: 38.h),
82   - child: Row(
83   - children: [
84   - Text(
85   - type.title,
86   - style: TextStyle(
87   - fontWeight: FontWeight.w700,
88   - color: const Color(0xFF333333),
89   - fontSize: 21.sp,
90   - ),
91   - ),
92   - 20.horizontalSpace,
93   - // 输入框 or 选择框
94   - _buildTextFieldWidget(context),
95   - // 占位
96   - Expanded(
97   - child: Container(),
98   - ),
99   - // 按钮
100   - GestureDetector(
101   - onTap: () {
102   - var text = '';
103   - if (type == ModifyUserInformationType.name || type == ModifyUserInformationType.age){
104   - if(bloc.modifyTextController.text.isEmpty) {
105   - showToast('内容不能为空');
106   - return;
107   - }
108   - text = bloc.modifyTextController.text;
109   - }
110   -
111   - if (type == ModifyUserInformationType.gender) {
112   - text = bloc.gender.toString();
113   - }
114   - // 更新type类型的字段
115   - context.read<UserBloc>().add(UserUpdate(type,text));
116   - },
117   - child: Container(
118   - alignment: Alignment.center,
119   - width: 90.w,
120   - height: 44.h,
121   - decoration: const BoxDecoration(
122   - image: DecorationImage(image: AssetImage(AssetsConst.bgButtonBlue), fit: BoxFit.fill),
123   - ),
124   - child: Text(
125   - '确定',
126   - style: TextStyle(fontSize: 17.sp, color: Colors.white),
127   - ),
128   - ),
129   - )
130   - ],
131   - )),
132   - Stack(
133   - alignment: Alignment.topRight,
  81 + children: [
  82 + Padding(
  83 + padding:
  84 + EdgeInsets.only(left: 65.w, right: 55.w, top: 38.h),
  85 + child: Row(
134 86 children: [
135   - Image.asset(
136   - AssetsConst.bgEditUserInformation,
137   - width: double.infinity,
  87 + Text(
  88 + type.title,
  89 + style: TextStyle(
  90 + fontWeight: FontWeight.w700,
  91 + color: const Color(0xFF333333),
  92 + fontSize: 21.sp,
  93 + ),
138 94 ),
139   - Positioned(
140   - right: 125.w,
141   - top: 10.h,
142   - child: Image.asset(AssetsConst.bgIcSteveWrite, width: 161.w, height: 249.w),
  95 + 20.horizontalSpace,
  96 + // 输入框 or 选择框
  97 + _buildTextFieldWidget(context),
  98 + // 占位
  99 + Expanded(
  100 + child: Container(),
143 101 ),
  102 + // 按钮
  103 + GestureDetector(
  104 + onTap: () {
  105 + var text = '';
  106 + if (type == ModifyUserInformationType.name ||
  107 + type == ModifyUserInformationType.age) {
  108 + if (bloc.modifyTextController.text.isEmpty) {
  109 + showToast('内容不能为空');
  110 + return;
  111 + }
  112 + text = bloc.modifyTextController.text;
  113 + }
  114 +
  115 + if (type == ModifyUserInformationType.gender) {
  116 + text = bloc.gender.toString();
  117 + }
  118 + // 更新type类型的字段
  119 + context
  120 + .read<UserBloc>()
  121 + .add(UserUpdate(type, text));
  122 + },
  123 + child: Container(
  124 + alignment: Alignment.center,
  125 + width: 90.w,
  126 + height: 44.h,
  127 + decoration: const BoxDecoration(
  128 + image: DecorationImage(
  129 + image: AssetImage(AssetsConst.bgButtonBlue),
  130 + fit: BoxFit.fill),
  131 + ),
  132 + child: Text(
  133 + '确定',
  134 + style: TextStyle(
  135 + fontSize: 17.sp, color: Colors.white),
  136 + ),
  137 + ),
  138 + )
144 139 ],
  140 + )),
  141 + Stack(
  142 + alignment: Alignment.topRight,
  143 + children: [
  144 + Image.asset(
  145 + AssetsConst.bgEditUserInformation,
  146 + width: double.infinity,
  147 + ),
  148 + Positioned(
  149 + right: 125.w,
  150 + top: 10.h,
  151 + child: Image.asset(AssetsConst.bgIcSteveWrite,
  152 + width: 161.w, height: 249.w),
145 153 ),
146 154 ],
147   - )),
  155 + ),
  156 + ],
  157 + )),
148 158 );
149 159 },
150 160 ),
... ... @@ -155,22 +165,22 @@ class ModifyUserInformationPage extends StatelessWidget {
155 165 Widget _buildTextFieldWidget(BuildContext context) {
156 166 if (type == ModifyUserInformationType.gender) {
157 167 return BlocBuilder<UserInfoBloc, UserInfoState>(
158   - builder: (context,state){
159   - final bloc = BlocProvider.of<UserInfoBloc>(context);
160   - return Row(
161   - children: <Widget>[
162   - GestureDetector(
163   - onTap: () => bloc.add(ChangeGenderEvent(0)),
164   - child: _buildSexWidget('男', bloc.gender == 0),
165   - ),
166   - 70.horizontalSpace,
167   - GestureDetector(
168   - onTap: () => bloc.add(ChangeGenderEvent(1)),
169   - child: _buildSexWidget('女', bloc.gender == 1),
170   - )
171   - ],
172   - );
173   - });
  168 + builder: (context, state) {
  169 + final bloc = BlocProvider.of<UserInfoBloc>(context);
  170 + return Row(
  171 + children: <Widget>[
  172 + GestureDetector(
  173 + onTap: () => bloc.add(ChangeGenderEvent(0)),
  174 + child: _buildSexWidget('男', bloc.gender == 0),
  175 + ),
  176 + 70.horizontalSpace,
  177 + GestureDetector(
  178 + onTap: () => bloc.add(ChangeGenderEvent(1)),
  179 + child: _buildSexWidget('女', bloc.gender == 1),
  180 + )
  181 + ],
  182 + );
  183 + });
174 184 }
175 185  
176 186 var formatters = [
... ... @@ -187,29 +197,28 @@ class ModifyUserInformationPage extends StatelessWidget {
187 197 inputType = TextInputType.number;
188 198 }
189 199  
190   - return BlocBuilder<UserInfoBloc, UserInfoState>(
191   - builder: (context,state){
192   - final bloc = BlocProvider.of<UserInfoBloc>(context);
193   - return TextFieldCustomerWidget(
194   - height: 65.h,
195   - width: 222.w,
196   - textStyle: TextStyle(
197   - fontWeight: FontWeight.w700,
198   - color: const Color(0xFF333333),
199   - fontSize: 21.sp,
200   - ),
201   - bgImageName: 'Input_layer_up',
202   - textInputType: inputType,
203   - inputFormatters: formatters,
204   - controller: bloc.modifyTextController,
205   - onChangeValue: (String value) {
206   - bloc.add(ChangeTextFieldEvent(value));
207   - },
208   - );
209   - });
  200 + return BlocBuilder<UserInfoBloc, UserInfoState>(builder: (context, state) {
  201 + final bloc = BlocProvider.of<UserInfoBloc>(context);
  202 + return TextFieldCustomerWidget(
  203 + height: 65.h,
  204 + width: 222.w,
  205 + textStyle: TextStyle(
  206 + fontWeight: FontWeight.w700,
  207 + color: const Color(0xFF333333),
  208 + fontSize: 21.sp,
  209 + ),
  210 + bgImageName: 'Input_layer_up',
  211 + textInputType: inputType,
  212 + inputFormatters: formatters,
  213 + controller: bloc.modifyTextController,
  214 + onChangeValue: (String value) {
  215 + bloc.add(ChangeTextFieldEvent(value));
  216 + },
  217 + );
  218 + });
210 219 }
211 220  
212   - Widget _buildSexWidget(String title,bool isSelect) {
  221 + Widget _buildSexWidget(String title, bool isSelect) {
213 222 return Row(
214 223 children: [
215 224 Container(
... ... @@ -218,13 +227,9 @@ class ModifyUserInformationPage extends StatelessWidget {
218 227 padding: EdgeInsets.all(4.h),
219 228 decoration: BoxDecoration(
220 229 borderRadius: BorderRadius.circular(21.r),
221   - border: Border.all(
222   - color: const Color(0xFF140C10),
223   - width: 1.5
224   - )
225   - ),
  230 + border: Border.all(color: const Color(0xFF140C10), width: 1.5)),
226 231 child: Offstage(
227   - offstage:!isSelect,
  232 + offstage: !isSelect,
228 233 child: ClipRRect(
229 234 borderRadius: BorderRadius.circular(13.r),
230 235 child: Container(
... ...
lib/pages/user/modify/user_info_bloc/user_info_bloc.dart
... ... @@ -8,7 +8,7 @@ part &#39;user_info_state.dart&#39;;
8 8 class UserInfoBloc extends Bloc<UserInfoEvent, UserInfoState> {
9 9 final TextEditingController modifyTextController = TextEditingController();
10 10  
11   - int _gender = UserUtil.getUser()!.gender??0;
  11 + int _gender = UserUtil.getUser()!.gender ?? 0;
12 12  
13 13 int get gender => _gender;
14 14  
... ... @@ -22,18 +22,25 @@ class UserInfoBloc extends Bloc&lt;UserInfoEvent, UserInfoState&gt; {
22 22 on<InitControllerTextEvent>(_initControllerText);
23 23 }
24 24  
25   - void _initControllerText(InitControllerTextEvent event,Emitter<UserInfoState> emitter) async {
26   - modifyTextController.text = event.text;
  25 + void _initControllerText(
  26 + InitControllerTextEvent event, Emitter<UserInfoState> emitter) async {
  27 + if (event.text == 'null') {
  28 + modifyTextController.text = '0';
  29 + } else {
  30 + modifyTextController.text = event.text;
  31 + }
27 32 _primitiveText = event.text;
28 33 }
29 34  
30   - void _changeGender(ChangeGenderEvent event,Emitter<UserInfoState> emitter) async {
  35 + void _changeGender(
  36 + ChangeGenderEvent event, Emitter<UserInfoState> emitter) async {
31 37 _gender = event.gender;
32   - isChangeInfo = _gender != (UserUtil.getUser()!.gender??0);
  38 + isChangeInfo = _gender != (UserUtil.getUser()!.gender ?? 0);
33 39 emitter(ChangeGenderState());
34 40 }
35 41  
36   - void _changeTextField(ChangeTextFieldEvent event,Emitter<UserInfoState> emitter) async {
  42 + void _changeTextField(
  43 + ChangeTextFieldEvent event, Emitter<UserInfoState> emitter) async {
37 44 isChangeInfo = _primitiveText != event.text;
38 45 }
39 46 }
... ...