Generic fixes (#1274)

* Display fees currency as wallet currency not the selected one

* remove unused code
catch balance network issues

* pop send screen when send completes successfully

* revert change [skip ci]

* Enable restoring haven wallets

* verify context is mounted before showing snackbar [skip ci]

* Update privacy [skip ci]

* Add user consent popup to inapp webview permission request
This commit is contained in:
Omar Hatem
2024-01-27 00:51:21 +02:00
committed by GitHub
parent aed60a7282
commit 89fdc0f4d1
36 changed files with 134 additions and 86 deletions
+27 -2
View File
@@ -1,4 +1,7 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:permission_handler/permission_handler.dart';
@@ -14,13 +17,14 @@ class WebViewPage extends BasePage {
@override
Widget body(BuildContext context) {
return WebViewPageBody(_url);
return WebViewPageBody(_title, _url);
}
}
class WebViewPageBody extends StatefulWidget {
WebViewPageBody(this.uri);
WebViewPageBody(this.title, this.uri);
final String title;
final Uri uri;
@override
@@ -40,6 +44,27 @@ class WebViewPageBodyState extends State<WebViewPageBody> {
onPermissionRequest: (controller, request) async {
bool permissionGranted = await Permission.camera.status == PermissionStatus.granted;
if (!permissionGranted) {
final bool userConsent = await showPopUp<bool>(
context: context,
builder: (BuildContext context) {
return AlertWithTwoActions(
alertTitle: S.of(context).privacy,
alertContent: S.of(context).camera_consent(widget.title),
rightButtonText: S.of(context).agree,
leftButtonText: S.of(context).cancel,
actionRightButton: () => Navigator.of(context).pop(true),
actionLeftButton: () => Navigator.of(context).pop(false));
}) ??
false;
/// if user did NOT give the consent then return permission denied
if (!userConsent) {
return PermissionResponse(
resources: request.resources,
action: PermissionResponseAction.DENY,
);
}
permissionGranted = await Permission.camera.request().isGranted;
}
@@ -166,12 +166,16 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
}
try {
changeProcessText(S.of(context).wallet_list_loading_wallet(wallet.name));
if (context.mounted) {
changeProcessText(S.of(context).wallet_list_loading_wallet(wallet.name));
}
await widget.walletListViewModel.loadWallet(wallet);
hideProgressText();
setState(() {});
} catch (e) {
changeProcessText(S.of(context).wallet_list_failed_to_load(wallet.name, e.toString()));
if (context.mounted) {
changeProcessText(S.of(context).wallet_list_failed_to_load(wallet.name, e.toString()));
}
}
},
conditionToDetermineIfToUse2FA:
@@ -28,15 +28,18 @@ class NewWalletTypePage extends BasePage {
@override
Widget body(BuildContext context) => WalletTypeForm(
onTypeSelected: onTypeSelected,
walletImage: currentTheme.type == ThemeType.dark ? walletTypeImage : walletTypeLightImage);
onTypeSelected: onTypeSelected,
walletImage: currentTheme.type == ThemeType.dark ? walletTypeImage : walletTypeLightImage,
isCreate: isCreate,
);
}
class WalletTypeForm extends StatefulWidget {
WalletTypeForm({required this.onTypeSelected, required this.walletImage});
WalletTypeForm({required this.onTypeSelected, required this.walletImage, required this.isCreate});
final void Function(BuildContext, WalletType) onTypeSelected;
final Image walletImage;
final bool isCreate;
@override
WalletTypeFormState createState() => WalletTypeFormState();
@@ -131,7 +134,7 @@ class WalletTypeFormState extends State<WalletTypeForm> {
throw Exception('Wallet Type is not selected yet.');
}
if (selected == WalletType.haven) {
if (selected == WalletType.haven && widget.isCreate) {
return await showPopUp<void>(
context: context,
builder: (BuildContext context) {
+1 -1
View File
@@ -478,7 +478,7 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
Text(
output.estimatedFee.toString() +
' ' +
sendViewModel.selectedCryptoCurrency.toString(),
sendViewModel.currency.toString(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,