25-7-26-1

This commit is contained in:
Hamza-Ayed
2025-07-26 10:30:10 +03:00
parent 83fa8c776c
commit 3742d5b417
645 changed files with 134317 additions and 0 deletions

View File

@@ -0,0 +1,218 @@
import 'package:Intaleq/controller/functions/crud.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:get/get.dart';
import 'package:Intaleq/constant/box_name.dart';
import 'package:Intaleq/constant/colors.dart';
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/main.dart';
import 'package:Intaleq/views/widgets/my_scafold.dart';
import '../../constant/info.dart';
import '../../controller/auth/apple_signin_controller.dart';
import '../../controller/auth/login_controller.dart';
import '../widgets/elevated_btn.dart';
import 'otp_page.dart';
class LoginPage extends StatelessWidget {
final controller = Get.put(LoginController());
final AuthController authController = Get.put(AuthController());
LoginPage({super.key});
@override
Widget build(BuildContext context) {
Get.put(LoginController());
Get.put(CRUD());
return GetBuilder<LoginController>(
builder: (controller) => MyScafolld(
title: 'Login'.tr,
isleading: false,
body: [
if (box.read(BoxName.agreeTerms) != 'agreed')
_buildAgreementPage(context, controller)
else if (box.read(BoxName.locationPermission) != 'true')
_buildLocationPermissionDialog(controller)
// else if (box.read(BoxName.isTest).toString() == '0')
// buildEmailPasswordForm(controller)
else
// _buildLoginContent(controller, authController),
PhoneNumberScreen()
],
),
);
}
Widget _buildAgreementPage(BuildContext context, LoginController controller) {
// This UI can be identical to the one in LoginPage for consistency.
// I am reusing the improved design from the previous request.
return Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.policy_outlined,
size: 80, color: AppColor.primaryColor),
const SizedBox(height: 20),
Text("passenger agreement".tr,
textAlign: TextAlign.center, style: AppStyle.headTitle2),
const SizedBox(height: 30),
RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: AppStyle.title.copyWith(height: 1.5),
children: [
TextSpan(
text:
"To become a passenger, you must review and agree to the "
.tr),
TextSpan(
text: 'Terms of Use'.tr,
style: const TextStyle(
decoration: TextDecoration.underline,
color: AppColor.blueColor,
fontWeight: FontWeight.bold),
recognizer: TapGestureRecognizer()..onTap = () {}),
TextSpan(text: " and acknowledge our Privacy Policy.".tr),
],
),
),
Expanded(
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(8),
),
child: SingleChildScrollView(
padding: const EdgeInsets.all(12),
child: HtmlWidget(box.read(BoxName.lang).toString() == 'ar'
? AppInformation.privacyPolicyArabic
: AppInformation.privacyPolicyEnglish),
),
),
),
CheckboxListTile(
title: Text('I Agree'.tr, style: AppStyle.title),
value: controller.isAgreeTerms,
onChanged: (value) => controller.changeAgreeTerm(),
activeColor: AppColor.primaryColor,
controlAffinity: ListTileControlAffinity.leading,
),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: MyElevatedButton(
title: 'Continue'.tr,
onPressed: controller.isAgreeTerms
? () => controller.saveAgreementTerms()
: () {},
),
),
],
),
);
}
Widget buildEmailPasswordForm(LoginController controller) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
child: Form(
key: controller.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
keyboardType: TextInputType.emailAddress,
controller: controller.emailController,
decoration: InputDecoration(
labelText: 'Email'.tr,
hintText: 'Your email address'.tr,
border: const OutlineInputBorder(),
),
validator: (value) => value == null ||
value.isEmpty ||
!value.contains('@') ||
!value.contains('.')
? 'Enter a valid email'.tr
: null,
),
const SizedBox(height: 16),
TextFormField(
obscureText: true,
controller: controller.passwordController,
decoration: InputDecoration(
labelText: 'Password'.tr,
hintText: 'Your password'.tr,
border: const OutlineInputBorder(),
),
validator: (value) => value == null || value.isEmpty
? 'Enter your password'.tr
: null,
),
const SizedBox(height: 24),
GetBuilder<LoginController>(
builder: (controller) => controller.isloading
? const Center(child: CircularProgressIndicator())
: ElevatedButton(
onPressed: () {
if (controller.formKey.currentState!.validate()) {
controller.login();
}
},
child: Text('Submit'.tr),
),
),
],
),
),
);
}
Widget _buildLocationPermissionDialog(LoginController controller) {
return Padding(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.location_on, size: 60, color: AppColor.primaryColor),
const SizedBox(height: 20),
Text(
'Enable Location Access'.tr,
style: AppStyle.headTitle2,
textAlign: TextAlign.center,
),
const SizedBox(height: 10),
Text(
'We need your location to find nearby drivers for pickups and drop-offs.'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () async => await controller.getLocationPermission(),
child: Text('Next'.tr),
// child: Text('Allow Location Access'.tr),
),
// TextButton(
// onPressed: () => openAppSettings(),
// child: Text('Open Settings'.tr),
// ),
],
),
);
}
}

View File

@@ -0,0 +1,486 @@
import 'package:Intaleq/controller/auth/login_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/box_name.dart';
import '../../controller/auth/otp_controller.dart';
import '../../controller/local/phone_intel/intl_phone_field.dart';
import '../../main.dart';
import '../../print.dart';
class AuthScreen extends StatelessWidget {
final String title;
final String subtitle;
final Widget form;
// Using a more neutral, tech-themed animated logo
// final String logoUrl = 'https://i.gifer.com/ZZ5H.gif';
const AuthScreen({
super.key,
required this.title,
required this.subtitle,
required this.form,
});
@override
Widget build(BuildContext context) {
final controller = Get.find<LoginController>();
return Scaffold(
body: Container(
// UPDATED: Changed gradient colors to a green theme
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.teal.shade700, Colors.green.shade600],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/images/logo.gif', height: 120),
const SizedBox(height: 20),
Text(
title,
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.white),
),
const SizedBox(height: 10),
Text(
subtitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16, color: Colors.white.withOpacity(0.8)),
),
const SizedBox(height: 30),
GetBuilder<LoginController>(builder: (context) {
return box.read(BoxName.isTest).toString() == '0'
? Container(
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.symmetric(
horizontal: 24, vertical: 32),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 12,
offset: const Offset(0, 6),
),
],
),
child: Form(
key: controller.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Title
Text(
'Please login to continue',
style: TextStyle(
fontSize: 16,
color: Colors.grey[600],
),
textAlign: TextAlign.center,
),
const SizedBox(height: 32),
// Email Field
TextFormField(
keyboardType: TextInputType.emailAddress,
controller: controller.emailController,
decoration: InputDecoration(
labelText: 'Email'.tr,
hintText: 'Enter your email address'.tr,
prefixIcon:
const Icon(Icons.email_outlined),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
validator: (value) => value == null ||
value.isEmpty ||
!value.contains('@') ||
!value.contains('.')
? 'Enter a valid email'.tr
: null,
),
const SizedBox(height: 20),
// Password Field
TextFormField(
obscureText: true,
controller: controller.passwordController,
decoration: InputDecoration(
labelText: 'Password'.tr,
hintText: 'Enter your password'.tr,
prefixIcon: const Icon(Icons.lock_outline),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
validator: (value) =>
value == null || value.isEmpty
? 'Enter your password'.tr
: null,
),
const SizedBox(height: 24),
// Submit Button
GetBuilder<LoginController>(
builder: (controller) => controller.isloading
? const Center(
child: CircularProgressIndicator())
: SizedBox(
height: 50,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
Colors.blueAccent,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(12),
),
),
onPressed: () {
if (controller
.formKey.currentState!
.validate()) {
controller.login();
}
},
child: Text(
'Login'.tr,
style:
const TextStyle(fontSize: 16),
),
),
),
),
const SizedBox(height: 16),
// Optional: Forgot Password / Create Account
],
),
),
)
: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: form,
),
);
}),
],
),
),
),
),
);
}
}
// --- UI Screens ---
class PhoneNumberScreen extends StatefulWidget {
const PhoneNumberScreen({super.key});
@override
State<PhoneNumberScreen> createState() => _PhoneNumberScreenState();
}
class _PhoneNumberScreenState extends State<PhoneNumberScreen> {
final _phoneController = TextEditingController();
final _formKey = GlobalKey<FormState>();
bool _isLoading = false;
void _submit() async {
if (_formKey.currentState!.validate()) {
setState(() => _isLoading = true);
// إزالة + من بداية الرقم
final rawPhone = _phoneController.text.trim().replaceFirst('+', '');
final success = await PhoneAuthHelper.sendOtp(rawPhone);
if (success && mounted) {
Get.to(() => OtpVerificationScreen(phoneNumber: rawPhone));
}
if (mounted) setState(() => _isLoading = false);
}
}
@override
Widget build(BuildContext context) {
return AuthScreen(
title: 'welcome to intaleq'.tr,
subtitle: 'login or register subtitle'.tr,
form: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: IntlPhoneField(
// languageCode: 'ar',
showCountryFlag: false,
flagsButtonMargin: EdgeInsets.only(right: 8),
flagsButtonPadding: EdgeInsets.all(4),
dropdownDecoration:
BoxDecoration(borderRadius: BorderRadius.circular(8)),
// controller: _phoneController,
decoration: InputDecoration(
labelText: 'Phone Number'.tr,
border: const OutlineInputBorder(
borderSide: BorderSide(),
),
),
initialCountryCode: 'SY',
onChanged: (phone) {
// Properly concatenate country code and number
_phoneController.text = phone.completeNumber.toString();
Log.print(' phone.number: ${phone.number}');
print("Formatted phone number: ${_phoneController.text}");
},
validator: (phone) {
// Check if the phone number is not null and is valid
if (phone == null || phone.completeNumber.isEmpty) {
return 'Please enter your phone number';
}
// Extract the phone number (excluding the country code)
final number = phone.completeNumber.toString();
// Check if the number length is exactly 11 digits
if (number.length != 13) {
return 'Phone number must be exactly 11 digits long';
}
// If all validations pass, return null
return null;
},
),
),
// TextFormField(
// controller: _phoneController,
// decoration: InputDecoration(
// labelText: 'phone number label'.tr,
// prefixIcon:
// Icon(Icons.phone_android, color: Colors.teal.shade400),
// border:
// OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
// ),
// keyboardType: TextInputType.phone,
// validator: (v) => v!.isEmpty ? 'phone number required'.tr : null,
// ),
const SizedBox(height: 24),
_isLoading
? const CircularProgressIndicator()
: ElevatedButton(
onPressed: _submit,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.teal,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
minimumSize: const Size(double.infinity, 50),
),
child: Text('send otp button'.tr),
),
],
),
),
);
}
}
class OtpVerificationScreen extends StatefulWidget {
final String phoneNumber;
const OtpVerificationScreen({super.key, required this.phoneNumber});
@override
State<OtpVerificationScreen> createState() => _OtpVerificationScreenState();
}
class _OtpVerificationScreenState extends State<OtpVerificationScreen> {
final _formKey = GlobalKey<FormState>();
final TextEditingController _otpControllers = TextEditingController();
// final List<FocusNode> _focusNodes = List.generate(5, (_) => FocusNode());
bool _isLoading = false;
@override
void dispose() {
// for (var controller in _otpControllers) {
// controller.dispose();
// }
// for (var node in _focusNodes) {
// node.dispose();
// }
super.dispose();
}
void _submit() async {
if (_formKey.currentState!.validate()) {
setState(() => _isLoading = true);
final otp = _otpControllers.text;
await PhoneAuthHelper.verifyOtp(widget.phoneNumber, otp);
if (mounted) setState(() => _isLoading = false);
}
}
Widget _buildOtpInput() {
return Form(
key: _formKey,
child: Container(
width: 200,
height: 50,
decoration: BoxDecoration(
color: Colors.grey.shade200,
shape: BoxShape.circle,
),
child: Center(
child: TextFormField(
controller: _otpControllers,
// focusNode: _focusNodes[index],
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 5,
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
decoration: const InputDecoration(
counterText: "",
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
),
onChanged: (value) {},
validator: (v) => v!.isEmpty ? '' : null,
),
),
),
);
}
@override
Widget build(BuildContext context) {
return AuthScreen(
title: 'verify your number title'.tr,
subtitle:
'otp sent subtitle'.trParams({'phoneNumber': widget.phoneNumber}),
form: Column(
mainAxisSize: MainAxisSize.min,
children: [
_buildOtpInput(),
const SizedBox(height: 30),
_isLoading
? const CircularProgressIndicator()
: ElevatedButton(
onPressed: _submit,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.teal,
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: Text('verify and continue button'.tr),
),
],
),
);
}
}
class RegistrationScreen extends StatefulWidget {
final String phoneNumber;
const RegistrationScreen({super.key, required this.phoneNumber});
@override
State<RegistrationScreen> createState() => _RegistrationScreenState();
}
class _RegistrationScreenState extends State<RegistrationScreen> {
final _formKey = GlobalKey<FormState>();
final _firstNameController = TextEditingController();
final _lastNameController = TextEditingController();
final _emailController = TextEditingController();
bool _isLoading = false;
void _submit() async {
if (_formKey.currentState!.validate()) {
setState(() => _isLoading = true);
await PhoneAuthHelper.registerUser(
phoneNumber: widget.phoneNumber,
firstName: _firstNameController.text.trim(),
lastName: _lastNameController.text.trim(),
email: _emailController.text.trim(),
);
if (mounted) setState(() => _isLoading = false);
}
}
@override
Widget build(BuildContext context) {
return AuthScreen(
title: 'one last step title'.tr,
subtitle: 'complete profile subtitle'.tr,
form: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextFormField(
controller: _firstNameController,
decoration: InputDecoration(
labelText: 'first name label'.tr,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)))),
validator: (v) => v!.isEmpty ? 'first name required'.tr : null,
),
const SizedBox(height: 16),
TextFormField(
controller: _lastNameController,
decoration: InputDecoration(
labelText: 'last name label'.tr,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)))),
validator: (v) => v!.isEmpty ? 'last name required'.tr : null,
),
const SizedBox(height: 16),
TextFormField(
controller: _emailController,
decoration: InputDecoration(
labelText: 'email optional label'.tr,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12)))),
keyboardType: TextInputType.emailAddress,
),
const SizedBox(height: 24),
_isLoading
? const CircularProgressIndicator()
: ElevatedButton(
onPressed: _submit,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.teal,
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: Text('complete registration button'.tr),
),
],
),
),
);
}
}

View File

@@ -0,0 +1,176 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../controller/auth/token_otp_change_controller.dart';
class OtpVerificationPage extends StatefulWidget {
final String phone;
final String deviceToken;
final String token;
final String ptoken;
const OtpVerificationPage({
super.key,
required this.phone,
required this.deviceToken,
required this.token,
required this.ptoken,
});
@override
State<OtpVerificationPage> createState() => _OtpVerificationPageState();
}
class _OtpVerificationPageState extends State<OtpVerificationPage> {
late final OtpVerificationController controller;
final List<FocusNode> _focusNodes = List.generate(6, (index) => FocusNode());
final List<TextEditingController> _textControllers =
List.generate(6, (index) => TextEditingController());
@override
void initState() {
super.initState();
controller = Get.put(OtpVerificationController(
phone: widget.phone,
deviceToken: widget.deviceToken,
token: widget.token,
));
}
@override
void dispose() {
for (var node in _focusNodes) {
node.dispose();
}
for (var controller in _textControllers) {
controller.dispose();
}
super.dispose();
}
void _onOtpChanged(String value, int index) {
if (value.isNotEmpty) {
if (index < 5) {
_focusNodes[index + 1].requestFocus();
} else {
_focusNodes[index].unfocus(); // إلغاء التركيز بعد آخر حقل
}
} else if (index > 0) {
_focusNodes[index - 1].requestFocus();
}
// تجميع نصوص كل الحقول لتكوين الرمز النهائي
controller.otpCode.value = _textControllers.map((c) => c.text).join();
}
Widget _buildOtpInputFields() {
return Directionality(
textDirection: TextDirection.ltr, // لضمان ترتيب الحقول من اليسار لليمين
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(5, (index) {
return SizedBox(
width: 45,
height: 55,
child: TextFormField(
controller: _textControllers[index],
focusNode: _focusNodes[index],
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 1,
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
decoration: InputDecoration(
counterText: "",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.grey.shade300),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: Theme.of(context).primaryColor, width: 2),
),
),
onChanged: (value) => _onOtpChanged(value, index),
),
);
}),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Verify OTP'.tr),
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
),
backgroundColor: Colors.grey[50],
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 20),
Icon(Icons.phonelink_lock_rounded,
size: 80, color: Theme.of(context).primaryColor),
const SizedBox(height: 24),
Text(
'Verification Code'.tr,
style:
const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Text(
'${'We have sent a verification code to your mobile number:'.tr} ${widget.phone}',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey.shade600, fontSize: 16, height: 1.5),
),
),
const SizedBox(height: 40),
_buildOtpInputFields(),
const SizedBox(height: 40),
Obx(() => SizedBox(
width: double.infinity,
height: 50,
child: controller.isVerifying.value
? const Center(child: CircularProgressIndicator())
: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12))),
onPressed: () =>
controller.verifyOtp(widget.ptoken),
child: Text('Verify'.tr,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600)),
),
)),
const SizedBox(height: 24),
Obx(
() => controller.canResend.value
? TextButton(
onPressed: controller.sendOtp,
child: Text('Resend Code'.tr),
)
: Text(
'${'You can resend in'.tr} ${controller.countdown.value} ${'seconds'.tr}',
style: const TextStyle(color: Colors.grey),
),
)
],
),
),
),
);
}
}

View File

@@ -0,0 +1,295 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/controller/auth/register_controller.dart';
import 'package:Intaleq/views/widgets/elevated_btn.dart';
import 'package:Intaleq/views/widgets/my_scafold.dart';
import '../../constant/colors.dart';
class RegisterPage extends StatelessWidget {
const RegisterPage({super.key});
@override
Widget build(BuildContext context) {
Get.put(RegisterController());
return MyScafolld(
title: 'Register'.tr,
body: [
GetBuilder<RegisterController>(
builder: (controller) => Form(
key: controller.formKey,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Container(
decoration: const BoxDecoration(
boxShadow: [
BoxShadow(
offset: Offset(3, 3),
color: AppColor.accentColor,
blurRadius: 3)
],
color: AppColor.secondaryColor,
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: TextFormField(
keyboardType: TextInputType.text,
controller: controller.firstNameController,
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: 'First name'.tr,
hintText: 'Enter your first name'.tr,
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your first name.'.tr;
}
return null;
},
),
),
SizedBox(
width: Get.width * .4,
child: TextFormField(
keyboardType: TextInputType.text,
controller: controller.lastNameController,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: AppColor.primaryColor,
width: 2.0,
),
borderRadius: BorderRadius.circular(10),
),
focusColor: AppColor.accentColor,
fillColor: AppColor.accentColor,
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12))),
labelText: 'Last name'.tr,
hintText: 'Enter your last name'.tr,
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your last name.'.tr;
}
return null;
},
),
),
],
),
const SizedBox(
height: 15,
),
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: 'Enter your Password'.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;
},
),
const SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: TextFormField(
keyboardType: TextInputType.phone,
cursorColor: AppColor.accentColor,
controller: controller.phoneController,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: AppColor.primaryColor,
width: 2.0,
),
borderRadius: BorderRadius.circular(10),
),
focusColor: AppColor.accentColor,
fillColor: AppColor.accentColor,
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12))),
labelText: 'Phone'.tr,
hintText: 'Enter your phone number'.tr,
),
validator: (value) {
if (value!.isEmpty || value.length != 10) {
return 'Please enter your phone number.'.tr;
}
return null;
},
),
),
SizedBox(
width: Get.width * .4,
child: TextFormField(
keyboardType: TextInputType.text,
controller: controller.siteController,
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: AppColor.primaryColor,
width: 2.0,
),
borderRadius: BorderRadius.circular(10),
),
focusColor: AppColor.accentColor,
fillColor: AppColor.accentColor,
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12))),
labelText: 'City'.tr,
hintText: 'Enter your City'.tr,
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your City.'.tr;
}
return null;
},
),
),
],
),
const SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () => controller.getBirthDate(),
child: Container(
height: 50,
width: Get.width * .4,
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.circular(13)),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20),
child: Text(
controller.birthDate,
style: AppStyle.title,
),
),
),
),
// DropdownButton(
// value: controller.gender,
// items: [
// DropdownMenuItem(
// value: 'Male'.tr,
// child: Text('Male'.tr),
// ),
// DropdownMenuItem(
// value: 'Female'.tr,
// child: Text('Female'.tr),
// ),
// DropdownMenuItem(
// value: '--'.tr,
// child: Text('--'.tr),
// ),
// ],
// onChanged: (value) {
// controller.changeGender(value!);
// },
// )
],
),
MyElevatedButton(
title: 'Register'.tr,
onPressed: () => controller.register())
]),
),
),
),
),
),
)
],
isleading: true);
}
}

View File

@@ -0,0 +1,119 @@
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/controller/auth/register_controller.dart';
import 'package:Intaleq/views/widgets/elevated_btn.dart';
import 'package:Intaleq/views/widgets/my_scafold.dart';
import 'package:Intaleq/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../controller/local/phone_intel/intl_phone_field.dart';
import '../../print.dart';
import '../widgets/mycircular.dart';
// import 'package:intl_phone_field/intl_phone_field.dart';
class SmsSignupEgypt extends StatelessWidget {
SmsSignupEgypt({super.key});
@override
Widget build(BuildContext context) {
Get.put(RegisterController());
return MyScafolld(
title: "Phone Number Check".tr,
body: [
GetBuilder<RegisterController>(builder: (registerController) {
return ListView(
children: [
// Logo at the top
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
height: 100,
),
),
// Message to the driver
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Text(
'We need your phone number to contact you and to help you.'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
),
// Phone number input field with country code dropdown
Padding(
padding: const EdgeInsets.all(16.0),
child: IntlPhoneField(
decoration: InputDecoration(
labelText: 'Phone Number'.tr,
border: const OutlineInputBorder(
borderSide: BorderSide(),
),
),
initialCountryCode: 'EG',
onChanged: (phone) {
// Properly concatenate country code and number
registerController.phoneController.text =
phone.completeNumber.toString();
Log.print(' phone.number: ${phone.number}');
print(
"Formatted phone number: ${registerController.phoneController.text}");
},
validator: (phone) {
// Check if the phone number is not null and is valid
if (phone == null || phone.completeNumber.isEmpty) {
return 'Please enter your phone number';
}
// Extract the phone number (excluding the country code)
final number = phone.completeNumber.toString();
// Check if the number length is exactly 11 digits
if (number.length != 13) {
return 'Phone number must be exactly 11 digits long';
}
// If all validations pass, return null
return null;
},
),
),
const SizedBox(
height: 10,
),
if (registerController.isSent)
Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: registerController.formKey3,
child: MyTextForm(
controller: registerController.verifyCode,
label: '5 digit'.tr,
hint: '5 digit'.tr,
type: TextInputType.number),
),
),
// Submit button
registerController.isLoading
? const MyCircularProgressIndicator()
: Padding(
padding: const EdgeInsets.all(16.0),
child: MyElevatedButton(
onPressed: () async {
!registerController.isSent
? await registerController.sendOtpMessage()
: await registerController.verifySMSCode();
},
title: 'Submit'.tr,
),
),
],
);
}),
],
isleading: false,
);
}
}

View File

@@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:Intaleq/constant/colors.dart';
import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/controller/auth/register_controller.dart';
import 'package:Intaleq/views/widgets/elevated_btn.dart';
import 'package:Intaleq/views/widgets/my_scafold.dart';
class VerifyEmailPage extends StatelessWidget {
const VerifyEmailPage({super.key});
@override
Widget build(BuildContext context) {
Get.put(RegisterController());
return MyScafolld(
title: 'Verify Email'.tr,
body: [
Positioned(
top: 10,
left: 20,
right: 20,
child: Text(
'We sent 5 digit to your Email provided'.tr,
style: AppStyle.title.copyWith(fontSize: 20),
)),
GetBuilder<RegisterController>(
builder: (controller) => Positioned(
top: 100,
left: 80,
right: 80,
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
SizedBox(
width: 100,
child: TextField(
controller: controller.verifyCode,
decoration: InputDecoration(
labelStyle: AppStyle.title,
border: const OutlineInputBorder(),
hintText: '5 digit'.tr,
counterStyle: AppStyle.number,
hintStyle: AppStyle.subtitle
.copyWith(color: AppColor.accentColor),
),
maxLength: 5,
keyboardType: TextInputType.number,
),
),
const SizedBox(
height: 30,
),
MyElevatedButton(
title: 'Send Verfication Code'.tr,
onPressed: () => controller.sendVerifications())
],
),
),
)),
],
isleading: true,
);
}
Padding verifyEmail() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: AppColor.accentColor,
width: 2,
),
borderRadius: BorderRadius.circular(8),
),
child: const Padding(
padding: EdgeInsets.all(10),
child: SizedBox(
width: 20,
child: TextField(
maxLength: 1,
keyboardType: TextInputType.number,
),
),
),
),
);
}
}