Hide country dropdown on subsequent runs once a country is set in local storage
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user