mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
CW-33 Add app review after successful transactions and exchange (#864)
* Add app reveiw on transactions and exchange * Update Onramper page * Fix issues in popup review
This commit is contained in:
parent
4a203a43c8
commit
a472527c6f
6 changed files with 44 additions and 6 deletions
|
@ -31,6 +31,8 @@ class PreferencesKey {
|
|||
static const pinTimeOutDuration = 'pin_timeout_duration';
|
||||
static const lastAuthTimeMilliseconds = 'last_auth_time_milliseconds';
|
||||
static const lastPopupDate = 'last_popup_date';
|
||||
static const lastAppReviewDate = 'last_app_review_date';
|
||||
|
||||
|
||||
|
||||
static String moneroWalletUpdateV1Key(String name)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:ui';
|
||||
import 'package:cake_wallet/utils/request_review_handler.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -351,8 +352,10 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
right: 24,
|
||||
bottom: 24,
|
||||
child: PrimaryButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(popupContext).pop(),
|
||||
onPressed: () {
|
||||
Navigator.of(popupContext).pop();
|
||||
RequestReviewHandler.requestReview();
|
||||
},
|
||||
text: S.of(popupContext).send_got_it,
|
||||
color: Theme.of(popupContext)
|
||||
.accentTextTheme!
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
|||
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:cake_wallet/utils/request_review_handler.dart';
|
||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -383,9 +384,11 @@ class SendPage extends BasePage {
|
|||
alertContent: S.of(context).send_success(
|
||||
sendViewModel.selectedCryptoCurrency.toString()),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () =>
|
||||
Navigator.of(context).pop());
|
||||
}
|
||||
buttonAction: () {
|
||||
Navigator.of(context).pop();
|
||||
RequestReviewHandler.requestReview();
|
||||
});
|
||||
}
|
||||
|
||||
return Offstage();
|
||||
});
|
||||
|
|
29
lib/utils/request_review_handler.dart
Normal file
29
lib/utils/request_review_handler.dart
Normal file
|
@ -0,0 +1,29 @@
|
|||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:in_app_review/in_app_review.dart';
|
||||
|
||||
class RequestReviewHandler {
|
||||
static const _coolDownDurationInDays = 30;
|
||||
|
||||
static void requestReview() async {
|
||||
final sharedPrefs = await SharedPreferences.getInstance();
|
||||
|
||||
final lastReviewRequestDate =
|
||||
DateTime.tryParse(sharedPrefs.getString(PreferencesKey.lastAppReviewDate) ?? '') ??
|
||||
DateTime.now().subtract(Duration(days: _coolDownDurationInDays + 1));
|
||||
|
||||
final durationSinceLastRequest = DateTime.now().difference(lastReviewRequestDate).inDays;
|
||||
|
||||
if (durationSinceLastRequest < _coolDownDurationInDays) {
|
||||
return;
|
||||
}
|
||||
|
||||
sharedPrefs.setString(PreferencesKey.lastAppReviewDate, DateTime.now().toString());
|
||||
|
||||
final InAppReview inAppReview = InAppReview.instance;
|
||||
|
||||
if (await inAppReview.isAvailable()) {
|
||||
inAppReview.requestReview();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -146,7 +146,7 @@ abstract class DashboardViewModelBase with Store {
|
|||
}
|
||||
|
||||
reaction((_) => appStore.wallet, _onWalletChange);
|
||||
|
||||
|
||||
connectMapToListWithTransform(
|
||||
appStore.wallet!.transactionHistory.transactions,
|
||||
transactions,
|
||||
|
|
|
@ -67,6 +67,7 @@ dependencies:
|
|||
wakelock: ^0.6.2
|
||||
flutter_mailer: ^2.0.2
|
||||
device_info_plus: 8.1.0
|
||||
in_app_review: ^2.0.6
|
||||
cake_backup:
|
||||
git:
|
||||
url: https://github.com/cake-tech/cake_backup.git
|
||||
|
|
Loading…
Reference in a new issue