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 | 23 | Widget build(BuildContext context) { |
| 24 | 24 | return BlocProvider( |
| 25 | 25 | create: (context) => HomeBloc(moduleId)..add(RequestDataEvent()), |
| 26 | - child: _HomePageView(), | |
| 26 | + child: _HomePageView(context), | |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | class _HomePageView extends StatelessWidget { |
| 32 | + | |
| 33 | + const _HomePageView(this.context); | |
| 34 | + | |
| 35 | + final BuildContext context; | |
| 36 | + | |
| 32 | 37 | void _headerActionEvent(HeaderActionType type) { |
| 33 | 38 | if (type == HeaderActionType.video) { |
| 34 | 39 | pushNamed(AppRouteName.reAfter); |
| 35 | 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 | 42 | } else if (type == HeaderActionType.listen) { |
| 42 | 43 | pushNamed(AppRouteName.listen); |
| 43 | 44 | } else if (type == HeaderActionType.shop) { |
| 44 | 45 | pushNamed(AppRouteName.shop); |
| 45 | 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 | 19 | //购买 |
| 20 | 20 | shop, |
| 21 | 21 | //个人信息 |
| 22 | - user | |
| 22 | + user, | |
| 23 | + //返回到(模块选择)首页 | |
| 24 | + home, | |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | 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 | 30 | final CourseEntity? entity; |
| 29 | 31 | final Function(HeaderActionType type)? actionTap; |
| 30 | 32 | |
| 31 | 33 | @override |
| 32 | 34 | Widget build(BuildContext context) { |
| 33 | - return BlocBuilder<UserBloc,UserState>( | |
| 34 | - builder: (context,state) { | |
| 35 | + return BlocBuilder<UserBloc, UserState>( | |
| 36 | + builder: (context, state) { | |
| 35 | 37 | return Container( |
| 36 | 38 | height: 45, |
| 37 | 39 | width: double.infinity, |
| 38 | - color: CourseModuleModel(entity?.courseModuleCode??'Phase-1').color, | |
| 40 | + color: | |
| 41 | + CourseModuleModel(entity?.courseModuleCode ?? 'Phase-1').color, | |
| 39 | 42 | padding: EdgeInsets.symmetric(horizontal: 9.5.w), |
| 40 | 43 | child: Row( |
| 41 | 44 | children: [ |
| 42 | 45 | ScreenUtil().bottomBarHeight.horizontalSpace, |
| 43 | 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 | 47 | onTap: () { |
| 61 | 48 | if (actionTap != null) { |
| 62 | - actionTap!(HeaderActionType.user); | |
| 49 | + actionTap!(HeaderActionType.home); | |
| 63 | 50 | } |
| 64 | 51 | }, |
| 65 | 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 | 97 | 20.horizontalSpace, |
| 80 | 98 | Expanded( |
| 81 | 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 | 105 | // IconButton( |
| 87 | 106 | // onPressed: () { |
| 88 | 107 | // if (actionTap != null) { |
| ... | ... | @@ -105,17 +124,15 @@ class HomeTabHeaderWidget extends StatelessWidget { |
| 105 | 124 | }, |
| 106 | 125 | icon: Image.asset('listen'.assetPng)), |
| 107 | 126 | IconButton( |
| 108 | - onPressed: (){ | |
| 109 | - if(actionTap != null) { | |
| 127 | + onPressed: () { | |
| 128 | + if (actionTap != null) { | |
| 110 | 129 | actionTap!(HeaderActionType.shop); |
| 111 | 130 | } |
| 112 | 131 | }, |
| 113 | - icon: Image.asset('shop'.assetPng) | |
| 114 | - ), | |
| 132 | + icon: Image.asset('shop'.assetPng)), | |
| 115 | 133 | ScreenUtil().bottomBarHeight.horizontalSpace, |
| 116 | 134 | ], |
| 117 | - ) | |
| 118 | - ); | |
| 135 | + )); | |
| 119 | 136 | }, |
| 120 | 137 | ); |
| 121 | 138 | } | ... | ... |