rework _getCurrencyImage func

Serhii committed Dec 3, 2022 at 00:34 UTC 4c7a0a8cb97a4e1af58127bd52e185a3ae60a4e5
1 file changed +6 -68
lib/src/screens/contact/contact_list_page.dart
+6 -68
@@ -111,7 +111,10 @@ class ContactListPage extends BasePage {
111 }
112
113 Widget generateRaw(BuildContext context, ContactBase contact) {
114 - final image = _getCurrencyImage(contact.type);
114 + final image = contact.type.iconPath;
115 + final currencyIcon = image != null ? Image.asset(image, height: 24, width: 24)
116 + : const SizedBox(height: 24, width: 24);
117 +
118
119 return GestureDetector(
120 onTap: () async {
@@ -136,12 +139,10 @@ class ContactListPage extends BasePage {
139 mainAxisSize: MainAxisSize.min,
140 mainAxisAlignment: MainAxisAlignment.start,
141 children: <Widget>[
139 - image ?? Offstage(),
142 + currencyIcon,
143 Expanded(
144 child: Padding(
142 - padding: image != null
143 - ? EdgeInsets.only(left: 12)
144 - : EdgeInsets.only(left: 0),
145 + padding: EdgeInsets.only(left: 12),
146 child: Text(
147 contact.name,
148 style: TextStyle(
@@ -157,69 +158,6 @@ class ContactListPage extends BasePage {
158 );
159 }
160
160 - Image? _getCurrencyImage(CryptoCurrency currency) {
161 - Image? image;
162 -
163 - switch (currency) {
164 - case CryptoCurrency.xmr:
165 - image =
166 - Image.asset('assets/images/monero_logo.png', height: 24, width: 24);
167 - break;
168 - case CryptoCurrency.ada:
169 - image = Image.asset('assets/images/ada.png', height: 24, width: 24);
170 - break;
171 - case CryptoCurrency.bch:
172 - image = Image.asset('assets/images/bch.png', height: 24, width: 24);
173 - break;
174 - case CryptoCurrency.bnb:
175 - image = Image.asset('assets/images/bnb.png', height: 24, width: 24);
176 - break;
177 - case CryptoCurrency.btc:
178 - image = Image.asset('assets/images/bitcoin.png', height: 24, width: 24);
179 - break;
180 - case CryptoCurrency.dai:
181 - image = Image.asset('assets/images/dai.png', height: 24, width: 24);
182 - break;
183 - case CryptoCurrency.dash:
184 - image = Image.asset('assets/images/dash.png', height: 24, width: 24);
185 - break;
186 - case CryptoCurrency.eos:
187 - image = Image.asset('assets/images/eos.png', height: 24, width: 24);
188 - break;
189 - case CryptoCurrency.eth:
190 - image = Image.asset('assets/images/eth.png', height: 24, width: 24);
191 - break;
192 - case CryptoCurrency.ltc:
193 - image =
194 - Image.asset('assets/images/litecoin.png', height: 24, width: 24);
195 - break;
196 - case CryptoCurrency.nano:
197 - image = Image.asset('assets/images/nano.png', height: 24, width: 24);
198 - break;
199 - case CryptoCurrency.trx:
200 - image = Image.asset('assets/images/trx.png', height: 24, width: 24);
201 - break;
202 - case CryptoCurrency.usdt:
203 - image = Image.asset('assets/images/usdt.png', height: 24, width: 24);
204 - break;
205 - case CryptoCurrency.usdterc20:
206 - image = Image.asset('assets/images/usdterc.png', height: 24, width: 24);
207 - break;
208 - case CryptoCurrency.xlm:
209 - image = Image.asset('assets/images/xlm.png', height: 24, width: 24);
210 - break;
211 - case CryptoCurrency.xrp:
212 - image = Image.asset('assets/images/xrp.png', height: 24, width: 24);
213 - break;
214 - case CryptoCurrency.xhv:
215 - image = Image.asset('assets/images/haven_logo.png', height: 24, width: 24);
216 - break;
217 - default:
218 - image = null;
219 - }
220 - return image;
221 - }
222 -
161 Future<bool> showAlertDialog(BuildContext context) async {
162 return await showPopUp<bool>(
163 context: context,