259 lines
8.4 KiB
Dart
259 lines
8.4 KiB
Dart
import 'package:siro_admin/constant/theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import '../../../controller/admin/wallet_admin_controller.dart';
|
|
import '../../widgets/mycircular.dart';
|
|
|
|
class Wallet extends StatelessWidget {
|
|
Wallet({super.key});
|
|
final WalletAdminController walletAdminController =
|
|
Get.put(WalletAdminController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final cs = Theme.of(context).colorScheme;
|
|
|
|
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: [
|
|
cs.success.withValues(alpha: 0.20),
|
|
cs.success.withValues(alpha: 0.08),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: cs.success.withValues(alpha: 0.2)),
|
|
),
|
|
child: Icon(Icons.person_rounded, color: cs.success, 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,
|
|
),
|
|
),
|
|
const SizedBox(height: 3),
|
|
Text(
|
|
'سائق',
|
|
style: TextStyle(
|
|
color: cs.onSurfaceVariant,
|
|
fontSize: 11,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
amount,
|
|
style: TextStyle(
|
|
color: cs.success,
|
|
fontWeight: FontWeight.w800,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
Text(
|
|
'ل.س',
|
|
style: TextStyle(
|
|
color: cs.success.withValues(alpha: 0.6),
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|