6/25/1
This commit is contained in:
51
lib/views/home/my_wallet/bank_account_egypt.dart
Normal file
51
lib/views/home/my_wallet/bank_account_egypt.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class BankController extends GetxController {
|
||||
String selectedBank = '';
|
||||
Map<String, String> bankNames = {
|
||||
'CIB Bank'.tr: 'CIB',
|
||||
'National Bank of Egypt'.tr: 'NBE',
|
||||
'QNB Al Ahli'.tr: 'QNB',
|
||||
'Bank Misr'.tr: 'BM',
|
||||
// Add other bank full names and short names here
|
||||
};
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
selectedBank = bankNames.values.first;
|
||||
}
|
||||
|
||||
void updateSelectedBank(String? bankShortName) {
|
||||
selectedBank = bankShortName ?? '';
|
||||
update();
|
||||
}
|
||||
|
||||
List<DropdownMenuItem<String>> getDropdownItems() {
|
||||
return bankNames.keys.map<DropdownMenuItem<String>>((bankFullName) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: bankNames[bankFullName],
|
||||
child: Text(bankFullName),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class BankDropdown extends StatelessWidget {
|
||||
final BankController bankController = Get.put(BankController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<BankController>(
|
||||
init: bankController,
|
||||
builder: (controller) {
|
||||
return DropdownButton<String>(
|
||||
value: controller.selectedBank,
|
||||
onChanged: controller.updateSelectedBank,
|
||||
items: controller.getDropdownItems(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user