diff --git a/siro_admin/lib/controller/auth/otp_helper.dart b/siro_admin/lib/controller/auth/otp_helper.dart index 30b0ef6e..b26fad08 100644 --- a/siro_admin/lib/controller/auth/otp_helper.dart +++ b/siro_admin/lib/controller/auth/otp_helper.dart @@ -24,6 +24,7 @@ class OtpHelper extends GetxController { '${AppLink.server}/Admin/auth/login.php'; var selectedCountry = 'Jordan'.obs; + bool isFirstRun = box.read(BoxName.countryCode) == null; void changeCountry(String country) { selectedCountry.value = country; @@ -288,6 +289,9 @@ class OtpHelper extends GetxController { @override void onInit() { + if (box.read(BoxName.countryCode) == null) { + box.write(BoxName.countryCode, 'Jordan'); + } selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan'; super.onInit(); DeviceHelper.getDeviceFingerprint().then((deviceFingerprint) { diff --git a/siro_admin/lib/views/auth/login_page.dart b/siro_admin/lib/views/auth/login_page.dart index d42e04b5..0c335c09 100644 --- a/siro_admin/lib/views/auth/login_page.dart +++ b/siro_admin/lib/views/auth/login_page.dart @@ -297,58 +297,60 @@ class _AdminLoginPageState extends State return null; }, ), - const SizedBox(height: 20), + if (Get.find().isFirstRun) ...[ + 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, + // ── 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: 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), ), - ), - ); - }), - const SizedBox(height: 28), + 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 ──────────────────────────── _isLoading diff --git a/siro_service/lib/controller/login_controller.dart b/siro_service/lib/controller/login_controller.dart index cc56bdb3..4f898c96 100644 --- a/siro_service/lib/controller/login_controller.dart +++ b/siro_service/lib/controller/login_controller.dart @@ -22,6 +22,7 @@ class LoginController extends GetxController { final FlutterSecureStorage storage = const FlutterSecureStorage(); var selectedCountry = 'Jordan'.obs; + bool isFirstRun = box.read(BoxName.countryCode) == null; void changeCountry(String country) { selectedCountry.value = country; @@ -184,6 +185,9 @@ class LoginController extends GetxController { @override void onInit() async { + if (box.read(BoxName.countryCode) == null) { + await box.write(BoxName.countryCode, 'Jordan'); + } 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 b7e0fb47..fdace61a 100644 --- a/siro_service/lib/login_page.dart +++ b/siro_service/lib/login_page.dart @@ -100,37 +100,37 @@ 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); - } - }, + if (controller.isFirstRun) ...[ + 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)), ), - ), - )), - const SizedBox(height: 40), + 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 Container(