You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			75 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			75 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Dart
		
	
| 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<String> 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,
 | |
|     );
 | |
|   }
 | |
| }
 |