import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:wow_english/common/extension/string_extension.dart'; import 'package:wow_english/pages/user/bloc/user_bloc.dart'; import '../../../common/core/app_config_helper.dart'; import '../../../common/core/module_cache.dart'; enum HeaderActionType { //视频跟读 video, //阶段选择 phase, //磨耳朵 listen, //购买 shop, //个人信息 user, } class HomeTabHeaderWidget extends StatelessWidget { const HomeTabHeaderWidget( {super.key, this.courseModuleCode, this.actionTap, this.onBack}); final String? courseModuleCode; final Function(HeaderActionType type)? actionTap; final VoidCallback? onBack; @override Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { return Container( height: 45, width: double.infinity, color: ModuleCache.instance.getCurrentThemeColor(), padding: EdgeInsets.symmetric(horizontal: 9.5.w), child: Row( children: [ ScreenUtil().bottomBarHeight.horizontalSpace, GestureDetector( onTap: () { if (onBack == null) { Navigator.pop(context); } else { onBack?.call(); } }, child: Container( alignment: Alignment.center, child: Image.asset( 'back_around'.assetPng, height: 40.h, width: 40.w, ), ), ), 20.horizontalSpace, Expanded( child: Text( ModuleCache.instance.getCurrentThemeName(), textAlign: TextAlign.left, style: const TextStyle(color: Colors.white, fontSize: 30.0), )), GestureDetector( onTap: () { if (actionTap != null) { actionTap!(HeaderActionType.phase); } }, child: Image( image: AssetImage('home'.assetPng), width: 36.0.w, height: 36.0.h, fit: BoxFit.contain)), 8.horizontalSpace, GestureDetector( onTap: () { if (actionTap != null) { actionTap!(HeaderActionType.listen); } }, child: Image( image: AssetImage('listen'.assetPng), width: 36.0.w, height: 36.0.h, fit: BoxFit.contain)), 8.horizontalSpace, Offstage( offstage: AppConfigHelper.shouldHidePay(), child: GestureDetector( onTap: () { if (actionTap != null) { actionTap!(HeaderActionType.shop); } }, child: Image( image: AssetImage('shop'.assetPng), width: 36.0.w, height: 36.0.h, fit: BoxFit.contain)), ), ScreenUtil().bottomBarHeight.horizontalSpace, ], )); }, ); } }