Commit 454dc3872ac2007144e1edd87c23274526ef17b8
1 parent
278208b8
feat:原阶段选择页(首页)增加返回按钮
Showing
2 changed files
with
69 additions
and
55 deletions
lib/pages/home/home_page.dart
| @@ -23,33 +23,30 @@ class HomePage extends StatelessWidget { | @@ -23,33 +23,30 @@ class HomePage extends StatelessWidget { | ||
| 23 | Widget build(BuildContext context) { | 23 | Widget build(BuildContext context) { |
| 24 | return BlocProvider( | 24 | return BlocProvider( |
| 25 | create: (context) => HomeBloc(moduleId)..add(RequestDataEvent()), | 25 | create: (context) => HomeBloc(moduleId)..add(RequestDataEvent()), |
| 26 | - child: _HomePageView(), | 26 | + child: _HomePageView(context), |
| 27 | ); | 27 | ); |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | class _HomePageView extends StatelessWidget { | 31 | class _HomePageView extends StatelessWidget { |
| 32 | + | ||
| 33 | + const _HomePageView(this.context); | ||
| 34 | + | ||
| 35 | + final BuildContext context; | ||
| 36 | + | ||
| 32 | void _headerActionEvent(HeaderActionType type) { | 37 | void _headerActionEvent(HeaderActionType type) { |
| 33 | if (type == HeaderActionType.video) { | 38 | if (type == HeaderActionType.video) { |
| 34 | pushNamed(AppRouteName.reAfter); | 39 | pushNamed(AppRouteName.reAfter); |
| 35 | } else if (type == HeaderActionType.phase) { | 40 | } else if (type == HeaderActionType.phase) { |
| 36 | - if (UserUtil.isLogined()) { | ||
| 37 | - pushNamed(AppRouteName.lesson); | ||
| 38 | - } else { | ||
| 39 | - pushNamed(AppRouteName.login); | ||
| 40 | - } | 41 | + pushNamed(AppRouteName.lesson); |
| 41 | } else if (type == HeaderActionType.listen) { | 42 | } else if (type == HeaderActionType.listen) { |
| 42 | pushNamed(AppRouteName.listen); | 43 | pushNamed(AppRouteName.listen); |
| 43 | } else if (type == HeaderActionType.shop) { | 44 | } else if (type == HeaderActionType.shop) { |
| 44 | pushNamed(AppRouteName.shop); | 45 | pushNamed(AppRouteName.shop); |
| 45 | } else if (type == HeaderActionType.user) { | 46 | } else if (type == HeaderActionType.user) { |
| 46 | - if (UserUtil.isLogined()) { | ||
| 47 | - pushNamed(AppRouteName.user); | ||
| 48 | - } else { | ||
| 49 | - pushNamed(AppRouteName.login); | ||
| 50 | - } | ||
| 51 | - } else { | ||
| 52 | - | 47 | + pushNamed(AppRouteName.user); |
| 48 | + } else if (type == HeaderActionType.home) { | ||
| 49 | + Navigator.pop(context); | ||
| 53 | } | 50 | } |
| 54 | } | 51 | } |
| 55 | 52 |
lib/pages/home/widgets/home_tab_header_widget.dart
| @@ -19,70 +19,89 @@ enum HeaderActionType { | @@ -19,70 +19,89 @@ enum HeaderActionType { | ||
| 19 | //购买 | 19 | //购买 |
| 20 | shop, | 20 | shop, |
| 21 | //个人信息 | 21 | //个人信息 |
| 22 | - user | 22 | + user, |
| 23 | + //返回到(模块选择)首页 | ||
| 24 | + home, | ||
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | class HomeTabHeaderWidget extends StatelessWidget { | 27 | class HomeTabHeaderWidget extends StatelessWidget { |
| 26 | - const HomeTabHeaderWidget({super.key,this.entity, this.actionTap}); | 28 | + const HomeTabHeaderWidget({super.key, this.entity, this.actionTap}); |
| 27 | 29 | ||
| 28 | final CourseEntity? entity; | 30 | final CourseEntity? entity; |
| 29 | final Function(HeaderActionType type)? actionTap; | 31 | final Function(HeaderActionType type)? actionTap; |
| 30 | 32 | ||
| 31 | @override | 33 | @override |
| 32 | Widget build(BuildContext context) { | 34 | Widget build(BuildContext context) { |
| 33 | - return BlocBuilder<UserBloc,UserState>( | ||
| 34 | - builder: (context,state) { | 35 | + return BlocBuilder<UserBloc, UserState>( |
| 36 | + builder: (context, state) { | ||
| 35 | return Container( | 37 | return Container( |
| 36 | height: 45, | 38 | height: 45, |
| 37 | width: double.infinity, | 39 | width: double.infinity, |
| 38 | - color: CourseModuleModel(entity?.courseModuleCode??'Phase-1').color, | 40 | + color: |
| 41 | + CourseModuleModel(entity?.courseModuleCode ?? 'Phase-1').color, | ||
| 39 | padding: EdgeInsets.symmetric(horizontal: 9.5.w), | 42 | padding: EdgeInsets.symmetric(horizontal: 9.5.w), |
| 40 | child: Row( | 43 | child: Row( |
| 41 | children: [ | 44 | children: [ |
| 42 | ScreenUtil().bottomBarHeight.horizontalSpace, | 45 | ScreenUtil().bottomBarHeight.horizontalSpace, |
| 43 | GestureDetector( | 46 | GestureDetector( |
| 44 | - onTap: () => actionTap?.call(HeaderActionType.user), | ||
| 45 | - child: Container( | ||
| 46 | - decoration: BoxDecoration( | ||
| 47 | - border: Border.all( | ||
| 48 | - width: 1.0, | ||
| 49 | - color: const Color(0xFF140C10), | ||
| 50 | - ), | ||
| 51 | - borderRadius: BorderRadius.circular(21), | ||
| 52 | - ), | ||
| 53 | - child: CircleAvatar( | ||
| 54 | - radius: 21, | ||
| 55 | - backgroundImage: ImageUtil.getImageProviderOnDefault(UserUtil.getUser()?.avatarUrl), | ||
| 56 | - ), | ||
| 57 | - ), | ||
| 58 | - ), | ||
| 59 | - GestureDetector( | ||
| 60 | onTap: () { | 47 | onTap: () { |
| 61 | if (actionTap != null) { | 48 | if (actionTap != null) { |
| 62 | - actionTap!(HeaderActionType.user); | 49 | + actionTap!(HeaderActionType.home); |
| 63 | } | 50 | } |
| 64 | }, | 51 | }, |
| 65 | child: Container( | 52 | child: Container( |
| 66 | - margin: const EdgeInsets.only(left: 7), | ||
| 67 | - padding: const EdgeInsets.all(4.0), | ||
| 68 | - decoration: BoxDecoration( | ||
| 69 | - color: Colors.white, | ||
| 70 | - borderRadius: BorderRadius.circular(2), | ||
| 71 | - border: Border.all(width: 1.0, color: const Color(0xFF140C10), style: BorderStyle.solid), | ||
| 72 | - ), | ||
| 73 | - child: Text( | ||
| 74 | - UserUtil.getUser()?.name ?? '未登录', | ||
| 75 | - style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp), | 53 | + alignment: Alignment.center, |
| 54 | + child: Image.asset( | ||
| 55 | + 'back_around'.assetPng, | ||
| 56 | + height: 40.h, | ||
| 57 | + width: 40.w, | ||
| 76 | ), | 58 | ), |
| 77 | ), | 59 | ), |
| 78 | ), | 60 | ), |
| 61 | + // GestureDetector( | ||
| 62 | + // onTap: () => actionTap?.call(HeaderActionType.user), | ||
| 63 | + // child: Container( | ||
| 64 | + // decoration: BoxDecoration( | ||
| 65 | + // border: Border.all( | ||
| 66 | + // width: 1.0, | ||
| 67 | + // color: const Color(0xFF140C10), | ||
| 68 | + // ), | ||
| 69 | + // borderRadius: BorderRadius.circular(21), | ||
| 70 | + // ), | ||
| 71 | + // child: CircleAvatar( | ||
| 72 | + // radius: 21, | ||
| 73 | + // backgroundImage: ImageUtil.getImageProviderOnDefault(UserUtil.getUser()?.avatarUrl), | ||
| 74 | + // ), | ||
| 75 | + // ), | ||
| 76 | + // ), | ||
| 77 | + // GestureDetector( | ||
| 78 | + // onTap: () { | ||
| 79 | + // if (actionTap != null) { | ||
| 80 | + // actionTap!(HeaderActionType.user); | ||
| 81 | + // } | ||
| 82 | + // }, | ||
| 83 | + // child: Container( | ||
| 84 | + // margin: const EdgeInsets.only(left: 7), | ||
| 85 | + // padding: const EdgeInsets.all(4.0), | ||
| 86 | + // decoration: BoxDecoration( | ||
| 87 | + // color: Colors.white, | ||
| 88 | + // borderRadius: BorderRadius.circular(2), | ||
| 89 | + // border: Border.all(width: 1.0, color: const Color(0xFF140C10), style: BorderStyle.solid), | ||
| 90 | + // ), | ||
| 91 | + // child: Text( | ||
| 92 | + // UserUtil.getUser()?.name ?? '未登录', | ||
| 93 | + // style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp), | ||
| 94 | + // ), | ||
| 95 | + // ), | ||
| 96 | + // ), | ||
| 79 | 20.horizontalSpace, | 97 | 20.horizontalSpace, |
| 80 | Expanded( | 98 | Expanded( |
| 81 | child: Text( | 99 | child: Text( |
| 82 | - CourseModuleModel(entity?.courseModuleCode??'Phase-1').courseModuleTitle, | ||
| 83 | - textAlign: TextAlign.left, | ||
| 84 | - style: const TextStyle(color: Colors.white, fontSize: 30.0), | ||
| 85 | - )), | 100 | + CourseModuleModel(entity?.courseModuleCode ?? 'Phase-1') |
| 101 | + .courseModuleTitle, | ||
| 102 | + textAlign: TextAlign.left, | ||
| 103 | + style: const TextStyle(color: Colors.white, fontSize: 30.0), | ||
| 104 | + )), | ||
| 86 | // IconButton( | 105 | // IconButton( |
| 87 | // onPressed: () { | 106 | // onPressed: () { |
| 88 | // if (actionTap != null) { | 107 | // if (actionTap != null) { |
| @@ -105,17 +124,15 @@ class HomeTabHeaderWidget extends StatelessWidget { | @@ -105,17 +124,15 @@ class HomeTabHeaderWidget extends StatelessWidget { | ||
| 105 | }, | 124 | }, |
| 106 | icon: Image.asset('listen'.assetPng)), | 125 | icon: Image.asset('listen'.assetPng)), |
| 107 | IconButton( | 126 | IconButton( |
| 108 | - onPressed: (){ | ||
| 109 | - if(actionTap != null) { | 127 | + onPressed: () { |
| 128 | + if (actionTap != null) { | ||
| 110 | actionTap!(HeaderActionType.shop); | 129 | actionTap!(HeaderActionType.shop); |
| 111 | } | 130 | } |
| 112 | }, | 131 | }, |
| 113 | - icon: Image.asset('shop'.assetPng) | ||
| 114 | - ), | 132 | + icon: Image.asset('shop'.assetPng)), |
| 115 | ScreenUtil().bottomBarHeight.horizontalSpace, | 133 | ScreenUtil().bottomBarHeight.horizontalSpace, |
| 116 | ], | 134 | ], |
| 117 | - ) | ||
| 118 | - ); | 135 | + )); |
| 119 | }, | 136 | }, |
| 120 | ); | 137 | ); |
| 121 | } | 138 | } |