5/27/1
This commit is contained in:
@@ -6,7 +6,7 @@ class BoxName {
|
||||
static const String lang = "lang";
|
||||
static const String carType = "carType";
|
||||
static const String carPlate = "carPlate";
|
||||
static const String isVerified = 'false';
|
||||
static const String isVerified = '0';
|
||||
static const String statusDriverLocation = "statusDriverLocation";
|
||||
static const String password = "password";
|
||||
static const String arrivalTime = "arrivalTime";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'colors.dart';
|
||||
|
||||
class AppStyle {
|
||||
@@ -10,42 +9,42 @@ class AppStyle {
|
||||
fontSize: 40,
|
||||
color: AppColor.accentColor,
|
||||
fontFamily: box.read(BoxName.lang) == 'en'
|
||||
? GoogleFonts.josefinSans().fontFamily
|
||||
? 'josefin'
|
||||
: box.read(BoxName.lang) == 'ar'
|
||||
? GoogleFonts.amiri().fontFamily
|
||||
: GoogleFonts.josefinSans().fontFamily);
|
||||
? 'mohanad'
|
||||
: 'josefin');
|
||||
static TextStyle headTitle2 = TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 26,
|
||||
color: AppColor.primaryColor,
|
||||
fontFamily: box.read(BoxName.lang) == 'en'
|
||||
? GoogleFonts.josefinSans().fontFamily
|
||||
? 'josefin'
|
||||
: box.read(BoxName.lang) == 'ar'
|
||||
? GoogleFonts.amiri().fontFamily
|
||||
: GoogleFonts.josefinSans().fontFamily);
|
||||
? 'mohanad'
|
||||
: 'josefin');
|
||||
static TextStyle title = TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
fontSize: 14,
|
||||
color: AppColor.primaryColor,
|
||||
fontFamily: box.read(BoxName.lang) == 'en'
|
||||
? GoogleFonts.josefinSans().fontFamily
|
||||
? 'josefin'
|
||||
: box.read(BoxName.lang) == 'ar'
|
||||
? GoogleFonts.amiri().fontFamily
|
||||
: GoogleFonts.josefinSans().fontFamily);
|
||||
? 'mohanad'
|
||||
: 'josefin');
|
||||
static TextStyle subtitle = TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13,
|
||||
color: AppColor.primaryColor,
|
||||
fontFamily: box.read(BoxName.lang) == 'en'
|
||||
? GoogleFonts.josefinSans().fontFamily
|
||||
? 'josefin'
|
||||
: box.read(BoxName.lang) == 'ar'
|
||||
? GoogleFonts.amiri().fontFamily
|
||||
: GoogleFonts.josefinSans().fontFamily);
|
||||
static TextStyle number = TextStyle(
|
||||
? 'mohanad'
|
||||
: 'josefin');
|
||||
static TextStyle number = const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: AppColor.primaryColor,
|
||||
fontFamily: GoogleFonts.averiaSansLibre().fontFamily);
|
||||
fontFamily: 'digit');
|
||||
|
||||
static BoxDecoration boxDecoration = const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
|
||||
35
lib/controller/auth/apple_signin_controller.dart
Normal file
35
lib/controller/auth/apple_signin_controller.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
|
||||
|
||||
class AuthController extends GetxController {
|
||||
final FirebaseAuth _auth = FirebaseAuth.instance;
|
||||
|
||||
Future<User?> signInWithApple() async {
|
||||
try {
|
||||
final appleCredential = await SignInWithApple.getAppleIDCredential(
|
||||
scopes: [
|
||||
AppleIDAuthorizationScopes.email,
|
||||
AppleIDAuthorizationScopes.fullName,
|
||||
],
|
||||
);
|
||||
|
||||
final oAuthProvider = OAuthProvider('apple.com');
|
||||
final credential = oAuthProvider.credential(
|
||||
idToken: appleCredential.identityToken,
|
||||
accessToken: appleCredential.authorizationCode,
|
||||
);
|
||||
|
||||
UserCredential userCredential =
|
||||
await _auth.signInWithCredential(credential);
|
||||
return userCredential.user;
|
||||
} catch (error) {
|
||||
print("Error during Apple sign-in: $error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void signOut() async {
|
||||
await _auth.signOut();
|
||||
}
|
||||
}
|
||||
@@ -66,8 +66,9 @@ class LoginController extends GetxController {
|
||||
if (jsonDecoeded['status'] == 'success' &&
|
||||
jsonDecoeded['data'][0]['verified'] == 1) {
|
||||
//
|
||||
box.write(BoxName.isVerified, 'true');
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
|
||||
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
|
||||
|
||||
print(box.read(BoxName.tokenFCM));
|
||||
var token = await CRUD().get(link: AppLink.getTokens, payload: {
|
||||
@@ -78,12 +79,14 @@ class LoginController extends GetxController {
|
||||
if (token != 'failure') {
|
||||
if (jsonDecode(token)['data'][0]['token'] !=
|
||||
box.read(BoxName.tokenFCM)) {
|
||||
print('token changed');
|
||||
Get.put(FirebaseMessagesController())
|
||||
.sendNotificationToAnyWithoutData(
|
||||
'token change',
|
||||
'change device',
|
||||
jsonDecode(token)['data'][0]['token'].toString(),
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1));
|
||||
await CRUD().post(link: AppLink.addTokens, payload: {
|
||||
'token': box.read(BoxName.tokenFCM),
|
||||
'passengerID': box.read(BoxName.passengerID).toString()
|
||||
|
||||
@@ -116,7 +116,7 @@ class RegisterController extends GetxController {
|
||||
payload: payload,
|
||||
);
|
||||
if (jsonDecode(res1)['status'] == 'success') {
|
||||
box.write(BoxName.isVerified, 'true');
|
||||
box.write(BoxName.isVerified, '1');
|
||||
box.write(BoxName.phone, '+2${phoneController.text}');
|
||||
Get.offAll(const MapPagePassenger());
|
||||
}
|
||||
|
||||
@@ -94,12 +94,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
if (box.read(BoxName.email) == null) {
|
||||
box.write(BoxName.tokenDriver, token);
|
||||
} else {
|
||||
box.write(BoxName.tokenFCM, token);
|
||||
}
|
||||
print(token);
|
||||
box.write(BoxName.tokenFCM, token);
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
|
||||
@@ -13,24 +13,24 @@ void launchCommunication(
|
||||
String method, String contactInfo, String message) async {
|
||||
String url;
|
||||
|
||||
// Encode the message
|
||||
String encodedMessage = Uri.encodeComponent(message);
|
||||
|
||||
if (Platform.isIOS) {
|
||||
switch (method) {
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
url = 'sms:$contactInfo?body=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'whatsapp':
|
||||
url = 'https://api.whatsapp.com/send?phone=$contactInfo&text=$message';
|
||||
url =
|
||||
'https://api.whatsapp.com/send?phone=$contactInfo&text=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$encodedMessage';
|
||||
break;
|
||||
|
||||
default:
|
||||
print('Method not supported on iOS');
|
||||
return;
|
||||
@@ -40,19 +40,15 @@ void launchCommunication(
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
url = 'sms:$contactInfo?body=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'whatsapp':
|
||||
url = 'whatsapp://send?phone=$contactInfo&text=$message';
|
||||
url = 'whatsapp://send?phone=$contactInfo&text=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$encodedMessage';
|
||||
break;
|
||||
|
||||
default:
|
||||
print('Method not supported on Android');
|
||||
return;
|
||||
@@ -62,8 +58,8 @@ void launchCommunication(
|
||||
return;
|
||||
}
|
||||
|
||||
if (await canLaunchUrl(Uri.parse(url))) {
|
||||
launchUrl(Uri.parse(url));
|
||||
if (await canLaunch(url)) {
|
||||
await launch(url);
|
||||
} else {
|
||||
print('Could not launch $url');
|
||||
}
|
||||
|
||||
@@ -479,14 +479,13 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
void sendWhatsapp(String to) async {
|
||||
// Get the driver's phone number.
|
||||
// String driverPhone =
|
||||
// dataCarsLocationByPassenger['message'][carsOrder]['phone'].toString();
|
||||
// String driverPhone = dataCarsLocationByPassenger['message'][carsOrder]['phone'].toString();
|
||||
|
||||
// Format the message.
|
||||
String message =
|
||||
'${'${'Hi! This is'.tr} ${box.read(BoxName.name)}.\n${' I am using'.tr}'} ${AppInformation.appName}${' to ride with'.tr} $firstName${' as the driver.'.tr} $firstName \n${'is driving a '.tr}$model\n${' with license plate '.tr}$licensePlate.\n${' I am currently located at '.tr} https://www.google.com/maps/place/${passengerLocation.latitude},${passengerLocation.longitude}.\n${' If you need to reach me, please contact the driver directly at'.tr}\n\n $driverPhone.';
|
||||
|
||||
// Launch the URL to send the SMS.
|
||||
// Launch the URL to send the WhatsApp message.
|
||||
launchCommunication('whatsapp', to, message);
|
||||
}
|
||||
|
||||
@@ -889,7 +888,7 @@ class MapPassengerController extends GetxController {
|
||||
driverPhone =
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['phone'].toString();
|
||||
firstName = dataCarsLocationByPassenger['message'][carsOrder]
|
||||
['driverName']
|
||||
['first_name'] // driverName
|
||||
.toString();
|
||||
carColor =
|
||||
dataCarsLocationByPassenger['message'][carsOrder]['color'].toString();
|
||||
@@ -1338,7 +1337,9 @@ class MapPassengerController extends GetxController {
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(seconds: 4));
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
if (isRideFinished == true) {
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
}
|
||||
@@ -1352,7 +1353,9 @@ class MapPassengerController extends GetxController {
|
||||
// Wait for 50 seconds.
|
||||
print('loop is $i from $loopCount');
|
||||
await Future.delayed(const Duration(seconds: 4));
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
if (isRideFinished == true) {
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
}
|
||||
@@ -1642,7 +1645,7 @@ class MapPassengerController extends GetxController {
|
||||
Future getPlaces() async {
|
||||
var url =
|
||||
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AK.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeDestinationController.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=${box.read(BoxName.lang)}&key=${AK.mapAPIKEY.toString()}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeDestinationController.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=ar&key=${AK.mapAPIKEY.toString()}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
@@ -1654,7 +1657,7 @@ class MapPassengerController extends GetxController {
|
||||
Future getPlacesStart() async {
|
||||
var url =
|
||||
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AK.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeStartController.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=${box.read(BoxName.lang)}&key=${AK.mapAPIKEY.toString()}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeStartController.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=ar&key=${AK.mapAPIKEY.toString()}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
@@ -1665,7 +1668,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
Future getPlacesListsWayPoint(int index) async {
|
||||
var url =
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint0Controller.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=${box.read(BoxName.lang)}&key=${AK.mapAPIKEY.toString()}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint0Controller.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=ar&key=${AK.mapAPIKEY.toString()}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
@@ -2619,6 +2622,7 @@ class MapPassengerController extends GetxController {
|
||||
startMarkerReloading();
|
||||
Get.put(TextToSpeechController());
|
||||
box.write(BoxName.carType, 'yet');
|
||||
box.write(BoxName.tipPercentage, '0');
|
||||
// await getNearestDriverByPassengerLocation();
|
||||
|
||||
initilizeGetStorage();
|
||||
|
||||
@@ -45,12 +45,16 @@ class SplashScreenController extends GetxController
|
||||
}
|
||||
|
||||
void startTimer() async {
|
||||
print(box.read(BoxName.email));
|
||||
print(box.read(BoxName.phone));
|
||||
print(box.read(BoxName.isVerified));
|
||||
print('---------');
|
||||
Timer(const Duration(seconds: 5), () async {
|
||||
box.read(BoxName.onBoarding) == null
|
||||
? Get.off(() => OnBoardingPage())
|
||||
: box.read(BoxName.email) != null &&
|
||||
box.read(BoxName.phone) != null &&
|
||||
box.read(BoxName.isVerified) == 'true'
|
||||
box.read(BoxName.isVerified) == '1'
|
||||
// ? Get.off(() => const MapPagePassenger())
|
||||
? await Get.put(LoginController()).loginFromSignInGoogle(
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:SEFER/views/home/map_page_passenger.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../payment/payment_controller.dart';
|
||||
|
||||
// import '../home/captin/home_captain_controller.dart';
|
||||
|
||||
@@ -78,7 +79,7 @@ class RateController extends GetxController {
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(title: 'Ok', onPressed: () => Get.back()));
|
||||
} else {
|
||||
} else if (Get.find<PaymentController>().isWalletChecked == true) {
|
||||
var tip = (Get.find<MapPassengerController>().totalPassenger) *
|
||||
(double.parse(box.read(BoxName.tipPercentage.toString())));
|
||||
var res = await CRUD().post(link: AppLink.addTips, payload: {
|
||||
@@ -108,17 +109,16 @@ class RateController extends GetxController {
|
||||
Get.find<MapPassengerController>().driverToken.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
await CRUD().post(link: AppLink.addRateToDriver, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'driver_id': driverId,
|
||||
'ride_id': rideId,
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
}).then((value) {
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
});
|
||||
}
|
||||
await CRUD().post(link: AppLink.addRateToDriver, payload: {
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'driver_id': driverId,
|
||||
'ride_id': rideId,
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
}).then((value) {
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +108,9 @@ class RateDriverFromPassenger extends StatelessWidget {
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
(Get.find<PaymentController>().isCashChecked ==
|
||||
false &&
|
||||
Get.find<PaymentController>()
|
||||
.isWalletChecked ==
|
||||
true)
|
||||
(Get.find<PaymentController>()
|
||||
.isWalletChecked ==
|
||||
true)
|
||||
? const DriverTipWidget()
|
||||
: const SizedBox(),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:SEFER/views/auth/sms_verfy_page.dart';
|
||||
import 'package:animated_text_kit/animated_text_kit.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||
@@ -15,6 +17,7 @@ import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
|
||||
import '../../constant/info.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../controller/auth/apple_signin_controller.dart';
|
||||
import '../../controller/auth/google_sign.dart';
|
||||
import '../../controller/auth/login_controller.dart';
|
||||
import '../../controller/firebase/firbase_messge.dart';
|
||||
@@ -25,6 +28,7 @@ import 'register_page.dart';
|
||||
|
||||
class LoginPage extends StatelessWidget {
|
||||
final controller = Get.put(LoginController());
|
||||
final AuthController authController = Get.put(AuthController());
|
||||
|
||||
LoginPage({super.key});
|
||||
|
||||
@@ -219,15 +223,30 @@ class LoginPage extends StatelessWidget {
|
||||
},
|
||||
kolor: AppColor.blueColor,
|
||||
),
|
||||
// MyElevatedButton(
|
||||
// title: 'Sign In by Google'.tr,
|
||||
// onPressed: () async {
|
||||
// print(box.read(BoxName.email));
|
||||
// print(box.read(BoxName.phone));
|
||||
// print(box.read(BoxName.isVerified));
|
||||
// },
|
||||
// kolor: AppColor.blueColor,
|
||||
// ),
|
||||
!Platform.isAndroid
|
||||
? MyElevatedButton(
|
||||
title: 'Sign In by Apple'.tr,
|
||||
onPressed: () async {
|
||||
User? user =
|
||||
await authController.signInWithApple();
|
||||
if (user != null) {
|
||||
print(
|
||||
"Successfully signed in: ${user.email}");
|
||||
print(
|
||||
"Successfully signed in: ${user.uid}");
|
||||
box.write(BoxName.driverID, user.uid);
|
||||
box.write(
|
||||
BoxName.emailDriver, user.email);
|
||||
await GoogleSignInHelper
|
||||
.signInFromLogin();
|
||||
// Navigate to another screen or perform other actions
|
||||
} else {
|
||||
print("Sign-in failed");
|
||||
}
|
||||
},
|
||||
kolor: AppColor.primaryColor,
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/views/home/profile/feed_back_page.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -45,7 +46,7 @@ class RideBeginPassenger extends StatelessWidget {
|
||||
CircleAvatar(
|
||||
radius: 30,
|
||||
backgroundImage: NetworkImage(
|
||||
'https://ride.mobile-app.store/portrate_captain_image/${controller.driverId}.jpg'),
|
||||
'${AppLink.server}/portrate_captain_image/${controller.driverId}.jpg'),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user