import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:muaawana/config/style.dart'; import 'package:muaawana/utils/text_style.dart'; import '../config/app_constant.dart'; import '../config/lang_enum.dart'; import '../config/provider.dart'; import '../config/size.dart'; import '../providers/language_provider.dart'; import '../utils/text_widget.dart'; class CustomAppBar extends StatelessWidget { final String title; final Color? titleColor; final double titleSize; final bool thirdWidget; final VoidCallback? onThirdWidgetPressed; final Color colorBackButton; final bool back; const CustomAppBar({ Key? key, required this.title, this.titleColor, this.titleSize = 18.0, this.colorBackButton = AppStyle.buttonBlue, this.thirdWidget = false, this.onThirdWidgetPressed, this.back = true, }) : super(key: key); @override Widget build(BuildContext context) { final langProvider = Provider.of(context); final hm = SizeConfig.heightMultiplier; final wm = SizeConfig.widthMultiplier; return Directionality( textDirection: langProvider.currentLangCode == Language.en ? TextDirection.ltr : TextDirection.rtl, child: SafeArea( bottom: false, child: Padding( // use directional padding so it works for both LTR/RTL padding: EdgeInsetsDirectional.only( start: wm * 4, end: wm * 4, top: hm * 3, ), child: Stack( alignment: Alignment.center, children: [ if (back) Align( alignment: AlignmentDirectional.centerStart, child: IconButton( icon: Icon(Icons.arrow_back_ios), onPressed: () => Navigator.of(context).maybePop(), tooltip: MaterialLocalizations.of(context).backButtonTooltip, ), ), Txt( text: title, maxLines: 1, overflow: TextOverflow.ellipsis, style: tS( "Inter", titleSize, FontWeight.bold, titleColor != null ? titleColor! : Theme.of(context).brightness == Brightness.dark ? AppNewStyle.appBackground : AppNewStyle.darkAppBackground, ), ), ], ), ), ), ); } } // thirdWidget // ? Align( // alignment: langProvider.currentLangCode == Language.en // ? AlignmentDirectional.centerEnd // : AlignmentDirectional.centerStart, // child: Padding( // padding: langProvider.currentLangCode == Language.en // ? EdgeInsetsDirectional.only(end: wm * 10) // : EdgeInsetsDirectional.only(start: wm * 10), // child: Container( // height: hm * 6, // decoration: const BoxDecoration( // shape: BoxShape.circle, // color: AppStyle.appBackground), // child: Padding( // padding: EdgeInsets.all(hm * 0.5), // child: Image.asset( // Consts.appLogo, // height: hm * 6, // ), // ), // ), // ), // ) // : Container(),