feat: استيراد كود سيرو إلى تريبز (سيرو @ecfe7568) — بلا تعديل

قرار المالك 2026-07-27: باك إند سيرو PHP هو المعتمد، وتطبيقاته المجرّبة
ميدانياً تحل محل إعادة البناء المؤرشفة. سيرو نفسه لم يُمسّ.

الخريطة:
  backend · payment_server · loction_server · ride_server ·
  passenger_server · docker · dashboard · stress_test  → الجذر
  siro_rider  → apps/rider          siro_driver  → apps/driver
  siro_admin  → dashboards/admin    siro_service → dashboards/service
  android_bot → apps/android_bot    socialBot    → apps/socialBot

نُسخ المتعقَّب في git سيرو فقط عبر `git archive` (3,198 ملفاً / ~169 م.ب)
لا `cp -r` — فاستُثنيت مخلفات البناء تلقائياً. بلا أي تعديل محتوى عمداً:
كل ما يلي يصير فرقاً مقروءاً مقابل المصدر.

لم يُستورد وسببه: siromove.com (الموقع التسويقي يبقى marketing/ في تريبز،
سيرو فيه 8 ملفات) · docs و planning (تريبز له docs/ الخاص) · deploy.sh
(ليس نشراً على سيرفر بل `git add . && git push origin --all` — فخّ في
مستودع آخر) · transit_dashboard (بانتظار قرار مصير backend-transit و
dashboards/transit-web).

⚠️ لا يبني بعد — ثلاثة نواقص متوقعة ومقصودة:
1. `.env` و `lib/env/env.g.dart` غير متعقَّبين في سيرو (أسرار لكل مستأجر):
   كل تطبيق فلاتر يحتاج .env خاصاً ثم توليد env.g.dart بـ build_runner.
2. إعدادات Firebase (9 ملفات google-services.json و GoogleService-Info.plist)
   يستبعدها .gitignore تريبز — ولكل مستأجر مشروع Firebase خاص أصلاً.
3. apps/driver في سيرو يشير إلى `../../Intaleq/packages/get` خارج المستودع →
   يجب ضمّ الحزم داخله أسوة بـ apps/rider.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-07-27 05:14:13 +03:00
co-authored by Claude Opus 5
parent 9909d9b4c1
commit 4d8414c96b
3198 changed files with 766859 additions and 0 deletions
@@ -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
// ),
// ),
// );
// }
@@ -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)) <
homeCaptainController.minPointsThreshold
? CupertinoButton(
onPressed: () {
Get.defaultDialog(
// backgroundColor: CupertinoColors.destructiveRed,
barrierDismissible: false,
title: double.parse(
(captainWalletController.totalPoints)) <
homeCaptainController.minPointsThreshold
? '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)) <
homeCaptainController.minPointsThreshold
? 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)) <
homeCaptainController.minPointsThreshold
? '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)) <
homeCaptainController.minPointsThreshold
? 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,
),
),
],
),
),
)),
);
}
}
@@ -0,0 +1,241 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import 'package:siro_driver/constant/colors.dart';
import 'package:siro_driver/controller/home/captin/destination_controller.dart';
import 'package:siro_driver/controller/functions/tts.dart';
class DestinationBottomSheet extends StatelessWidget {
const DestinationBottomSheet({super.key});
@override
Widget build(BuildContext context) {
Get.put(DestinationController());
return Container(
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? const Color(0xFF16213E)
: const Color(0xFFF8F9FA),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
),
),
padding: const EdgeInsets.fromLTRB(20, 12, 20, 28),
child: GetBuilder<DestinationController>(
builder: (c) {
if (c.isLoading) {
return const SizedBox(
height: 200,
child: Center(
child: CircularProgressIndicator(color: AppColor.primaryColor),
),
);
}
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Drag handle
Center(
child: Container(
width: 36,
height: 4,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.3),
borderRadius: BorderRadius.circular(2),
),
),
),
const SizedBox(height: 16),
// Header & Speaker
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Personal Destination'.tr,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
GetBuilder<TextToSpeechController>(
init: Get.find<TextToSpeechController>(),
builder: (tts) => IconButton(
icon: Icon(
tts.isSpeaking ? Icons.volume_up_rounded : Icons.volume_mute_rounded,
color: AppColor.primaryColor,
size: 26,
),
onPressed: c.toggleSpeaker,
tooltip: 'Listen to description'.tr,
),
),
],
),
const SizedBox(height: 12),
// Description Box (Smart container with soft color)
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppColor.primaryColor.withOpacity(0.08),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: AppColor.primaryColor.withOpacity(0.2),
),
),
child: Text(
'Destination Tool Description'.tr,
style: const TextStyle(
fontSize: 12,
height: 1.4,
),
),
),
const SizedBox(height: 16),
// Active Destination Card (If set)
if (c.activeLatLng != null) ...[
Card(
elevation: 0,
color: Colors.green.withOpacity(0.1),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: Colors.green.withOpacity(0.3)),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
child: Row(
children: [
const Icon(Icons.check_circle_rounded, color: Colors.green, size: 22),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
c.activeName,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
'${c.activeLatLng!.latitude.toStringAsFixed(5)}, ${c.activeLatLng!.longitude.toStringAsFixed(5)}',
style: const TextStyle(
fontSize: 11,
color: Colors.grey,
),
),
],
),
),
TextButton(
onPressed: c.clearDestination,
child: Text(
'Clear Destination'.tr,
style: const TextStyle(color: Colors.red),
),
),
],
),
),
),
const SizedBox(height: 16),
],
// Autocomplete Place Search Field
TextField(
controller: c.searchController,
onChanged: c.onSearchChanged,
decoration: InputDecoration(
hintText: 'Search for area or city...'.tr,
prefixIcon: const Icon(Icons.search_rounded),
filled: true,
fillColor: Theme.of(context).brightness == Brightness.dark
? const Color(0xFF202B4B)
: Colors.grey.withOpacity(0.1),
contentPadding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide.none,
),
),
),
// Suggestions List
if (c.placesSuggestions.isNotEmpty) ...[
const SizedBox(height: 8),
Container(
constraints: const BoxConstraints(maxHeight: 180),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? const Color(0xFF1E2746)
: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(color: Colors.grey.withOpacity(0.2)),
),
child: ListView.separated(
shrinkWrap: true,
itemCount: c.placesSuggestions.length,
separatorBuilder: (_, __) => const Divider(height: 1),
itemBuilder: (context, index) {
final place = c.placesSuggestions[index];
return ListTile(
leading: const Icon(Icons.place_rounded, color: Colors.grey),
title: Text(
place['name'] ?? "",
style: const TextStyle(fontSize: 13),
),
subtitle: Text(
place['description'] ?? "",
style: const TextStyle(fontSize: 11, color: Colors.grey),
),
onTap: () {
FocusScope.of(context).unfocus();
Get.back(); // Close sheet
final lat = double.tryParse(place['latitude']?.toString() ?? '0') ?? 0.0;
final lng = double.tryParse(place['longitude']?.toString() ?? '0') ?? 0.0;
c.saveDestination(LatLng(lat, lng), place['name'] ?? 'Destination');
},
);
},
),
),
],
const SizedBox(height: 16),
// Select on Map Button
ElevatedButton.icon(
onPressed: () {
Get.back(); // Close sheet
c.isSelectingDestinationOnMap = true;
c.update();
},
icon: const Icon(Icons.map_rounded),
label: Text('Select on Map'.tr),
style: ElevatedButton.styleFrom(
backgroundColor: AppColor.primaryColor,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
padding: const EdgeInsets.symmetric(vertical: 14),
),
),
],
),
);
},
),
);
}
}
@@ -0,0 +1,296 @@
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';
import 'package:siro_driver/views/home/statistics/statistics_dashboard.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') {
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: 'Statistics'.tr,
onTap: () {
Get.to(() => StatisticsDashboard());
},
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)
// ─────────────────────────────────────────────
bool _isCheckingPendingOrder = false;
Future<void> checkForPendingOrderFromServer() async {
if (_isCheckingPendingOrder) return;
if (Get.currentRoute == '/passenger-location-map') return;
final driverId = box.read(BoxName.driverID)?.toString();
if (driverId == null) return;
_isCheckingPendingOrder = true;
try {
var response = await CRUD().post(
link: AppLink.getArgumentAfterAppliedFromBackground,
payload: {'driver_id': driverId},
);
Log.print('response: $response');
if (response != 'failure') {
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 (_) {
box.write(BoxName.rideArgumentsFromBackground, 'failure');
} finally {
_isCheckingPendingOrder = 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',
);
}
@@ -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);
}
}