إصلاح توافق فلاتر مع Theme الجديد
This commit is contained in:
@@ -1,81 +1,255 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_admin/constant/style.dart';
|
||||
import 'package:siro_admin/views/widgets/elevated_btn.dart';
|
||||
import 'package:siro_admin/views/widgets/mycircular.dart';
|
||||
|
||||
import '../../../controller/admin/wallet_admin_controller.dart';
|
||||
import '../../widgets/my_scafold.dart';
|
||||
import '../../widgets/mycircular.dart';
|
||||
|
||||
class Wallet extends StatelessWidget {
|
||||
Wallet({super.key});
|
||||
final WalletAdminController walletAdminController =
|
||||
Get.put(WalletAdminController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MyScafolld(
|
||||
title: 'Wallet'.tr,
|
||||
body: [
|
||||
GetBuilder<WalletAdminController>(builder: (walletAdminController) {
|
||||
return Center(
|
||||
child: walletAdminController.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: Column(
|
||||
children: [
|
||||
MyElevatedButton(
|
||||
title: 'Pay to them to banks'.tr,
|
||||
onPressed: () async {
|
||||
await walletAdminController.payToBankDriverAll();
|
||||
}),
|
||||
SizedBox(
|
||||
height: Get.height * .8,
|
||||
child: ListView.builder(
|
||||
itemCount:
|
||||
walletAdminController.driversWalletPoints.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var res = walletAdminController
|
||||
.driversWalletPoints[index];
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
if (res != null && res['name_arabic'] != null) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Container(
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'driver name: ${res['name_arabic'].toString()}'),
|
||||
Text(
|
||||
'Amount: ${res['total_amount'].toString()}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container(); // Return an empty container if the data is null
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
return Scaffold(
|
||||
backgroundColor: cs.surface,
|
||||
body: Column(
|
||||
children: [
|
||||
_buildAppBar(context, cs),
|
||||
Expanded(
|
||||
child: GetBuilder<WalletAdminController>(
|
||||
builder: (controller) {
|
||||
if (controller.isLoading) {
|
||||
return _buildLoadingState(cs);
|
||||
}
|
||||
|
||||
if (controller.driversWalletPoints.isEmpty) {
|
||||
return _buildEmptyState(cs);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
_buildPayAllButton(context, controller, cs),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 80),
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: controller.driversWalletPoints.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, index) {
|
||||
var res = controller.driversWalletPoints[index];
|
||||
if (res != null && res['name_arabic'] != null) {
|
||||
return _buildWalletCard(res, cs);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context, ColorScheme cs) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(16, 50, 16, 16),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surface,
|
||||
border: Border(bottom: BorderSide(color: cs.outline)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.back(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Icon(Icons.arrow_back_ios_new_rounded,
|
||||
color: cs.onSurfaceVariant, size: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.primary.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: cs.primary.withValues(alpha: 0.25)),
|
||||
),
|
||||
child: Icon(Icons.account_balance_wallet_rounded,
|
||||
color: cs.primary, size: 18),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
'المحافظ المالية',
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
walletAdminController.getWalletForEachDriverToPay();
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Icon(Icons.refresh_rounded,
|
||||
color: cs.onSurfaceVariant, size: 18),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingState(ColorScheme cs) {
|
||||
return const Center(child: MyCircularProgressIndicator());
|
||||
}
|
||||
|
||||
Widget _buildEmptyState(ColorScheme cs) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(Icons.account_balance_wallet_rounded,
|
||||
size: 48, color: cs.onSurfaceVariant),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('لا توجد محافظ مالية',
|
||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPayAllButton(
|
||||
BuildContext context, WalletAdminController controller, ColorScheme cs) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.send_rounded, color: Colors.white, size: 18),
|
||||
label: Text(
|
||||
'دفع الجميع للبنوك',
|
||||
style: const TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: cs.primary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14)),
|
||||
elevation: 0,
|
||||
),
|
||||
onPressed: () async {
|
||||
await controller.payToBankDriverAll();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildWalletCard(dynamic res, ColorScheme cs) {
|
||||
final String name = res['name_arabic']?.toString() ?? 'بدون اسم';
|
||||
final String amount = res['total_amount']?.toString() ?? '0';
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: cs.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: cs.outline),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
const Color(0xFF10B981).withValues(alpha: 0.20),
|
||||
const Color(0xFF10B981).withValues(alpha: 0.08),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: const Color(0xFF10B981).withValues(alpha: 0.2)),
|
||||
),
|
||||
child: Icon(Icons.person_rounded, color: const Color(0xFF10B981), size: 22),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
style: TextStyle(
|
||||
color: cs.onSurface,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
],
|
||||
isleading: true,
|
||||
action: IconButton(
|
||||
onPressed: () async {
|
||||
walletAdminController.getWalletForEachDriverToPay();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.refresh,
|
||||
color: Colors.black,
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'سائق',
|
||||
style: TextStyle(
|
||||
color: cs.onSurfaceVariant,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
amount,
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF10B981),
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'ل.س',
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF10B981).withValues(alpha: 0.6),
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user