import 'dart:io'; import 'package:sefer_driver/constant/links.dart'; import 'package:sefer_driver/constant/style.dart'; import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart'; import 'package:sefer_driver/views/Rate/rate_app_page.dart'; import 'package:sefer_driver/views/auth/captin/contact_us_page.dart'; import 'package:sefer_driver/views/auth/captin/invite_driver_screen.dart'; import 'package:sefer_driver/views/notification/available_rides_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:get/get.dart'; import 'package:sefer_driver/constant/box_name.dart'; import 'package:sefer_driver/main.dart'; import 'package:sefer_driver/views/auth/captin/logout_captain.dart'; import 'package:sefer_driver/views/home/Captin/history/history_captain.dart'; import 'package:sefer_driver/views/home/Captin/home_captain/help_captain.dart'; import 'package:sefer_driver/views/home/Captin/About%20Us/settings_captain.dart'; import 'package:sefer_driver/views/home/my_wallet/walet_captain.dart'; import 'package:sefer_driver/views/home/profile/profile_captain.dart'; import 'package:sefer_driver/views/notification/notification_captain.dart'; import '../../../../constant/colors.dart'; import '../../../../controller/functions/upload_image.dart'; import '../About Us/video_page.dart'; import '../assurance_health_page.dart'; import '../maintain_center_page.dart'; import 'package:flutter/cupertino.dart'; import 'device_compatibility_page.dart'; // class CupertinoDrawerCaptain extends StatelessWidget { // final ImageController imageController = Get.put(ImageController()); // @override // Widget build(BuildContext context) { // return CupertinoPageScaffold( // navigationBar: CupertinoNavigationBar( // middle: Text('Menu'.tr), // ), // child: SafeArea( // child: CustomScrollView( // slivers: [ // const SliverToBoxAdapter(child: const UserAccountHeader()), // SliverList( // delegate: SliverChildListDelegate([ // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.money_dollar, // text: 'Wallet'.tr, // onTap: () => Get.to(() => WalletCaptain()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.person, // text: 'Profile'.tr, // onTap: () => Get.to(() => ProfileCaptain()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.clock, // text: 'History of Trip'.tr, // onTap: () => Get.to(() => const HistoryCaptain()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.car_detailed, // text: 'Available for rides'.tr, // onTap: () => Get.to(() => const AvailableRidesPage()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.bell, // text: 'Notifications'.tr, // onTap: () => Get.to(() => const NotificationCaptain()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.question_circle, // text: 'Helping Center'.tr, // onTap: () => Get.to(() => HelpCaptain()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.share, // text: 'Share App'.tr, // onTap: () => Get.to(() => InviteScreen()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.wrench, // text: "Maintenance Center".tr, // onTap: () => Get.to(() => MaintainCenterPage()), // ), // _buildDivider(), // _buildDrawerItem( // icon: // CupertinoIcons.heart, // Updated icon to represent health // text: "Health Insurance".tr, // Updated English text // onTap: () => Get.to(() => AssuranceHealthPage()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.mail, // text: "Contact Us".tr, // onTap: () => Get.to(() => ContactUsPage()), // ), // _buildDivider(), // _buildDrawerItem( // icon: // Icons.play_circle_filled, // Icon representing video play // text: 'Videos Tutorials'.tr, // onTap: () => Get.to(() => VideoListPage()), // ), // _buildDivider(), // _buildDrawerItem( // icon: Icons.star, // Another option with a filled star icon // text: "Rate Our App".tr, // onTap: () => Get.to(() => RatingScreen()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.settings, // text: 'Settings'.tr, // onTap: () => Get.to(() => const SettingsCaptain()), // ), // _buildDivider(), // _buildDrawerItem( // icon: CupertinoIcons.square_arrow_right, // text: 'Sign Out'.tr, // onTap: () => Get.to(() => const LogoutCaptain()), // ), // _buildDivider(), // ]), // ), // ], // ), // ), // ); // } // Widget _buildDivider() { // return const Divider( // thickness: 1, // height: 1, // color: CupertinoColors.systemGrey4, // ); // } // Widget _buildDrawerItem({ // required IconData icon, // required String text, // required VoidCallback onTap, // }) { // return CupertinoButton( // onPressed: onTap, // child: Row( // children: [ // Icon(icon, color: CupertinoColors.activeBlue), // const SizedBox(width: 10), // Text(text, style: const TextStyle(color: CupertinoColors.label)), // const Spacer(), // const Icon(CupertinoIcons.right_chevron, // color: CupertinoColors.systemGrey), // ], // ), // ); // } // } // class UserAccountHeader extends StatelessWidget { // const UserAccountHeader({super.key}); // @override // Widget build(BuildContext context) { // return Container( // padding: const EdgeInsets.all(16), // decoration: const BoxDecoration( // gradient: LinearGradient( // colors: [AppColor.blueColor, AppColor.twitterColor], // begin: Alignment.topLeft, // end: Alignment.bottomRight, // ), // ), // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // GetBuilder( // builder: (imageController) { // return Stack( // children: [ // imageController.isloading // ? const CupertinoActivityIndicator() // : Container( // width: 100, // height: 100, // decoration: BoxDecoration( // shape: BoxShape.circle, // image: DecorationImage( // fit: BoxFit.cover, // image: NetworkImage( // '${AppLink.seferCairoServer}/portrate_captain_image/${box.read(BoxName.driverID)}.jpg', // ), // ), // ), // ), // Positioned( // right: 0, // top: 0, // child: CupertinoButton( // onPressed: () { // imageController.choosImagePicture( // AppLink.uploadImage1, 'portrait'); // }, // child: const Icon(CupertinoIcons.pencil_circle_fill, // color: CupertinoColors.white), // ), // ), // ], // ); // }, // ), // const SizedBox(height: 10), // Text( // '${box.read(BoxName.nameDriver).toString().split(' ')[0]} ${box.read(BoxName.nameDriver).toString().split(' ')[1]}', // style: const TextStyle( // color: CupertinoColors.white, // fontSize: 18, // fontWeight: FontWeight.bold), // ), // const SizedBox(height: 5), // Text( // box.read(BoxName.emailDriver), // style: const TextStyle(color: CupertinoColors.white, fontSize: 14), // ), // const SizedBox(height: 10), // Row( // children: [ // Text( // Get.find().rating.toString(), // style: const TextStyle( // color: CupertinoColors.systemYellow, fontSize: 16), // ), // const SizedBox(width: 5), // // You might want to replace this with a Cupertino-style rating widget // // For now, we'll use text to represent stars // // const Text('★★★★★', // // style: TextStyle(color: CupertinoColors.systemYellow)), // Container( // padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1), // color: AppColor.greenColor, // child: RatingBar.builder( // initialRating: double.parse( // Get.find().rating.toString()), // minRating: 1, // direction: Axis.horizontal, // itemCount: 5, // itemSize: 20, // itemPadding: const EdgeInsets.symmetric(horizontal: 2), // itemBuilder: (context, _) => const Icon( // Icons.star, // color: Colors.amber, // ), // onRatingUpdate: (rating) {}, // ), // ), // ], // ), // ], // ), // ); // } // } class CupertinoDrawerCaptain extends StatelessWidget { final ImageController imageController = Get.put(ImageController()); @override Widget build(BuildContext context) { return CupertinoPageScaffold( backgroundColor: CupertinoColors.systemGroupedBackground, navigationBar: CupertinoNavigationBar( middle: Text('Menu'.tr, style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600)), backgroundColor: Colors.transparent, border: null, ), child: SafeArea( child: CustomScrollView( slivers: [ const SliverToBoxAdapter(child: UserAccountHeader()), SliverList( delegate: SliverChildListDelegate([ const SizedBox(height: 10), _buildSectionHeader('Account'.tr), _buildDrawerItem( icon: CupertinoIcons.money_dollar_circle_fill, text: 'Wallet'.tr, onTap: () => Get.to(() => WalletCaptain()), ), _buildDrawerItem( icon: CupertinoIcons.person_fill, text: 'Profile'.tr, onTap: () => Get.to(() => ProfileCaptain()), ), _buildSectionHeader('Activities'.tr), _buildDrawerItem( icon: CupertinoIcons.clock_fill, text: 'History of Trip'.tr, onTap: () => Get.to(() => const HistoryCaptain()), ), _buildDrawerItem( icon: CupertinoIcons.car_fill, text: 'Available for rides'.tr, onTap: () => Get.to(() => const AvailableRidesPage()), ), _buildSectionHeader('Support'.tr), _buildDrawerItem( icon: CupertinoIcons.bell_fill, text: 'Notifications'.tr, onTap: () => Get.to(() => const NotificationCaptain()), ), _buildDrawerItem( icon: CupertinoIcons.question_circle_fill, text: 'Helping Center'.tr, onTap: () => Get.to(() => HelpCaptain()), ), _buildSectionHeader('More'.tr), ...moreMenuItems(), ]), ), ], ), ), ); } List moreMenuItems() => [ _buildDrawerItem( icon: CupertinoIcons.share_up, text: 'Share App'.tr, onTap: () => Get.to(() => InviteScreen()), ), _buildDrawerItem( icon: CupertinoIcons.wrench_fill, text: "Maintenance Center".tr, onTap: () => Get.to(() => MaintainCenterPage()), ), _buildDrawerItem( icon: CupertinoIcons.heart_fill, text: "Health Insurance".tr, onTap: () => Get.to(() => AssuranceHealthPage()), ), _buildDrawerItem( icon: CupertinoIcons.mail_solid, text: "Contact Us".tr, onTap: () => Get.to(() => ContactUsPage()), ), _buildDrawerItem( icon: CupertinoIcons.play_circle_fill, text: 'Videos Tutorials'.tr, onTap: () => Get.to(() => VideoListPage()), ), _buildDrawerItem( icon: CupertinoIcons.star_fill, text: "Rate Our App".tr, onTap: () => Get.to(() => RatingScreen()), ), _buildDrawerItem( icon: Icons.memory, text: 'Is device compatible'.tr, onTap: () => Get.to(() => const DeviceCompatibilityPage()), ), Platform.isAndroid ? _buildDrawerItem( icon: CupertinoIcons.settings_solid, text: 'Settings'.tr, onTap: () => Get.to(() => const SettingsCaptain()), ) : SizedBox(), _buildDrawerItem( icon: CupertinoIcons.square_arrow_right, text: 'Sign Out'.tr, onTap: () => Get.to(() => const LogoutCaptain()), isDestructive: true, ), ]; Widget _buildSectionHeader(String title) { return Padding( padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), child: Text( title, style: const TextStyle( color: CupertinoColors.systemGrey, fontSize: 13, fontWeight: FontWeight.w600, ), ), ); } Widget _buildDrawerItem({ required IconData icon, required String text, required VoidCallback onTap, bool isDestructive = false, }) { return Container( margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), decoration: BoxDecoration( color: CupertinoColors.white, borderRadius: BorderRadius.circular(10), ), child: CupertinoButton( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), onPressed: onTap, child: Row( children: [ Icon( icon, color: isDestructive ? CupertinoColors.destructiveRed : CupertinoColors.activeBlue, size: 22, ), const SizedBox(width: 12), Text( text, style: AppStyle.title, // TextStyle( // color: isDestructive // ? CupertinoColors.destructiveRed // : CupertinoColors.label, // fontSize: 16, // ), ), const Spacer(), Icon( CupertinoIcons.chevron_right, color: CupertinoColors.systemGrey3, size: 18, ), ], ), ), ); } } class UserAccountHeader extends StatelessWidget { const UserAccountHeader({super.key}); @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.fromLTRB(20, 20, 20, 24), decoration: BoxDecoration( gradient: const LinearGradient( colors: [AppColor.blueColor, Color(0xFF2196F3)], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(10), blurRadius: 10, spreadRadius: 2, ), ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ GetBuilder( builder: (imageController) { return Stack( children: [ Container( width: 100, height: 100, decoration: BoxDecoration( shape: BoxShape.circle, border: Border.all(color: Colors.white, width: 3), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), blurRadius: 8, spreadRadius: 2, ), ], ), child: imageController.isloading ? const CupertinoActivityIndicator() : ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.network( '${AppLink.seferCairoServer}/portrate_captain_image/${(box.read(BoxName.driverID))}.jpg', fit: BoxFit.cover, ), ), ), Positioned( right: 0, bottom: 0, child: CupertinoButton( padding: EdgeInsets.zero, onPressed: () { imageController.choosImagePicture( AppLink.uploadImagePortrate, 'portrait'); }, child: Container( padding: const EdgeInsets.all(6), decoration: const BoxDecoration( color: Colors.white, shape: BoxShape.circle, ), child: const Icon( CupertinoIcons.camera_fill, color: AppColor.blueColor, size: 20, ), ), ), ), ], ); }, ), const SizedBox(height: 16), Text( box.read(BoxName.nameDriver).toString(), style: const TextStyle( color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, shadows: [ Shadow( color: Colors.black26, blurRadius: 2, offset: Offset(0, 1), ), ], ), ), const SizedBox(height: 4), Text( box.read(BoxName.emailDriver), style: TextStyle( color: Colors.white.withOpacity(0.9), fontSize: 14, ), ), const SizedBox(height: 12), Container( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: BoxDecoration( color: Colors.white.withOpacity(0.15), borderRadius: BorderRadius.circular(20), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ // const Icon( // CupertinoIcons.star_fill, // color: CupertinoColors.systemYellow, // size: 18, // ), // const SizedBox(width: 4), Text( Get.find().rating.toString(), style: const TextStyle( color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600, ), ), const SizedBox(width: 8), RatingBar.builder( initialRating: double.parse( Get.find().rating.toString()), minRating: 1, direction: Axis.horizontal, itemCount: 5, itemSize: 16, ignoreGestures: true, itemBuilder: (context, _) => const Icon( CupertinoIcons.star_fill, color: CupertinoColors.systemYellow, ), onRatingUpdate: (rating) {}, ), ], ), ), ], ), ); } }