Untitled
unknown
dart
2 years ago
19 kB
5
Indexable
import 'dart:math' as math; import 'package:centro/app/Services/authentication/auth_manager.dart'; import 'package:centro/app/modules/Minister/Projects/binding/project_binding.dart'; import 'package:centro/app/modules/Minister/Projects/views/project_view.dart'; import 'package:centro/app/modules/Minister/Travel/binding/travel_binding.dart'; import 'package:centro/app/modules/Minister/Travel/view/travel_view.dart'; import 'package:centro/app/modules/News/binding/news_binding.dart'; import 'package:centro/app/modules/News/views/news_view.dart'; import 'package:centro/app/modules/Profile/binding/profile_binding.dart'; import 'package:centro/app/modules/Profile/views/profile_view.dart'; import 'package:centro/app/modules/ST/Home/binding/social_twitter_binding.dart'; import 'package:centro/app/modules/ST/Home/views/new_tweet_view.dart'; import 'package:centro/app/services/translation_service.dart'; import 'package:centro/app/utilities/constants/app_colors.dart'; import 'package:centro/app/utilities/ui/widgets/primary_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; class DashboardAppBar extends StatelessWidget implements PreferredSizeWidget { final bool showBackButton; const DashboardAppBar({super.key, required this.showBackButton}); @override Size get preferredSize => Size.fromHeight(appTools.userType == 2 ? Get.width * 0.75 : Get.width * 0.7); @override Widget build(BuildContext context) { return PreferredSize( preferredSize: preferredSize, child: Container( decoration: const BoxDecoration( // borderRadius: BorderRadius.only( // bottomLeft: Radius.elliptical(200, 10), // bottomRight: Radius.elliptical(200, 10), // ), // color: AppColors.black, // borderRadius: BorderRadius.vertical( // bottom: Radius.elliptical(250, 15), // ), image: DecorationImage( image: AssetImage('assets/images/appbar2.png'), fit: BoxFit.fitWidth, alignment: Alignment.topCenter, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Row( children: [ showBackButton == true ? IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: () { Get.back(); }, icon: Transform.rotate( angle: TranslationService().isLocaleArabic() ? (180 * math.pi / 180) : 0, child: SvgPicture.asset( 'assets/icons/backArrow.svg', width: Get.width * 0.06, ), ), ) : IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: () {}, icon: SvgPicture.asset( 'assets/icons/search.svg', width: Get.width * 0.05, ), ), appTools.userType == 2 ? IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: () {}, icon: SvgPicture.asset( 'assets/icons/twitter2.svg', width: Get.width * 0.05, ), ) : IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: null, icon: SvgPicture.asset( 'assets/icons/search.svg', width: Get.width * 0.05, color: Colors.transparent, ), ), IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: null, icon: SvgPicture.asset( 'assets/icons/comments.svg', width: Get.width * 0.05, color: Colors.transparent, ), ), ], ), SvgPicture.asset( 'assets/icons/MinistryLogo.svg', color: AppColors.white, width: Get.width * 0.25, ), Row( children: [ showBackButton == true ? IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: () {}, icon: SvgPicture.asset( 'assets/icons/search.svg', width: Get.width * 0.05, ), ) : IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: null, icon: SvgPicture.asset( 'assets/icons/search.svg', width: Get.width * 0.05, color: Colors.transparent, ), ), IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: () {}, icon: Stack( alignment: Alignment.topRight, children: [ SvgPicture.asset( 'assets/icons/comments.svg', width: Get.width * 0.05, ), ClipOval( child: Container( color: AppColors.red, width: 8, height: 8, ), ), ], ), ), IconButton( padding: const EdgeInsets.symmetric(horizontal: 6), constraints: const BoxConstraints(), onPressed: () {}, icon: Stack( alignment: Alignment.topRight, children: [ SvgPicture.asset( 'assets/icons/notifications.svg', width: Get.width * 0.05, ), ClipOval( child: Container( color: AppColors.red, width: 8, height: 8, ), ), ], ), ), ], ), ], ).paddingOnly(top: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: Row( children: [ InkWell( onTap: () { Get.to( () => const ProfileView(), binding: ProfileBinding(), ); }, child: CircleAvatar( child: Image.asset('assets/images/Avatar.png'), ), ), const SizedBox( width: 12, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'خالد بن عبد العزيز الفالح', style: Get.textTheme.headline6!.copyWith( color: AppColors.white, ), ), Text( 'معالي الوزير', style: Get.textTheme.headline6!.copyWith( color: AppColors.white, ), ), ], ), ], ), ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Welcome...'.tr, style: Get.textTheme.headline6!.copyWith( color: AppColors.white, ), ), Text( 'Again'.tr, style: Get.textTheme.headline6!.copyWith( color: AppColors.white, ), ), ], ), ], ).paddingSymmetric(horizontal: 20, vertical: 24), Container( height: appTools.userType == 2 ? Get.width * 0.4 : Get.width * 0.3, padding: const EdgeInsets.all(8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: AppColors.white, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: appTools.userType == 2 ? [ AppBarStatisticItem( title: 'التغريدات', number: '6520', subtitle: 'تغريدة', color: AppColors.green, onTap: () {}, ), const SizedBox( width: 8, ), AppBarStatisticItem( title: 'الطلبات', number: '6', subtitle: 'طلبات', color: AppColors.lightPurple, onTap: () {}, ), const SizedBox( width: 8, ), AppBarStatisticItem( title: 'المرفوضة', number: '3', subtitle: 'طلبات', color: AppColors.red, onTap: () {}, ), ] : [ AppBarListItem( icon: 'assets/icons/aeroplane.svg', title: 'Travel Trips'.tr, color: const Color.fromRGBO(243, 64, 64, 1.0), onTap: () { Get.to( () => const TravelView(), binding: TravelBinding(), ); }, ), const SizedBox( width: 8, ), AppBarListItem( icon: 'assets/icons/research.svg', title: 'Latest News'.tr, color: const Color.fromRGBO(157, 138, 221, 1.0), onTap: () { Get.to( () => const NewsView(), binding: NewsBinding(), ); }, ), const SizedBox( width: 8, ), AppBarListItem( icon: 'assets/icons/briefcase.svg', title: 'Ministry Projects'.tr, color: const Color.fromRGBO(186, 92, 37, 1.0), onTap: () { Get.to( () => const ProjectView(), binding: ProjectBinding(), ); }, ), const SizedBox( width: 8, ), AppBarListItem( icon: 'assets/icons/group.svg', title: 'Committees and Councils'.tr, color: const Color.fromRGBO(115, 195, 213, 1.0), onTap: () {}, ), ], ), ), appTools.userType == 2 ? PrimaryButton( text: 'إضافة تغريدة جديدة', width: Get.width, padding: 12, function: () { Get.to( () => NewTweetView(), binding: SocialTwitterBinding(), ); }, ).marginOnly(top: 8) : const SizedBox(), ], ), ).paddingSymmetric(horizontal: 24), ], ), ), ); } } class AppBarListItem extends StatelessWidget { final String icon; final String title; final Color color; final Function() onTap; const AppBarListItem({ super.key, required this.icon, required this.title, required this.color, required this.onTap, }); @override Widget build(BuildContext context) { return Expanded( child: InkWell( onTap: onTap, child: Container( // width: Get.width * 0.18, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( color: color, width: 0.5, ), color: color.withOpacity(0.05), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SvgPicture.asset(icon), const SizedBox( height: 8, ), Text( title, textAlign: TextAlign.center, ).paddingSymmetric(horizontal: 16), ], ), ), ), ); } } class AppBarStatisticItem extends StatelessWidget { final String title; final String number; final String subtitle; final Color color; final Function() onTap; const AppBarStatisticItem({ super.key, required this.title, required this.number, required this.subtitle, required this.color, required this.onTap, }); @override Widget build(BuildContext context) { return Expanded( child: InkWell( onTap: onTap, child: Container( // width: Get.width * 0.18, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( color: AppColors.blueGrey, width: 0.3, ), color: AppColors.white, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( title, textAlign: TextAlign.center, ), const SizedBox( height: 4, ), Text( number, textAlign: TextAlign.center, style: Get.textTheme.headline4?.copyWith( color: color, ), ), const SizedBox( height: 4, ), Text( subtitle, textAlign: TextAlign.center, style: Get.textTheme.bodyText2?.copyWith( color: AppColors.limeGreen, ), ) ], ), ), ), ); } }
Editor is loading...