Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions lib/pages/signing/signing_view.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../providers/global/wallets_provider.dart';
import '../../themes/stack_colors.dart';
import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../wallets/wallet/wallet_mixin_interfaces/view_only_option_interface.dart';
import '../../widgets/background.dart';
import '../../widgets/conditional_parent.dart';
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
Expand Down Expand Up @@ -31,35 +33,38 @@ class _SigningViewState extends ConsumerState<SigningView> {
// keep auto dispose providers alive
ref.listen(pSignIsValid, (_, __) {});
ref.listen(pVerifyIsValid, (_, __) {});
final wallet = ref.watch(pWallets).getWallet(widget.walletId);
final viewOnly = wallet is ViewOnlyOptionInterface && wallet.isViewOnly;

return ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => Background(
child: Scaffold(
backgroundColor: Theme.of(
context,
).extension<StackColors>()!.background,
backgroundColor: Theme.of(context)
.extension<StackColors>()!
.background,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
"Sign / Verify",
viewOnly ? "Verify message" : "Sign / Verify",
style: STextStyles.navBarTitle(context),
),
),
body: SafeArea(child: child),
body: SafeArea(child: SingleChildScrollView(child: child)),
),
),
child: CustomTabView(
titles: const ["Sign message", "Verify message"],
titles: [if (!viewOnly) "Sign message", "Verify message"],
children: [
SignMessageForm(
key: const Key("_SignMessageFormKey"),
walletId: widget.walletId,
),
if (!viewOnly)
SignMessageForm(
key: const Key("_SignMessageFormKey"),
walletId: widget.walletId,
),
VerifyMessageForm(
key: const Key("_VerifyMessageFormKey"),
walletId: widget.walletId,
Expand Down
32 changes: 22 additions & 10 deletions lib/pages/signing/sub_widgets/sign_message_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import '../../../widgets/detail_item.dart';
import '../../../widgets/dialogs/s_dialog.dart';
import '../../../widgets/rounded_container.dart';
import '../../../widgets/textfields/adaptive_text_field.dart';
import '../../wallet_view/transaction_views/transaction_details_view.dart'
show IconCopyButton;
import '../signing_view.dart';
import 'address_list.dart';

Expand All @@ -32,7 +34,7 @@ final class _SignState {
required this.signature,
});

bool get isValid => message.isNotEmpty && address != null;
bool get isValid => message.trim().isNotEmpty && address != null;

_SignState copyWith({String? message, String? signature}) {
return _SignState(
Expand Down Expand Up @@ -77,9 +79,9 @@ class _SignMessageFormState extends ConsumerState<SignMessageForm> {
TextStyle _getStyle(BuildContext context) {
return Util.isDesktop
? STextStyles.desktopTextExtraExtraSmall(context).copyWith(
color: Theme.of(
context,
).extension<StackColors>()!.textFieldActiveSearchIconRight,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
)
: STextStyles.smallMed12(context);
}
Expand Down Expand Up @@ -133,9 +135,9 @@ class _SignMessageFormState extends ConsumerState<SignMessageForm> {
child: RoundedContainer(
padding: EdgeInsets.zero,
color: Colors.transparent,
borderColor: Theme.of(
context,
).extension<StackColors>()!.textFieldDefaultBG,
borderColor: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
child: child,
),
),
Expand Down Expand Up @@ -181,9 +183,11 @@ class _SignMessageFormState extends ConsumerState<SignMessageForm> {
onException: (e) => ex = e,
);

if (mounted && ex != null) {
if (!mounted || !identical(ref.read(_pSignState), state)) return;

if (ex != null) {
await showSignVerifyError(ex!, context: context);
} else if (signature != null && mounted) {
} else if (signature != null) {
ref.read(_pSignState.notifier).state = state.copyWith(
signature: signature,
);
Expand Down Expand Up @@ -214,7 +218,13 @@ class _SignMessageFormState extends ConsumerState<SignMessageForm> {
AdaptiveTextField(
controller: messageController,
showPasteClearButton: true,
maxLines: 1,
trimPastedText: false,
autocorrect: false,
smartDashesType: SmartDashesType.disabled,
smartQuotesType: SmartQuotesType.disabled,
enableSuggestions: false,
minLines: 1,
maxLines: 5,
onChangedComprehensive: (_) {
if (mounted) {
ref.read(_pSignState.notifier).state = ref
Expand Down Expand Up @@ -249,6 +259,8 @@ class _SignMessageFormState extends ConsumerState<SignMessageForm> {
noPadding: Util.isDesktop,
button: ref.watch(_pSignState.select((s) => s.signature)).isEmpty
? null
: Util.isDesktop
? IconCopyButton(data: ref.read(_pSignState).signature)
: SimpleCopyButton(data: ref.read(_pSignState).signature),
),

Expand Down
17 changes: 12 additions & 5 deletions lib/pages/signing/sub_widgets/verify_message_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class _VerifyMessageFormState extends ConsumerState<VerifyMessageForm> {
TextStyle _getStyle(BuildContext context) {
return Util.isDesktop
? STextStyles.desktopTextExtraExtraSmall(context).copyWith(
color: Theme.of(
context,
).extension<StackColors>()!.textFieldActiveSearchIconRight,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
)
: STextStyles.smallMed12(context);
}
Expand All @@ -84,6 +84,7 @@ class _VerifyMessageFormState extends ConsumerState<VerifyMessageForm> {

_verify = IfNotAlreadyAsync<void>(() async {
Exception? ex;
final state = ref.read(_pVerifyState);

final verified = await showLoading(
whileFuture:
Expand All @@ -100,7 +101,7 @@ class _VerifyMessageFormState extends ConsumerState<VerifyMessageForm> {
onException: (e) => ex = e,
);

if (mounted) {
if (mounted && identical(ref.read(_pVerifyState), state)) {
if (ex != null) {
await showSignVerifyError(ex!, context: context);
} else {
Expand Down Expand Up @@ -145,7 +146,13 @@ class _VerifyMessageFormState extends ConsumerState<VerifyMessageForm> {
AdaptiveTextField(
controller: messageController,
showPasteClearButton: true,
maxLines: 1,
trimPastedText: false,
autocorrect: false,
smartDashesType: SmartDashesType.disabled,
smartQuotesType: SmartQuotesType.disabled,
enableSuggestions: false,
minLines: 1,
maxLines: 5,
onChangedComprehensive: (_) {
if (mounted) {
ref.read(_pVerifyState.notifier).state = ref
Expand Down
Loading
Loading