This commit is contained in:
Hamza-Ayed
2024-06-27 17:41:40 +03:00
parent ce2dfa2ff4
commit 929ecf39f9
26 changed files with 461 additions and 274 deletions

View File

@@ -1,8 +1,5 @@
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';
@@ -16,16 +13,10 @@ import 'package:SEFER/views/widgets/elevated_btn.dart';
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';
import '../../controller/functions/crud.dart';
import '../../controller/functions/toast.dart';
import '../home/profile/passenger_profile_page.dart';
import '../widgets/mycircular.dart';
import 'register_page.dart';
class LoginPage extends StatelessWidget {
final controller = Get.put(LoginController());
@@ -88,53 +79,45 @@ class LoginPage extends StatelessWidget {
kolor: AppColor.blueColor,
),
!Platform.isAndroid
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.apple,
size: 30,
? GestureDetector(
onTap: () async {
User? user =
await authController.signInWithApple();
if (user != null) {
box.write(BoxName.passengerID, user.uid);
box.write(BoxName.email, user.email);
await GoogleSignInHelper
.signInFromLogin();
// Navigate to another screen or perform other actions
} else {}
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 10),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(8),
),
const SizedBox(
width: 8), // Adjust spacing as needed
MyElevatedButton(
title: 'Sign in with Apple'.tr,
onPressed: () async {
try {
User? user = await authController
.signInWithApple();
if (user != null) {
box.write(
BoxName.driverID, user.uid);
box.write(BoxName.emailDriver,
user.email);
// Provide user feedback
await GoogleSignInHelper
.signInFromLogin();
Navigator.of(context)
.pushReplacementNamed('/home');
Toast.show(
context,
'Signed in successfully',
AppColor.greenColor);
} else {
Toast.show(
context,
'Sign in failed. Please try again.',
AppColor.yellowColor);
}
} catch (error) {
print('Sign in error: $error');
Toast.show(
context,
'An error occurred. Please check your connection and try again.',
AppColor.redColor);
}
},
kolor: Colors.black,
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(),
],

View File

@@ -73,6 +73,40 @@ class SmsSignupEgypt extends StatelessWidget {
const SizedBox(
height: 10,
),
if (registerController.isSent)
Obx(() => Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: registerController.remainingTime > 0
? Column(
children: [
Text(
'${(registerController.remainingTime / 60).floor()}:${(registerController.remainingTime % 60).toString().padLeft(2, '0')} remaining',
style: AppStyle.subtitle,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
LinearProgressIndicator(
value: registerController.remainingTime /
300, // Assuming 300 seconds (5 minutes) total
backgroundColor: Colors.grey[300],
valueColor: AlwaysStoppedAnimation<Color>(
Theme.of(context).primaryColor),
),
],
)
: TextButton(
onPressed: () =>
registerController.sendOtpMessage(),
child: Text('Resend code'.tr),
),
),
const SizedBox(
height:
16), // Add some space after the timer or button
],
)),
Padding(
padding: const EdgeInsets.all(16.0),
child: registerController.isSent