diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 281229d..c65d121 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -23,33 +23,30 @@ class HomePage extends StatelessWidget { Widget build(BuildContext context) { return BlocProvider( create: (context) => HomeBloc(moduleId)..add(RequestDataEvent()), - child: _HomePageView(), + child: _HomePageView(context), ); } } class _HomePageView extends StatelessWidget { + + const _HomePageView(this.context); + + final BuildContext context; + void _headerActionEvent(HeaderActionType type) { if (type == HeaderActionType.video) { pushNamed(AppRouteName.reAfter); } else if (type == HeaderActionType.phase) { - if (UserUtil.isLogined()) { - pushNamed(AppRouteName.lesson); - } else { - pushNamed(AppRouteName.login); - } + pushNamed(AppRouteName.lesson); } else if (type == HeaderActionType.listen) { pushNamed(AppRouteName.listen); } else if (type == HeaderActionType.shop) { pushNamed(AppRouteName.shop); } else if (type == HeaderActionType.user) { - if (UserUtil.isLogined()) { - pushNamed(AppRouteName.user); - } else { - pushNamed(AppRouteName.login); - } - } else { - + pushNamed(AppRouteName.user); + } else if (type == HeaderActionType.home) { + Navigator.pop(context); } } diff --git a/lib/pages/home/widgets/home_tab_header_widget.dart b/lib/pages/home/widgets/home_tab_header_widget.dart index d77785a..475e2b8 100644 --- a/lib/pages/home/widgets/home_tab_header_widget.dart +++ b/lib/pages/home/widgets/home_tab_header_widget.dart @@ -19,70 +19,89 @@ enum HeaderActionType { //购买 shop, //个人信息 - user + user, + //返回到(模块选择)首页 + home, } class HomeTabHeaderWidget extends StatelessWidget { - const HomeTabHeaderWidget({super.key,this.entity, this.actionTap}); + const HomeTabHeaderWidget({super.key, this.entity, this.actionTap}); final CourseEntity? entity; final Function(HeaderActionType type)? actionTap; @override Widget build(BuildContext context) { - return BlocBuilder( - builder: (context,state) { + return BlocBuilder( + builder: (context, state) { return Container( height: 45, width: double.infinity, - color: CourseModuleModel(entity?.courseModuleCode??'Phase-1').color, + color: + CourseModuleModel(entity?.courseModuleCode ?? 'Phase-1').color, padding: EdgeInsets.symmetric(horizontal: 9.5.w), child: Row( children: [ ScreenUtil().bottomBarHeight.horizontalSpace, GestureDetector( - onTap: () => actionTap?.call(HeaderActionType.user), - child: Container( - decoration: BoxDecoration( - border: Border.all( - width: 1.0, - color: const Color(0xFF140C10), - ), - borderRadius: BorderRadius.circular(21), - ), - child: CircleAvatar( - radius: 21, - backgroundImage: ImageUtil.getImageProviderOnDefault(UserUtil.getUser()?.avatarUrl), - ), - ), - ), - GestureDetector( onTap: () { if (actionTap != null) { - actionTap!(HeaderActionType.user); + actionTap!(HeaderActionType.home); } }, child: Container( - margin: const EdgeInsets.only(left: 7), - padding: const EdgeInsets.all(4.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(2), - border: Border.all(width: 1.0, color: const Color(0xFF140C10), style: BorderStyle.solid), - ), - child: Text( - UserUtil.getUser()?.name ?? '未登录', - style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp), + alignment: Alignment.center, + child: Image.asset( + 'back_around'.assetPng, + height: 40.h, + width: 40.w, ), ), ), + // GestureDetector( + // onTap: () => actionTap?.call(HeaderActionType.user), + // child: Container( + // decoration: BoxDecoration( + // border: Border.all( + // width: 1.0, + // color: const Color(0xFF140C10), + // ), + // borderRadius: BorderRadius.circular(21), + // ), + // child: CircleAvatar( + // radius: 21, + // backgroundImage: ImageUtil.getImageProviderOnDefault(UserUtil.getUser()?.avatarUrl), + // ), + // ), + // ), + // GestureDetector( + // onTap: () { + // if (actionTap != null) { + // actionTap!(HeaderActionType.user); + // } + // }, + // child: Container( + // margin: const EdgeInsets.only(left: 7), + // padding: const EdgeInsets.all(4.0), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(2), + // border: Border.all(width: 1.0, color: const Color(0xFF140C10), style: BorderStyle.solid), + // ), + // child: Text( + // UserUtil.getUser()?.name ?? '未登录', + // style: TextStyle(color: const Color(0xFF333333), fontSize: 16.sp), + // ), + // ), + // ), 20.horizontalSpace, Expanded( child: Text( - CourseModuleModel(entity?.courseModuleCode??'Phase-1').courseModuleTitle, - textAlign: TextAlign.left, - style: const TextStyle(color: Colors.white, fontSize: 30.0), - )), + CourseModuleModel(entity?.courseModuleCode ?? 'Phase-1') + .courseModuleTitle, + textAlign: TextAlign.left, + style: const TextStyle(color: Colors.white, fontSize: 30.0), + )), // IconButton( // onPressed: () { // if (actionTap != null) { @@ -105,17 +124,15 @@ class HomeTabHeaderWidget extends StatelessWidget { }, icon: Image.asset('listen'.assetPng)), IconButton( - onPressed: (){ - if(actionTap != null) { + onPressed: () { + if (actionTap != null) { actionTap!(HeaderActionType.shop); } }, - icon: Image.asset('shop'.assetPng) - ), + icon: Image.asset('shop'.assetPng)), ScreenUtil().bottomBarHeight.horizontalSpace, ], - ) - ); + )); }, ); }