mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-21 10:24:15 +01:00
cake pay country picker (#1779)
* cake pay country picker * UI changes * hide picker after the country is set * Revert "hide picker after the country is set" This reverts commit cce358b94f55c22e0807b4d3641a13ebd299106c. * show country picker initially * flags * minor ui fixes * Update lib/view_model/cake_pay/cake_pay_cards_list_view_model.dart --------- Co-authored-by: tuxpizza <tuxsudo@tux.pizza> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
tuxpizza
Omar Hatem
parent
c8cfc2cff1
commit
48457fdd6d
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:cake_wallet/cake_pay/cake_pay_order.dart';
|
||||
import 'package:cake_wallet/cake_pay/cake_pay_user_credentials.dart';
|
||||
import 'package:cake_wallet/cake_pay/cake_pay_vendor.dart';
|
||||
import 'package:cake_wallet/entities/country.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class CakePayApi {
|
||||
@@ -171,7 +172,7 @@ class CakePayApi {
|
||||
}
|
||||
|
||||
/// Get Countries
|
||||
Future<List<String>> getCountries(
|
||||
Future<List<Country>> getCountries(
|
||||
{required String CSRFToken, required String authorization}) async {
|
||||
final uri = Uri.https(baseCakePayUri, countriesPath);
|
||||
|
||||
@@ -188,8 +189,11 @@ class CakePayApi {
|
||||
}
|
||||
|
||||
final bodyJson = json.decode(response.body) as List;
|
||||
|
||||
return bodyJson.map<String>((country) => country['name'] as String).toList();
|
||||
return bodyJson
|
||||
.map<String>((country) => country['name'] as String)
|
||||
.map((name) => Country.fromCakePayName(name))
|
||||
.whereType<Country>()
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Get Vendors
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:cake_wallet/cake_pay/cake_pay_api.dart';
|
||||
import 'package:cake_wallet/cake_pay/cake_pay_order.dart';
|
||||
import 'package:cake_wallet/cake_pay/cake_pay_vendor.dart';
|
||||
import 'package:cake_wallet/core/secure_storage.dart';
|
||||
import 'package:cake_wallet/entities/country.dart';
|
||||
|
||||
class CakePayService {
|
||||
CakePayService(this.secureStorage, this.cakePayApi);
|
||||
@@ -23,7 +24,7 @@ class CakePayService {
|
||||
final CakePayApi cakePayApi;
|
||||
|
||||
/// Get Available Countries
|
||||
Future<List<String>> getCountries() async =>
|
||||
Future<List<Country>> getCountries() async =>
|
||||
await cakePayApi.getCountries(CSRFToken: CSRFToken, authorization: authorization);
|
||||
|
||||
/// Get Vendors
|
||||
|
||||
Reference in New Issue
Block a user