This commit is contained in:
Hamza-Ayed
2023-10-16 16:53:27 +03:00
parent 2105de243c
commit 06905be0e9
13 changed files with 339 additions and 191 deletions

View File

@@ -6,6 +6,7 @@ class BoxName {
static const String password = "password"; static const String password = "password";
static const String passwordDriver = "passwordDriver"; static const String passwordDriver = "passwordDriver";
static const String agreeTerms = "agreeTerms"; static const String agreeTerms = "agreeTerms";
static const String sosPhonePassenger = "sosPhonePassenger";
static const String passengerID = "pasengerID"; static const String passengerID = "pasengerID";
static const String phone = "phone"; static const String phone = "phone";
static const String phoneDriver = "phoneDriver"; static const String phoneDriver = "phoneDriver";

View File

@@ -18,6 +18,9 @@ class AppCredintials {
class MyClass { class MyClass {
static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0'; static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS';
static const String accountSIDTwillo = 'ACb4ad857efe0903bfd6238a763a2ce4d1';
static const String authTokenTwillo = '14f39ef4628bb8a4f18469f462f8af75';
static const String additionalText = 'additional text'; static const String additionalText = 'additional text';
String getBasicAuthCredentials() { String getBasicAuthCredentials() {

View File

@@ -1,4 +1,3 @@
import 'package:flutter_sms/flutter_sms.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart'; import 'package:ride/constant/box_name.dart';
import 'dart:async'; import 'dart:async';
@@ -62,14 +61,6 @@ class HomeCaptainController extends GetxController {
super.onInit(); super.onInit();
} }
void sendSMSToRecipents(String message, List<String> recipents) async {
String _result = await sendSMS(message: message, recipients: recipents)
.catchError((onError) {
print(onError);
});
print(_result);
}
@override @override
void dispose() { void dispose() {
activeTimer?.cancel(); activeTimer?.cancel();

View File

@@ -17,10 +17,13 @@ import 'package:ride/views/Rate/rate_captain.dart';
import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/elevated_btn.dart';
import '../../main.dart'; import '../../main.dart';
import '../../models/model/locations.dart'; import '../../models/model/locations.dart';
import '../functions/launch.dart';
class MapPassengerController extends GetxController { class MapPassengerController extends GetxController {
bool isLoading = true; bool isLoading = true;
TextEditingController placeController = TextEditingController(); TextEditingController placeController = TextEditingController();
TextEditingController sosPhonePassengerProfile = TextEditingController();
final sosFormKey = GlobalKey<FormState>();
List data = []; List data = [];
List<LatLng> bounds = []; List<LatLng> bounds = [];
List places = []; List places = [];
@@ -80,6 +83,9 @@ class MapPassengerController extends GetxController {
double progressTimerRideBegin = 0; double progressTimerRideBegin = 0;
int remainingTimeTimerRideBegin = 60; int remainingTimeTimerRideBegin = 60;
String stringRemainingTimeRideBegin = ''; String stringRemainingTimeRideBegin = '';
late String rideId;
late String driverToken;
int carsOrder = 0;
void onChangedPassengerCount(int newValue) { void onChangedPassengerCount(int newValue) {
selectedPassengerCount = newValue; selectedPassengerCount = newValue;
@@ -116,6 +122,32 @@ class MapPassengerController extends GetxController {
update(); update();
} }
void sendSMS(String to) async {
// Get the driver's phone number.
String driverPhone =
dataCarsLocationByPassenger['message'][carsOrder]['phone'].toString();
// Format the message.
String message =
'Hi! This is ${box.read(BoxName.name)}. I am using Sefer to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} is driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()} with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}. I am currently located at $myLocation. If you need to reach me, please contact the driver directly at $driverPhone.';
// Launch the URL to send the SMS.
launchCommunication('sms', to, message);
}
void sendWhatsapp(String to) async {
// Get the driver's phone number.
String driverPhone =
dataCarsLocationByPassenger['message'][carsOrder]['phone'].toString();
// Format the message.
String message =
'Hi! This is ${box.read(BoxName.name)}. I am using Sefer to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} is driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()} with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}. I am currently located at $myLocation. If you need to reach me, please contact the driver directly at $driverPhone.';
// Launch the URL to send the SMS.
launchCommunication('whatsapp', to, message);
}
void changeCancelRidePageShow() { void changeCancelRidePageShow() {
// rideConfirm == true // rideConfirm == true
// ? // ?
@@ -223,9 +255,6 @@ class MapPassengerController extends GetxController {
update(); update();
} }
late String rideId;
late String driverToken;
int carsOrder = 0;
changeConfirmRide() async { changeConfirmRide() async {
PaymentController paymentController = Get.find<PaymentController>(); PaymentController paymentController = Get.find<PaymentController>();
rideConfirm = true; rideConfirm = true;

View File

@@ -15,7 +15,7 @@ class ProfileController extends GetxController {
TextEditingController txtController = TextEditingController(); TextEditingController txtController = TextEditingController();
List genders = ['Male', 'Female', 'Non-binary']; List genders = ['Male', 'Female', 'Non-binary'];
String gender = ''; String gender = 'Male';
void setGender(String value) { void setGender(String value) {
gender = value; gender = value;

View File

@@ -121,8 +121,8 @@ class HomeCaptain extends StatelessWidget {
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
homeCaptainController.sendSMSToRecipents( // homeCaptainController.sendSMSToRecipents(
'hi from Sefer', ['+962798583052']); // 'hi from Sefer', ['+962798583052']);
}, },
child: const Text('send msg')), child: const Text('send msg')),
], ],

View File

@@ -151,7 +151,7 @@ class MapPage extends StatelessWidget {
onTap: (argument) { onTap: (argument) {
controller.hidePlaces(); controller.hidePlaces();
controller.changeBottomSheetShown(); // controller.changeBottomSheetShown();
// controller.bottomSheet(); // controller.bottomSheet();
}, },
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(

View File

@@ -327,7 +327,7 @@ GetBuilder<MapPassengerController> buttomSheetMapPage() {
.tr, .tr,
style: AppStyle.title, style: AppStyle.title,
), ),
Container( SizedBox(
height: height:
200, // Set the desired height here 200, // Set the desired height here
child: CupertinoPicker( child: CupertinoPicker(

View File

@@ -71,24 +71,26 @@ class MainBottomMenuMap extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
height: 30, height: 30,
child: AnimatedTextKit( child: Text(
animatedTexts: [ '${'Where to'.tr} ${box.read(BoxName.name)}')
ScaleAnimatedText( // AnimatedTextKit(
'${'Where to'.tr} ${box.read(BoxName.name)}'), // animatedTexts: [
// WavyAnimatedText( // ScaleAnimatedText(
// '${'Where to'.tr} ${box.read(BoxName.name)}'), // '${'Where to'.tr} ${box.read(BoxName.name)}'),
// FlickerAnimatedText( // // WavyAnimatedText(
// '${'Where to'.tr} ${box.read(BoxName.name)}'), // // '${'Where to'.tr} ${box.read(BoxName.name)}'),
// WavyAnimatedText( // // FlickerAnimatedText(
// '${'Where to'.tr} ${box.read(BoxName.name)}'), // // '${'Where to'.tr} ${box.read(BoxName.name)}'),
], // // WavyAnimatedText(
isRepeatingAnimation: true, // // '${'Where to'.tr} ${box.read(BoxName.name)}'),
onTap: () { // ],
print("Tap Event"); // isRepeatingAnimation: true,
}, // onTap: () {
), // print("Tap Event");
), // },
// ),
),
Row( Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@@ -148,96 +150,88 @@ class FavioratePlacesDialogu extends StatelessWidget {
builder: (controller) => DefaultTextStyle( builder: (controller) => DefaultTextStyle(
style: AppStyle.title, style: AppStyle.title,
child: Center( child: Center(
child: AnimatedTextKit( child: InkWell(
animatedTexts: [ onTap: () async {
TypewriterAnimatedText('Favorite Places'.tr), List favoritePlaces =
ScaleAnimatedText( await sql.getAllData(TableName.placesFavorite);
'Favorite Places'.tr, // print(favoritePlaces);
), Get.defaultDialog(
// TyperAnimatedText( title: 'Favorite Places'.tr,
// 'Favorite Places'.tr, content: SizedBox(
// ), width: Get.width * .8,
], height: 300,
isRepeatingAnimation: true, child: favoritePlaces.isEmpty
onTap: () async { ? Center(
List favoritePlaces = child: Column(
await sql.getAllData(TableName.placesFavorite); mainAxisAlignment: MainAxisAlignment.center,
print(favoritePlaces); children: [
Get.defaultDialog( const Icon(
title: 'Favorite Places'.tr, Icons.hourglass_empty_rounded,
content: SizedBox( size: 99,
width: Get.width * .8, color: AppColor.primaryColor,
height: 300, ),
child: favoritePlaces.isEmpty Text(
? Center( 'You Dont Have Any places yet !'.tr,
child: Column( style: AppStyle.title,
mainAxisAlignment: MainAxisAlignment.center, ),
],
),
)
: ListView.builder(
itemCount: favoritePlaces.length,
itemBuilder: (BuildContext context, int index) {
return Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [ children: [
const Icon( TextButton(
Icons.hourglass_empty_rounded, onPressed: () async {
size: 99, await controller.getMap(
color: AppColor.primaryColor, '${controller.myLocation.latitude},${controller.myLocation.longitude}',
'${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}',
);
// controller.changePickerShown();
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
},
child: Text(
favoritePlaces[index]['name'],
style: AppStyle.title,
),
), ),
Text( IconButton(
'You Dont Have Any places yet !'.tr, onPressed: () async {
style: AppStyle.title, await sql.deleteData(
TableName.placesFavorite,
favoritePlaces[index]['id']);
Get.back();
// ignore: use_build_context_synchronously
Toast.show(
context,
'${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
AppColor.redColor);
// Get.snackbar('Deleted'.tr,
// '${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
// backgroundColor:
// AppColor.accentColor);
},
icon: const Icon(Icons.favorite_outlined),
), ),
], ],
), );
) },
: ListView.builder( ),
itemCount: favoritePlaces.length, ),
itemBuilder: (BuildContext context, int index) { cancel: MyElevatedButton(
return Row( title: 'Back'.tr, onPressed: () => Get.back()),
mainAxisAlignment: );
MainAxisAlignment.spaceBetween, },
children: [ child: Text(
TextButton( '\u{1F3D8} ' 'Favorite Places'.tr,
onPressed: () async { style: AppStyle.title,
await controller.getMap(
'${controller.myLocation.latitude},${controller.myLocation.longitude}',
'${favoritePlaces[index]['latitude']},${favoritePlaces[index]['longitude']}',
);
// controller.changePickerShown();
controller.showBottomSheet1();
Get.back();
controller.showBottomSheet1();
},
child: Text(
favoritePlaces[index]['name'],
style: AppStyle.title,
),
),
IconButton(
onPressed: () async {
await sql.deleteData(
TableName.placesFavorite,
favoritePlaces[index]['id']);
Get.back();
// ignore: use_build_context_synchronously
Toast.show(
context,
'${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
AppColor.redColor);
// Get.snackbar('Deleted'.tr,
// '${'You are Delete'.tr} ${favoritePlaces[index]['name']} from your list',
// backgroundColor:
// AppColor.accentColor);
},
icon:
const Icon(Icons.favorite_outlined),
),
],
);
},
),
),
cancel: MyElevatedButton(
title: 'Back'.tr, onPressed: () => Get.back()),
);
},
), ),
), )),
)); ));
} }
} }

View File

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart';
import 'package:ride/controller/profile/profile_controller.dart';
import 'package:ride/main.dart';
import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart'; import '../../../constant/colors.dart';
@@ -13,6 +16,7 @@ class RideBeginPassenger extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProfileController profileController = Get.put(ProfileController());
return GetBuilder<MapPassengerController>(builder: (controller) { return GetBuilder<MapPassengerController>(builder: (controller) {
if (controller.rideTimerBegin) { if (controller.rideTimerBegin) {
return Positioned( return Positioned(
@@ -26,6 +30,7 @@ class RideBeginPassenger extends StatelessWidget {
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
'You will arrive to your destination after '.tr, 'You will arrive to your destination after '.tr,
@@ -50,34 +55,137 @@ class RideBeginPassenger extends StatelessWidget {
) )
], ],
), ),
controller.remainingTimeTimerRideBegin < 5 Row(
? MyElevatedButton( mainAxisAlignment: MainAxisAlignment.spaceAround,
title: children: [
'If you in destination Now. Press finish The Ride', IconButton(
onPressed: () async { onPressed: () {
//todo finish the trip and rest all counter ,start new counter of the trip time if (box.read(BoxName.sosPhonePassenger).toString() ==
'') {
Get.defaultDialog(
title: 'You dont Add Emergency Phone Yet!'.tr,
content: Column(
children: [
Form(
key: controller.sosFormKey,
child: TextFormField(
keyboardType: TextInputType
.phone, // Set the keyboard type to phone
validator: (value) {
if (value!.isEmpty ||
value.length < 10) {
return 'Please enter a phone number';
}
// Add additional validation if needed
return null;
},
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Type here',
),
),
)
],
),
confirm: MyElevatedButton(
title: 'Add Phone'.tr,
onPressed: () async {
await profileController
.updatField('sosPhone');
box.write(
BoxName.sosPhonePassenger,
profileController
.prfoileData['sosPhone']);
}));
} else {
controller
.sendSMS(box.read(BoxName.sosPhonePassenger));
}
},
icon: const Icon(
Icons.sos_rounded,
color: AppColor.redColor,
),
),
IconButton(
onPressed: () {
if (box.read(BoxName.sosPhonePassenger).toString() ==
'') {
Get.defaultDialog(
title: 'You dont Add Emergency Phone Yet!'.tr,
content: Column(
children: [
Form(
key: controller.sosFormKey,
child: TextFormField(
keyboardType: TextInputType
.phone, // Set the keyboard type to phone
validator: (value) {
if (value!.isEmpty ||
value.length < 10) {
return 'Please enter a phone number';
}
// Add additional validation if needed
return null;
},
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: 'Type here',
),
),
)
],
),
confirm: MyElevatedButton(
title: 'Add Phone'.tr,
onPressed: () async {
await profileController
.updatField('sosPhone');
box.write(
BoxName.sosPhonePassenger,
profileController
.prfoileData['sosPhone']);
}));
} else {
controller.sendWhatsapp(
box.read(BoxName.sosPhonePassenger));
}
},
icon: const Icon(
Icons.ring_volume,
color: AppColor.blueColor,
),
),
],
)
// controller.remainingTimeTimerRideBegin < 5
// ? MyElevatedButton(
// title:
// 'If you in destination Now. Press finish The Ride',
// onPressed: () async {
//todo finish the trip and rest all counter ,start new counter of the trip time
// await CRUD() // await CRUD()
// .post(link: AppLink.updateRides, payload: { // .post(link: AppLink.updateRides, payload: {
// 'id': controller.rideId, // 'id': controller.rideId,
// 'rideTimeStart': DateTime.now().toString(), // 'rideTimeStart': DateTime.now().toString(),
// 'status': 'Applied' // 'status': 'Applied'
// }); // });
// controller.driverArrivePassenger(); // controller.driverArrivePassenger();
// // Send notification to driver to alert him that trip is begin // // Send notification to driver to alert him that trip is begin
// FirebaseMessagesController() // FirebaseMessagesController()
// .sendNotificationToAnyWithoutData( // .sendNotificationToAnyWithoutData(
// 'BeginTrip', // 'BeginTrip',
// box.read(BoxName.name).toString(), // box.read(BoxName.name).toString(),
// controller.driverToken.toString(), // controller.driverToken.toString(),
// ); // );
// print(controller.driverToken.toString()); // print(controller.driverToken.toString());
// Get.defaultDialog( // Get.defaultDialog(
// title: 'The Ride is Begin'.tr, // title: 'The Ride is Begin'.tr,
// backgroundColor: AppColor.greenColor, // backgroundColor: AppColor.greenColor,
// ); // );
}) // })
: const SizedBox() // : const SizedBox()
], ],
), ),
), ),

View File

@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart'; import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/colors.dart';
import 'package:ride/constant/style.dart'; import 'package:ride/constant/style.dart';
import 'package:ride/controller/profile/profile_controller.dart'; import 'package:ride/controller/profile/profile_controller.dart';
import 'package:ride/main.dart'; import 'package:ride/main.dart';
@@ -106,23 +107,27 @@ class PassengerProfilePage extends StatelessWidget {
.toString()), .toString()),
onTap: () { onTap: () {
Get.defaultDialog( Get.defaultDialog(
barrierDismissible: true,
title: 'Update Education'.tr, title: 'Update Education'.tr,
content: Column( content: SizedBox(
children: [ height: 200,
EducationDegreePicker(), child: Column(
MyElevatedButton( children: [
title: 'Update Education'.tr, EducationDegreePicker(),
onPressed: () { ],
controller.updateColumn({ ),
'id': controller.prfoileData['id'] ),
.toString(), confirm: MyElevatedButton(
'education': title: 'Update Education'.tr,
controller.selectedDegree, onPressed: () {
}); controller.updateColumn({
Get.back(); 'id': controller.prfoileData['id']
}, .toString(),
) 'education':
], controller.selectedDegree,
});
Get.back();
},
)); ));
}, },
), ),
@@ -160,6 +165,25 @@ class PassengerProfilePage extends StatelessWidget {
controller.updatField('maritalStatus'); controller.updatField('maritalStatus');
}, },
), ),
ListTile(
title: Text(
'SOS Phone'.tr,
style: AppStyle.title,
),
leading: const Icon(
Icons.sos,
color: AppColor.redColor,
size: 35,
),
trailing: const Icon(Icons.arrow_forward_ios),
subtitle: Text(controller.prfoileData['sosPhone']
.toString()),
onTap: () async {
await controller.updatField('sosPhone');
box.write(BoxName.sosPhonePassenger,
controller.prfoileData['sosPhone']);
},
),
], ],
), ),
), ),
@@ -189,14 +213,17 @@ class GenderPicker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CupertinoPicker( return SizedBox(
itemExtent: 32.0, height: 100,
onSelectedItemChanged: (int index) { child: CupertinoPicker(
controller.setGender(genderOptions[index]); itemExtent: 32.0,
}, onSelectedItemChanged: (int index) {
children: genderOptions.map((String value) { controller.setGender(genderOptions[index]);
return Text(value); },
}).toList(), children: genderOptions.map((String value) {
return Text(value);
}).toList(),
),
); );
} }
} }
@@ -216,17 +243,21 @@ class EducationDegreePicker extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CupertinoPicker( return SizedBox(
// backgroundColor: AppColor.accentColor, height: 200,
looping: true, child: CupertinoPicker(
squeeze: 2, diameterRatio: 2, // backgroundColor: AppColor.accentColor,
itemExtent: 32.0, // looping: true,
onSelectedItemChanged: (int index) { squeeze: 2,
controller.setDegree(degreeOptions[index]); // diameterRatio: 5,
}, itemExtent: 32,
children: degreeOptions.map((String value) { onSelectedItemChanged: (int index) {
return Text(value); controller.setDegree(degreeOptions[index]);
}).toList(), },
children: degreeOptions.map((String value) {
return Text(value);
}).toList(),
),
); );
} }
} }

View File

@@ -326,14 +326,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
flutter_sms:
dependency: "direct main"
description:
name: flutter_sms
sha256: "2fe5f584f02596343557eeca56348f9b82413fefe83a423fab880cdbdf54d8d8"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
flutter_spinkit: flutter_spinkit:
dependency: transitive dependency: transitive
description: description:

View File

@@ -37,7 +37,6 @@ dependencies:
flutter_launcher_icons: ^0.13.1 flutter_launcher_icons: ^0.13.1
crypto: ^3.0.3 crypto: ^3.0.3
flutter_rating_bar: ^4.0.1 flutter_rating_bar: ^4.0.1
flutter_sms: ^2.3.3
dev_dependencies: dev_dependencies: