358 lines
12 KiB
Dart
Executable File
358 lines
12 KiB
Dart
Executable File
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(
|
|
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<Widget> 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<ImageController>(
|
|
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<HomeCaptainController>().rating.toString(),
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
RatingBar.builder(
|
|
initialRating: double.parse(
|
|
Get.find<HomeCaptainController>().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) {},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|