mirror of
https://github.com/hmalik144/easy_cc_flutter.git
synced 2025-12-10 03:05:34 +00:00
Ability to cache currency selection (#5)
This commit is contained in:
@@ -19,7 +19,7 @@ abstract class BaseStatelessWidget<T extends BaseViewmodel>
|
||||
Widget build(BuildContext parent) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(PADDING_GLOBAL),
|
||||
padding: const EdgeInsets.all(paddingGlobal),
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
|
||||
import 'BaseStatelessWidget.dart';
|
||||
import 'Utils/Constants.dart';
|
||||
|
||||
class HomePage extends BaseStatelessWidget<MainViewModel> {
|
||||
@override
|
||||
@@ -15,11 +16,13 @@ class HomePage extends BaseStatelessWidget<MainViewModel> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget displayWidget(
|
||||
BuildContext context, MainViewModel model, Widget? child) {
|
||||
Widget displayWidget(BuildContext context, MainViewModel model, Widget? child) {
|
||||
TextEditingController controller1 = TextEditingController();
|
||||
TextEditingController controller2 = TextEditingController();
|
||||
|
||||
String selected1 = model.getConversionPair(SelectionType.conversionFrom);
|
||||
String selected2 = model.getConversionPair(SelectionType.conversionTo);
|
||||
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -27,7 +30,10 @@ class HomePage extends BaseStatelessWidget<MainViewModel> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
DropDownBox(model.data, (selected) {}),
|
||||
DropDownBox(listOfCurrencies, selected1, (selected) {
|
||||
selected1 = selected!;
|
||||
model.setConversionPair(selected1, selected2);
|
||||
}),
|
||||
ConverterEditText("Enter conversion from", controller1, (input) => {
|
||||
controller2.text = model.convertInput(input, SelectionType.conversionFrom)
|
||||
})
|
||||
@@ -38,7 +44,10 @@ class HomePage extends BaseStatelessWidget<MainViewModel> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
DropDownBox(model.data, (selected) {}),
|
||||
DropDownBox(listOfCurrencies, selected2, (selected) {
|
||||
selected2 = selected!;
|
||||
model.setConversionPair(selected1, selected2);
|
||||
}),
|
||||
ConverterEditText("Enter conversion from", controller2, (input) => {
|
||||
controller1.text = model.convertInput(input, SelectionType.conversionTo)
|
||||
})
|
||||
|
||||
@@ -1,165 +1,33 @@
|
||||
import 'package:easy_cc_flutter/BaseViewModel.dart';
|
||||
import 'package:easy_cc_flutter/Utils/SelectionType.dart';
|
||||
|
||||
import 'Utils/Constants.dart';
|
||||
import 'data/prefs/CurrencyPair.dart';
|
||||
import 'data/repository/Repository.dart';
|
||||
import 'data/repository/RepositoryImpl.dart';
|
||||
import 'locator.dart';
|
||||
|
||||
class MainViewModel extends BaseViewmodel {
|
||||
final Repository _repository = locator<RepositoryImpl>();
|
||||
|
||||
double conversionRate = 1.4;
|
||||
|
||||
final List<String> data = <String>['ALL - Albanian Lek',
|
||||
'AFN - Afghan Afghani',
|
||||
'DZD - Algerian Dinar',
|
||||
'AOA - Angolan Kwanza',
|
||||
'ARS - Argentine Peso',
|
||||
'AMD - Armenian Dram',
|
||||
'AWG - Aruban Florin',
|
||||
'AUD - Australian Dollar',
|
||||
'AZN - Azerbaijani Manat',
|
||||
'BSD - Bahamian Dollar',
|
||||
'BHD - Bahraini Dinar',
|
||||
'BDT - Bangladeshi Taka',
|
||||
'BBD - Barbadian Dollar',
|
||||
'BYR - Belarusian Ruble',
|
||||
'BZD - Belize Dollar',
|
||||
'BTN - Bhutanese Ngultrum',
|
||||
'BTC - Bitcoin',
|
||||
'BOB - Bolivian Boliviano',
|
||||
'BAM - Bosnia And Herzegovina Konvertibilna Marka',
|
||||
'BWP - Botswana Pula',
|
||||
'BRL - Brazilian Real',
|
||||
'GBP - British Pound',
|
||||
'BND - Brunei Dollar',
|
||||
'BGN - Bulgarian Lev',
|
||||
'BIF - Burundi Franc',
|
||||
'KHR - Cambodian Riel',
|
||||
'CAD - Canadian Dollar',
|
||||
'CVE - Cape Verdean Escudo',
|
||||
'KYD - Cayman Islands Dollar',
|
||||
'XAF - Central African CFA Franc',
|
||||
'XPF - CFP Franc',
|
||||
'CLP - Chilean Peso',
|
||||
'CNY - Chinese Yuan',
|
||||
'COP - Colombian Peso',
|
||||
'KMF - Comorian Franc',
|
||||
'CDF - Congolese Franc',
|
||||
'CRC - Costa Rican Colon',
|
||||
'HRK - Croatian Kuna',
|
||||
'CUP - Cuban Peso',
|
||||
'CZK - Czech Koruna',
|
||||
'DKK - Danish Krone',
|
||||
'DJF - Djiboutian Franc',
|
||||
'DOP - Dominican Peso',
|
||||
'XCD - East Caribbean Dollar',
|
||||
'EGP - Egyptian Pound',
|
||||
'ERN - Eritrean Nakfa',
|
||||
'ETB - Ethiopian Birr',
|
||||
'EUR - Euro',
|
||||
'FKP - Falkland Islands Pound',
|
||||
'FJD - Fijian Dollar',
|
||||
'GMD - Gambian Dalasi',
|
||||
'GEL - Georgian Lari',
|
||||
'GHS - Ghanaian Cedi',
|
||||
'GIP - Gibraltar Pound',
|
||||
'GTQ - Guatemalan Quetzal',
|
||||
'GNF - Guinean Franc',
|
||||
'GYD - Guyanese Dollar',
|
||||
'HTG - Haitian Gourde',
|
||||
'HNL - Honduran Lempira',
|
||||
'HKD - Hong Kong Dollar',
|
||||
'HUF - Hungarian Forint',
|
||||
'ISK - Icelandic Kr\u00f3na',
|
||||
'INR - Indian Rupee',
|
||||
'IDR - Indonesian Rupiah',
|
||||
'IRR - Iranian Rial',
|
||||
'IQD - Iraqi Dinar',
|
||||
'ILS - Israeli New Sheqel',
|
||||
'JMD - Jamaican Dollar',
|
||||
'JPY - Japanese Yen',
|
||||
'JOD - Jordanian Dinar',
|
||||
'KZT - Kazakhstani Tenge',
|
||||
'KES - Kenyan Shilling',
|
||||
'KWD - Kuwaiti Dinar',
|
||||
'KGS - Kyrgyzstani Som',
|
||||
'LAK - Lao Kip',
|
||||
'LVL - Latvian Lats',
|
||||
'LBP - Lebanese Lira',
|
||||
'LSL - Lesotho Loti',
|
||||
'LRD - Liberian Dollar',
|
||||
'LYD - Libyan Dinar',
|
||||
'MOP - Macanese Pataca',
|
||||
'MKD - Macedonian Denar',
|
||||
'MGA - Malagasy Ariary',
|
||||
'MWK - Malawian Kwacha',
|
||||
'MYR - Malaysian Ringgit',
|
||||
'MVR - Maldivian Rufiyaa',
|
||||
'MRO - Mauritanian Ouguiya',
|
||||
'MUR - Mauritian Rupee',
|
||||
'MXN - Mexican Peso',
|
||||
'MDL - Moldovan Leu',
|
||||
'MNT - Mongolian Tugrik',
|
||||
'MAD - Moroccan Dirham',
|
||||
'MZN - Mozambican Metical',
|
||||
'MMK - Myanma Kyat',
|
||||
'NAD - Namibian Dollar',
|
||||
'NPR - Nepalese Rupee',
|
||||
'ANG - Netherlands Antillean Gulden',
|
||||
'TWD - New Taiwan Dollar',
|
||||
'NZD - New Zealand Dollar',
|
||||
'NIO - Nicaraguan Cordoba',
|
||||
'NGN - Nigerian Naira',
|
||||
'KPW - North Korean Won',
|
||||
'NOK - Norwegian Krone',
|
||||
'OMR - Omani Rial',
|
||||
'TOP - Paanga',
|
||||
'PKR - Pakistani Rupee',
|
||||
'PAB - Panamanian Balboa',
|
||||
'PGK - Papua New Guinean Kina',
|
||||
'PYG - Paraguayan Guarani',
|
||||
'PEN - Peruvian Nuevo Sol',
|
||||
'PHP - Philippine Peso',
|
||||
'PLN - Polish Zloty',
|
||||
'QAR - Qatari Riyal',
|
||||
'RON - Romanian Leu',
|
||||
'RUB - Russian Ruble',
|
||||
'RWF - Rwandan Franc',
|
||||
'SHP - Saint Helena Pound',
|
||||
'WST - Samoan Tala',
|
||||
'STD - Sao Tome And Principe Dobra',
|
||||
'SAR - Saudi Riyal',
|
||||
'RSD - Serbian Dinar',
|
||||
'SCR - Seychellois Rupee',
|
||||
'SLL - Sierra Leonean Leone',
|
||||
'SGD - Singapore Dollar',
|
||||
'SBD - Solomon Islands Dollar',
|
||||
'SOS - Somali Shilling',
|
||||
'ZAR - South African Rand',
|
||||
'KRW - South Korean Won',
|
||||
'XDR - Special Drawing Rights',
|
||||
'LKR - Sri Lankan Rupee',
|
||||
'SDG - Sudanese Pound',
|
||||
'SRD - Surinamese Dollar',
|
||||
'SZL - Swazi Lilangeni',
|
||||
'SEK - Swedish Krona',
|
||||
'CHF - Swiss Franc',
|
||||
'SYP - Syrian Pound',
|
||||
'TJS - Tajikistani Somoni',
|
||||
'TZS - Tanzanian Shilling',
|
||||
'THB - Thai Baht',
|
||||
'TTD - Trinidad and Tobago Dollar',
|
||||
'TND - Tunisian Dinar',
|
||||
'TRY - Turkish New Lira',
|
||||
'TMT - Turkmenistan Manat',
|
||||
'AED - UAE Dirham',
|
||||
'UGX - Ugandan Shilling',
|
||||
'UAH - Ukrainian Hryvnia',
|
||||
'USD - United States Dollar',
|
||||
'UYU - Uruguayan Peso',
|
||||
'UZS - Uzbekistani Som',
|
||||
'VUV - Vanuatu Vatu',
|
||||
'VEF - Venezuelan Bolivar',
|
||||
'VND - Vietnamese Dong',
|
||||
'XOF - West African CFA Franc',
|
||||
'YER - Yemeni Rial',
|
||||
'ZMW - Zambian Kwacha'];
|
||||
String getConversionPair(SelectionType type) {
|
||||
CurrencyPair pair = _repository.getConversionPair();
|
||||
|
||||
switch (type) {
|
||||
case SelectionType.conversionFrom:
|
||||
return pair.currencyOne != null ? pair.currencyOne! : listOfCurrencies[0];
|
||||
case SelectionType.conversionTo:
|
||||
return pair.currencyTwo != null ? pair.currencyTwo! : listOfCurrencies[0];
|
||||
default:
|
||||
throw NullThrownError();
|
||||
}
|
||||
}
|
||||
|
||||
void setConversionPair(String fromCurrency, String toCurrency) {
|
||||
_repository.setConversionPair(fromCurrency, toCurrency);
|
||||
}
|
||||
|
||||
String convertInput(String? input, SelectionType type) {
|
||||
if (input == null || input.isEmpty) {
|
||||
|
||||
@@ -6,4 +6,162 @@ const Color colourThree = Color(0xFF2978A0);
|
||||
const Color colourFour = Color(0xFF8549ff);
|
||||
const Color colourFive = Color(0xFFC6E0FF);
|
||||
|
||||
const double PADDING_GLOBAL = 12;
|
||||
const double paddingGlobal = 12;
|
||||
|
||||
final List<String> listOfCurrencies = <String>[
|
||||
'ALL - Albanian Lek',
|
||||
'AFN - Afghan Afghani',
|
||||
'DZD - Algerian Dinar',
|
||||
'AOA - Angolan Kwanza',
|
||||
'ARS - Argentine Peso',
|
||||
'AMD - Armenian Dram',
|
||||
'AWG - Aruban Florin',
|
||||
'AUD - Australian Dollar',
|
||||
'AZN - Azerbaijani Manat',
|
||||
'BSD - Bahamian Dollar',
|
||||
'BHD - Bahraini Dinar',
|
||||
'BDT - Bangladeshi Taka',
|
||||
'BBD - Barbadian Dollar',
|
||||
'BYR - Belarusian Ruble',
|
||||
'BZD - Belize Dollar',
|
||||
'BTN - Bhutanese Ngultrum',
|
||||
'BTC - Bitcoin',
|
||||
'BOB - Bolivian Boliviano',
|
||||
'BAM - Bosnia And Herzegovina Konvertibilna Marka',
|
||||
'BWP - Botswana Pula',
|
||||
'BRL - Brazilian Real',
|
||||
'GBP - British Pound',
|
||||
'BND - Brunei Dollar',
|
||||
'BGN - Bulgarian Lev',
|
||||
'BIF - Burundi Franc',
|
||||
'KHR - Cambodian Riel',
|
||||
'CAD - Canadian Dollar',
|
||||
'CVE - Cape Verdean Escudo',
|
||||
'KYD - Cayman Islands Dollar',
|
||||
'XAF - Central African CFA Franc',
|
||||
'XPF - CFP Franc',
|
||||
'CLP - Chilean Peso',
|
||||
'CNY - Chinese Yuan',
|
||||
'COP - Colombian Peso',
|
||||
'KMF - Comorian Franc',
|
||||
'CDF - Congolese Franc',
|
||||
'CRC - Costa Rican Colon',
|
||||
'HRK - Croatian Kuna',
|
||||
'CUP - Cuban Peso',
|
||||
'CZK - Czech Koruna',
|
||||
'DKK - Danish Krone',
|
||||
'DJF - Djiboutian Franc',
|
||||
'DOP - Dominican Peso',
|
||||
'XCD - East Caribbean Dollar',
|
||||
'EGP - Egyptian Pound',
|
||||
'ERN - Eritrean Nakfa',
|
||||
'ETB - Ethiopian Birr',
|
||||
'EUR - Euro',
|
||||
'FKP - Falkland Islands Pound',
|
||||
'FJD - Fijian Dollar',
|
||||
'GMD - Gambian Dalasi',
|
||||
'GEL - Georgian Lari',
|
||||
'GHS - Ghanaian Cedi',
|
||||
'GIP - Gibraltar Pound',
|
||||
'GTQ - Guatemalan Quetzal',
|
||||
'GNF - Guinean Franc',
|
||||
'GYD - Guyanese Dollar',
|
||||
'HTG - Haitian Gourde',
|
||||
'HNL - Honduran Lempira',
|
||||
'HKD - Hong Kong Dollar',
|
||||
'HUF - Hungarian Forint',
|
||||
'ISK - Icelandic Kr\u00f3na',
|
||||
'INR - Indian Rupee',
|
||||
'IDR - Indonesian Rupiah',
|
||||
'IRR - Iranian Rial',
|
||||
'IQD - Iraqi Dinar',
|
||||
'ILS - Israeli New Sheqel',
|
||||
'JMD - Jamaican Dollar',
|
||||
'JPY - Japanese Yen',
|
||||
'JOD - Jordanian Dinar',
|
||||
'KZT - Kazakhstani Tenge',
|
||||
'KES - Kenyan Shilling',
|
||||
'KWD - Kuwaiti Dinar',
|
||||
'KGS - Kyrgyzstani Som',
|
||||
'LAK - Lao Kip',
|
||||
'LVL - Latvian Lats',
|
||||
'LBP - Lebanese Lira',
|
||||
'LSL - Lesotho Loti',
|
||||
'LRD - Liberian Dollar',
|
||||
'LYD - Libyan Dinar',
|
||||
'MOP - Macanese Pataca',
|
||||
'MKD - Macedonian Denar',
|
||||
'MGA - Malagasy Ariary',
|
||||
'MWK - Malawian Kwacha',
|
||||
'MYR - Malaysian Ringgit',
|
||||
'MVR - Maldivian Rufiyaa',
|
||||
'MRO - Mauritanian Ouguiya',
|
||||
'MUR - Mauritian Rupee',
|
||||
'MXN - Mexican Peso',
|
||||
'MDL - Moldovan Leu',
|
||||
'MNT - Mongolian Tugrik',
|
||||
'MAD - Moroccan Dirham',
|
||||
'MZN - Mozambican Metical',
|
||||
'MMK - Myanma Kyat',
|
||||
'NAD - Namibian Dollar',
|
||||
'NPR - Nepalese Rupee',
|
||||
'ANG - Netherlands Antillean Gulden',
|
||||
'TWD - New Taiwan Dollar',
|
||||
'NZD - New Zealand Dollar',
|
||||
'NIO - Nicaraguan Cordoba',
|
||||
'NGN - Nigerian Naira',
|
||||
'KPW - North Korean Won',
|
||||
'NOK - Norwegian Krone',
|
||||
'OMR - Omani Rial',
|
||||
'TOP - Paanga',
|
||||
'PKR - Pakistani Rupee',
|
||||
'PAB - Panamanian Balboa',
|
||||
'PGK - Papua New Guinean Kina',
|
||||
'PYG - Paraguayan Guarani',
|
||||
'PEN - Peruvian Nuevo Sol',
|
||||
'PHP - Philippine Peso',
|
||||
'PLN - Polish Zloty',
|
||||
'QAR - Qatari Riyal',
|
||||
'RON - Romanian Leu',
|
||||
'RUB - Russian Ruble',
|
||||
'RWF - Rwandan Franc',
|
||||
'SHP - Saint Helena Pound',
|
||||
'WST - Samoan Tala',
|
||||
'STD - Sao Tome And Principe Dobra',
|
||||
'SAR - Saudi Riyal',
|
||||
'RSD - Serbian Dinar',
|
||||
'SCR - Seychellois Rupee',
|
||||
'SLL - Sierra Leonean Leone',
|
||||
'SGD - Singapore Dollar',
|
||||
'SBD - Solomon Islands Dollar',
|
||||
'SOS - Somali Shilling',
|
||||
'ZAR - South African Rand',
|
||||
'KRW - South Korean Won',
|
||||
'XDR - Special Drawing Rights',
|
||||
'LKR - Sri Lankan Rupee',
|
||||
'SDG - Sudanese Pound',
|
||||
'SRD - Surinamese Dollar',
|
||||
'SZL - Swazi Lilangeni',
|
||||
'SEK - Swedish Krona',
|
||||
'CHF - Swiss Franc',
|
||||
'SYP - Syrian Pound',
|
||||
'TJS - Tajikistani Somoni',
|
||||
'TZS - Tanzanian Shilling',
|
||||
'THB - Thai Baht',
|
||||
'TTD - Trinidad and Tobago Dollar',
|
||||
'TND - Tunisian Dinar',
|
||||
'TRY - Turkish New Lira',
|
||||
'TMT - Turkmenistan Manat',
|
||||
'AED - UAE Dirham',
|
||||
'UGX - Ugandan Shilling',
|
||||
'UAH - Ukrainian Hryvnia',
|
||||
'USD - United States Dollar',
|
||||
'UYU - Uruguayan Peso',
|
||||
'UZS - Uzbekistani Som',
|
||||
'VUV - Vanuatu Vatu',
|
||||
'VEF - Venezuelan Bolivar',
|
||||
'VND - Vietnamese Dong',
|
||||
'XOF - West African CFA Franc',
|
||||
'YER - Yemeni Rial',
|
||||
'ZMW - Zambian Kwacha'
|
||||
];
|
||||
6
lib/data/prefs/CurrencyPair.dart
Normal file
6
lib/data/prefs/CurrencyPair.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
class CurrencyPair {
|
||||
String? currencyOne;
|
||||
String? currencyTwo;
|
||||
|
||||
CurrencyPair(this.currencyOne, this.currencyTwo);
|
||||
}
|
||||
27
lib/data/prefs/PreferenceProvider.dart
Normal file
27
lib/data/prefs/PreferenceProvider.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'CurrencyPair.dart';
|
||||
|
||||
const String CURRENCY_ONE = "conversion_one";
|
||||
const String CURRENCY_TWO = "conversion_two";
|
||||
class PreferenceProvider {
|
||||
late final SharedPreferences _prefs;
|
||||
|
||||
Future<void> init() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
|
||||
Future<void> saveConversionPair(String s1, String s2) async {
|
||||
await _prefs.setString(CURRENCY_ONE, s1);
|
||||
await _prefs.setString(CURRENCY_TWO, s2);
|
||||
}
|
||||
|
||||
CurrencyPair getConversionPair() {
|
||||
String? s1 = _prefs.getString(CURRENCY_ONE);
|
||||
String? s2 = _prefs.getString(CURRENCY_TWO);
|
||||
|
||||
return CurrencyPair(s1, s2);
|
||||
}
|
||||
}
|
||||
6
lib/data/repository/Repository.dart
Normal file
6
lib/data/repository/Repository.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
import '../prefs/CurrencyPair.dart';
|
||||
|
||||
abstract class Repository {
|
||||
CurrencyPair getConversionPair();
|
||||
Future<void> setConversionPair(String fromCurrency, String toCurrency);
|
||||
}
|
||||
20
lib/data/repository/RepositoryImpl.dart
Normal file
20
lib/data/repository/RepositoryImpl.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:easy_cc_flutter/data/prefs/CurrencyPair.dart';
|
||||
import 'package:easy_cc_flutter/data/prefs/PreferenceProvider.dart';
|
||||
|
||||
import '../../locator.dart';
|
||||
import 'Repository.dart';
|
||||
|
||||
class RepositoryImpl extends Repository {
|
||||
final PreferenceProvider _prefs = locator<PreferenceProvider>();
|
||||
|
||||
@override
|
||||
CurrencyPair getConversionPair() {
|
||||
return _prefs.getConversionPair();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setConversionPair(String fromCurrency, String toCurrency) {
|
||||
return _prefs.saveConversionPair(fromCurrency, toCurrency);
|
||||
}
|
||||
|
||||
}
|
||||
14
lib/locator.dart
Normal file
14
lib/locator.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:easy_cc_flutter/MainViewModel.dart';
|
||||
import 'package:easy_cc_flutter/data/repository/RepositoryImpl.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import 'data/prefs/PreferenceProvider.dart';
|
||||
|
||||
GetIt locator = GetIt.instance;
|
||||
|
||||
void setupLocator() {
|
||||
|
||||
locator.registerLazySingleton(() => PreferenceProvider());
|
||||
locator.registerLazySingleton(() => RepositoryImpl());
|
||||
locator.registerFactory(() => MainViewModel());
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'Home.dart';
|
||||
import 'data/prefs/PreferenceProvider.dart';
|
||||
import 'locator.dart';
|
||||
|
||||
void main() {
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
setupLocator();
|
||||
await locator<PreferenceProvider>().init();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import 'package:dropdown_search/dropdown_search.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../Utils/Constants.dart';
|
||||
|
||||
class DropDownBox extends StatelessWidget {
|
||||
final List<String> _selection;
|
||||
final String _hintText;
|
||||
final Function(String?) _onChanged;
|
||||
|
||||
const DropDownBox(this._selection, this._onChanged, {super.key});
|
||||
const DropDownBox(this._selection, this._hintText, this._onChanged,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -18,20 +19,21 @@ class DropDownBox extends StatelessWidget {
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(22))),
|
||||
child: DropdownSearch<String>(
|
||||
popupProps: const PopupProps.dialog(showSearchBox: true),
|
||||
popupProps: const PopupProps.dialog(
|
||||
showSearchBox: true,
|
||||
dialogProps: DialogProps(backgroundColor: colourThree)),
|
||||
items: _selection,
|
||||
dropdownDecoratorProps: const DropDownDecoratorProps(
|
||||
dropdownDecoratorProps: DropDownDecoratorProps(
|
||||
dropdownSearchDecoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.all(14),
|
||||
contentPadding: const EdgeInsets.all(14),
|
||||
border: InputBorder.none,
|
||||
filled: true,
|
||||
fillColor: Colors.transparent,
|
||||
hintText: "Select a currency",
|
||||
hintText: _hintText,
|
||||
),
|
||||
),
|
||||
onChanged: _onChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user