first commit

This commit is contained in:
Hamza-Ayed
2026-06-09 08:40:31 +03:00
commit d8901e1a87
3161 changed files with 536187 additions and 0 deletions

View File

@@ -0,0 +1,711 @@
import 'package:siro_rider/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:siro_rider/constant/box_name.dart';
import 'package:siro_rider/constant/colors.dart';
import 'package:siro_rider/constant/style.dart';
import 'package:siro_rider/main.dart';
import 'package:siro_rider/views/widgets/my_scafold.dart';
import 'package:path/path.dart';
import 'package:url_launcher/url_launcher.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(context, controller)
else
PhoneNumberScreen()
],
),
);
}
// ─────────────────────────────────────────────────────────────────────────
// SHARED HELPERS
// ─────────────────────────────────────────────────────────────────────────
/// Subtle geometric background — two soft circles, no heavy blur needed.
Widget _buildBackground(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return Stack(
children: [
// Base gradient
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: isDark
? [const Color(0xFF0D0D14), const Color(0xFF161622)]
: [const Color(0xFFF8F9FF), const Color(0xFFEFF1FB)],
),
),
),
// Top-right accent circle
Positioned(
top: -80,
right: -60,
child: Container(
width: 260,
height: 260,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
colors: [
AppColor.primaryColor.withOpacity(isDark ? 0.18 : 0.12),
AppColor.primaryColor.withOpacity(0.0),
],
),
),
),
),
// Bottom-left accent circle
Positioned(
bottom: -100,
left: -80,
child: Container(
width: 320,
height: 320,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
colors: [
AppColor.primaryColor.withOpacity(isDark ? 0.12 : 0.08),
AppColor.primaryColor.withOpacity(0.0),
],
),
),
),
),
],
);
}
/// Glassy card container used across screens.
Widget _glassCard({
required Widget child,
required bool isDark,
EdgeInsets padding = const EdgeInsets.all(20),
double radius = 20,
}) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(radius),
color: isDark
? Colors.white.withOpacity(0.05)
: Colors.white.withOpacity(0.75),
border: Border.all(
color: isDark
? Colors.white.withOpacity(0.08)
: Colors.white.withOpacity(0.9),
width: 1,
),
boxShadow: [
BoxShadow(
color: isDark
? Colors.black.withOpacity(0.3)
: Colors.black.withOpacity(0.06),
blurRadius: 24,
offset: const Offset(0, 8),
),
],
),
padding: padding,
child: child,
);
}
/// Pill-shaped icon badge with gradient background.
Widget _iconBadge(IconData icon, bool isDark) {
return Container(
width: 80,
height: 80,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
AppColor.primaryColor,
AppColor.primaryColor.withOpacity(0.7),
],
),
boxShadow: [
BoxShadow(
color: AppColor.primaryColor.withOpacity(0.35),
blurRadius: 20,
offset: const Offset(0, 8),
),
],
),
child: Icon(icon, color: Colors.white, size: 36),
);
}
/// Section divider line.
Widget _divider(bool isDark) => Container(
height: 1,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.transparent,
isDark
? Colors.white.withOpacity(0.1)
: Colors.black.withOpacity(0.08),
Colors.transparent,
],
),
),
);
// ─────────────────────────────────────────────────────────────────────────
// AGREEMENT PAGE
// ─────────────────────────────────────────────────────────────────────────
Widget _buildAgreementPage(BuildContext context, LoginController controller) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final textMain = isDark ? Colors.white : const Color(0xFF1A1A2E);
final textSub = isDark ? Colors.white60 : const Color(0xFF6B7280);
return Stack(
children: [
_buildBackground(context),
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
child: Column(
children: [
// ── Header ──────────────────────────────────────────────
const SizedBox(height: 20),
_iconBadge(Icons.policy_outlined, isDark),
const SizedBox(height: 16),
Text(
"passenger agreement".tr,
textAlign: TextAlign.center,
style: AppStyle.headTitle2.copyWith(
color: textMain,
fontSize: 22,
fontWeight: FontWeight.w700,
letterSpacing: 0.3,
),
),
const SizedBox(height: 10),
// Subtitle with link
RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: AppStyle.title.copyWith(
height: 1.6,
color: textSub,
fontSize: 13.5,
),
children: [
TextSpan(
text:
"To become a passenger, you must review and agree to the "
.tr,
),
TextSpan(
text: 'Terms of Use'.tr,
style: TextStyle(
decoration: TextDecoration.underline,
decorationColor: AppColor.primaryColor,
color: AppColor.primaryColor,
fontWeight: FontWeight.w600,
),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrl(Uri.parse(
'https://intaleq.xyz/intaleq/privacy_policy.php'));
},
),
TextSpan(text: " and acknowledge our Privacy Policy.".tr),
],
),
),
const SizedBox(height: 16),
_divider(isDark),
const SizedBox(height: 12),
// ── Policy scroll area ──────────────────────────────────
Expanded(
child: _glassCard(
isDark: isDark,
padding: EdgeInsets.zero,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.all(18),
child: HtmlWidget(
box.read(BoxName.lang).toString() == 'ar'
? AppInformation.privacyPolicyArabic
: AppInformation.privacyPolicy,
textStyle: TextStyle(
color: textSub,
fontSize: 13,
height: 1.7,
),
),
),
),
),
),
const SizedBox(height: 12),
_divider(isDark),
// ── Checkbox row ────────────────────────────────────────
_glassCard(
isDark: isDark,
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: CheckboxListTile(
title: Text(
'I Agree'.tr,
style: AppStyle.title.copyWith(
color: textMain,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
value: controller.isAgreeTerms,
onChanged: (value) => controller.changeAgreeTerm(),
activeColor: AppColor.primaryColor,
checkColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6)),
controlAffinity: ListTileControlAffinity.leading,
contentPadding: EdgeInsets.zero,
dense: true,
),
),
const SizedBox(height: 12),
// ── CTA Button ──────────────────────────────────────────
_buildPrimaryButton(
label: 'Continue'.tr,
enabled: controller.isAgreeTerms,
onPressed: controller.isAgreeTerms
? () => controller.saveAgreementTerms()
: () {},
isDark: isDark,
),
const SizedBox(height: 8),
],
),
),
),
],
);
}
// ─────────────────────────────────────────────────────────────────────────
// EMAIL / PASSWORD FORM
// ─────────────────────────────────────────────────────────────────────────
Widget buildEmailPasswordForm(
BuildContext context, LoginController controller) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final textMain = isDark ? Colors.white : const Color(0xFF1A1A2E);
final textSub = isDark ? Colors.white60 : const Color(0xFF6B7280);
return Stack(
children: [
_buildBackground(context),
SafeArea(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Logo / badge
Center(child: _iconBadge(Icons.lock_outline_rounded, isDark)),
const SizedBox(height: 20),
Text(
'Welcome Back'.tr,
textAlign: TextAlign.center,
style: AppStyle.headTitle2.copyWith(
color: textMain,
fontSize: 26,
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 6),
Text(
'Sign in to continue'.tr,
textAlign: TextAlign.center,
style:
AppStyle.title.copyWith(color: textSub, fontSize: 14),
),
const SizedBox(height: 32),
_glassCard(
isDark: isDark,
padding: const EdgeInsets.all(24),
child: Form(
key: controller.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Email field
_buildTextField(
controller: controller.emailController,
label: 'Email'.tr,
hint: 'Your email address'.tr,
icon: Icons.email_outlined,
isDark: isDark,
keyboardType: TextInputType.emailAddress,
validator: (value) => value == null ||
value.isEmpty ||
!value.contains('@') ||
!value.contains('.')
? 'Enter a valid email'.tr
: null,
),
const SizedBox(height: 16),
// Password field
_buildTextField(
controller: controller.passwordController,
label: 'Password'.tr,
hint: 'Your password'.tr,
icon: Icons.lock_outline,
isDark: isDark,
obscureText: true,
validator: (value) => value == null || value.isEmpty
? 'Enter your password'.tr
: null,
),
const SizedBox(height: 28),
GetBuilder<LoginController>(
builder: (controller) => controller.isloading
? Center(
child: SizedBox(
width: 28,
height: 28,
child: CircularProgressIndicator(
color: AppColor.primaryColor,
strokeWidth: 2.5,
),
),
)
: _buildPrimaryButton(
label: 'Submit'.tr,
enabled: true,
isDark: isDark,
onPressed: () {
if (controller.formKey.currentState!
.validate()) {
controller.login();
}
},
),
),
],
),
),
),
],
),
),
),
),
],
);
}
// ─────────────────────────────────────────────────────────────────────────
// LOCATION PERMISSION PAGE
// ─────────────────────────────────────────────────────────────────────────
Widget _buildLocationPermissionDialog(
BuildContext context, LoginController controller) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final textMain = isDark ? Colors.white : const Color(0xFF1A1A2E);
final textSub = isDark ? Colors.white60 : const Color(0xFF6B7280);
return Stack(
children: [
_buildBackground(context),
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Spacer(flex: 2),
// Animated-look stacked circles around icon
Stack(
alignment: Alignment.center,
children: [
// Outer glow ring
Container(
width: 140,
height: 140,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.primaryColor.withOpacity(0.08),
border: Border.all(
color: AppColor.primaryColor.withOpacity(0.2),
width: 1,
),
),
),
// Mid ring
Container(
width: 108,
height: 108,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.primaryColor.withOpacity(0.12),
border: Border.all(
color: AppColor.primaryColor.withOpacity(0.3),
width: 1,
),
),
),
// Core badge
_iconBadge(Icons.location_on_outlined, isDark),
],
),
const SizedBox(height: 36),
Text(
'Enable Location Access'.tr,
style: AppStyle.headTitle2.copyWith(
color: textMain,
fontSize: 24,
fontWeight: FontWeight.w700,
letterSpacing: 0.2,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 14),
Text(
'We need your location to find nearby drivers for pickups and drop-offs.'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(
color: textSub,
fontSize: 14.5,
height: 1.6,
),
),
const SizedBox(height: 40),
// Feature chips row
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_featureChip(
Icons.speed_outlined, 'Fast matching'.tr, isDark),
const SizedBox(width: 10),
_featureChip(Icons.shield_outlined, 'Secure'.tr, isDark),
const SizedBox(width: 10),
_featureChip(Icons.near_me_outlined, 'Nearby'.tr, isDark),
],
),
const Spacer(flex: 3),
_buildPrimaryButton(
label: 'Next'.tr,
enabled: true,
isDark: isDark,
onPressed: () async =>
await controller.getLocationPermission(),
),
const SizedBox(height: 16),
],
),
),
),
],
);
}
// ─────────────────────────────────────────────────────────────────────────
// SHARED SMALL WIDGETS
// ─────────────────────────────────────────────────────────────────────────
/// Reusable styled text field.
Widget _buildTextField({
required TextEditingController controller,
required String label,
required String hint,
required IconData icon,
required bool isDark,
bool obscureText = false,
TextInputType? keyboardType,
String? Function(String?)? validator,
}) {
final fill = isDark ? Colors.white.withOpacity(0.05) : Colors.white;
final border =
isDark ? Colors.white.withOpacity(0.1) : const Color(0xFFE5E7EB);
return TextFormField(
controller: controller,
obscureText: obscureText,
keyboardType: keyboardType,
style: TextStyle(
color: isDark ? Colors.white : const Color(0xFF1A1A2E),
fontSize: 14.5,
),
decoration: InputDecoration(
labelText: label,
hintText: hint,
prefixIcon: Icon(icon,
size: 20, color: isDark ? Colors.white38 : const Color(0xFF9CA3AF)),
labelStyle: TextStyle(
color: isDark ? Colors.white38 : const Color(0xFF9CA3AF),
fontSize: 13.5,
),
hintStyle: TextStyle(
color: isDark ? Colors.white24 : const Color(0xFFD1D5DB),
),
filled: true,
fillColor: fill,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide(color: border, width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: BorderSide(color: AppColor.primaryColor, width: 1.5),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xFFEF4444), width: 1),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xFFEF4444), width: 1.5),
),
),
validator: validator,
);
}
/// Full-width gradient primary button.
Widget _buildPrimaryButton({
required String label,
required bool enabled,
required VoidCallback onPressed,
required bool isDark,
}) {
return SizedBox(
width: double.infinity,
height: 54,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: enabled
? LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
AppColor.primaryColor,
AppColor.primaryColor.withOpacity(0.8),
],
)
: null,
color: enabled
? null
: (isDark ? Colors.white12 : const Color(0xFFE5E7EB)),
boxShadow: enabled
? [
BoxShadow(
color: AppColor.primaryColor.withOpacity(0.32),
blurRadius: 16,
offset: const Offset(0, 6),
)
]
: null,
),
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
),
child: Text(
label,
style: TextStyle(
color: enabled
? Colors.white
: (isDark ? Colors.white38 : const Color(0xFF9CA3AF)),
fontWeight: FontWeight.w600,
fontSize: 15,
letterSpacing: 0.4,
),
),
),
),
);
}
/// Small chip used on location page.
Widget _featureChip(IconData icon, String text, bool isDark) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: isDark
? Colors.white.withOpacity(0.06)
: Colors.white.withOpacity(0.8),
border: Border.all(
color: isDark
? Colors.white.withOpacity(0.1)
: Colors.black.withOpacity(0.07),
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 14, color: AppColor.primaryColor),
const SizedBox(width: 5),
Text(
text,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white70 : const Color(0xFF374151),
),
),
],
),
);
}
}

View File

@@ -0,0 +1,929 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:siro_rider/controller/auth/login_controller.dart';
import '../../constant/colors.dart';
import '../../controller/auth/otp_controller.dart';
import '../../controller/local/phone_intel/intl_phone_field.dart';
// ─────────────────────────────────────────────────────────────────────────────
// SHARED DESIGN TOKENS
// ─────────────────────────────────────────────────────────────────────────────
Color _textMain(bool isDark) => isDark ? Colors.white : const Color(0xFF1A1A2E);
Color _textSub(bool isDark) =>
isDark ? Colors.white60 : const Color(0xFF6B7280);
InputBorder _inputBorder(bool isDark, {bool focused = false}) =>
OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: focused
? BorderSide(color: AppColor.primaryColor, width: 1.5)
: BorderSide(
color: isDark
? Colors.white.withOpacity(0.12)
: const Color(0xFFE5E7EB),
),
);
// ─────────────────────────────────────────────────────────────────────────────
// AUTH SCREEN (shared scaffold for all auth steps)
// ─────────────────────────────────────────────────────────────────────────────
/// A visually revamped authentication screen with a glassmorphism effect.
/// It provides a consistent and beautiful UI for all authentication steps.
///
/// A hidden feature for testers is included: a long-press on the logo
/// will open a dialog for email/password login, suitable for app reviews.
class AuthScreen extends StatelessWidget {
final String title;
final String subtitle;
final Widget form;
const AuthScreen({
super.key,
required this.title,
required this.subtitle,
required this.form,
});
/// Shows a dialog for testers to log in using email and password.
void _showTesterLoginDialog(
BuildContext context, LoginController controller) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final testerEmailController = TextEditingController();
final testerPasswordController = TextEditingController();
final testerFormKey = GlobalKey<FormState>();
showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext dialogContext) {
return BackdropFilter(
filter: ImageFilter.blur(sigmaX: 8, sigmaY: 8),
child: AlertDialog(
backgroundColor: isDark
? const Color(0xFF161622).withOpacity(0.97)
: Colors.white.withOpacity(0.97),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)),
titlePadding: const EdgeInsets.fromLTRB(24, 24, 24, 0),
contentPadding: const EdgeInsets.all(24),
title: Column(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.primaryColor.withOpacity(0.12),
),
child: Icon(Icons.admin_panel_settings_outlined,
color: AppColor.primaryColor, size: 28),
),
const SizedBox(height: 12),
Text(
'App Tester Login'.tr,
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 17,
color: _textMain(isDark),
),
),
],
),
content: Form(
key: testerFormKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_AuthTextField(
controller: testerEmailController,
label: 'Email'.tr,
icon: Icons.email_outlined,
isDark: isDark,
keyboardType: TextInputType.emailAddress,
validator: (value) => value == null || !value.contains('@')
? 'Enter a valid email'.tr
: null,
),
const SizedBox(height: 14),
_AuthTextField(
controller: testerPasswordController,
label: 'Password'.tr,
icon: Icons.lock_outline,
isDark: isDark,
obscureText: true,
validator: (value) => value == null || value.isEmpty
? 'Enter a password'.tr
: null,
),
],
),
),
actionsPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
actions: [
Row(
children: [
Expanded(
child: TextButton(
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: isDark
? Colors.white12
: const Color(0xFFE5E7EB),
),
),
),
onPressed: () => Navigator.of(dialogContext).pop(),
child: Text('Cancel'.tr,
style: TextStyle(
color: _textSub(isDark),
fontWeight: FontWeight.w500)),
),
),
const SizedBox(width: 10),
Expanded(
child: _PrimaryButton(
label: 'Login'.tr,
onPressed: () {
if (testerFormKey.currentState!.validate()) {
controller.emailController.text =
testerEmailController.text;
controller.passwordController.text =
testerPasswordController.text;
controller.login();
Navigator.of(dialogContext).pop();
}
},
),
),
],
),
],
),
);
},
);
}
@override
Widget build(BuildContext context) {
final loginController = Get.find<LoginController>();
final isDark = Theme.of(context).brightness == Brightness.dark;
return Scaffold(
body: Stack(
children: [
// ── Gradient background ────────────────────────────────────
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: isDark
? [
const Color(0xFF0D0D14),
const Color(0xFF12121E),
const Color(0xFF161622),
]
: [
const Color(0xFFF8F9FF),
const Color(0xFFEFF1FB),
const Color(0xFFFFFFFF),
],
),
),
),
// ── Decorative Shape 1 (top-left) ─────────────────────────
Positioned(
top: -90,
left: -70,
child: Container(
width: 280,
height: 280,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
colors: [
AppColor.primaryColor.withOpacity(isDark ? 0.18 : 0.10),
AppColor.primaryColor.withOpacity(0.0),
],
),
),
),
),
// ── Decorative Shape 2 (bottom-right) ────────────────────
Positioned(
bottom: -110,
right: -90,
child: Container(
width: 340,
height: 340,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
colors: [
AppColor.primaryColor.withOpacity(isDark ? 0.12 : 0.07),
AppColor.primaryColor.withOpacity(0.0),
],
),
),
),
),
// ── Content ───────────────────────────────────────────────
SafeArea(
child: Center(
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Logo
GestureDetector(
onLongPress: () =>
_showTesterLoginDialog(context, loginController),
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: isDark
? Colors.white.withOpacity(0.05)
: Colors.white.withOpacity(0.9),
border: Border.all(
color: isDark
? Colors.white.withOpacity(0.1)
: AppColor.primaryColor.withOpacity(0.15),
width: 1.5,
),
boxShadow: [
BoxShadow(
color: AppColor.primaryColor.withOpacity(0.18),
blurRadius: 24,
offset: const Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child:
Image.asset('assets/images/logo.gif', height: 96),
),
),
),
const SizedBox(height: 22),
// Title
Text(
title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.w700,
letterSpacing: 0.2,
color: _textMain(isDark),
),
),
const SizedBox(height: 8),
// Subtitle
Text(
subtitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.5,
height: 1.55,
color: _textSub(isDark),
),
),
const SizedBox(height: 28),
// ── Glass card ─────────────────────────────────
ClipRRect(
borderRadius: BorderRadius.circular(24),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16),
child: Container(
padding: const EdgeInsets.all(24.0),
decoration: BoxDecoration(
color: isDark
? Colors.white.withOpacity(0.05)
: Colors.white.withOpacity(0.72),
borderRadius: BorderRadius.circular(24),
border: Border.all(
color: isDark
? Colors.white.withOpacity(0.09)
: Colors.white.withOpacity(0.9),
width: 1,
),
boxShadow: [
BoxShadow(
color: isDark
? Colors.black.withOpacity(0.28)
: Colors.black.withOpacity(0.06),
blurRadius: 28,
offset: const Offset(0, 10),
),
],
),
child: form,
),
),
),
const SizedBox(height: 18),
// Tester link
Material(
color: Colors.transparent,
child: InkWell(
onTap: () =>
_showTesterLoginDialog(context, loginController),
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 10, horizontal: 14),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.admin_panel_settings_outlined,
size: 15,
color: isDark ? Colors.white24 : Colors.black26,
),
const SizedBox(width: 7),
Text(
'For App Reviewers / Testers'.tr,
style: TextStyle(
color:
isDark ? Colors.white24 : Colors.black26,
fontWeight: FontWeight.w400,
fontSize: 12,
),
),
],
),
),
),
),
],
),
),
),
),
],
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// PHONE NUMBER SCREEN
// ─────────────────────────────────────────────────────────────────────────────
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) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return AuthScreen(
title: 'welcome to intaleq'.tr,
subtitle: 'login or register subtitle'.tr,
form: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Label row
Row(
children: [
Container(
padding: const EdgeInsets.all(7),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: AppColor.primaryColor.withOpacity(0.12),
),
child: Icon(Icons.phone_outlined,
size: 18, color: AppColor.primaryColor),
),
const SizedBox(width: 10),
Text(
'Enter your phone number'.tr,
style: TextStyle(
color: _textMain(isDark),
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
],
),
const SizedBox(height: 18),
// Phone field
IntlPhoneField(
showCountryFlag: false,
searchText: 'Search country'.tr,
languageCode: 'ar',
style: TextStyle(color: _textMain(isDark), fontSize: 15),
dropdownTextStyle: TextStyle(color: _textMain(isDark)),
decoration: InputDecoration(
labelText: 'Phone Number'.tr,
hintText: 'witout zero'.tr,
labelStyle: TextStyle(color: _textSub(isDark), fontSize: 13.5),
hintStyle: TextStyle(
color: isDark ? Colors.white24 : const Color(0xFFD1D5DB),
),
filled: true,
fillColor:
isDark ? Colors.white.withOpacity(0.05) : Colors.white,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
enabledBorder: _inputBorder(isDark),
focusedBorder: _inputBorder(isDark, focused: true),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide:
const BorderSide(color: Color(0xFFEF4444), width: 1),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide:
const BorderSide(color: Color(0xFFEF4444), width: 1.5),
),
),
initialCountryCode: 'SY',
onChanged: (phone) {
_phoneController.text = phone.completeNumber;
},
validator: (phone) {
if (phone == null || phone.number.isEmpty) {
return 'Please enter your phone number'.tr;
}
if (phone.number.startsWith('0')) {
return 'Please enter the number without the leading 0'.tr;
}
if (phone.completeNumber.length < 10) {
return 'Phone number seems too short'.tr;
}
return null;
},
),
const SizedBox(height: 24),
_isLoading
? _LoadingIndicator()
: _PrimaryButton(
label: 'send otp button'.tr,
onPressed: _submit,
),
],
),
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// OTP VERIFICATION SCREEN
// ─────────────────────────────────────────────────────────────────────────────
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 _otpController = TextEditingController();
bool _isLoading = false;
void _submit() async {
if (_formKey.currentState!.validate()) {
setState(() => _isLoading = true);
await PhoneAuthHelper.verifyOtp(widget.phoneNumber, _otpController.text.trim());
if (mounted) setState(() => _isLoading = false);
}
}
@override
Widget build(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return AuthScreen(
title: 'verify your number title'.tr,
subtitle:
'otp sent subtitle'.trParams({'phoneNumber': widget.phoneNumber}),
form: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Label row
Row(
children: [
Container(
padding: const EdgeInsets.all(7),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: AppColor.primaryColor.withOpacity(0.12),
),
child: Icon(Icons.mark_email_read_outlined,
size: 18, color: AppColor.primaryColor),
),
const SizedBox(width: 10),
Text(
'Enter the 5-digit code'.tr,
style: TextStyle(
color: _textMain(isDark),
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
],
),
const SizedBox(height: 24),
// OTP Input — underline style, large characters
Form(
key: _formKey,
child: Container(
decoration: BoxDecoration(
color: isDark ? Colors.white.withOpacity(0.05) : Colors.white,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isDark
? Colors.white.withOpacity(0.1)
: const Color(0xFFE5E7EB),
),
),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
child: TextFormField(
controller: _otpController,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 3,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w700,
color: AppColor.primaryColor,
letterSpacing: 20,
),
decoration: InputDecoration(
counterText: '',
hintText: '···',
hintStyle: TextStyle(
color: isDark ? Colors.white12 : const Color(0xFFD1D5DB),
letterSpacing: 20,
fontSize: 30,
fontWeight: FontWeight.w300,
),
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(vertical: 6),
),
validator: (v) => v == null || v.length < 3 ? '' : null,
),
),
),
// Progress dots
const SizedBox(height: 14),
ValueListenableBuilder<TextEditingValue>(
valueListenable: _otpController,
builder: (_, value, __) {
final filled = value.text.length.clamp(0, 3);
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(3, (i) {
final active = i < filled;
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
margin: const EdgeInsets.symmetric(horizontal: 4),
width: active ? 22 : 8,
height: 6,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: active
? AppColor.primaryColor
: (isDark ? Colors.white12 : const Color(0xFFE5E7EB)),
),
);
}),
);
},
),
const SizedBox(height: 28),
_isLoading
? _LoadingIndicator()
: _PrimaryButton(
label: 'verify and continue button'.tr,
onPressed: _submit,
),
],
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// REGISTRATION SCREEN
// ─────────────────────────────────────────────────────────────────────────────
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);
}
}
Widget _buildTextFormField({
required BuildContext context,
required TextEditingController controller,
required String label,
required IconData icon,
TextInputType keyboardType = TextInputType.text,
bool optional = false,
String? Function(String?)? validator,
}) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return _AuthTextField(
controller: controller,
label: label,
icon: icon,
isDark: isDark,
keyboardType: keyboardType,
validator: validator,
);
}
@override
Widget build(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return AuthScreen(
title: 'one last step title'.tr,
subtitle: 'complete profile subtitle'.tr,
form: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Header row
Row(
children: [
Container(
padding: const EdgeInsets.all(7),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: AppColor.primaryColor.withOpacity(0.12),
),
child: Icon(Icons.person_outline_rounded,
size: 18, color: AppColor.primaryColor),
),
const SizedBox(width: 10),
Text(
'Complete your profile'.tr,
style: TextStyle(
color: _textMain(isDark),
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
],
),
const SizedBox(height: 20),
Row(
children: [
Expanded(
child: _buildTextFormField(
context: context,
controller: _firstNameController,
label: 'first name label'.tr,
icon: Icons.badge_outlined,
validator: (v) =>
v!.isEmpty ? 'first name required'.tr : null,
),
),
const SizedBox(width: 12),
Expanded(
child: _buildTextFormField(
context: context,
controller: _lastNameController,
label: 'last name label'.tr,
icon: Icons.badge_outlined,
validator: (v) =>
v!.isEmpty ? 'last name required'.tr : null,
),
),
],
),
const SizedBox(height: 14),
_buildTextFormField(
context: context,
controller: _emailController,
label: 'email optional label'.tr,
icon: Icons.email_outlined,
keyboardType: TextInputType.emailAddress,
optional: true,
),
const SizedBox(height: 24),
_isLoading
? _LoadingIndicator()
: _PrimaryButton(
label: 'complete registration button'.tr,
onPressed: _submit,
),
],
),
),
);
}
}
// ─────────────────────────────────────────────────────────────────────────────
// SHARED PRIVATE WIDGETS (scoped to this file)
// ─────────────────────────────────────────────────────────────────────────────
/// Reusable styled text field with icon prefix.
class _AuthTextField extends StatelessWidget {
final TextEditingController controller;
final String label;
final IconData icon;
final bool isDark;
final bool obscureText;
final TextInputType? keyboardType;
final String? Function(String?)? validator;
const _AuthTextField({
required this.controller,
required this.label,
required this.icon,
required this.isDark,
this.obscureText = false,
this.keyboardType,
this.validator,
});
@override
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
obscureText: obscureText,
keyboardType: keyboardType,
style: TextStyle(
color: _textMain(isDark),
fontSize: 14.5,
),
decoration: InputDecoration(
labelText: label,
prefixIcon: Icon(icon,
size: 20, color: isDark ? Colors.white38 : const Color(0xFF9CA3AF)),
labelStyle: TextStyle(color: _textSub(isDark), fontSize: 13.5),
filled: true,
fillColor: isDark ? Colors.white.withOpacity(0.05) : Colors.white,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 15),
enabledBorder: _inputBorder(isDark),
focusedBorder: _inputBorder(isDark, focused: true),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xFFEF4444), width: 1),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xFFEF4444), width: 1.5),
),
),
validator: validator,
);
}
}
/// Full-width gradient primary button.
class _PrimaryButton extends StatelessWidget {
final String label;
final VoidCallback onPressed;
const _PrimaryButton({required this.label, required this.onPressed});
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: 52,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
AppColor.primaryColor,
AppColor.primaryColor.withOpacity(0.8),
],
),
boxShadow: [
BoxShadow(
color: AppColor.primaryColor.withOpacity(0.32),
blurRadius: 16,
offset: const Offset(0, 6),
),
],
),
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
),
child: Text(
label,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 15,
letterSpacing: 0.4,
),
),
),
),
);
}
}
/// Branded loading indicator.
class _LoadingIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
width: 28,
height: 28,
child: CircularProgressIndicator(
color: AppColor.primaryColor,
strokeWidth: 2.5,
),
);
}
}

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(3, (index) => FocusNode());
final List<TextEditingController> _textControllers =
List.generate(3, (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 < 2) {
_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(3, (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:siro_rider/constant/style.dart';
import 'package:siro_rider/controller/auth/register_controller.dart';
import 'package:siro_rider/views/widgets/elevated_btn.dart';
import 'package:siro_rider/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: BoxDecoration(
boxShadow: const [
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:siro_rider/constant/style.dart';
import 'package:siro_rider/controller/auth/register_controller.dart';
import 'package:siro_rider/views/widgets/elevated_btn.dart';
import 'package:siro_rider/views/widgets/my_scafold.dart';
import 'package:siro_rider/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}');
Log.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:siro_rider/constant/colors.dart';
import 'package:siro_rider/constant/style.dart';
import 'package:siro_rider/controller/auth/register_controller.dart';
import 'package:siro_rider/views/widgets/elevated_btn.dart';
import 'package:siro_rider/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,
),
),
),
),
);
}
}