import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/widgets/language_switcher.dart'; import '../../generated/locale_keys.g.dart'; class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { final VoidCallback onBackPressed; final ValueChanged onLanguageChanged; bool hideLogoAndLang; CustomAppBar({ Key? key, required this.onBackPressed, required this.onLanguageChanged, this.hideLogoAndLang = false, }) : super(key: key); @override Size get preferredSize => const Size.fromHeight(kToolbarHeight); @override Widget build(BuildContext context) { return AppBar( backgroundColor: Colors.transparent, leading: null, automaticallyImplyLeading: false, title: Padding( padding: EdgeInsets.symmetric(horizontal: 10.h), child: Row( // mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Align( alignment: context.locale.languageCode == "ar" ? Alignment.centerRight : Alignment.centerLeft, child: GestureDetector( onTap: onBackPressed, child: Utils.buildSvgWithAssets(icon: AppAssets.arrow_back, width: 32.h, height: 32.h), ), ), ), // Logo if (!hideLogoAndLang) Utils.buildSvgWithAssets( icon: AppAssets.habiblogo, ), if (!hideLogoAndLang) Expanded( child: Align( alignment: context.locale.languageCode == "ar" ? Alignment.centerLeft : Alignment.centerRight, child: LanguageSelector( currentLanguage: context.locale.languageCode, showOnlyIcon: false, onLanguageChanged: onLanguageChanged, languages: [ {'code': 'ar', 'name': LocaleKeys.arabic.tr()}, {'code': 'en', 'name': LocaleKeys.english.tr()} ], ), ), ), ], ), ), centerTitle: true, ); } }