This commit is contained in:
Hamza-Ayed
2024-10-11 08:43:49 +03:00
parent 9b0caf3bed
commit 9854f80971
9 changed files with 295 additions and 98 deletions

View File

@@ -5,6 +5,7 @@ import 'package:SEFER/views/auth/captin/contact_us_page.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
@@ -21,6 +22,7 @@ import '../../../controller/functions/overlay_permisssion.dart';
import '../../../main.dart';
import '../../widgets/elevated_btn.dart';
import '../../widgets/my_scafold.dart';
import '../../widgets/mycircular.dart';
import '../country_widget.dart';
class LoginCaptin extends StatelessWidget {
@@ -196,40 +198,202 @@ class LoginCaptin extends StatelessWidget {
width: Get.width * .3,
fit: BoxFit.fill,
),
Container(
decoration: AppStyle.boxDecoration1,
height: Get.height * .3,
width: Get.width * .8,
child: Center(
child: Text(
'Sign in with Google for easier email and name entry'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
Platform.isIOS && controller.isTest == 0
? Container(
decoration: AppStyle.boxDecoration,
child: Column(
children: [
Form(
key: controller.formKey,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
children: [
TextFormField(
keyboardType: TextInputType
.emailAddress,
controller: controller
.emailController,
decoration: InputDecoration(
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color: AppColor
.primaryColor,
width: 2.0,
),
borderRadius:
BorderRadius
.circular(10),
),
fillColor:
AppColor.accentColor,
hoverColor:
AppColor.accentColor,
focusColor:
AppColor.accentColor,
border: const OutlineInputBorder(
borderRadius:
BorderRadius.all(
Radius
.circular(
12))),
labelText: 'Email'.tr,
hintText:
'Enter your email address'
.tr,
),
validator: (value) {
if (value!.isEmpty ||
(!value.contains(
'@') ||
!value.contains(
'.'))) {
return 'Please enter Your Email.'
.tr;
}
return null;
},
),
const SizedBox(
height: 15,
),
TextFormField(
obscureText: true,
keyboardType: TextInputType
.emailAddress,
controller: controller
.passwordController,
decoration: InputDecoration(
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color: AppColor
.primaryColor,
width: 2.0,
),
borderRadius:
BorderRadius
.circular(10),
),
fillColor:
AppColor.accentColor,
hoverColor:
AppColor.accentColor,
focusColor:
AppColor.accentColor,
border: const OutlineInputBorder(
borderRadius:
BorderRadius.all(
Radius
.circular(
12))),
labelText: 'Password'.tr,
hintText:
'Please enter your phone number.'
.tr,
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter Your Password.'
.tr;
}
if (value.length < 6) {
return 'Password must br at least 6 character.'
.tr;
}
return null;
},
),
GetBuilder<
LoginDriverController>(
builder: (controller) =>
controller.isloading
? const MyCircularProgressIndicator()
: MyElevatedButton(
onPressed:
() async {
if (controller
.formKey
.currentState!
.validate()) {
await Get.find<
LoginDriverController>()
.loginUsingCredentials(
controller
.passwordController
.text,
controller
.emailController
.text,
);
}
},
title:
'Submit'.tr,
),
)
],
),
),
),
),
const SizedBox(
height: 10,
),
],
),
)
: Container(
decoration: AppStyle.boxDecoration1,
height: Get.height * .3,
width: Get.width * .8,
child: Center(
child: Text(
'Sign in with Google for easier email and name entry'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
),
),
GestureDetector(
onTap: () async {
await GoogleSignInHelper().signInFromLogin();
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 10),
decoration: BoxDecoration(
color: AppColor.redColor,
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
FontAwesome.google,
color: AppColor.blueColor,
),
const SizedBox(width: 8),
Text(
'Sign In by Google'.tr,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
],
),
),
),
MyElevatedButton(
title: 'Sign In by Google'.tr,
onPressed: () async {
await GoogleSignInHelper().signInFromLogin();
},
kolor: AppColor.redColor,
),
// Platform.isAndroid
// ? MyElevatedButton(
// title: 'Sign In by Facebook'.tr,
// onPressed: () async {
// await FacebookSignIn()
// .signInWithFacebook();
// },
// kolor: AppColor.blueColor,
// )
// : const SizedBox(),
!Platform.isAndroid
? MyElevatedButton(
title: 'Sign In by Apple'.tr,
onPressed: () async {
? GestureDetector(
onTap: () async {
User? user = await authController
.signInWithApple();
if (user != null) {
@@ -246,19 +410,38 @@ class LoginCaptin extends StatelessWidget {
// Navigate to another screen or perform other actions
} else {}
},
kolor: AppColor.primaryColor,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 10),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.apple,
color: Colors.white,
size: 24,
),
const SizedBox(width: 8),
Text(
'Sign in with Apple'.tr,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
],
),
),
)
: const SizedBox(),
// MyElevatedButton(
// title: 'Sign In by Google'.tr,
// onPressed: () async {
// },
// kolor: AppColor.redColor,
// ),
],
),
))),
GestureDetector(
onTap: () => Get.to(() => ContactUsPage()),
child: Text(
@@ -267,40 +450,6 @@ class LoginCaptin extends StatelessWidget {
style: AppStyle.subtitle,
),
),
// AnimatedTextKit(
// onTap: () => Get.to(() => const RegisterCaptin()),
// animatedTexts: [
// TypewriterAnimatedText(
// 'Register as Driver'.tr,
// textStyle: AppStyle.headTitle2,
// speed: const Duration(milliseconds: 200),
// ),
// ],
// totalRepeatCount: 4,
// pause: const Duration(milliseconds: 200),
// displayFullTextOnTap: true,
// stopPauseOnTap: true,
// ),
// // IconButton(
// onPressed: () async {
// AC credentials = AC();
// String apiKey = AK.payMobApikey;
// String convertedStringN = credentials.c(
// credentials.c(credentials.c(apiKey, cs), cC), cn);
//
// String retrievedStringS = credentials.r(
// credentials.r(
// credentials.r(convertedStringN, cn), cC),
// cs);
// //
// if (retrievedStringS == apiKey) {
// }
// },
// icon: const Icon(
// Icons.close,
// color: AppColor.blueColor,
// ),
// ),
],
),
)
@@ -414,13 +563,13 @@ class LoginCaptin extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'We use location to get accurate and nearest passengers for you'
'We need access to your location to match you with nearby passengers and ensure accurate navigation.'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
Text(
'You will choose allow all the time to be ready receive orders'
'Please allow location access at all times to receive ride requests and ensure smooth service.'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(color: AppColor.greenColor),
@@ -428,22 +577,31 @@ class LoginCaptin extends StatelessWidget {
MyElevatedButton(
title: "Allow Location Access".tr,
onPressed: () async {
// await Get.put(LocationBackgroundController()); //////
// Request location permissions
PermissionStatus status =
await Permission.location.status;
if (!status.isGranted) {
// WidgetsBinding.instance.addPostFrameCallback((_) {
// getPermissionLocation();
// getPermissionLocation();
getLocationPermission();
// });
getLocationPermission(); // Function to request permission
return;
}
// Save permission status to local storage
box.write(BoxName.locationPermission, 'true');
controller.update();
},
kolor: AppColor.greenColor,
)
),
TextButton(
onPressed: () {
// Optionally, navigate to app settings for manual permission control
openAppSettings();
},
child: Text(
"Open Settings".tr,
style: const TextStyle(color: AppColor.blueColor),
),
),
],
),
),