import 'package:flutter/material.dart'; import 'package:skywood/main/lib_file.dart'; import 'package:skywood/utils/tools/widgets/sky_common_widget.dart'; import '../help_nav.dart'; class SkyAppBar extends StatelessWidget implements PreferredSizeWidget { const SkyAppBar({ super.key, this.title, this.titleWidget, this.leading, this.actions, this.onBack, this.showBackButton = true, this.centerTitle = true, this.backgroundColor = Colors.white, this.foregroundColor, this.elevation = 0, this.bottom, this.toolbarHeight = kToolbarHeight, this.titleColor, }); final String? title; final Color? titleColor; final Widget? titleWidget; final Widget? leading; final List? actions; final VoidCallback? onBack; final bool showBackButton; final bool centerTitle; final Color? backgroundColor; final Color? foregroundColor; final double elevation; final PreferredSizeWidget? bottom; final double toolbarHeight; @override Size get preferredSize => Size.fromHeight(toolbarHeight + (bottom?.preferredSize.height ?? 0)); @override Widget build(BuildContext context) { return _buildNormalAppBar(context); } PreferredSizeWidget _buildNormalAppBar(BuildContext context) { final canPop = Navigator.of(context).canPop(); Widget? resolvedLeading = leading; if (resolvedLeading == null && showBackButton && canPop) { resolvedLeading = IconButton( icon: HelpImg.asset(ConstImg.back, width: 32), onPressed: onBack ?? () => HelpNav.back(), ); } return AppBar( title: titleWidget ?? (title != null ? SkyText(text: title!, fontSize: 18, fontWeight: FontWeight.bold, color: titleColor) : null), leading: resolvedLeading, actions: actions, centerTitle: centerTitle, backgroundColor: backgroundColor, foregroundColor: foregroundColor, elevation: elevation, scrolledUnderElevation: 0, toolbarHeight: toolbarHeight, ); } }