إصلاح توافق فلاتر مع Theme الجديد
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../controller/admin/promo_controller.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
import '../../widgets/my_textField.dart';
|
||||
import '../../widgets/mydialoug.dart';
|
||||
@@ -15,89 +13,110 @@ class PromoManagementPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MyScafolld(
|
||||
title: 'إدارة أكواد الخصم'.tr,
|
||||
isleading: true,
|
||||
action: IconButton(
|
||||
icon: const Icon(Icons.add_circle_outline_rounded, color: AppColor.accent),
|
||||
onPressed: () => _showPromoSheet(context),
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: cs.surface,
|
||||
appBar: AppBar(
|
||||
backgroundColor: cs.surface,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: Text('إدارة أكواد الخصم'.tr, style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: cs.onSurface)),
|
||||
leading: GestureDetector(
|
||||
onTap: () => Get.back(),
|
||||
child: Icon(Icons.arrow_back_ios_new_rounded, color: cs.onSurface),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.add_circle_outline_rounded, color: cs.primary),
|
||||
onPressed: () => _showPromoSheet(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: [
|
||||
Obx(() => controller.isLoading.value && controller.promoList.isEmpty
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: controller.promoList.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.confirmation_number_outlined, size: 64, color: AppColor.textMuted),
|
||||
const SizedBox(height: 16),
|
||||
Text('لا يوجد أكواد خصم حالياً', style: AppStyle.subtitle),
|
||||
],
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => controller.getPromos(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 80),
|
||||
itemCount: controller.promoList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final promo = controller.promoList[index];
|
||||
return _buildPromoCard(context, promo);
|
||||
},
|
||||
),
|
||||
)),
|
||||
],
|
||||
body: Obx(() => controller.isLoading.value && controller.promoList.isEmpty
|
||||
? Center(child: CircularProgressIndicator(color: cs.primary))
|
||||
: controller.promoList.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: cs.onSurfaceVariant.withValues(alpha: 0.1)),
|
||||
child: Icon(Icons.confirmation_number_outlined, size: 48, color: cs.onSurfaceVariant),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('لا يوجد أكواد خصم حالياً', style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => controller.getPromos(),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 80),
|
||||
itemCount: controller.promoList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final promo = controller.promoList[index];
|
||||
return _buildPromoCard(context, promo);
|
||||
},
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPromoCard(BuildContext context, dynamic promo) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
decoration: AppStyle.cardDecoration,
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.accentSoft,
|
||||
color: cs.primary.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.local_offer_rounded, color: AppColor.accent),
|
||||
child: Icon(Icons.local_offer_rounded, color: cs.primary),
|
||||
),
|
||||
title: Text(
|
||||
promo['promo_code']?.toString() ?? 'N/A',
|
||||
style: AppStyle.title,
|
||||
style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: cs.onSurface),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Text(promo['description']?.toString() ?? '', style: AppStyle.caption),
|
||||
Text(promo['description']?.toString() ?? '', style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.money_rounded, size: 14, color: AppColor.success),
|
||||
Icon(Icons.money_rounded, size: 14, color: const Color(0xFF10B981)),
|
||||
const SizedBox(width: 4),
|
||||
Text('% ${promo['amount']}', style: AppStyle.number.copyWith(color: AppColor.success)),
|
||||
Text('% ${promo['amount']}', style: GoogleFonts.jetBrainsMono(fontWeight: FontWeight.bold, color: const Color(0xFF10B981))),
|
||||
const SizedBox(width: 12),
|
||||
Icon(Icons.person_rounded, size: 14, color: AppColor.info),
|
||||
Icon(Icons.person_rounded, size: 14, color: cs.tertiary),
|
||||
const SizedBox(width: 4),
|
||||
Text(promo['passengerID'] == 'none' ? 'عام' : 'مخصص', style: AppStyle.caption),
|
||||
Text(promo['passengerID'] == 'none' ? 'عام' : 'مخصص', style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert_rounded, color: AppColor.textSecondary),
|
||||
color: AppColor.surfaceElevated,
|
||||
icon: Icon(Icons.more_vert_rounded, color: cs.onSurfaceVariant),
|
||||
color: cs.surfaceContainerHighest,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'edit',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.edit_rounded, size: 18, color: AppColor.info),
|
||||
Icon(Icons.edit_rounded, size: 18, color: cs.tertiary),
|
||||
const SizedBox(width: 8),
|
||||
Text('تعديل'.tr),
|
||||
],
|
||||
@@ -107,9 +126,9 @@ class PromoManagementPage extends StatelessWidget {
|
||||
value: 'delete',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.delete_outline_rounded, size: 18, color: AppColor.danger),
|
||||
Icon(Icons.delete_outline_rounded, size: 18, color: cs.error),
|
||||
const SizedBox(width: 8),
|
||||
Text('حذف'.tr, style: const TextStyle(color: AppColor.danger)),
|
||||
Text('حذف'.tr, style: TextStyle(color: cs.error)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -131,6 +150,7 @@ class PromoManagementPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _showPromoSheet(BuildContext context, {dynamic promo}) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
final TextEditingController codeController = TextEditingController(text: promo?['promo_code']);
|
||||
final TextEditingController amountController = TextEditingController(text: promo?['amount']?.toString());
|
||||
final TextEditingController descController = TextEditingController(text: promo?['description']);
|
||||
@@ -141,9 +161,9 @@ class PromoManagementPage extends StatelessWidget {
|
||||
Get.bottomSheet(
|
||||
Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColor.surfaceElevated,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
@@ -152,10 +172,10 @@ class PromoManagementPage extends StatelessWidget {
|
||||
Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(color: AppColor.divider, borderRadius: BorderRadius.circular(2)),
|
||||
decoration: BoxDecoration(color: cs.outline, borderRadius: BorderRadius.circular(2)),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(promo == null ? 'إضافة كود خصم جديد' : 'تعديل كود الخصم', style: AppStyle.headTitle),
|
||||
Text(promo == null ? 'إضافة كود خصم جديد' : 'تعديل كود الخصم', style: GoogleFonts.cairo(fontWeight: FontWeight.bold, color: cs.onSurface, fontSize: 18)),
|
||||
const SizedBox(height: 24),
|
||||
MyTextForm(
|
||||
controller: codeController,
|
||||
|
||||
Reference in New Issue
Block a user