Update: 2026-07-02 05:27:04
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// DriverEarningsBadge
|
||||
/// ─────────────────────
|
||||
/// ويدجت يعرض للسائق مقارنة أرباحه مع سيرو مقارنةً بالمنافسين.
|
||||
/// يُستخدم في شاشة قبول الطلب ليحفّز السائق على القبول.
|
||||
class DriverEarningsBadge extends StatelessWidget {
|
||||
/// النص الكامل الجاهز من السيرفر
|
||||
final String? earningsLabel;
|
||||
|
||||
/// المبلغ الإضافي الذي يكسبه السائق (موجب = أكثر مع سيرو)
|
||||
final double? extraAmount;
|
||||
|
||||
/// رمز العملة
|
||||
final String currency;
|
||||
|
||||
const DriverEarningsBadge({
|
||||
super.key,
|
||||
this.earningsLabel,
|
||||
this.extraAmount,
|
||||
this.currency = 'ل.س',
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (earningsLabel == null || earningsLabel!.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final double extra = extraAmount ?? 0;
|
||||
final bool isPositive = extra >= 0;
|
||||
|
||||
return AnimatedOpacity(
|
||||
opacity: 1.0,
|
||||
duration: const Duration(milliseconds: 350),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: isPositive
|
||||
? [const Color(0xFF064E3B), const Color(0xFF065F46)]
|
||||
: [const Color(0xFF1E1B4B), const Color(0xFF312E81)],
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isPositive
|
||||
? const Color(0xFF10B981).withOpacity(0.4)
|
||||
: const Color(0xFF818CF8).withOpacity(0.4),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
isPositive ? Icons.attach_money_rounded : Icons.info_outline_rounded,
|
||||
color: isPositive
|
||||
? const Color(0xFF34D399)
|
||||
: const Color(0xFFA5B4FC),
|
||||
size: 22,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
earningsLabel!,
|
||||
style: TextStyle(
|
||||
color: isPositive
|
||||
? const Color(0xFF34D399)
|
||||
: const Color(0xFFA5B4FC),
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (extra > 0)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF10B981).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF10B981).withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'+${extra.toStringAsFixed(2)} $currency',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF34D399),
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user