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:
co-authored by
Claude Opus 5
parent
9909d9b4c1
commit
4d8414c96b
@@ -0,0 +1,210 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:siro_rider/constant/links.dart';
|
||||
import 'package:siro_rider/app_bindings.dart';
|
||||
import 'package:siro_rider/controller/functions/crud.dart';
|
||||
import 'package:siro_rider/views/home/HomePage/contact_us.dart';
|
||||
import 'package:siro_rider/views/home/HomePage/share_app_page.dart';
|
||||
import 'package:siro_rider/views/home/my_wallet/passenger_wallet.dart';
|
||||
import 'package:siro_rider/views/home/profile/passenger_profile_page.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
import 'constant/info.dart';
|
||||
import 'constant/box_name.dart';
|
||||
import 'controller/home/ios_live_activity_service.dart';
|
||||
import 'services/android_live_update_service.dart';
|
||||
import 'controller/local/local_controller.dart';
|
||||
import 'controller/local/translations.dart';
|
||||
import 'controller/firebase/local_notification.dart';
|
||||
import 'controller/themes/themes.dart';
|
||||
import 'firebase_options.dart';
|
||||
import 'models/db_sql.dart';
|
||||
import 'print.dart';
|
||||
import 'splash_screen_page.dart';
|
||||
import 'services/geofencing_service.dart';
|
||||
|
||||
// -- Global instances for easy access --
|
||||
final box = GetStorage();
|
||||
final storage = FlutterSecureStorage();
|
||||
DbSql sql = DbSql.instance;
|
||||
|
||||
// Firebase background message handler must be a top-level function.
|
||||
@pragma('vm:entry-point')
|
||||
Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
Log.print("Handling a background message: ${message.messageId}");
|
||||
|
||||
if (message.data.isNotEmpty) {
|
||||
try {
|
||||
await GetStorage.init();
|
||||
final storage = GetStorage();
|
||||
final passengerId = storage.read('passenger_id') ?? '';
|
||||
if (passengerId.toString().isEmpty) return;
|
||||
|
||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!serviceEnabled) return;
|
||||
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied ||
|
||||
permission == LocationPermission.deniedForever) return;
|
||||
|
||||
final position = await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.high);
|
||||
|
||||
final url = Uri.parse('${AppLink.server}/api/location/sync_location.php');
|
||||
await http.post(url, body: {
|
||||
'passenger_id': passengerId.toString(),
|
||||
'lat': position.latitude.toString(),
|
||||
'lng': position.longitude.toString(),
|
||||
'source': 'silent_push',
|
||||
});
|
||||
|
||||
// Update geofences on device silently
|
||||
await SiroGeofencingService.syncZonesWithServer(
|
||||
position.latitude, position.longitude);
|
||||
} catch (e) {
|
||||
Log.print("Silent push location update failed: $e");
|
||||
}
|
||||
|
||||
// 🆕 عرض الإشعارات المترجمة في الخلفية
|
||||
try {
|
||||
final category = message.data['category'] ?? '';
|
||||
if (category == 'Accepted Ride' ||
|
||||
category == 'Arrive Ride' ||
|
||||
category == 'Trip is Begin' ||
|
||||
category == 'Driver Finish Trip') {
|
||||
final storage = GetStorage();
|
||||
final lang = storage.read(BoxName.lang) ?? 'ar';
|
||||
String titleKey = '';
|
||||
String bodyKey = '';
|
||||
|
||||
if (category == 'Accepted Ride') {
|
||||
titleKey = 'Ride Accepted ✅';
|
||||
bodyKey = 'The captain is on their way to you now.';
|
||||
} else if (category == 'Arrive Ride') {
|
||||
titleKey = 'Driver is outside 🚖';
|
||||
bodyKey = 'The captain has arrived at your location.';
|
||||
} else if (category == 'Trip is Begin') {
|
||||
titleKey = 'Trip Begun 🚀';
|
||||
bodyKey = 'Have a safe and comfortable trip.';
|
||||
} else if (category == 'Driver Finish Trip') {
|
||||
titleKey = 'Trip Finished 🏁';
|
||||
bodyKey = 'Please pay and rate the driver.';
|
||||
}
|
||||
|
||||
// ترجمة باستخدام ملفات الترجمة حتى في الخلفية
|
||||
String title = titleKey;
|
||||
String body = bodyKey;
|
||||
|
||||
if (lang.toString().startsWith('ar')) {
|
||||
title = MyTranslation().keys['ar']?[titleKey] ?? titleKey;
|
||||
body = MyTranslation().keys['ar']?[bodyKey] ?? bodyKey;
|
||||
}
|
||||
|
||||
// عرض الإشعار المحلي عبر الكلاس المخصص
|
||||
await NotificationController.showBackgroundNotification(title, body, 'ding');
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print("Background local notification failed: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Use runZonedGuarded to catch all unhandled exceptions in the app.
|
||||
runZonedGuarded<Future<void>>(() async {
|
||||
// --- Step 1: Critical initializations before runApp() ---
|
||||
// These must complete before the UI can be built.
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await GetStorage.init();
|
||||
// Purge any previously stored CVV (PCI-DSS compliance)
|
||||
await storage.delete(key: BoxName.cvvCode);
|
||||
WakelockPlus.enable();
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform);
|
||||
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
|
||||
}
|
||||
// ✅ التعديل هنا: تهيئة خدمة الـ Live Activity للآيفون
|
||||
IosLiveActivityService.init();
|
||||
|
||||
// ✅ تهيئة خدمة Android Live Update (Progress Style)
|
||||
await AndroidLiveUpdateService.init();
|
||||
|
||||
// Initialize Geofencing Service only if permission is already granted to avoid auto-prompt
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission != LocationPermission.denied &&
|
||||
permission != LocationPermission.deniedForever) {
|
||||
await SiroGeofencingService.initAndStart();
|
||||
}
|
||||
}
|
||||
|
||||
// Lock screen orientation.
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
Get.put(LocaleController());
|
||||
// --- Step 2: Run the app immediately ---
|
||||
// All heavy initializations are deferred to the SplashScreen.
|
||||
runApp(const MyApp());
|
||||
}, (error, stack) {
|
||||
// Global error handler.
|
||||
final s = error.toString();
|
||||
final ignored = s.contains('PERMISSION_DENIED') ||
|
||||
s.contains('FormatException') ||
|
||||
s.contains('Null check operator used on a null value');
|
||||
|
||||
if (!ignored) {
|
||||
CRUD.addError(s, stack.toString(), 'main_zone_guard');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Get.find() is used here because LocaleController is already put in AppBindings.
|
||||
final LocaleController localController = Get.find<LocaleController>();
|
||||
|
||||
return GetMaterialApp(
|
||||
title: AppInformation.appName,
|
||||
translations: MyTranslation(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: localController.language,
|
||||
theme: localController.language?.languageCode.startsWith('ar') == true
|
||||
? lightThemeArabic
|
||||
: lightThemeEnglish,
|
||||
darkTheme: localController.language?.languageCode.startsWith('ar') == true
|
||||
? darkThemeArabic
|
||||
: darkThemeEnglish,
|
||||
themeMode: localController.themeMode,
|
||||
|
||||
// --- [CRITICAL] ---
|
||||
// initialBinding tells GetX to run AppBindings once at the start.
|
||||
// This sets up all our controllers (put, lazyPut) for the entire app lifecycle.
|
||||
initialBinding: AppBindings(),
|
||||
|
||||
initialRoute: '/',
|
||||
getPages: [
|
||||
GetPage(name: '/', page: () => const SplashScreen()),
|
||||
// These routes are used by QuickActions and other navigation events.
|
||||
GetPage(name: '/shareApp', page: () => ShareAppPage()),
|
||||
GetPage(name: '/wallet', page: () => const PassengerWallet()),
|
||||
GetPage(name: '/profile', page: () => PassengerProfilePage()),
|
||||
GetPage(name: '/contactSupport', page: () => ContactUsPage()),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user