desktop block explorer dialog

This commit is contained in:
ryleedavis 2022-11-17 14:08:06 -07:00
parent 95a9fade38
commit 682966dab8
2 changed files with 142 additions and 62 deletions

View file

@ -30,6 +30,8 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart';
import 'package:stackwallet/widgets/icon_widgets/pencil_icon.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -154,60 +156,136 @@ class _TransactionDetailsViewState
Future<bool> showExplorerWarning(String explorer) async {
final bool? shouldContinue = await showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (_) => StackDialog(
title: "Attention",
message:
"You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.",
icon: Row(
children: [
Consumer(builder: (_, ref, __) {
return Checkbox(
value: ref.watch(prefsChangeNotifierProvider
.select((value) => value.hideBlockExplorerWarning)),
onChanged: (value) {
if (value is bool) {
ref
.read(prefsChangeNotifierProvider)
.hideBlockExplorerWarning = value;
setState(() {});
}
context: context,
barrierDismissible: false,
builder: (_) {
if (!isDesktop) {
return StackDialog(
title: "Attention",
message:
"You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.",
icon: Row(
children: [
Consumer(builder: (_, ref, __) {
return Checkbox(
value: ref.watch(prefsChangeNotifierProvider
.select((value) => value.hideBlockExplorerWarning)),
onChanged: (value) {
if (value is bool) {
ref
.read(prefsChangeNotifierProvider)
.hideBlockExplorerWarning = value;
setState(() {});
}
},
);
}),
Text(
"Never show again",
style: STextStyles.smallMed14(context),
)
],
),
leftButton: TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
);
}),
Text(
"Never show again",
style: STextStyles.smallMed14(context),
)
],
),
leftButton: TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: Text(
"Cancel",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
child: Text(
"Cancel",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
onPressed: () {
Navigator.of(context).pop(true);
},
child: Text(
"Continue",
style: STextStyles.button(context),
),
),
),
);
.getPrimaryEnabledButtonColor(context),
onPressed: () {
Navigator.of(context).pop(true);
},
child: Text(
"Continue",
style: STextStyles.button(context),
),
),
);
} else {
return DesktopDialog(
maxWidth: 550,
maxHeight: 300,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 32, vertical: 20),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Attention",
style: STextStyles.desktopH2(context),
),
Row(
children: [
Consumer(builder: (_, ref, __) {
return Checkbox(
value: ref.watch(prefsChangeNotifierProvider
.select((value) =>
value.hideBlockExplorerWarning)),
onChanged: (value) {
if (value is bool) {
ref
.read(prefsChangeNotifierProvider)
.hideBlockExplorerWarning = value;
setState(() {});
}
},
);
}),
Text(
"Never show again",
style: STextStyles.smallMed14(context),
)
],
),
],
),
const SizedBox(height: 16),
Text(
"You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.",
style: STextStyles.desktopTextSmall(context),
),
const SizedBox(height: 35),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SecondaryButton(
width: 200,
buttonHeight: ButtonHeight.l,
label: "Cancel",
onPressed: () {
Navigator.of(context).pop(false);
},
),
const SizedBox(width: 20),
PrimaryButton(
width: 200,
buttonHeight: ButtonHeight.l,
label: "Continue",
onPressed: () {
Navigator.of(context).pop(true);
},
),
],
),
],
),
),
);
}
});
return shouldContinue ?? false;
}
@ -995,15 +1073,17 @@ class _TransactionDetailsViewState
.externalApplication,
);
} catch (_) {
unawaited(showDialog<void>(
context: context,
builder: (_) => StackOkDialog(
title:
"Could not open in block explorer",
message:
"Failed to open \"${uri.toString()}\"",
unawaited(
showDialog<void>(
context: context,
builder: (_) => StackOkDialog(
title:
"Could not open in block explorer",
message:
"Failed to open \"${uri.toString()}\"",
),
),
));
);
} finally {
// Future<void>.delayed(
// const Duration(seconds: 1),

View file

@ -440,7 +440,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
SecondaryButton(
width: 180,
width: 200,
buttonHeight: ButtonHeight.l,
label: "Cancel",
onPressed: () {
@ -449,7 +449,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
),
const SizedBox(width: 20),
PrimaryButton(
width: 180,
width: 200,
buttonHeight: ButtonHeight.l,
label: "Continue",
onPressed: () {