first commit

This commit is contained in:
Hamza-Ayed
2026-06-09 08:40:31 +03:00
commit d8901e1a87
3161 changed files with 536187 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
// import 'package:SEFER/constant/colors.dart';
// import 'package:SEFER/constant/style.dart';
// import 'package:SEFER/controller/firebase/firbase_messge.dart';
// import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
// import 'package:SEFER/views/widgets/my_scafold.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
// import '../../../../../controller/functions/call_controller.dart';
// class CallPage extends StatelessWidget {
// const CallPage({super.key});
// @override
// Widget build(BuildContext context) {
// return MyScafolld(
// title: 'Call Page'.tr, isleading: true, body: [callPage()]);
// }
// }
// GetBuilder<HomeCaptainController> callPage() {
// CallController callController = Get.put(CallController());
// Get.put(MapDriverController());
// // callController.join();
// return GetBuilder<HomeCaptainController>(
// builder: (controller) => Positioned(
// top: Get.height * .2,
// child: Container(
// height: 100, width: Get.width,
// decoration: AppStyle.boxDecoration,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// GestureDetector(
// onTap: () async {
// callController.join();
// },
// child: Container(
// width: 50,
// height: 50,
// decoration: const BoxDecoration(
// shape: BoxShape.circle, color: AppColor.greenColor),
// child: const Icon(
// Icons.phone,
// size: 35,
// color: AppColor.secondaryColor,
// )),
// ),
// Column(
// children: [
// Text(callController.status),
// Text(Get.find<MapDriverController>().passengerName.toString()),
// ],
// ),
// GestureDetector(
// onTap: () async {
// FirebaseMessagesController().sendNotificationToPassengerToken(
// 'Call End'.tr,
// 'Call End',
// Get.find<MapDriverController>().tokenPassenger,
// [],
// 'iphone_ringtone.wav');
// callController.leave();
// Get.back();
// },
// child: Container(
// width: 50,
// height: 50,
// decoration: const BoxDecoration(
// shape: BoxShape.circle, color: AppColor.redColor),
// child: const Icon(
// Icons.phone_disabled_sharp,
// size: 35,
// color: AppColor.secondaryColor,
// )),
// )
// ],
// ),
// // ignore: prefer_const_constructors
// ),
// ),
// );
// }

View File

@@ -0,0 +1,151 @@
import 'package:siro_driver/controller/functions/tts.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:siro_driver/controller/home/payment/captain_wallet_controller.dart';
import '../../../../../constant/style.dart';
import '../../../../widgets/elevated_btn.dart';
import '../../../../../controller/home/captin/home_captain_controller.dart';
class ConnectWidget extends StatelessWidget {
const ConnectWidget({
super.key,
});
@override
Widget build(BuildContext context) {
// final OrderRequestController orderRequestController =
// Get.put(OrderRequestController());
CaptainWalletController captainWalletController =
Get.put(CaptainWalletController());
int refusedRidesToday = 0;
captainWalletController.getCaptainWalletFromBuyPoints();
return Center(
child: GetBuilder<HomeCaptainController>(
builder: (homeCaptainController) => double.parse(
(captainWalletController.totalPoints)) <
-200
? CupertinoButton(
onPressed: () {
Get.defaultDialog(
// backgroundColor: CupertinoColors.destructiveRed,
barrierDismissible: false,
title: double.parse(
(captainWalletController.totalPoints)) <
-200
? 'You dont have Points'.tr
: 'You Are Stopped For this Day !'.tr,
titleStyle: AppStyle.title,
content: Column(
children: [
IconButton(
onPressed: () async {
double.parse((captainWalletController
.totalPoints)) <
-200
? await Get.find<TextToSpeechController>()
.speakText(
'You must be recharge your Account'
.tr)
: await Get.find<TextToSpeechController>()
.speakText(
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr);
},
icon: const Icon(Icons.headphones),
),
Text(
double.parse((captainWalletController
.totalPoints)) <
-200
? 'You must be recharge your Account'.tr
: 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr,
style: AppStyle.title,
),
],
),
confirm: double.parse(
(captainWalletController.totalPoints)) <
-200
? MyElevatedButton(
title: 'Recharge my Account'.tr,
onPressed: () {
homeCaptainController.goToWalletFromConnect();
})
: MyElevatedButton(
title: 'Ok , See you Tomorrow'.tr,
onPressed: () {
Get.back();
Get.back();
}));
},
color: CupertinoColors.destructiveRed,
child: Text(
'You are Stopped'.tr,
style: AppStyle.title,
),
)
: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: homeCaptainController.isActive
? [const Color(0xFF00C853), const Color(0xFF00E676)]
: [Colors.grey.shade600, Colors.grey.shade400],
),
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: (homeCaptainController.isActive
? const Color(0xFF00C853)
: Colors.grey)
.withOpacity(0.4),
spreadRadius: 0,
blurRadius: 15,
offset: const Offset(0, 5),
),
],
),
child: CupertinoButton(
onPressed: homeCaptainController.onButtonSelected,
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 10),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: Icon(
homeCaptainController.isActive
? Icons.power_settings_new_rounded
: Icons.power_off_rounded,
color: Colors.white,
size: 20,
),
),
const SizedBox(width: 10),
Text(
homeCaptainController.isActive
? 'Online'.tr
: 'Offline'.tr,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
letterSpacing: 0.5,
),
),
],
),
),
)),
);
}
}

View File

@@ -0,0 +1,323 @@
import 'package:siro_driver/constant/box_name.dart';
import 'package:siro_driver/controller/firebase/local_notification.dart';
import 'package:siro_driver/main.dart';
import 'package:siro_driver/views/home/Captin/driver_map_page.dart';
import 'package:siro_driver/views/home/Captin/orderCaptin/vip_order_page.dart';
import 'package:siro_driver/views/auth/syria/registration_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
import 'package:siro_driver/controller/home/captin/home_captain_controller.dart';
import 'package:siro_driver/views/widgets/mydialoug.dart';
import '../../../../../constant/links.dart';
import '../../../../../controller/firebase/notification_service.dart';
import '../../../../../controller/functions/crud.dart';
import '../../../../../controller/home/captin/order_request_controller.dart';
import '../../../../../print.dart';
import '../../../../Rate/ride_calculate_driver.dart';
// ─────────────────────────────────────────────
// Design Tokens (Responsive)
// ─────────────────────────────────────────────
class _T {
static Color surface(BuildContext context) =>
Theme.of(context).brightness == Brightness.dark
? const Color(0xFF16213E)
: Colors.white;
static const Color accent = Color(0xFFF0A500);
static const Color blue = Color(0xFF3498DB);
static Color border(BuildContext context) =>
Theme.of(context).brightness == Brightness.dark
? const Color(0xFF2A2A4A)
: Colors.grey.withOpacity(0.2);
static const double radius = 14.0;
}
// ─────────────────────────────────────────────
// Left Side Menu
// ─────────────────────────────────────────────
/// Returns the vertical icon column anchored to the left-center of the map.
GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
return GetBuilder<HomeCaptainController>(
builder: (ctrl) => Positioned(
// Place just above the bottom status bar
bottom: 100,
left: 10,
child: Builder(builder: (context) {
return Container(
decoration: BoxDecoration(
color: _T.surface(context),
borderRadius: BorderRadius.circular(_T.radius),
border: Border.all(color: _T.border(context)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 10,
offset: const Offset(2, 4),
),
],
),
padding: const EdgeInsets.symmetric(vertical: 6),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// ── 1. Active Ride shortcut ──────────
_MenuIcon(
icon: Icons.directions_car_rounded,
color:
box.read(BoxName.rideArgumentsFromBackground) == 'failure'
? Colors.red.shade400
: Colors.green.shade400,
tooltip: 'Active Ride'.tr,
onTap: () async {
await checkForPendingOrderFromServer();
if (box.read(BoxName.rideArgumentsFromBackground) !=
'failure') {
Get.to(
() => PassengerLocationMapPage(),
arguments: box.read(BoxName.rideArgumentsFromBackground),
);
} else {
MyDialog().getDialog(
'Ride info'.tr,
'you dont have accepted ride'.tr,
() => Get.back(),
);
}
},
onLongPress: () {
box.write(BoxName.rideArgumentsFromBackground, 'failure');
box.write(BoxName.statusDriverLocation, 'off');
box.write(BoxName.rideStatus, 'no_ride');
Log.print(box.read(BoxName.statusDriverLocation));
ctrl.update();
},
),
_Divider(context),
// ── 2. Earnings Chart ────────────────
_MenuIcon(
icon: FontAwesome5.chart_bar,
color: _T.blue,
tooltip: 'Earnings'.tr,
onTap: () {
final now = DateTime.now();
final lastTimeRaw = box.read(BoxName.lastTimeStaticThrottle);
DateTime? lastTime;
if (lastTimeRaw != null) {
try {
lastTime = DateTime.parse(lastTimeRaw.toString());
} catch (_) {
lastTime = null;
}
}
if (lastTime == null ||
now.difference(lastTime).inMinutes >= 2) {
box.write(
BoxName.lastTimeStaticThrottle, now.toIso8601String());
Get.to(() => RideCalculateDriver());
} else {
final left = 2 - now.difference(lastTime).inMinutes;
NotificationController().showNotification(
'Intaleq Driver'.tr,
'${'Please wait'.tr} $left ${"minutes before trying again.".tr}',
'ding',
'',
);
}
},
onLongPress: () =>
box.write(BoxName.statusDriverLocation, 'off'),
),
// ── 3. VIP Orders (2023+ cars only) ──
if (int.tryParse(box.read(BoxName.carYear).toString()) != null &&
int.parse(box.read(BoxName.carYear).toString()) > 2023) ...[
_Divider(context),
_MenuIcon(
icon: Octicons.watch,
color: _T.accent,
tooltip: 'VIP Orders'.tr,
onTap: () => Get.to(() => const VipOrderPage()),
),
],
// _Divider(context),
// // ── 4. Driver Registration ──────────
// _MenuIcon(
// icon: Icons.person_add_alt_1_rounded,
// color: Colors.purple.shade400,
// tooltip: 'Registration'.tr,
// onTap: () => Get.to(() => const RegistrationView()),
// ),
],
),
);
}),
),
);
}
// ─────────────────────────────────────────────
// Reusable sub-widgets
// ─────────────────────────────────────────────
class _MenuIcon extends StatelessWidget {
final IconData icon;
final Color color;
final String tooltip;
final VoidCallback onTap;
final VoidCallback? onLongPress;
const _MenuIcon({
required this.icon,
required this.color,
required this.tooltip,
required this.onTap,
this.onLongPress,
});
@override
Widget build(BuildContext context) => Tooltip(
message: tooltip,
child: InkWell(
onTap: onTap,
onLongPress: onLongPress,
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Icon(icon, color: color, size: 26),
),
),
);
}
/// Thin separator between icons
class _Divider extends StatelessWidget {
final BuildContext context;
const _Divider(this.context);
@override
Widget build(BuildContext context) => Container(
height: 1,
width: 32,
margin: const EdgeInsets.symmetric(horizontal: 6),
color: _T.border(this.context),
);
}
// ─────────────────────────────────────────────
// Server Helpers (unchanged logic)
// ─────────────────────────────────────────────
Future<void> checkForPendingOrderFromServer() async {
bool isProcessing = false;
if (isProcessing) return;
final driverId = box.read(BoxName.driverID)?.toString();
if (driverId == null) return;
isProcessing = true;
try {
var response = await CRUD().post(
link: AppLink.getArgumentAfterAppliedFromBackground,
payload: {'driver_id': driverId},
);
Log.print('response: $response');
if (response['status'] == 'success') {
final Map<String, dynamic> orderInfo = response['message'];
final Map<String, dynamic> rideArgs =
_transformServerDataToAppArguments(orderInfo);
final customerToken = response['message']['token_passenger'];
final orderId = response['message']['ride_id'].toString();
box.write(BoxName.rideArgumentsFromBackground, rideArgs);
box.write(BoxName.statusDriverLocation, 'on');
box.write(BoxName.rideStatus, 'Apply');
Get.put(OrderRequestController()).changeApplied();
Get.to(
() => PassengerLocationMapPage(),
arguments: box.read(BoxName.rideArgumentsFromBackground),
);
} else {
box.write(BoxName.rideArgumentsFromBackground, 'failure');
}
} catch (_) {
// silent
} finally {
isProcessing = false;
}
}
Map<String, dynamic> _transformServerDataToAppArguments(
Map<String, dynamic> d) {
String s(String key, [String def = 'unknown']) => d[key]?.toString() ?? def;
return {
'passengerLocation': s('passenger_location'),
'passengerDestination': s('passenger_destination'),
'Duration': s('duration'),
'totalCost': s('total_cost'),
'Distance': s('distance'),
'name': s('name'),
'phone': s('phone'),
'email': s('email'),
'tokenPassenger': s('token_passenger'),
'direction': s('direction_url'),
'DurationToPassenger': s('duration_to_passenger'),
'rideId': s('ride_id'),
'passengerId': s('passenger_id'),
'driverId': s('driver_id'),
'durationOfRideValue': s('duration_of_ride'),
'paymentAmount': s('payment_amount'),
'paymentMethod': s('payment_method'),
'passengerWalletBurc': s('passenger_wallet_burc'),
'timeOfOrder': s('time_of_order'),
'totalPassenger': s('total_passenger'),
'carType': s('car_type'),
'kazan': s('kazan'),
'startNameLocation': s('start_name_location'),
'endNameLocation': s('end_name_location'),
'step0': s('step0'),
'step1': s('step1'),
'step2': s('step2'),
'step3': s('step3'),
'step4': s('step4'),
'WalletChecked': (d['wallet_checked'] == 1).toString(),
'isHaveSteps': (d['has_steps'] == 1) ? 'startEnd' : 'noSteps',
};
}
void _sendAcceptanceNotification(String? customerToken, dynamic rideId) {
if (customerToken == null || customerToken.isEmpty) return;
List<String> body = [
box.read(BoxName.driverID).toString(),
box.read(BoxName.nameDriver).toString(),
box.read(BoxName.tokenDriver).toString(),
rideId.toString(),
];
NotificationService.sendNotification(
target: customerToken,
title: 'Accepted Ride'.tr,
body: 'your ride is Accepted'.tr,
isTopic: false,
tone: 'start',
driverList: body,
category: 'Accepted Ride',
);
}

View File

@@ -0,0 +1,67 @@
import 'dart:convert';
import 'dart:math';
import 'package:get/get.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
class ZonesController extends GetxController {
Map<String, List<LatLng>> generateZoneMap(
LatLng southwest, LatLng southEast, LatLng northeast) {
const double desiredZoneArea = 4; // in square kilometers
final double width = (southEast.longitude - southwest.longitude) * 100;
final double height = (northeast.latitude - southEast.latitude) * 100;
final double totalArea = width * height;
// final int numZones = (totalArea / desiredZoneArea).ceil();
final double zoneWidth = width / sqrt(desiredZoneArea);
final double zoneHeight = height / sqrt(desiredZoneArea);
final numRows =
((northeast.latitude - southwest.latitude) / zoneHeight).ceil();
final numCols =
((southEast.longitude - southwest.longitude) / zoneWidth).ceil();
List<String> zoneNames = [];
List<LatLng> zoneCoordinates = [];
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
final double zoneSouthwestLat =
southwest.latitude + (row * zoneHeight / 100);
final double zoneSouthwestLng =
southwest.longitude + (col * zoneWidth / 100);
final double zoneNortheastLat = zoneSouthwestLat + zoneHeight / 100;
final double zoneNortheastLng = zoneSouthwestLng + zoneWidth / 100;
LatLng zoneSouthwest = LatLng(zoneSouthwestLat, zoneSouthwestLng);
LatLng zoneNortheast = LatLng(zoneNortheastLat, zoneNortheastLng);
String zoneName =
'Zone${row + col}'; // Assign a unique name to each zone
zoneNames.add(zoneName);
zoneCoordinates.add(zoneSouthwest);
zoneCoordinates.add(zoneNortheast);
}
}
Map<String, List<LatLng>> zoneMap = {};
for (int i = 0; i < zoneNames.length; i++) {
zoneMap[zoneNames[i]] = [
zoneCoordinates[i], // Southwest LatLng
zoneCoordinates[i + 1], // Northeast LatLng
];
}
return zoneMap;
}
void getJsonOfZones() {
LatLng southwest = const LatLng(32.111107, 36.062222);
LatLng southEast = const LatLng(32.108333, 36.101667);
LatLng northeast = const LatLng(32.143889, 36.058889);
Map<String, List<LatLng>> zoneMap =
generateZoneMap(southwest, southEast, northeast);
String jsonMap = json.encode(zoneMap);
}
}