إصلاح توافق فلاتر مع Theme الجديد
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
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/kazan_controller.dart';
|
||||
import '../../../views/widgets/snackbar.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import '../../widgets/elevated_btn.dart';
|
||||
|
||||
class KazanEditorPage extends StatelessWidget {
|
||||
@@ -14,63 +12,72 @@ class KazanEditorPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MyScafolld(
|
||||
title: 'تعديل أسعار كازان'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
Column(
|
||||
children: [
|
||||
_buildCountryDropdown(),
|
||||
Expanded(
|
||||
child: Obx(() => controller.isLoading.value && controller.kazanData.isEmpty
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSectionHeader('⚙️ الإعدادات العامة'),
|
||||
_buildGeneralSettings(),
|
||||
const SizedBox(height: 24),
|
||||
_buildSectionHeader('🚗 أسعار الكيلومتر لكل نوع سيارة'),
|
||||
_buildKmPricesGrid(),
|
||||
const SizedBox(height: 24),
|
||||
_buildSectionHeader('⏱️ أسعار الدقيقة (حسب وقت اليوم)'),
|
||||
_buildMinutePrices(),
|
||||
const SizedBox(height: 32),
|
||||
MyElevatedButton(
|
||||
title: '💾 حفظ جميع التعديلات',
|
||||
icon: Icons.save_rounded,
|
||||
onPressed: () => _handleSave(),
|
||||
),
|
||||
const SizedBox(height: 100),
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_buildCountryDropdown(cs),
|
||||
Expanded(
|
||||
child: Obx(() => controller.isLoading.value && controller.kazanData.isEmpty
|
||||
? Center(child: CircularProgressIndicator(color: cs.primary))
|
||||
: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSectionHeader('⚙️ الإعدادات العامة', cs),
|
||||
_buildGeneralSettings(cs),
|
||||
const SizedBox(height: 24),
|
||||
_buildSectionHeader('🚗 أسعار الكيلومتر لكل نوع سيارة', cs),
|
||||
_buildKmPricesGrid(cs),
|
||||
const SizedBox(height: 24),
|
||||
_buildSectionHeader('⏱️ أسعار الدقيقة (حسب وقت اليوم)', cs),
|
||||
_buildMinutePrices(cs),
|
||||
const SizedBox(height: 32),
|
||||
MyElevatedButton(
|
||||
title: '💾 حفظ جميع التعديلات',
|
||||
icon: Icons.save_rounded,
|
||||
onPressed: () => _handleSave(),
|
||||
),
|
||||
const SizedBox(height: 100),
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCountryDropdown() {
|
||||
Widget _buildCountryDropdown(ColorScheme cs) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||
child: Obx(() => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.surface,
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColor.divider),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
value: controller.selectedCountry.value,
|
||||
isExpanded: true,
|
||||
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
style: AppStyle.title.copyWith(fontSize: 16),
|
||||
style: GoogleFonts.inter(fontWeight: FontWeight.w600, fontSize: 16, color: cs.onSurface),
|
||||
items: controller.countries.map((c) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: c['name'],
|
||||
@@ -92,13 +99,14 @@ class KazanEditorPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// 1. الإعدادات العامة
|
||||
// ====================================================================
|
||||
Widget _buildGeneralSettings() {
|
||||
Widget _buildGeneralSettings(ColorScheme cs) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: AppStyle.cardDecoration,
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSliderItem(
|
||||
@@ -106,31 +114,30 @@ class KazanEditorPage extends StatelessWidget {
|
||||
'kazanPercent',
|
||||
'النسبة المئوية التي تقتطعها المنصة من كل رحلة',
|
||||
Icons.percent_rounded,
|
||||
cs,
|
||||
),
|
||||
const Divider(height: 32, color: AppColor.divider),
|
||||
Divider(height: 32, color: cs.outline),
|
||||
_buildPriceInputRow(
|
||||
'سعر الوقود المرجعي',
|
||||
'fuelPrice',
|
||||
'السعر المستخدم في حسابات تعويض الوقود',
|
||||
Icons.local_gas_station_rounded,
|
||||
cs,
|
||||
),
|
||||
const Divider(height: 32, color: AppColor.divider),
|
||||
Divider(height: 32, color: cs.outline),
|
||||
_buildPriceInputRow(
|
||||
'رمز العملة',
|
||||
'currency',
|
||||
'مثال: SYP, EGP, JOD, IQD',
|
||||
Icons.currency_exchange_rounded,
|
||||
cs,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// 2. أسعار الكيلومتر - كل نوع سيارة له حقل خاص به
|
||||
// ====================================================================
|
||||
Widget _buildKmPricesGrid() {
|
||||
// 🆕 9 أنواع سيارات - كل واحد له عمود سعر مستقل
|
||||
Widget _buildKmPricesGrid(ColorScheme cs) {
|
||||
final Map<String, Map<String, dynamic>> priceFields = {
|
||||
'speedPrice': {
|
||||
'label': 'Speed ⚡',
|
||||
@@ -180,13 +187,17 @@ class KazanEditorPage extends StatelessWidget {
|
||||
};
|
||||
|
||||
return Container(
|
||||
decoration: AppStyle.cardDecoration,
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3, // 3 أعمدة بدلاً من 2
|
||||
crossAxisCount: 3,
|
||||
childAspectRatio: 1.8,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
@@ -196,14 +207,14 @@ class KazanEditorPage extends StatelessWidget {
|
||||
String key = priceFields.keys.elementAt(index);
|
||||
var field = priceFields[key]!;
|
||||
return _buildKmPriceCard(
|
||||
key, field['label'], field['icon'], field['color']);
|
||||
key, field['label'], field['icon'], field['color'], cs);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildKmPriceCard(
|
||||
String key, String label, IconData icon, Color color) {
|
||||
String key, String label, IconData icon, Color color, ColorScheme cs) {
|
||||
final TextEditingController textController =
|
||||
TextEditingController(text: _getValue(key));
|
||||
|
||||
@@ -225,8 +236,7 @@ class KazanEditorPage extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: AppStyle.caption
|
||||
.copyWith(fontSize: 10, fontWeight: FontWeight.bold),
|
||||
style: GoogleFonts.inter(fontSize: 10, fontWeight: FontWeight.bold, color: cs.onSurfaceVariant),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
@@ -240,7 +250,7 @@ class KazanEditorPage extends StatelessWidget {
|
||||
controller: textController,
|
||||
keyboardType: TextInputType.number,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.number.copyWith(fontSize: 13, color: color),
|
||||
style: GoogleFonts.jetBrainsMono(fontSize: 13, fontWeight: FontWeight.bold, color: color),
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
@@ -256,10 +266,7 @@ class KazanEditorPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// 3. أسعار الدقيقة (حسب وقت اليوم)
|
||||
// ====================================================================
|
||||
Widget _buildMinutePrices() {
|
||||
Widget _buildMinutePrices(ColorScheme cs) {
|
||||
final Map<String, Map<String, dynamic>> minuteFields = {
|
||||
'normalMinPrice': {
|
||||
'label': 'Normal (سعر الدقيقة العادي)',
|
||||
@@ -282,7 +289,11 @@ class KazanEditorPage extends StatelessWidget {
|
||||
};
|
||||
|
||||
return Container(
|
||||
decoration: AppStyle.cardDecoration,
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: minuteFields.entries.map((entry) {
|
||||
@@ -293,6 +304,7 @@ class KazanEditorPage extends StatelessWidget {
|
||||
entry.key,
|
||||
entry.value['desc'],
|
||||
entry.value['icon'],
|
||||
cs,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
@@ -300,15 +312,12 @@ class KazanEditorPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// دوال مساعدة للـ UI
|
||||
// ====================================================================
|
||||
Widget _buildSectionHeader(String title) {
|
||||
Widget _buildSectionHeader(String title, ColorScheme cs) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12, left: 4),
|
||||
child: Text(
|
||||
title,
|
||||
style: AppStyle.title.copyWith(color: AppColor.accent),
|
||||
style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: cs.primary),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -322,21 +331,21 @@ class KazanEditorPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildPriceInputRow(
|
||||
String title, String key, String desc, IconData icon) {
|
||||
String title, String key, String desc, IconData icon, ColorScheme cs) {
|
||||
final TextEditingController textController =
|
||||
TextEditingController(text: _getValue(key));
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: AppColor.accent),
|
||||
Icon(icon, size: 20, color: cs.primary),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title,
|
||||
style: AppStyle.body.copyWith(fontWeight: FontWeight.bold)),
|
||||
Text(desc, style: AppStyle.caption.copyWith(fontSize: 10)),
|
||||
style: GoogleFonts.inter(fontSize: 14, color: cs.onSurface, fontWeight: FontWeight.bold)),
|
||||
Text(desc, style: GoogleFonts.inter(fontSize: 10, color: cs.onSurfaceVariant)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -344,16 +353,15 @@ class KazanEditorPage extends StatelessWidget {
|
||||
width: 100,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.surfaceElevated,
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.divider),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: TextField(
|
||||
controller: textController,
|
||||
keyboardType: TextInputType.number,
|
||||
textAlign: TextAlign.center,
|
||||
style:
|
||||
AppStyle.number.copyWith(fontSize: 16, color: AppColor.accent),
|
||||
style: GoogleFonts.jetBrainsMono(fontSize: 16, fontWeight: FontWeight.bold, color: cs.primary),
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
@@ -367,7 +375,7 @@ class KazanEditorPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildSliderItem(
|
||||
String title, String key, String desc, IconData icon) {
|
||||
String title, String key, String desc, IconData icon, ColorScheme cs) {
|
||||
double value = double.tryParse(_getValue(key)) ?? 0;
|
||||
|
||||
return Column(
|
||||
@@ -378,25 +386,25 @@ class KazanEditorPage extends StatelessWidget {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: AppColor.accent),
|
||||
Icon(icon, size: 18, color: cs.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text(title, style: AppStyle.title),
|
||||
Text(title, style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: cs.onSurface)),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'${value.toInt()}%',
|
||||
style: AppStyle.number.copyWith(fontSize: 18),
|
||||
style: GoogleFonts.jetBrainsMono(fontSize: 18, fontWeight: FontWeight.bold, color: cs.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(desc, style: AppStyle.caption),
|
||||
Text(desc, style: GoogleFonts.inter(color: cs.onSurfaceVariant, fontSize: 12)),
|
||||
Slider(
|
||||
value: value.clamp(0, 100),
|
||||
min: 0,
|
||||
max: 100,
|
||||
activeColor: AppColor.accent,
|
||||
inactiveColor: AppColor.divider,
|
||||
activeColor: cs.primary,
|
||||
inactiveColor: cs.outline,
|
||||
onChanged: (val) {
|
||||
_setValue(key, val.toInt().toString());
|
||||
},
|
||||
@@ -405,14 +413,10 @@ class KazanEditorPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// حفظ البيانات
|
||||
// ====================================================================
|
||||
void _handleSave() async {
|
||||
final data = Map<String, dynamic>.from(controller.kazanData);
|
||||
data['adminId'] = 'admin1';
|
||||
|
||||
// التأكد من وجود country
|
||||
if (!data.containsKey('country') ||
|
||||
data['country'] == null ||
|
||||
data['country'].toString().isEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user