Skip to content

Commit

Permalink
WIKIBANK - Send to another country code fixed (#209)
Browse files Browse the repository at this point in the history
* switch community on push with data (#207)

* switch community on push with data

* refactor

* change webview & add transak (#206)

* change webview

* back button on webview

* Bump version to 1.1.32+164

* fixed

* last fix

* added number to review page
  • Loading branch information
LiorAgnin authored May 18, 2020
1 parent 3a13b76 commit eb00678
Show file tree
Hide file tree
Showing 24 changed files with 547 additions and 719 deletions.
26 changes: 25 additions & 1 deletion lib/models/plugins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ class MoonpayPlugin extends DepositPlugin {
: null;
}

class TransakPlugin extends DepositPlugin {
TransakPlugin({name, isActive, widgetUrl}) : super(name, isActive, widgetUrl);

static TransakPlugin fromJson(dynamic json) => json != null
? TransakPlugin(
name: json['name'],
widgetUrl: json['widgetUrl'],
isActive: json["isActive"] || false,
)
: null;
}

class CarbonPlugin extends DepositPlugin {
CarbonPlugin({name, isActive, widgetUrl}) : super(name, isActive, widgetUrl);

Expand Down Expand Up @@ -187,6 +199,8 @@ class RampPlugin extends DepositPlugin {
class Plugins {
@JsonKey(name: 'moonpay', fromJson: _moonpayFromJson, toJson: _moonpayToJson, includeIfNull: false)
MoonpayPlugin moonpay;
@JsonKey(name: 'transak', fromJson: _transakFromJson, toJson: _transakToJson, includeIfNull: false)
TransakPlugin transak;
@JsonKey(name: 'carbon', fromJson: _carbonFromJson, toJson: _carbonToJson, includeIfNull: false)
CarbonPlugin carbon;
@JsonKey(name: 'wyre', fromJson: _wyreFromJson, toJson: _wyreToJson, includeIfNull: false)
Expand All @@ -204,7 +218,7 @@ class Plugins {
@JsonKey(name: 'inviteBonus', fromJson: _inviteBonusFromJson, toJson: _inviteBonusToJson, includeIfNull: false)
InviteBonusPlugin inviteBonus;

Plugins({this.moonpay, this.carbon, this.wyre, this.coindirect, this.ramp, this.joinBonus, this.walletBanner, this.backupBonus, this.inviteBonus});
Plugins({this.moonpay, this.transak, this.carbon, this.wyre, this.coindirect, this.ramp, this.joinBonus, this.walletBanner, this.backupBonus, this.inviteBonus});

static Map getServicesMap (dynamic json) {
if (json.containsKey('onramp')) {
Expand All @@ -225,6 +239,7 @@ class Plugins {
dynamic services= Plugins.getServicesMap(json);
return Plugins(
moonpay: MoonpayPlugin.fromJson(services["moonpay"]),
transak: TransakPlugin.fromJson(services["transak"]),
carbon: CarbonPlugin.fromJson(services["carbon"]),
wyre: WyrePlugin.fromJson(services["wyre"]),
coindirect: CoindirectPlugin.fromJson(services["coindirect"]),
Expand Down Expand Up @@ -280,9 +295,15 @@ class Plugins {
static MoonpayPlugin _moonpayFromJson(Map<String, dynamic> json) =>
json == null ? null : MoonpayPlugin.fromJson(json);

static TransakPlugin _transakFromJson(Map<String, dynamic> json) =>
json == null ? null : TransakPlugin.fromJson(json);

static Map<String, dynamic> _moonpayToJson(MoonpayPlugin moonpay) =>
moonpay != null ? moonpay.toJson() : null;

static Map<String, dynamic> _transakToJson(TransakPlugin transak) =>
transak != null ? transak.toJson() : null;

static CarbonPlugin _carbonFromJson(Map<String, dynamic> json) =>
json == null ? null : CarbonPlugin.fromJson(json);

Expand All @@ -291,6 +312,9 @@ class Plugins {

List getDepositPlugins() {
List depositPlugins = [];
if (this.transak != null && this.transak.isActive) {
depositPlugins.add(this.transak);
}
if (this.moonpay != null && this.moonpay.isActive) {
depositPlugins.add(this.moonpay);
}
Expand Down
1 change: 1 addition & 0 deletions lib/models/plugins.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions lib/redux/actions/cash_wallet_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:supervecina/redux/actions/user_actions.dart';
import 'package:supervecina/utils/addresses.dart';
import 'package:supervecina/redux/state/store.dart';
import 'package:supervecina/utils/constans.dart';
import 'package:supervecina/utils/firebase.dart';
import 'package:supervecina/utils/forks.dart';
import 'package:supervecina/utils/format.dart';
import 'package:http/http.dart';
Expand Down Expand Up @@ -252,15 +253,22 @@ ThunkAction enablePushNotifications() {
},
});

void switchOnPush(message) {
String communityAddress = communityAddressFromNotification(message);
if (communityAddress != null && communityAddress.isNotEmpty) {
// store.dispatch(switchCommunityCall(communityAddress));
}
}

firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
logger.info('onMessage called: $message');
switchOnPush(message);
},
onResume: (Map<String, dynamic> message) async {
logger.info('onResume called: $message');
switchOnPush(message);
},
onLaunch: (Map<String, dynamic> message) async {
logger.info('onLaunch called: $message');
switchOnPush(message);
},
);
} catch (e) {
Expand Down Expand Up @@ -300,7 +308,7 @@ ThunkAction segmentIdentifyCall(Map<String, dynamic> traits) {
final logger = await AppFactory().getLogger('action');
try {
UserState userState = store.state.userState;
String fullPhoneNumber = store.state.userState.normalizedPhoneNumber ?? '';// formatPhoneNumber(store.state.userState.phoneNumber, store.state.userState.countryCode);
String fullPhoneNumber = store.state.userState.normalizedPhoneNumber ?? '';
logger.info('Identify - $fullPhoneNumber');
traits = traits ?? new Map<String, dynamic>();
DateTime installedAt = userState.installedAt;
Expand Down
35 changes: 14 additions & 21 deletions lib/redux/actions/user_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,33 +310,26 @@ ThunkAction syncContactsCall(List<Contact> contacts) {
String countryCode = store.state.userState.countryCode;
String isoCode = store.state.userState.isoCode;
for (Contact contact in contacts) {
if (isoCode == null) {
List<String> uniquePhone = contact.phones
.map((Item phone) => formatPhoneNumber(
phone.value, store.state.userState.countryCode))
.toSet()
.toList();
for (String phone in uniquePhone) {
if (!syncedContacts.contains(phone)) {
newPhones.add(phone);
}
}
} else {
Future<List<String>> phones = Future.wait(contact.phones.map((Item phone) async {
Future<List<String>> phones = Future.wait(contact.phones.map((Item phone) async {
String value = clearNotNumbersAndPlusSymbol(phone.value);
try {
Map<String, dynamic> response = await phoneNumberUtil.parse(value);
return response['e164'];
} catch (e) {
String phoneNum = formatPhoneNumber(phone.value, countryCode);
bool isValid = await PhoneService.isValid(phoneNum, isoCode);
if (isValid) {
String ph = await PhoneService.getNormalizedPhoneNumber(phoneNum, isoCode);
return ph;
}
return phoneNum;
}));
List<String> result = await phones;
result = result.toSet().toList();
for (String phone in result) {
if (!syncedContacts.contains(phone)) {
newPhones.add(phone);
}
return '';
}
}));
List<String> result = await phones;
result = result.toSet().toList()..removeWhere((element) => element == '');
for (String phone in result) {
if (!syncedContacts.contains(phone)) {
newPhones.add(phone);
}
}
}
Expand Down
115 changes: 0 additions & 115 deletions lib/screens/cash_home/deposit_webview.dart

This file was deleted.

14 changes: 10 additions & 4 deletions lib/screens/cash_home/prize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:supervecina/models/app_state.dart';
import 'package:supervecina/models/draw_info.dart';
import 'package:supervecina/models/views/prize.dart';
import 'package:supervecina/redux/state/store.dart';
import 'package:supervecina/screens/cash_home/deposit_webview.dart';
import 'package:supervecina/screens/cash_home/webview_page.dart';
import 'package:supervecina/utils/format.dart';
import 'package:supervecina/widgets/main_scaffold.dart';
Expand Down Expand Up @@ -361,13 +360,20 @@ class _PrizeScreenState extends State<PrizeScreen> {
),
InkWell(
onTap: () {
dynamic depositPlugin =
depositPlugins[0];
dynamic url =
depositPlugin.generateUrl();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DepositWebView(
depositPlugin:
depositPlugins[0]),
WebViewPage(
pageArgs:
WebViewPageArguments(
url: url,
title:
'Top up')),
fullscreenDialog: true),
);
Segment.track(
Expand Down
Loading

0 comments on commit eb00678

Please sign in to comment.