Update: 2026-06-26 17:29:23

This commit is contained in:
Hamza-Ayed
2026-06-26 17:29:23 +03:00
parent a323da29aa
commit 9ded734e38
139 changed files with 1815 additions and 2676 deletions

View File

@@ -214,7 +214,7 @@ class MarketingPage extends StatelessWidget {
const SizedBox(width: 24),
_buildStatItem(
'الفارق',
'${((double.tryParse(anomaly['competitor_price']?.toString() ?? '0') ?? 0) - (double.tryParse(anomaly['our_price']?.toString() ?? '0') ?? 0)).toStringAsFixed(2)}',
((double.tryParse(anomaly['competitor_price']?.toString() ?? '0') ?? 0) - (double.tryParse(anomaly['our_price']?.toString() ?? '0') ?? 0)).toStringAsFixed(2),
_info,
),
],
@@ -264,7 +264,7 @@ class MarketingPage extends StatelessWidget {
: 0.0;
List<FlSpot> competitorSpots = [];
if (hourlyData is List && hourlyData.isNotEmpty) {
if (hourlyData.isNotEmpty) {
for (int i = 0; i < hourlyData.length && i < 24; i++) {
final val = hourlyData[i];
final double avg = double.tryParse((val['avg_price_per_km'] ?? 0).toString()) ?? 0.0;
@@ -280,7 +280,7 @@ class MarketingPage extends StatelessWidget {
List<FlSpot> siroSpots = [];
if (siroSpeedPrice > 0) {
for (int i = 0; i < (hourlyData is List ? hourlyData.length : 1); i++) {
for (int i = 0; i < hourlyData.length; i++) {
siroSpots.add(FlSpot(i.toDouble(), siroSpeedPrice));
}
}
@@ -303,7 +303,7 @@ class MarketingPage extends StatelessWidget {
),
const SizedBox(height: 4),
Text(
hourlyData is List && hourlyData.isNotEmpty
hourlyData.isNotEmpty
? 'مقارنة أسعار Siro مقابل متوسط المنافسين لآخر ${hourlyData.length} ساعة'
: 'مقارنة أسعار Siro مقابل متوسط المنافسين لآخر 24 ساعة',
style: const TextStyle(fontSize: 10, color: _textSecondary),
@@ -346,7 +346,7 @@ class MarketingPage extends StatelessWidget {
),
borderData: FlBorderData(show: false),
minX: 0,
maxX: ((hourlyData is List ? hourlyData.length : 1) - 1).toDouble(),
maxX: (hourlyData.length - 1).toDouble(),
minY: 0,
maxY: chartMaxY,
lineBarsData: [
@@ -391,10 +391,8 @@ class MarketingPage extends StatelessWidget {
return GetBuilder<MarketingController>(
builder: (c) {
final heatmapList = c.heatmapData;
final siroSpeedPrice = c.currentSiroPriceHeatmap;
List<Map<String, dynamic>> regions = [];
if (heatmapList is List && heatmapList.isNotEmpty) {
if (heatmapList.isNotEmpty) {
for (final item in heatmapList) {
final double pci = double.tryParse(item['pci'].toString()) ?? 1.0;
final pct = ((1 - pci) * 100).abs().toStringAsFixed(1);
@@ -433,7 +431,6 @@ class MarketingPage extends StatelessWidget {
),
const SizedBox(height: 12),
...regions.map((region) {
final pciVal = (region['pci'] as num).toDouble();
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Column(
@@ -462,7 +459,7 @@ class MarketingPage extends StatelessWidget {
],
),
);
}).toList(),
}),
],
),
),
@@ -725,7 +722,7 @@ class MarketingPage extends StatelessWidget {
style: const TextStyle(fontSize: 10, color: _textSecondary),
),
value: c.isAutopilotEnabled,
activeColor: _accent,
activeThumbColor: _accent,
onChanged: c.toggleAutopilot,
),
),
@@ -978,65 +975,4 @@ class MarketingPage extends StatelessWidget {
);
}
Widget _buildWinbackCampaignsSection(BuildContext context, MarketingController c) {
return Card(
color: _surface,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16), side: const BorderSide(color: _divider)),
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(
children: [
Icon(Icons.radar, color: _accent, size: 24),
SizedBox(width: 8),
Text('حملات استعادة العملاء (Win-Back)', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: _textPrimary)),
],
),
const SizedBox(height: 8),
const Text(
'يتم البحث عن الركاب المنقطعين عن التطبيق والذين يتواجدون حالياً بالقرب من مناطق تشهد أسعار ذروة لدى المنافسين.',
style: TextStyle(color: _textSecondary, fontSize: 11),
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: ElevatedButton.icon(
onPressed: () => c.fetchWinbackTargets(),
icon: const Icon(Icons.person_search, size: 18),
label: const Text('بحث عن أهداف حالية'),
style: ElevatedButton.styleFrom(
backgroundColor: _accent.withOpacity(0.1),
foregroundColor: _accent,
elevation: 0,
),
),
),
if (c.winbackTotalCount > 0) ...[
const SizedBox(width: 12),
Expanded(
child: ElevatedButton.icon(
onPressed: () {
// TODO: Implement trigger specific winback campaign
Get.snackbar("Campaign Triggered", "SMS sent to ${c.winbackTotalCount} targets");
},
icon: const Icon(Icons.send),
label: Text('إرسال SMS لـ ${c.winbackTotalCount}'),
style: ElevatedButton.styleFrom(
backgroundColor: _success,
foregroundColor: Colors.white,
),
),
),
]
],
),
],
),
),
);
}
}