Commit e5c9e98fe7e9b58db796760342d672c0aea83416
1 parent
1e7094e3
feat:首页模块颜色
Showing
13 changed files
with
87 additions
and
71 deletions
lib/generated/json/course_entity.g.dart
| ... | ... | @@ -23,6 +23,10 @@ CourseEntity $CourseEntityFromJson(Map<String, dynamic> json) { |
| 23 | 23 | if (totalCourseLesson != null) { |
| 24 | 24 | courseEntity.totalCourseLesson = totalCourseLesson; |
| 25 | 25 | } |
| 26 | + final String? courseModuleThemeColor = jsonConvert.convert<String>(json['courseModuleThemeColor']); | |
| 27 | + if (courseModuleThemeColor != null) { | |
| 28 | + courseEntity.courseModuleThemeColor = courseModuleThemeColor; | |
| 29 | + } | |
| 26 | 30 | return courseEntity; |
| 27 | 31 | } |
| 28 | 32 | |
| ... | ... | @@ -33,6 +37,7 @@ Map<String, dynamic> $CourseEntityToJson(CourseEntity entity) { |
| 33 | 37 | data['nowCourseModuleId'] = entity.nowCourseModuleId; |
| 34 | 38 | data['nowCourseModuleName'] = entity.nowCourseModuleName; |
| 35 | 39 | data['totalCourseLesson'] = entity.totalCourseLesson; |
| 40 | + data['courseModuleThemeColor'] = entity.courseModuleThemeColor; | |
| 36 | 41 | return data; |
| 37 | 42 | } |
| 38 | 43 | |
| ... | ... | @@ -86,10 +91,6 @@ CourseCourseLessons $CourseCourseLessonsFromJson(Map<String, dynamic> json) { |
| 86 | 91 | if (status != null) { |
| 87 | 92 | courseCourseLessons.status = status; |
| 88 | 93 | } |
| 89 | - final String? courseModuleThemeColor = jsonConvert.convert<String>(json['courseModuleThemeColor']); | |
| 90 | - if (courseModuleThemeColor != null) { | |
| 91 | - courseCourseLessons.courseModuleThemeColor = courseModuleThemeColor; | |
| 92 | - } | |
| 93 | 94 | return courseCourseLessons; |
| 94 | 95 | } |
| 95 | 96 | |
| ... | ... | @@ -107,6 +108,5 @@ Map<String, dynamic> $CourseCourseLessonsToJson(CourseCourseLessons entity) { |
| 107 | 108 | data['name'] = entity.name; |
| 108 | 109 | data['sortOrder'] = entity.sortOrder; |
| 109 | 110 | data['status'] = entity.status; |
| 110 | - data['courseModuleThemeColor'] = entity.courseModuleThemeColor; | |
| 111 | 111 | return data; |
| 112 | 112 | } |
| 113 | 113 | \ No newline at end of file | ... | ... |
lib/generated/json/course_module_entity.g.dart
| ... | ... | @@ -59,6 +59,11 @@ CourseModuleEntity $CourseModuleEntityFromJson(Map<String, dynamic> json) { |
| 59 | 59 | if (status != null) { |
| 60 | 60 | courseModuleEntity.status = status; |
| 61 | 61 | } |
| 62 | + | |
| 63 | + final String? courseModuleThemeColor = jsonConvert.convert<String>(json['courseModuleThemeColor']); | |
| 64 | + if (courseModuleThemeColor != null) { | |
| 65 | + courseModuleEntity.courseModuleThemeColor = courseModuleThemeColor; | |
| 66 | + } | |
| 62 | 67 | return courseModuleEntity; |
| 63 | 68 | } |
| 64 | 69 | |
| ... | ... | @@ -78,5 +83,6 @@ Map<String, dynamic> $CourseModuleEntityToJson(CourseModuleEntity entity) { |
| 78 | 83 | data['picUrl'] = entity.picUrl; |
| 79 | 84 | data['sortOrder'] = entity.sortOrder; |
| 80 | 85 | data['status'] = entity.status; |
| 86 | + data['courseModuleThemeColor'] = entity.courseModuleThemeColor; | |
| 81 | 87 | return data; |
| 82 | 88 | } |
| 83 | 89 | \ No newline at end of file | ... | ... |
lib/models/course_entity.dart
| ... | ... | @@ -9,6 +9,7 @@ class CourseEntity { |
| 9 | 9 | int? nowCourseModuleId; |
| 10 | 10 | String? nowCourseModuleName; |
| 11 | 11 | int? totalCourseLesson; |
| 12 | + String? courseModuleThemeColor; | |
| 12 | 13 | |
| 13 | 14 | CourseEntity(); |
| 14 | 15 | |
| ... | ... | @@ -36,7 +37,6 @@ class CourseCourseLessons { |
| 36 | 37 | String? name; |
| 37 | 38 | int? sortOrder; |
| 38 | 39 | int? status; |
| 39 | - String? courseModuleThemeColor; | |
| 40 | 40 | |
| 41 | 41 | CourseCourseLessons(); |
| 42 | 42 | ... | ... |
lib/models/course_module_entity.dart
lib/pages/home/home_page.dart
| ... | ... | @@ -8,6 +8,7 @@ import 'package:wow_english/pages/home/widgets/home_bouns_item.dart'; |
| 8 | 8 | import 'package:wow_english/pages/home/widgets/home_tab_header_widget.dart'; |
| 9 | 9 | import 'package:wow_english/pages/home/widgets/home_vidoe_item.dart'; |
| 10 | 10 | import 'package:wow_english/route/route.dart'; |
| 11 | +import 'package:wow_english/utils/color_util.dart'; | |
| 11 | 12 | import 'package:wow_english/utils/toast_util.dart'; |
| 12 | 13 | |
| 13 | 14 | import 'bloc/home_bloc.dart'; |
| ... | ... | @@ -88,13 +89,14 @@ class _HomePageView extends StatelessWidget { |
| 88 | 89 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 89 | 90 | children: [ |
| 90 | 91 | HomeTabHeaderWidget( |
| 92 | + themColor: bloc.modelData?.courseModuleThemeColor, | |
| 91 | 93 | actionTap: (HeaderActionType type) { |
| 92 | 94 | _headerActionEvent(type); |
| 93 | 95 | }, |
| 94 | 96 | ), |
| 95 | 97 | Expanded( |
| 96 | 98 | child: ListView.builder( |
| 97 | - itemCount: bloc.modelData?.totalCourseLesson, | |
| 99 | + itemCount: bloc.modelData?.totalCourseLesson??0, | |
| 98 | 100 | scrollDirection: Axis.horizontal, |
| 99 | 101 | itemBuilder: (BuildContext context, int index) { |
| 100 | 102 | CourseCourseLessons? data = bloc.modelData?.courseLessons?[index]; |
| ... | ... | @@ -133,6 +135,7 @@ class _HomePageView extends StatelessWidget { |
| 133 | 135 | bloc.add(RequestVideoLessonEvent(data.id!,data.courseType!)); |
| 134 | 136 | }, |
| 135 | 137 | child: HomeVideoItem( |
| 138 | + themColor: bloc.modelData?.courseModuleThemeColor, | |
| 136 | 139 | lessons: data, |
| 137 | 140 | ), |
| 138 | 141 | ); |
| ... | ... | @@ -150,12 +153,12 @@ class _HomePageView extends StatelessWidget { |
| 150 | 153 | ), |
| 151 | 154 | Container( |
| 152 | 155 | decoration: BoxDecoration( |
| 153 | - color: Colors.blue, | |
| 156 | + color: HexColor(bloc.modelData?.courseModuleThemeColor??''), | |
| 154 | 157 | borderRadius: BorderRadius.circular(14.5.r), |
| 155 | 158 | ), |
| 156 | 159 | padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 24.w), |
| 157 | 160 | child: Text( |
| 158 | - '${(bloc.modelData?.nowCourseLesson)}/${bloc.modelData?.totalCourseLesson}', | |
| 161 | + '${(bloc.modelData?.nowCourseLesson??0)}/${bloc.modelData?.totalCourseLesson??0}', | |
| 159 | 162 | style: TextStyle(color: Colors.white, fontSize: 12.sp), |
| 160 | 163 | ), |
| 161 | 164 | ), | ... | ... |
lib/pages/home/widgets/home_tab_header_widget.dart
| ... | ... | @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; |
| 2 | 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | 3 | import 'package:wow_english/common/core/user_util.dart'; |
| 4 | 4 | import 'package:wow_english/common/extension/string_extension.dart'; |
| 5 | +import 'package:wow_english/utils/color_util.dart'; | |
| 5 | 6 | import 'package:wow_english/utils/image_util.dart'; |
| 6 | 7 | |
| 7 | 8 | enum HeaderActionType { |
| ... | ... | @@ -18,8 +19,9 @@ enum HeaderActionType { |
| 18 | 19 | } |
| 19 | 20 | |
| 20 | 21 | class HomeTabHeaderWidget extends StatelessWidget { |
| 21 | - const HomeTabHeaderWidget({super.key, this.actionTap}); | |
| 22 | + const HomeTabHeaderWidget({super.key, this.actionTap, this.themColor}); | |
| 22 | 23 | |
| 24 | + final String? themColor; | |
| 23 | 25 | final Function(HeaderActionType type)? actionTap; |
| 24 | 26 | |
| 25 | 27 | @override |
| ... | ... | @@ -27,7 +29,7 @@ class HomeTabHeaderWidget extends StatelessWidget { |
| 27 | 29 | return Container( |
| 28 | 30 | height: 45, |
| 29 | 31 | width: double.infinity, |
| 30 | - color: Colors.purple, | |
| 32 | + color: HexColor(themColor??''), | |
| 31 | 33 | padding: EdgeInsets.symmetric(horizontal: 9.5.w), |
| 32 | 34 | child: Row( |
| 33 | 35 | children: [ | ... | ... |
lib/pages/home/widgets/home_vidoe_item.dart
| ... | ... | @@ -3,10 +3,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | 3 | import 'package:wow_english/common/extension/string_extension.dart'; |
| 4 | 4 | import 'package:wow_english/common/widgets/ow_image_widget.dart'; |
| 5 | 5 | import 'package:wow_english/models/course_entity.dart'; |
| 6 | +import 'package:wow_english/utils/color_util.dart'; | |
| 6 | 7 | |
| 7 | 8 | class HomeVideoItem extends StatelessWidget { |
| 8 | - const HomeVideoItem({super.key, this.lessons}); | |
| 9 | + const HomeVideoItem({super.key, this.lessons, this.themColor}); | |
| 9 | 10 | |
| 11 | + final String? themColor; | |
| 10 | 12 | final CourseCourseLessons? lessons; |
| 11 | 13 | |
| 12 | 14 | @override |
| ... | ... | @@ -46,6 +48,7 @@ class HomeVideoItem extends StatelessWidget { |
| 46 | 48 | width: 2, |
| 47 | 49 | color: const Color(0xFF140C10), |
| 48 | 50 | ), |
| 51 | + color: HexColor(themColor??''), | |
| 49 | 52 | borderRadius: BorderRadius.circular(6) |
| 50 | 53 | ), |
| 51 | 54 | padding: EdgeInsets.symmetric(horizontal: 10.w), | ... | ... |
lib/pages/lessons/lesson_page.dart
lib/pages/lessons/widgets/lesson_item_widget.dart
| ... | ... | @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | 3 | import 'package:wow_english/common/extension/string_extension.dart'; |
| 4 | 4 | import 'package:wow_english/common/widgets/ow_image_widget.dart'; |
| 5 | 5 | import 'package:wow_english/models/course_module_entity.dart'; |
| 6 | +import 'package:wow_english/utils/color_util.dart'; | |
| 6 | 7 | |
| 7 | 8 | class LessonItemWidget extends StatelessWidget { |
| 8 | 9 | const LessonItemWidget({super.key, required this.isSelected, this.model, this.onClickEvent}); |
| ... | ... | @@ -59,7 +60,7 @@ class LessonItemWidget extends StatelessWidget { |
| 59 | 60 | 10.verticalSpace, |
| 60 | 61 | Container( |
| 61 | 62 | decoration: BoxDecoration( |
| 62 | - color: Colors.red, | |
| 63 | + color: HexColor(model?.courseModuleThemeColor??'#FFC0C3E7'), | |
| 63 | 64 | borderRadius: BorderRadius.circular(6.r), |
| 64 | 65 | border: Border.all( |
| 65 | 66 | color: const Color(0xFF333333), | ... | ... |
lib/pages/user/information/user_information_page.dart
| ... | ... | @@ -40,12 +40,11 @@ class _UserInformationView extends StatelessWidget { |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | class _UserInformationContentView extends StatelessWidget { |
| 43 | - const _UserInformationContentView({super.key}); | |
| 44 | 43 | |
| 45 | 44 | void _openModifyPage(BuildContext context, ModifyUserInformationType type) { |
| 46 | 45 | Log.d('_openModifyPage($type)'); |
| 47 | 46 | // 暂时关闭修改,修复后打开 |
| 48 | - //ModifyUserInformationPage.push(context, type); | |
| 47 | + // ModifyUserInformationPage.push(context, type); | |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | 50 | @override | ... | ... |
lib/pages/user/modify/modify_user_information_page.dart
| ... | ... | @@ -79,7 +79,7 @@ class ModifyUserInformationPage extends StatelessWidget { |
| 79 | 79 | alignment: Alignment.center, |
| 80 | 80 | width: 90.w, |
| 81 | 81 | height: 44.h, |
| 82 | - decoration: BoxDecoration( | |
| 82 | + decoration: const BoxDecoration( | |
| 83 | 83 | image: DecorationImage(image: AssetImage(AssetsConst.bgButtonBlue), fit: BoxFit.fill), |
| 84 | 84 | ), |
| 85 | 85 | child: Text( |
| ... | ... | @@ -120,54 +120,9 @@ class ModifyUserInformationPage extends StatelessWidget { |
| 120 | 120 | if (type == ModifyUserInformationType.gender) { |
| 121 | 121 | return Row( |
| 122 | 122 | children: <Widget>[ |
| 123 | - SizedBox( | |
| 124 | - width: 100.w, | |
| 125 | - child: RadioListTile( | |
| 126 | - title: Text( | |
| 127 | - '男', | |
| 128 | - style: TextStyle( | |
| 129 | - fontWeight: FontWeight.w700, | |
| 130 | - color: const Color(0xFF333333), | |
| 131 | - fontSize: 21.sp, | |
| 132 | - ), | |
| 133 | - ), | |
| 134 | - activeColor: const Color(0xFF0E89BA), | |
| 135 | - value: 0, | |
| 136 | - //selected: user.gender == 0, | |
| 137 | - groupValue: userBloc.tempGender, | |
| 138 | - onChanged: (value) { | |
| 139 | - Log.d('男value = $value'); | |
| 140 | - if (value != null) { | |
| 141 | - userBloc.tempGender = value; | |
| 142 | - } | |
| 143 | - userBloc.add(UserUIUpdate(type)); | |
| 144 | - }, | |
| 145 | - ), | |
| 146 | - ), | |
| 147 | - SizedBox( | |
| 148 | - width: 100.w, | |
| 149 | - child: RadioListTile<int>( | |
| 150 | - //selected: user.gender == 1, | |
| 151 | - title: Text( | |
| 152 | - '女', | |
| 153 | - style: TextStyle( | |
| 154 | - fontWeight: FontWeight.w700, | |
| 155 | - color: const Color(0xFF333333), | |
| 156 | - fontSize: 21.sp, | |
| 157 | - ), | |
| 158 | - ), | |
| 159 | - activeColor: const Color(0xFF0E89BA), | |
| 160 | - value: 1, | |
| 161 | - groupValue: userBloc.tempGender, | |
| 162 | - onChanged: (int? value) { | |
| 163 | - Log.d('女value = $value'); | |
| 164 | - if (value != null) { | |
| 165 | - userBloc.tempGender = value; | |
| 166 | - } | |
| 167 | - userBloc.add(UserUIUpdate(type)); | |
| 168 | - }, | |
| 169 | - ), | |
| 170 | - ), | |
| 123 | + _buildSexWidget('男', true), | |
| 124 | + 70.horizontalSpace, | |
| 125 | + _buildSexWidget('女', false) | |
| 171 | 126 | ], |
| 172 | 127 | ); |
| 173 | 128 | } |
| ... | ... | @@ -203,4 +158,34 @@ class ModifyUserInformationPage extends StatelessWidget { |
| 203 | 158 | },*/ |
| 204 | 159 | ); |
| 205 | 160 | } |
| 161 | + | |
| 162 | + Widget _buildSexWidget(String title,bool isSelect) { | |
| 163 | + return Row( | |
| 164 | + children: [ | |
| 165 | + Container( | |
| 166 | + width: 21.h, | |
| 167 | + height: 21.h, | |
| 168 | + padding: EdgeInsets.all(4.h), | |
| 169 | + decoration: BoxDecoration( | |
| 170 | + borderRadius: BorderRadius.circular(21.r), | |
| 171 | + border: Border.all( | |
| 172 | + color: const Color(0xFF140C10), | |
| 173 | + width: 1.5 | |
| 174 | + ) | |
| 175 | + ), | |
| 176 | + child: Offstage( | |
| 177 | + offstage:!isSelect, | |
| 178 | + child: ClipRRect( | |
| 179 | + borderRadius: BorderRadius.circular(13.r), | |
| 180 | + child: Container( | |
| 181 | + color: Colors.blue, | |
| 182 | + ), | |
| 183 | + ), | |
| 184 | + ), | |
| 185 | + ), | |
| 186 | + 5.horizontalSpace, | |
| 187 | + Text(title) | |
| 188 | + ], | |
| 189 | + ); | |
| 190 | + } | |
| 206 | 191 | } | ... | ... |
lib/pages/user/user_page.dart
| ... | ... | @@ -137,14 +137,14 @@ class _UserView extends StatelessWidget { |
| 137 | 137 | style: textStyle21sp, |
| 138 | 138 | ), |
| 139 | 139 | onPressed: () { |
| 140 | - Navigator.of(AppRouter.context).pushNamed(AppRouteName.userInformation); | |
| 140 | + pushNamed(AppRouteName.userInformation); | |
| 141 | 141 | }, |
| 142 | 142 | ) |
| 143 | 143 | ], |
| 144 | 144 | ), |
| 145 | 145 | 30.verticalSpace, |
| 146 | 146 | OutlinedButton( |
| 147 | - onPressed: () => Navigator.of(context).pushNamed(AppRouteName.fogPwd), | |
| 147 | + onPressed: () => pushNamed(AppRouteName.fogPwd), | |
| 148 | 148 | style: normalButtonStyle, |
| 149 | 149 | child: Text( |
| 150 | 150 | "修改密码", |
| ... | ... | @@ -153,7 +153,7 @@ class _UserView extends StatelessWidget { |
| 153 | 153 | ), |
| 154 | 154 | 12.verticalSpace, |
| 155 | 155 | OutlinedButton( |
| 156 | - onPressed: () => Navigator.of(context).pushNamed(AppRouteName.exLesson), | |
| 156 | + onPressed: () => pushNamed(AppRouteName.exLesson), | |
| 157 | 157 | style: normalButtonStyle, |
| 158 | 158 | child: Text( |
| 159 | 159 | "兑换课程", |
| ... | ... | @@ -161,9 +161,8 @@ class _UserView extends StatelessWidget { |
| 161 | 161 | )), |
| 162 | 162 | 12.verticalSpace, |
| 163 | 163 | OutlinedButton( |
| 164 | - onPressed: () => { | |
| 165 | - Navigator.of(context).pushNamed(AppRouteName.webView, | |
| 166 | - arguments: {'urlStr': AppConsts.userPrivacyPolicyUrl, 'webViewTitle': '隐私协议'}) | |
| 164 | + onPressed: () { | |
| 165 | + pushNamed(AppRouteName.webView,arguments: {'urlStr': AppConsts.userPrivacyPolicyUrl, 'webViewTitle': '隐私协议'}); | |
| 167 | 166 | }, |
| 168 | 167 | style: normalButtonStyle, |
| 169 | 168 | child: Text( | ... | ... |
lib/utils/color_util.dart
0 → 100644
| 1 | +import 'dart:ui'; | |
| 2 | + | |
| 3 | +class HexColor extends Color { | |
| 4 | + static int _getColorFromHex(String hexColor) { | |
| 5 | + if (hexColor.isEmpty) { | |
| 6 | + hexColor = '#FFC0C3E7'; | |
| 7 | + } | |
| 8 | + hexColor = hexColor.toUpperCase().replaceAll("#", ""); | |
| 9 | + hexColor = hexColor.replaceAll('0X', ''); | |
| 10 | + if (hexColor.length == 6) { | |
| 11 | + hexColor = "FF$hexColor"; | |
| 12 | + } | |
| 13 | + return int.parse(hexColor, radix: 16); | |
| 14 | + } | |
| 15 | + | |
| 16 | + HexColor(final String hexColor) : super(_getColorFromHex(hexColor)); | |
| 17 | +} | |
| 0 | 18 | \ No newline at end of file | ... | ... |