import 'package:flutter/material.dart'; import 'package:novyronst/common/help/app_nav.dart'; import 'package:novyronst/tools/widgets/novy_com_widget.dart'; import '../../common/const/const_color.dart'; class NovyAppBar extends StatelessWidget implements PreferredSizeWidget { const NovyAppBar({ super.key, this.title, this.titleWidget, this.leading, this.actions, this.onBack, this.showBackButton = true, this.centerTitle = true, this.backgroundColor, 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: Icon(Icons.arrow_back_ios, size: 18, color: Colors.white), onPressed: onBack ?? () => AppNav.back(), ); } return AppBar( title: titleWidget ?? (title != null ? NovyText(title!, fontSize: 18, fontWeight: FontWeight.bold, color: titleColor) : null), leading: resolvedLeading, actions: actions, centerTitle: centerTitle, backgroundColor: backgroundColor ?? ConstColor.withValue('#110D08'), foregroundColor: foregroundColor, elevation: elevation, scrolledUnderElevation: 0, toolbarHeight: toolbarHeight, ); } }