section_header_widget.dart 1.95 KB
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/module_cache.dart';

/// 环节(课程)列表页标题栏
class SectionHeaderWidget extends StatelessWidget {
  const SectionHeaderWidget(
      {super.key, this.title, this.onBack});

  final String? title;

  final VoidCallback? onBack;

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<UserBloc, UserState>(
      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(
                  title ?? ModuleCache.instance.getCurrentThemeName(),
                  textAlign: TextAlign.left,
                  style: const TextStyle(color: Colors.white, fontSize: 30.0),
                )),
                ScreenUtil().bottomBarHeight.horizontalSpace,
              ],
            ));
      },
    );
  }
}