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';
|
'${AppLink.server}/Admin/auth/login.php';
|
||||||
|
|
||||||
var selectedCountry = 'Jordan'.obs;
|
var selectedCountry = 'Jordan'.obs;
|
||||||
|
bool isFirstRun = box.read(BoxName.countryCode) == null;
|
||||||
|
|
||||||
void changeCountry(String country) {
|
void changeCountry(String country) {
|
||||||
selectedCountry.value = country;
|
selectedCountry.value = country;
|
||||||
@@ -288,6 +289,9 @@ class OtpHelper extends GetxController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
|
if (box.read(BoxName.countryCode) == null) {
|
||||||
|
box.write(BoxName.countryCode, 'Jordan');
|
||||||
|
}
|
||||||
selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan';
|
selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan';
|
||||||
super.onInit();
|
super.onInit();
|
||||||
DeviceHelper.getDeviceFingerprint().then((deviceFingerprint) {
|
DeviceHelper.getDeviceFingerprint().then((deviceFingerprint) {
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ class _AdminLoginPageState extends State<AdminLoginPage>
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (Get.find<OtpHelper>().isFirstRun) ...[
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
// ── Country Dropdown ───────────────────────────
|
// ── Country Dropdown ───────────────────────────
|
||||||
@@ -349,6 +350,7 @@ class _AdminLoginPageState extends State<AdminLoginPage>
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
const SizedBox(height: 28),
|
const SizedBox(height: 28),
|
||||||
|
],
|
||||||
|
|
||||||
// ── Submit button ────────────────────────────
|
// ── Submit button ────────────────────────────
|
||||||
_isLoading
|
_isLoading
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class LoginController extends GetxController {
|
|||||||
final FlutterSecureStorage storage = const FlutterSecureStorage();
|
final FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||||
|
|
||||||
var selectedCountry = 'Jordan'.obs;
|
var selectedCountry = 'Jordan'.obs;
|
||||||
|
bool isFirstRun = box.read(BoxName.countryCode) == null;
|
||||||
|
|
||||||
void changeCountry(String country) {
|
void changeCountry(String country) {
|
||||||
selectedCountry.value = country;
|
selectedCountry.value = country;
|
||||||
@@ -184,6 +185,9 @@ class LoginController extends GetxController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() async {
|
void onInit() async {
|
||||||
|
if (box.read(BoxName.countryCode) == null) {
|
||||||
|
await box.write(BoxName.countryCode, 'Jordan');
|
||||||
|
}
|
||||||
selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan';
|
selectedCountry.value = box.read(BoxName.countryCode) ?? 'Jordan';
|
||||||
await EncryptionHelper.initialize();
|
await EncryptionHelper.initialize();
|
||||||
await DeviceHelper.getDeviceFingerprint();
|
await DeviceHelper.getDeviceFingerprint();
|
||||||
|
|||||||
@@ -100,8 +100,7 @@ class LoginPage extends StatelessWidget {
|
|||||||
hint: 'أدخل كلمة المرور',
|
hint: 'أدخل كلمة المرور',
|
||||||
type: TextInputType.visiblePassword,
|
type: TextInputType.visiblePassword,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
if (controller.isFirstRun) ...[
|
||||||
|
|
||||||
Obx(() => Container(
|
Obx(() => Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -131,6 +130,7 @@ class LoginPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
|
],
|
||||||
|
|
||||||
// Login Button
|
// Login Button
|
||||||
Container(
|
Container(
|
||||||
|
|||||||
Reference in New Issue
Block a user