Files
tripz-llc/apps/rider/lib/views/widgets/competitor_price_badge.dart
T
Hamza-AyedandClaude Opus 5 4d8414c96b 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>
2026-07-27 05:14:13 +03:00

155 lines
5.2 KiB
Dart

import 'package:flutter/material.dart';
/// CompetitorPriceBadge
/// ─────────────────────
/// ويدجت يعرض مقارنة ذكية بين سعر سيرو وسعر المنافسين.
/// يُستخدم في شاشة عرض الأسعار (bottomSheet) ويظهر فقط إذا توفرت
/// بيانات المنافسين من API (has_competitor_data = true).
class CompetitorPriceBadge extends StatelessWidget {
/// نسبة التوفير للراكب (مثال: 8.5 تعني "أوفر بـ 8.5%")
final double? savingsPercent;
/// النص التوضيحي الجاهز من السيرفر (مثال: "أوفر بـ 8% من التطبيقات الأخرى ⚡")
final String? savingsLabel;
/// اسم أكبر منافس للمقارنة (مثال: "Careem")
final String? topCompetitor;
const CompetitorPriceBadge({
super.key,
this.savingsPercent,
this.savingsLabel,
this.topCompetitor,
String? badgeText,
});
@override
Widget build(BuildContext context) {
// لا تُظهر الويدجت إذا لم تتوفر بيانات
if (savingsLabel == null || savingsLabel!.isEmpty) {
return const SizedBox.shrink();
}
final double pct = savingsPercent ?? 0.0;
final bool isSignificant = pct >= 5.0;
final bool isModerate = pct >= 2.0 && pct < 5.0;
// اختيار ألوان حسب قوة التوفير
final Color bgColor = isSignificant
? const Color(0xFF1A3A2A)
: isModerate
? const Color(0xFF1A2A3A)
: const Color(0xFF1F1F2E);
final Color borderColor = isSignificant
? const Color(0xFF34D399)
: isModerate
? const Color(0xFF60A5FA)
: const Color(0xFF818CF8);
final Color textColor = isSignificant
? const Color(0xFF34D399)
: isModerate
? const Color(0xFF60A5FA)
: const Color(0xFFA5B4FC);
return AnimatedOpacity(
opacity: 1.0,
duration: const Duration(milliseconds: 400),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: borderColor.withOpacity(0.5), width: 1),
boxShadow: [
BoxShadow(
color: borderColor.withOpacity(0.12),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Row(
children: [
// أيقونة التوفير
Container(
width: 32,
height: 32,
decoration: BoxDecoration(
color: borderColor.withOpacity(0.15),
shape: BoxShape.circle,
),
child: Icon(
isSignificant
? Icons.trending_down_rounded
: Icons.price_check_rounded,
color: textColor,
size: 18,
),
),
const SizedBox(width: 10),
// نص المقارنة
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
savingsLabel!,
style: TextStyle(
color: textColor,
fontSize: 12,
fontWeight: FontWeight.w700,
height: 1.3,
),
),
if (topCompetitor != null && topCompetitor!.isNotEmpty) ...[
const SizedBox(height: 2),
Text(
'مقارنةً بـ ${_formatCompetitorName(topCompetitor!)} والتطبيقات الأخرى',
style: TextStyle(
color: textColor.withOpacity(0.6),
fontSize: 10,
fontWeight: FontWeight.w400,
),
),
],
],
),
),
// شارة النسبة
if (pct >= 2.0)
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: borderColor.withOpacity(0.18),
borderRadius: BorderRadius.circular(20),
),
child: Text(
'-${pct.toStringAsFixed(1)}%',
style: TextStyle(
color: textColor,
fontSize: 11,
fontWeight: FontWeight.w800,
),
),
),
],
),
),
);
}
String _formatCompetitorName(String raw) {
final names = {
'careem': 'كريم',
'uber': 'أوبر',
'yallago': 'يلاكو',
'zaken': 'زاكن',
'tufaddal': 'تفضل',
'jeeny': 'جيني',
'taxif': 'تاكسيف',
};
return names[raw.toLowerCase()] ?? raw;
}
}