Update codebase
This commit is contained in:
@@ -0,0 +1,294 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../controller/insurance/driver_insurance_controller.dart';
|
||||
import '../../widgets/ui/siro_ui.dart';
|
||||
|
||||
/// شاشة التأمين: الوثيقة النشطة ودفترها، أو الخطط المتاحة.
|
||||
///
|
||||
/// الحالتان لا تظهران معاً — من له وثيقة يرى وثيقته، ومن لا وثيقة له
|
||||
/// يرى الخطط. عرض الاثنين كان سيوحي أن الاشتراك في ثانية ممكن، وهو
|
||||
/// ليس كذلك: تبديل الخطة يمرّ بإلغاء صريح ليبقى في السجل أثر.
|
||||
class DriverInsurancePage extends StatelessWidget {
|
||||
const DriverInsurancePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = Get.put(DriverInsuranceController());
|
||||
|
||||
return SiroPage(
|
||||
title: 'Insurance'.tr,
|
||||
body: Obx(() {
|
||||
if (c.isLoading.value) {
|
||||
return const SiroLoading();
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: c.refreshAll,
|
||||
color: SiroUi.interactive(context),
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: SiroUi.pageInsets,
|
||||
children:
|
||||
c.hasPolicy ? _policyView(context, c) : _plansView(context, c),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ── الوثيقة النشطة ─────────────────────────────────────────
|
||||
List<Widget> _policyView(BuildContext context, DriverInsuranceController c) {
|
||||
final p = c.policy.value!;
|
||||
|
||||
return [
|
||||
SiroCard(
|
||||
accent: AppColor.greenColor,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SiroIconBadge(Icons.verified_user_rounded,
|
||||
color: AppColor.greenColor),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${p['plan'] ?? ''}',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text('${p['provider'] ?? ''}',
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_row('Premium'.tr,
|
||||
'${p['premium']} ${p['currency']} / '
|
||||
'${p['billing_cycle'] == 'monthly' ? 'Monthly'.tr : 'Daily'.tr}'),
|
||||
_row('Started on'.tr, '${p['started_at'] ?? '—'}'),
|
||||
if ((p['policy_number'] ?? '').toString().isNotEmpty)
|
||||
_row('Policy number'.tr, '${p['policy_number']}'),
|
||||
if ((p['coverage'] ?? '').toString().isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text('${p['coverage']}',
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ── دفتر الأقساط ──
|
||||
// يظهر في نفس الشاشة لا في أخرى: الخصم الذي لا يرى السائق مقابله
|
||||
// مفاجأة تُفقد الثقة، مهما كان مشروحاً في مكان آخر.
|
||||
SiroCard(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Premium ledger'.tr,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 8),
|
||||
_row('Outstanding'.tr,
|
||||
'${c.pendingTotal.toStringAsFixed(2)} ${c.currency}'),
|
||||
_row('Settled'.tr,
|
||||
'${ledgerNum(c.ledger['settled_total'])} ${c.currency}'),
|
||||
if (c.entries.isNotEmpty) ...[
|
||||
const Divider(height: 24),
|
||||
...c.entries.take(10).map((e) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('${e['charge_date']}',
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
Text('${e['amount']} ${e['currency']}',
|
||||
style: TextStyle(
|
||||
color: e['status'] == 'settled'
|
||||
? AppColor.greenColor
|
||||
: AppColor.yellowColor,
|
||||
fontWeight: FontWeight.w700,
|
||||
)),
|
||||
],
|
||||
),
|
||||
)),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
OutlinedButton.icon(
|
||||
onPressed:
|
||||
c.isSubmitting.value ? null : () => _confirmCancel(context, c),
|
||||
icon: const Icon(Icons.cancel_outlined, size: 18),
|
||||
label: Text('Cancel policy'.tr),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppColor.redColor,
|
||||
side: const BorderSide(color: AppColor.redColor),
|
||||
minimumSize: const Size.fromHeight(48),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
];
|
||||
}
|
||||
|
||||
// ── الخطط المتاحة ──────────────────────────────────────────
|
||||
List<Widget> _plansView(BuildContext context, DriverInsuranceController c) {
|
||||
if (c.plans.isEmpty) {
|
||||
// الصفحة كانت تبدو "معطّلة" لأنها تعرض عنواناً واحداً بلا سبب.
|
||||
// الحالة الحقيقية: لا خطط مُفعّلة بعد لدى الشركاء — لا خطأ ولا
|
||||
// نقص أهلية — ونقولها صراحة حتى لا يظن الكابتن أن التطبيق خربان.
|
||||
return [
|
||||
const SizedBox(height: 48),
|
||||
SiroEmptyState(
|
||||
icon: Icons.health_and_safety_outlined,
|
||||
title: 'No insurance plans available yet'.tr,
|
||||
message:
|
||||
'Insurance plans have not been launched in your area yet. Once a partner plan is available it will appear here automatically.'
|
||||
.tr,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return c.plans.map((plan) {
|
||||
final eligible = plan['eligible'] == true;
|
||||
final missing = (plan['missing'] as List?) ?? [];
|
||||
final progress = (plan['progress_rides'] ?? 0) as num;
|
||||
final required = (plan['required_rides'] ?? 0) as num;
|
||||
|
||||
return SiroCard(
|
||||
accent: eligible ? AppColor.greenColor : null,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text('${plan['name'] ?? ''}',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
if (eligible)
|
||||
SiroTag('Eligible'.tr,
|
||||
color: AppColor.greenColor,
|
||||
icon: Icons.check_circle_rounded),
|
||||
],
|
||||
),
|
||||
Text('${plan['provider'] ?? ''}',
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'${plan['premium']} ${plan['currency']} / '
|
||||
'${plan['billing_cycle'] == 'monthly' ? 'Monthly'.tr : 'Daily'.tr}',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: SiroUi.interactive(context),
|
||||
),
|
||||
),
|
||||
if ((plan['coverage'] ?? '').toString().isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text('${plan['coverage']}',
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
|
||||
// شريط التقدّم نحو الشرط — الرقم وحده لا يحرّك أحداً،
|
||||
// ورؤية القرب من الهدف تفعل.
|
||||
if (!eligible && required > 0) ...[
|
||||
const SizedBox(height: 12),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 7,
|
||||
value: required == 0 ? 0 : (progress / required).clamp(0, 1),
|
||||
backgroundColor: SiroUi.border(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text('$progress / $required ${'rides'.tr}',
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
],
|
||||
|
||||
if (!eligible && missing.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
...missing.map((m) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(Icons.lock_outline,
|
||||
size: 14, color: AppColor.yellowColor),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text('$m',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColor.yellowColor)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
|
||||
const SizedBox(height: 14),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: (!eligible || c.isSubmitting.value)
|
||||
? null
|
||||
: () => c.subscribe(plan['id'] as int),
|
||||
child:
|
||||
Text(eligible ? 'Subscribe'.tr : 'Not eligible yet'.tr),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
void _confirmCancel(BuildContext context, DriverInsuranceController c) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Cancel policy'.tr),
|
||||
// نصرّح بأن المستحق السابق يبقى: الإلغاء يوقف القادم ولا يمحو
|
||||
// أياماً استُفيد من تغطيتها فعلاً.
|
||||
content: Text(c.pendingTotal > 0
|
||||
? '${'Cancelling stops future premiums. Outstanding dues remain payable.'.tr}\n\n'
|
||||
'${'Outstanding'.tr}: ${c.pendingTotal.toStringAsFixed(2)} ${c.currency}'
|
||||
: 'Cancelling stops future premiums. Outstanding dues remain payable.'.tr),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: Text('Back'.tr),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
c.cancel();
|
||||
},
|
||||
child: Text('Confirm'.tr,
|
||||
style: const TextStyle(color: AppColor.redColor)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String ledgerNum(dynamic v) =>
|
||||
(double.tryParse('${v ?? 0}') ?? 0).toStringAsFixed(2);
|
||||
|
||||
Widget _row(String label, String value) =>
|
||||
SiroDetailRow(label: label, value: value);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../controller/scheduled/driver_scheduled_rides_controller.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../widgets/ui/siro_ui.dart';
|
||||
|
||||
class DriverScheduledRidesPage extends StatelessWidget {
|
||||
const DriverScheduledRidesPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = Get.put(DriverScheduledRidesController());
|
||||
|
||||
return SiroPage(
|
||||
title: 'Upcoming Scheduled Rides'.tr,
|
||||
body: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
return const SiroLoading();
|
||||
}
|
||||
|
||||
// تعذّر الجلب: نقولها بدل ادّعاء "لا حجوزات" — الفرق بينهما
|
||||
// هو الفرق بين كابتن يطمئن وكابتن يفوته عمل مؤكد.
|
||||
if (controller.hasError.value) {
|
||||
return SiroErrorState(
|
||||
message: '${'Could not load scheduled rides'.tr}\n'
|
||||
'${'Please check your connection and try again.'.tr}',
|
||||
onRetry: controller.fetch,
|
||||
);
|
||||
}
|
||||
|
||||
if (controller.bookings.isEmpty) {
|
||||
return SiroEmptyState(
|
||||
icon: Icons.calendar_month_rounded,
|
||||
title: 'You have no upcoming scheduled rides'.tr,
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: controller.fetch,
|
||||
color: SiroUi.interactive(context),
|
||||
child: ListView.builder(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: SiroUi.pageInsets,
|
||||
itemCount: controller.bookings.length,
|
||||
itemBuilder: (context, index) {
|
||||
final booking = controller.bookings[index];
|
||||
return _buildBookingCard(booking, context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBookingCard(Map<String, dynamic> booking, BuildContext context) {
|
||||
return SiroCard(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: SiroTag(
|
||||
booking['scheduled_at'] ?? '',
|
||||
color: SiroUi.interactive(context),
|
||||
icon: Icons.access_time_rounded,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${booking['estimated_price']} ${'Currency'.tr}',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.greenColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.my_location_rounded,
|
||||
color: AppColor.greenColor, size: 18),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
booking['start_name'] ?? 'Starting Point'.tr,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.location_on_rounded,
|
||||
color: AppColor.redColor, size: 18),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
booking['end_name'] ?? 'Destination'.tr,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../constant/finance_design_system.dart';
|
||||
import '../../../controller/home/journal/schedule_controller.dart';
|
||||
import '../../widgets/ui/siro_ui.dart';
|
||||
|
||||
class SchedulePage extends StatelessWidget {
|
||||
SchedulePage({super.key});
|
||||
@@ -9,71 +9,34 @@ class SchedulePage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: FinanceDesignSystem.backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text('My Schedule'.tr,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: FinanceDesignSystem.primaryDark)),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back_ios_new_rounded,
|
||||
color: FinanceDesignSystem.primaryDark, size: 20),
|
||||
onPressed: () => Get.back()),
|
||||
),
|
||||
return SiroPage(
|
||||
title: 'My Schedule'.tr,
|
||||
padding: SiroUi.pageInsets,
|
||||
body: GetBuilder<ScheduleController>(builder: (sc) {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child:
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
// Summary Card
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: FinanceDesignSystem.balanceGradient,
|
||||
borderRadius:
|
||||
BorderRadius.circular(FinanceDesignSystem.cardRadius),
|
||||
),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Weekly Plan'.tr,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.7),
|
||||
fontSize: 14)),
|
||||
const SizedBox(height: 8),
|
||||
Text('${sc.totalWeeklyHours.toStringAsFixed(1)}h',
|
||||
style: const TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white)),
|
||||
Text('${sc.activeDays} ${'Days'.tr}',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.6),
|
||||
fontSize: 13)),
|
||||
])),
|
||||
Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SiroHeroHeader(
|
||||
label: 'Weekly Plan'.tr,
|
||||
value: '${sc.totalWeeklyHours.toStringAsFixed(1)}h',
|
||||
caption: '${sc.activeDays} ${'Days'.tr}',
|
||||
icon: Icons.calendar_today_rounded,
|
||||
trailing: Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(14)),
|
||||
child: const Icon(Icons.calendar_today_rounded,
|
||||
color: Colors.white, size: 28),
|
||||
color: Colors.white.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: const Icon(Icons.calendar_month_rounded,
|
||||
color: Colors.white, size: 26),
|
||||
),
|
||||
]),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
Text('Work Days'.tr, style: FinanceDesignSystem.headingStyle),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
...sc.schedule.map((slot) => _buildDayCard(context, slot, sc)),
|
||||
]),
|
||||
),
|
||||
SiroSectionTitle('Work Days'.tr),
|
||||
...sc.schedule.map((slot) => _buildDayCard(context, slot, sc)),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -82,76 +45,72 @@ class SchedulePage extends StatelessWidget {
|
||||
Widget _buildDayCard(
|
||||
BuildContext context, WorkSlot slot, ScheduleController sc) {
|
||||
final isAr = Get.locale?.languageCode == 'ar';
|
||||
return Container(
|
||||
final accent = SiroUi.interactive(context);
|
||||
final off = SiroUi.subtle(context);
|
||||
|
||||
return SiroCard(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: slot.isActive ? Colors.white : Colors.grey.shade50,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: slot.isActive
|
||||
? [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.03),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 3))
|
||||
]
|
||||
: null,
|
||||
),
|
||||
accent: slot.isActive ? accent : null,
|
||||
child: Row(children: [
|
||||
// Toggle
|
||||
GestureDetector(
|
||||
onTap: () => sc.toggleDay(slot.dayOfWeek),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
width: 44,
|
||||
height: 44,
|
||||
width: 42,
|
||||
height: 42,
|
||||
decoration: BoxDecoration(
|
||||
color: slot.isActive
|
||||
? FinanceDesignSystem.accentBlue.withValues(alpha: 0.1)
|
||||
: Colors.grey.shade200,
|
||||
? accent.withValues(alpha: 0.12)
|
||||
: off.withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
isAr ? slot.dayNameAr.substring(0, 2) : slot.dayName,
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
isAr ? slot.dayNameAr.substring(0, 2) : slot.dayName,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: slot.isActive
|
||||
? FinanceDesignSystem.accentBlue
|
||||
: Colors.grey.shade400),
|
||||
)),
|
||||
color: slot.isActive ? accent : off,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
const SizedBox(width: 12),
|
||||
// Day name
|
||||
Expanded(
|
||||
child:
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(isAr ? slot.dayNameAr : slot.dayName.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: slot.isActive
|
||||
? FinanceDesignSystem.primaryDark
|
||||
: Colors.grey.shade400)),
|
||||
if (slot.isActive)
|
||||
Text(slot.timeRange,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade500)),
|
||||
if (!slot.isActive)
|
||||
Text('Day Off'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade400,
|
||||
fontStyle: FontStyle.italic)),
|
||||
])),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
isAr ? slot.dayNameAr : slot.dayName.tr,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: slot.isActive ? null : off,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
slot.isActive ? slot.timeRange : 'Day Off'.tr,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
fontSize: 12,
|
||||
fontStyle:
|
||||
slot.isActive ? FontStyle.normal : FontStyle.italic,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Time pickers
|
||||
if (slot.isActive) ...[
|
||||
_timePicker(context, slot.startTime,
|
||||
(t) => sc.updateStartTime(slot.dayOfWeek, t)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text('-', style: TextStyle(color: Colors.grey.shade400))),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Text('-', style: TextStyle(color: off)),
|
||||
),
|
||||
_timePicker(context, slot.endTime,
|
||||
(t) => sc.updateEndTime(slot.dayOfWeek, t)),
|
||||
],
|
||||
@@ -159,7 +118,7 @@ class SchedulePage extends StatelessWidget {
|
||||
Switch(
|
||||
value: slot.isActive,
|
||||
onChanged: (_) => sc.toggleDay(slot.dayOfWeek),
|
||||
activeThumbColor: FinanceDesignSystem.accentBlue,
|
||||
activeThumbColor: accent,
|
||||
),
|
||||
]),
|
||||
);
|
||||
@@ -174,16 +133,19 @@ class SchedulePage extends StatelessWidget {
|
||||
if (picked != null) onChanged(picked);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(8)),
|
||||
color: SiroUi.interactive(context).withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: FinanceDesignSystem.primaryDark)),
|
||||
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: SiroUi.interactive(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user