Update: 2026-05-13 22:58:30
This commit is contained in:
@@ -7,6 +7,7 @@ class PhoneInputView extends StatelessWidget {
|
||||
|
||||
final AuthController controller = Get.put(AuthController());
|
||||
final TextEditingController phoneController = TextEditingController();
|
||||
final TextEditingController passwordController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -36,24 +37,47 @@ class PhoneInputView extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'أدخل رقم هاتفك المسجل في النظام لتسجيل الدخول',
|
||||
'أدخل رقم هاتفك أو البريد الإلكتروني لتسجيل الدخول',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
TextField(
|
||||
controller: phoneController,
|
||||
keyboardType: TextInputType.phone,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textDirection: TextDirection.ltr,
|
||||
onChanged: (val) => controller.phone.value = val,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'رقم الهاتف',
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
labelText: 'رقم الهاتف أو البريد الإلكتروني',
|
||||
prefixIcon: const Icon(Icons.person_outline),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 16),
|
||||
Obx(() {
|
||||
final isEmail = controller.phone.value.contains('@');
|
||||
if (!isEmail) return const SizedBox.shrink();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: passwordController,
|
||||
obscureText: true,
|
||||
textDirection: TextDirection.ltr,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'كلمة المرور',
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
);
|
||||
}),
|
||||
Obx(() => ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
@@ -63,10 +87,24 @@ class PhoneInputView extends StatelessWidget {
|
||||
),
|
||||
onPressed: controller.isLoading.value
|
||||
? null
|
||||
: () => controller.requestOtp(phoneController.text),
|
||||
: () {
|
||||
if (controller.phone.value.contains('@')) {
|
||||
controller.loginWithEmail(
|
||||
controller.phone.value,
|
||||
passwordController.text
|
||||
);
|
||||
} else {
|
||||
controller.requestOtp(phoneController.text);
|
||||
}
|
||||
},
|
||||
child: controller.isLoading.value
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
: const Text('إرسال رمز التحقق', style: TextStyle(fontSize: 16)),
|
||||
: Text(
|
||||
controller.phone.value.contains('@')
|
||||
? 'تسجيل الدخول'
|
||||
: 'إرسال رمز التحقق',
|
||||
style: const TextStyle(fontSize: 16)
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user