From c4fd8592571860796a5fb2d27ed619b50ec7368c Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Mon, 29 Jun 2026 00:41:31 +0300 Subject: [PATCH] Add country dropdown selector to login screens of siro_service and siro_admin --- .../lib/controller/auth/otp_helper.dart | 8 +++ siro_admin/lib/views/auth/login_page.dart | 51 +++++++++++++++++++ .../lib/controller/login_controller.dart | 8 +++ siro_service/lib/login_page.dart | 31 ++++++++++- 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/siro_admin/lib/controller/auth/otp_helper.dart b/siro_admin/lib/controller/auth/otp_helper.dart index 96844437..30b0ef6e 100644 --- a/siro_admin/lib/controller/auth/otp_helper.dart +++ b/siro_admin/lib/controller/auth/otp_helper.dart @@ -23,6 +23,13 @@ class OtpHelper extends GetxController { static final String _checkAdminLogin = '${AppLink.server}/Admin/auth/login.php'; + var selectedCountry = 'Jordan'.obs; + + void changeCountry(String country) { + selectedCountry.value = country; + box.write(BoxName.countryCode, country); + } + /// إرسال OTP static Future sendOtp(String phoneNumber) async { try { @@ -281,6 +288,7 @@ class OtpHelper extends GetxController { @override void onInit() { + selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan'; super.onInit(); DeviceHelper.getDeviceFingerprint().then((deviceFingerprint) { box.write(BoxName.fingerPrint, deviceFingerprint); diff --git a/siro_admin/lib/views/auth/login_page.dart b/siro_admin/lib/views/auth/login_page.dart index ca2ca0d3..d42e04b5 100644 --- a/siro_admin/lib/views/auth/login_page.dart +++ b/siro_admin/lib/views/auth/login_page.dart @@ -297,6 +297,57 @@ class _AdminLoginPageState extends State return null; }, ), + const SizedBox(height: 20), + + // ── Country Dropdown ─────────────────────────── + const Row( + children: [ + Icon(Icons.public_rounded, + color: _C.accent, size: 16), + SizedBox(width: 8), + Text( + 'الدولة', + style: TextStyle( + color: _C.textSec, + fontSize: 13, + fontWeight: FontWeight.w600, + letterSpacing: 0.3, + ), + ), + ], + ), + const SizedBox(height: 10), + Obx(() { + final otpHelper = Get.find(); + return Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), + decoration: BoxDecoration( + color: _C.inputBg, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: _C.border, width: 1), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: otpHelper.selectedCountry.value, + icon: const Icon(Icons.arrow_drop_down, color: _C.accent), + isExpanded: true, + dropdownColor: _C.card, + style: const TextStyle(color: _C.textPrimary, fontSize: 16), + items: ['Jordan', 'Egypt', 'Syria'].map((String country) { + return DropdownMenuItem( + value: country, + child: Text(country.tr), + ); + }).toList(), + onChanged: (String? val) { + if (val != null) { + otpHelper.changeCountry(val); + } + }, + ), + ), + ); + }), const SizedBox(height: 28), // ── Submit button ──────────────────────────── diff --git a/siro_service/lib/controller/login_controller.dart b/siro_service/lib/controller/login_controller.dart index f57d84c3..cc56bdb3 100644 --- a/siro_service/lib/controller/login_controller.dart +++ b/siro_service/lib/controller/login_controller.dart @@ -21,6 +21,13 @@ class LoginController extends GetxController { final FlutterSecureStorage storage = const FlutterSecureStorage(); + var selectedCountry = 'Jordan'.obs; + + void changeCountry(String country) { + selectedCountry.value = country; + box.write(BoxName.countryCode, country); + } + void login() async { // Ensure fingerprint is ready String fingerprint = box.read(BoxName.fingerPrint) ?? ''; @@ -177,6 +184,7 @@ class LoginController extends GetxController { @override void onInit() async { + selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan'; await EncryptionHelper.initialize(); await DeviceHelper.getDeviceFingerprint(); diff --git a/siro_service/lib/login_page.dart b/siro_service/lib/login_page.dart index 1b6a8840..b7e0fb47 100644 --- a/siro_service/lib/login_page.dart +++ b/siro_service/lib/login_page.dart @@ -100,7 +100,36 @@ class LoginPage extends StatelessWidget { hint: 'أدخل كلمة المرور', type: TextInputType.visiblePassword, ), - + const SizedBox(height: 20), + + Obx(() => Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), + decoration: BoxDecoration( + color: Colors.grey.withOpacity(0.08), + borderRadius: BorderRadius.circular(16), + border: Border.all(color: Colors.grey.withOpacity(0.2)), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: controller.selectedCountry.value, + icon: const Icon(Icons.arrow_drop_down, color: AppColor.blueColor), + isExpanded: true, + dropdownColor: Colors.white, + style: const TextStyle(color: Colors.black87, fontSize: 16), + items: ['Jordan', 'Egypt', 'Syria'].map((String country) { + return DropdownMenuItem( + value: country, + child: Text(country.tr), + ); + }).toList(), + onChanged: (String? val) { + if (val != null) { + controller.changeCountry(val); + } + }, + ), + ), + )), const SizedBox(height: 40), // Login Button