feat: refactor financial wallet UI components and add offline map service support

This commit is contained in:
Hamza-Ayed
2026-04-21 00:35:30 +03:00
parent 4293d20561
commit b92db3bb39
99 changed files with 22888 additions and 27387 deletions

View File

@@ -1,6 +1,3 @@
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/main.dart';
import 'package:sefer_driver/views/widgets/error_snakbar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -9,208 +6,171 @@ import '../../../controller/home/captin/help/assurance_controller.dart';
import 'package:flutter/cupertino.dart';
import '../../widgets/my_scafold.dart';
class AssuranceHealthPage extends StatelessWidget {
AssuranceHealthPage({super.key});
AssuranceHealthController assuranceHealthController =
final AssuranceHealthController assuranceHealthController =
Get.put(AssuranceHealthController());
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text("Health Insurance".tr),
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: GetBuilder<AssuranceHealthController>(
builder: (assuranceHealthController) {
return Column(
children: [
Text(
"When you complete 500 trips, you will be eligible for exclusive health insurance offers."
.tr,
textAlign: TextAlign.center,
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
CupertinoButton.filled(
child: Text("Show My Trip Count".tr),
onPressed: () async {
assuranceHealthController.getTripCountByCaptain();
},
final theme = Theme.of(context);
return MyScafolld(
title: "Health Insurance".tr,
isleading: true,
body: [
GetBuilder<AssuranceHealthController>(
builder: (controller) {
return SingleChildScrollView(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"When you complete 500 trips, you will be eligible for exclusive health insurance offers."
.tr,
textAlign: TextAlign.center,
style: theme.textTheme.titleMedium?.copyWith(
color:
theme.textTheme.bodyMedium?.color?.withOpacity(0.8),
height: 1.5,
),
_buildTripCountAvatar(
assuranceHealthController.tripCount['count'] == null
? '0'
: assuranceHealthController.tripCount['count']
.toString(),
),
],
),
const SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: CupertinoColors.systemGrey6,
borderRadius: BorderRadius.circular(10),
),
child: Padding(
padding: const EdgeInsets.all(14),
const SizedBox(height: 24),
Card(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Expanded(
child: ElevatedButton(
onPressed: () =>
controller.getTripCountByCaptain(),
style: ElevatedButton.styleFrom(
backgroundColor: AppColor.primaryColor,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
padding:
const EdgeInsets.symmetric(vertical: 12),
),
child: Text("Show My Trip Count".tr),
),
),
const SizedBox(width: 16),
_buildTripCountAvatar(
controller.tripCount['count'] == null
? '0'
: controller.tripCount['count'].toString(),
),
],
),
),
),
const SizedBox(height: 24),
Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceVariant.withOpacity(0.5),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: theme.dividerColor),
),
child: Text(
"We have partnered with health insurance providers to offer you special health coverage. Complete 500 trips and receive a 20% discount on health insurance premiums."
.tr,
style: CupertinoTheme.of(context)
.textTheme
.textStyle
.copyWith(fontWeight: FontWeight.w600),
style: theme.textTheme.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
),
),
const SizedBox(height: 10),
CupertinoButton.filled(
disabledColor: AppColor.blueColor,
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
borderRadius: BorderRadius.circular(12),
child: Text(
"Would you like to proceed with health insurance?".tr,
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () => _showInsuranceDialog(context, controller),
style: ElevatedButton.styleFrom(
backgroundColor: AppColor.primaryColor,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: Text(
"Would you like to proceed with health insurance?".tr,
style: const TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
onPressed: () async {
// Show confirmation dialog before proceeding
showCupertinoDialog(
context: context,
builder: (BuildContext context) {
// Variable to store the health insurance provider chosen by the driver
TextEditingController providerController =
TextEditingController();
return CupertinoAlertDialog(
title: Text(
"Confirmation".tr,
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
),
content: Column(
children: [
Text(
"Would you like to proceed with health insurance?"
.tr,
style: const TextStyle(fontSize: 14),
),
const SizedBox(height: 20),
CupertinoTextField(
controller: providerController,
placeholder:
"Do you have a disease for a long time?".tr,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(
color: CupertinoColors.systemGrey,
width: 1),
borderRadius: BorderRadius.circular(8),
),
),
],
),
actions: <Widget>[
CupertinoDialogAction(
isDefaultAction: true,
child: Text(
"Yes".tr,
style: const TextStyle(
color: CupertinoColors.activeBlue),
),
onPressed: () async {
// Ensure the provider name is not empty
if (providerController.text.isNotEmpty) {
// Call the function to insert data into the database
await assuranceHealthController
.addDriverHealthAssurance(
healthInsuranceProvider:
providerController.text,
);
// Close the dialog and navigate to a success screen or show a snackbar
Navigator.of(context).pop();
} else {
// Show an alert if the provider name is empty
showCupertinoDialog(
context: context,
builder: (_) => CupertinoAlertDialog(
title: Text("Error".tr),
content: Text(
"Do you have a disease for a long time?"
.tr),
actions: [
CupertinoDialogAction(
child: Text("OK".tr),
onPressed: () =>
Navigator.of(context).pop(),
),
],
),
);
}
},
),
CupertinoDialogAction(
child: Text(
"No".tr,
style: const TextStyle(
color: CupertinoColors.destructiveRed),
),
onPressed: () {
Navigator.of(context)
.pop(); // Just close the dialog
// Optionally show feedback if the driver opts out
// Get.snackbar(
// "Opted out".tr,
// "You have chosen not to proceed with health insurance."
// .tr,
// backgroundColor:
// CupertinoColors.systemGrey);
mySnackeBarError(
"You have chosen not to proceed with health insurance."
.tr);
},
),
],
);
},
);
},
),
],
],
),
);
}),
},
),
],
);
}
void _showInsuranceDialog(
BuildContext context, AssuranceHealthController controller) {
final TextEditingController providerController = TextEditingController();
Get.dialog(
AlertDialog(
title: Text("Confirmation".tr),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Would you like to proceed with health insurance?".tr),
const SizedBox(height: 16),
TextField(
controller: providerController,
decoration: InputDecoration(
hintText: "Do you have a disease for a long time?".tr,
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
),
),
],
),
actions: [
TextButton(
onPressed: () => Get.back(),
child: Text("No".tr, style: const TextStyle(color: Colors.red)),
),
ElevatedButton(
onPressed: () async {
if (providerController.text.isNotEmpty) {
await controller.addDriverHealthAssurance(
healthInsuranceProvider: providerController.text,
);
Get.back();
} else {
Get.snackbar("Error".tr,
"Please provide details about any long-term diseases.".tr);
}
},
child: Text("Yes".tr),
),
],
),
);
}
Widget _buildTripCountAvatar(String count) {
return Container(
width: 80,
height: 80,
width: 70,
height: 70,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: const RadialGradient(
colors: [
Color(0xFF42A5F5),
Color(0xFF1976D2),
], // Health theme colors
center: Alignment.center,
radius: 0.8,
gradient: const LinearGradient(
colors: [Color(0xFF42A5F5), Color(0xFF1976D2)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
boxShadow: [
BoxShadow(
color: CupertinoColors.black.withOpacity(0.2),
color: Colors.black.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 4),
),
@@ -220,9 +180,9 @@ class AssuranceHealthPage extends StatelessWidget {
child: Text(
count,
style: const TextStyle(
fontSize: 22,
fontSize: 20,
fontWeight: FontWeight.bold,
color: CupertinoColors.white,
color: Colors.white,
),
),
),