Hide country dropdown on subsequent runs once a country is set in local storage

This commit is contained in:
Hamza-Ayed
2026-06-29 00:45:47 +03:00
parent c4fd859257
commit b5e2bf2fed
4 changed files with 89 additions and 79 deletions

View File

@@ -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) {

View File

@@ -297,6 +297,7 @@ class _AdminLoginPageState extends State<AdminLoginPage>
return null;
},
),
if (Get.find<OtpHelper>().isFirstRun) ...[
const SizedBox(height: 20),
// ── Country Dropdown ───────────────────────────
@@ -349,6 +350,7 @@ class _AdminLoginPageState extends State<AdminLoginPage>
);
}),
const SizedBox(height: 28),
],
// ── Submit button ────────────────────────────
_isLoading

View File

@@ -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();

View File

@@ -100,8 +100,7 @@ class LoginPage extends StatelessWidget {
hint: 'أدخل كلمة المرور',
type: TextInputType.visiblePassword,
),
const SizedBox(height: 20),
if (controller.isFirstRun) ...[
Obx(() => Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(
@@ -131,6 +130,7 @@ class LoginPage extends StatelessWidget {
),
)),
const SizedBox(height: 40),
],
// Login Button
Container(