This commit is contained in:
Hamza-Ayed
2024-09-20 20:03:54 +03:00
parent b09e0da403
commit 519f4b651c
20 changed files with 935 additions and 831 deletions

View File

@@ -25,7 +25,7 @@ class SmsSignupEgypt extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Image.asset(
'assets/images/logo.png', // Make sure you have a logo image in your assets folder
'assets/images/logo.gif', // Make sure you have a logo image in your assets folder
height: 100,
),
),
@@ -91,13 +91,16 @@ class SmsSignupEgypt extends StatelessWidget {
// Submit button
registerCaptainController.isLoading
? const MyCircularProgressIndicator()
: MyElevatedButton(
onPressed: () async {
!registerCaptainController.isSent
? await registerCaptainController.sendOtpMessage()
: await registerCaptainController.verifySMSCode();
},
title: 'Submit'.tr,
: Padding(
padding: const EdgeInsets.all(16.0),
child: MyElevatedButton(
onPressed: () async {
!registerCaptainController.isSent
? await registerCaptainController.sendOtpMessage()
: await registerCaptainController.verifySMSCode();
},
title: 'Submit'.tr,
),
),
],
);

View File

@@ -1,169 +1,191 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:flutter_contacts/contact.dart';
import 'package:get/get.dart';
import '../../../controller/auth/captin/invit_controller.dart';
import '../../../print.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import '../../widgets/elevated_btn.dart';
class InviteDriverScreen extends StatelessWidget {
final InviteController controller = Get.put(InviteController());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Invite a Driver'.tr)),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Invite another driver and both get a gift after he completes 100 trips!"
.tr,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: MyTextForm(
controller: controller.invitePhoneController,
label: 'Enter driver\'s phone'.tr,
hint: 'Enter driver\'s phone'.tr,
type: TextInputType.phone,
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Invite a Driver'.tr),
leading: CupertinoNavigationBarBackButton(
onPressed: () => Get.back(),
),
),
child: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Invite another driver and both get a gift after he completes 100 trips!"
.tr,
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: CupertinoTextField(
controller: controller.invitePhoneController,
placeholder: 'Enter driver\'s phone'.tr,
keyboardType: TextInputType.phone,
),
),
),
IconButton(
icon: const Icon(Icons.contacts),
onPressed: () async {
await controller.pickContacts();
if (controller.contacts.isNotEmpty) {
if (box.read(BoxName.IsSavedPhones) == null) {
controller.savePhoneToServer();
box.write(BoxName.IsSavedPhones, true);
CupertinoButton(
child: const Icon(CupertinoIcons.person_2),
onPressed: () async {
await controller.pickContacts();
if (controller.contacts.isNotEmpty) {
if (box.read(BoxName.IsSavedPhones) == null) {
controller.savePhoneToServer();
box.write(BoxName.IsSavedPhones, true);
}
_showContactsDialog(context);
}
Get.defaultDialog(
title: 'Choose from contact'.tr,
content: Column(
children: [
SizedBox(
height: 300,
child: ListView.builder(
itemCount: controller.contactMaps.length,
itemBuilder: (context, index) {
final contact = controller.contactMaps[index];
return InkWell(
onTap: () {
controller.selectPhone(
contact['phones'].toString());
},
child: ListTile(
title: Text(contact['name'].toString()),
subtitle: Text(
controller.formatPhoneNumber(
contact['phones'][0].toString())),
),
);
},
),
],
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Send Invite'.tr,
onPressed: controller.sendInvite,
),
MyElevatedButton(
title: 'Show Invitations'.tr,
onPressed: () async {
controller.fetchDriverStats();
},
),
],
),
const SizedBox(height: 20),
GetBuilder<InviteController>(
builder: (controller) {
return SizedBox(
height: Get.height * .4,
child: controller.driverInvitationData.isEmpty
? Center(
child: Text(
"No invitation found yet!".tr,
style: CupertinoTheme.of(context)
.textTheme
.navTitleTextStyle,
),
)
: ListView.builder(
itemCount: controller.driverInvitationData.length,
itemBuilder: (context, index) {
int countOfInvitDriver = int.tryParse(controller
.driverInvitationData[index]
['countOfInvitDriver']
?.toString() ??
'0') ??
0;
double progressValue = countOfInvitDriver / 100.0;
progressValue = progressValue.clamp(0.0, 1.0);
return GestureDetector(
onTap: () async {
controller.onSelectDriverInvitation(index);
},
),
),
],
),
);
}
},
),
],
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Send Invite'.tr,
onPressed: controller.sendInvite,
),
MyElevatedButton(
title: 'Show Invitations'.tr,
onPressed: () async {
controller.fetchDriverStats();
},
),
],
),
const SizedBox(height: 20),
GetBuilder<InviteController>(builder: (controller) {
return SizedBox(
height: Get.height * .4,
child: controller.driverInvitationData.isEmpty
? Center(
child: Text(
"No invitation found yet!".tr,
style: AppStyle.title,
),
)
: ListView.builder(
itemCount: controller.driverInvitationData.length,
itemBuilder: (context, index) {
int countOfInvitDriver = 0;
if (controller.driverInvitationData[index]
.containsKey('countOfInvitDriver')) {
countOfInvitDriver = int.tryParse(controller
.driverInvitationData[index]
['countOfInvitDriver']
.toString()) ??
0;
}
double progressValue = countOfInvitDriver / 100.0;
if (progressValue > 1.0) progressValue = 1.0;
if (progressValue < 0.0) progressValue = 0.0;
return InkWell(
onTap: () async {
controller.onSelectDriverInvitation(index);
},
child: Container(
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color:
AppColor.accentColor.withOpacity(.5),
),
width: Get.width * .85,
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: LinearProgressIndicator(
value: progressValue,
color: AppColor.blueColor,
backgroundColor: AppColor.accentColor
.withOpacity(.3),
minHeight: 35,
child: Container(
margin:
const EdgeInsets.symmetric(vertical: 8.0),
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(12),
color: CupertinoColors.systemGrey5,
),
width: Get.width * .85,
height: 35,
child: ClipRRect(
borderRadius:
BorderRadius.circular(12),
child: LinearProgressIndicator(
value: progressValue,
backgroundColor:
CupertinoColors.systemGrey3,
valueColor:
const AlwaysStoppedAnimation<
Color>(
CupertinoColors.activeBlue),
),
),
),
),
Text(
'${controller.driverInvitationData[index]['invitorName']} ${countOfInvitDriver} / 100 ${'Trip'.tr}',
style: CupertinoTheme.of(context)
.textTheme
.textStyle,
),
],
),
Text(
'${controller.driverInvitationData[index]['invitorName']} ${controller.driverInvitationData[index]['countOfInvitDriver']} / 100 ${'Trip'.tr}',
),
],
),
),
);
},
),
);
})
],
),
);
},
),
);
},
)
],
),
),
),
);
}
void _showContactsDialog(BuildContext context) {
showCupertinoModalPopup(
context: context,
builder: (BuildContext context) => CupertinoActionSheet(
title: Text('Choose from contact'.tr),
actions: [
SizedBox(
height: 300,
child: CupertinoScrollbar(
child: ListView.builder(
itemCount: controller.contactMaps.length,
itemBuilder: (context, index) {
final contact = controller.contactMaps[index];
return CupertinoActionSheetAction(
child: Text(
'${contact['name']} - ${controller.formatPhoneNumber(contact['phones'][0].toString())}'),
onPressed: () {
controller.selectPhone(contact['phones'].toString());
// Navigator.pop(context);
},
);
},
),
),
),
],
cancelButton: CupertinoActionSheetAction(
child: Text('Cancel'.tr),
onPressed: () {
Navigator.pop(context);
},
),
),
);