mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
move tx note field to confirm tx page on desktop
This commit is contained in:
parent
93e44a4475
commit
7641539bf7
2 changed files with 206 additions and 111 deletions
|
@ -28,9 +28,12 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
|
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||||
|
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||||
|
|
||||||
class ConfirmTransactionView extends ConsumerStatefulWidget {
|
class ConfirmTransactionView extends ConsumerStatefulWidget {
|
||||||
const ConfirmTransactionView({
|
const ConfirmTransactionView({
|
||||||
|
@ -60,6 +63,9 @@ class _ConfirmTransactionViewState
|
||||||
late final String routeOnSuccessName;
|
late final String routeOnSuccessName;
|
||||||
late final bool isDesktop;
|
late final bool isDesktop;
|
||||||
|
|
||||||
|
late final FocusNode _noteFocusNode;
|
||||||
|
late final TextEditingController noteController;
|
||||||
|
|
||||||
Future<void> _attemptSend(BuildContext context) async {
|
Future<void> _attemptSend(BuildContext context) async {
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog<dynamic>(
|
showDialog<dynamic>(
|
||||||
|
@ -72,7 +78,7 @@ class _ConfirmTransactionViewState
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final note = transactionInfo["note"] as String? ?? "";
|
final note = noteController.text;
|
||||||
final manager =
|
final manager =
|
||||||
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||||
|
|
||||||
|
@ -194,9 +200,20 @@ class _ConfirmTransactionViewState
|
||||||
transactionInfo = widget.transactionInfo;
|
transactionInfo = widget.transactionInfo;
|
||||||
walletId = widget.walletId;
|
walletId = widget.walletId;
|
||||||
routeOnSuccessName = widget.routeOnSuccessName;
|
routeOnSuccessName = widget.routeOnSuccessName;
|
||||||
|
_noteFocusNode = FocusNode();
|
||||||
|
noteController = TextEditingController();
|
||||||
|
noteController.text = transactionInfo["note"] as String? ?? "";
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
noteController.dispose();
|
||||||
|
|
||||||
|
_noteFocusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final managerProvider = ref.watch(walletsChangeNotifierProvider
|
final managerProvider = ref.watch(walletsChangeNotifierProvider
|
||||||
|
@ -563,50 +580,132 @@ class _ConfirmTransactionViewState
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
// Container(
|
||||||
height: 1,
|
// height: 1,
|
||||||
color: Theme.of(context)
|
// color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// .extension<StackColors>()!
|
||||||
.background,
|
// .background,
|
||||||
),
|
// ),
|
||||||
Padding(
|
// Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
// padding: const EdgeInsets.all(12),
|
||||||
child: Column(
|
// child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
// mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
Text(
|
// Text(
|
||||||
"Note",
|
// "Note",
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(
|
// style: STextStyles.desktopTextExtraExtraSmall(
|
||||||
context),
|
// context),
|
||||||
),
|
// ),
|
||||||
const SizedBox(
|
// const SizedBox(
|
||||||
height: 2,
|
// height: 2,
|
||||||
),
|
// ),
|
||||||
Text(
|
// Text(
|
||||||
transactionInfo["note"] as String,
|
// transactionInfo["note"] as String,
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(
|
// style: STextStyles.desktopTextExtraExtraSmall(
|
||||||
context)
|
// context)
|
||||||
.copyWith(
|
// .copyWith(
|
||||||
color: Theme.of(context)
|
// color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// .extension<StackColors>()!
|
||||||
.textDark,
|
// .textDark,
|
||||||
),
|
// ),
|
||||||
)
|
// )
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (isDesktop)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 32,
|
||||||
|
right: 32,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Note (optional)",
|
||||||
|
style:
|
||||||
|
STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldActiveSearchIconRight,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
Constants.size.circularBorderRadius,
|
||||||
|
),
|
||||||
|
child: TextField(
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 5,
|
||||||
|
autocorrect: isDesktop ? false : true,
|
||||||
|
enableSuggestions: isDesktop ? false : true,
|
||||||
|
controller: noteController,
|
||||||
|
focusNode: _noteFocusNode,
|
||||||
|
style:
|
||||||
|
STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldActiveText,
|
||||||
|
height: 1.8,
|
||||||
|
),
|
||||||
|
onChanged: (_) => setState(() {}),
|
||||||
|
decoration: standardInputDecoration(
|
||||||
|
"Type something...",
|
||||||
|
_noteFocusNode,
|
||||||
|
context,
|
||||||
|
desktopMed: true,
|
||||||
|
).copyWith(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
left: 16,
|
||||||
|
top: 11,
|
||||||
|
bottom: 12,
|
||||||
|
right: 5,
|
||||||
|
),
|
||||||
|
suffixIcon: noteController.text.isNotEmpty
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 0),
|
||||||
|
child: UnconstrainedBox(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
TextFieldIconButton(
|
||||||
|
child: const XIcon(),
|
||||||
|
onTap: () async {
|
||||||
|
setState(
|
||||||
|
() => noteController.text = "",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
if (isDesktop)
|
if (isDesktop)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 32,
|
left: 32,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Transaction fee (estimated)",
|
"Transaction fee",
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(context),
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -71,16 +71,16 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
late TextEditingController sendToController;
|
late TextEditingController sendToController;
|
||||||
late TextEditingController cryptoAmountController;
|
late TextEditingController cryptoAmountController;
|
||||||
late TextEditingController baseAmountController;
|
late TextEditingController baseAmountController;
|
||||||
late TextEditingController noteController;
|
|
||||||
// late TextEditingController feeController;
|
// late TextEditingController feeController;
|
||||||
|
|
||||||
late final SendViewAutoFillData? _data;
|
late final SendViewAutoFillData? _data;
|
||||||
|
|
||||||
final _addressFocusNode = FocusNode();
|
final _addressFocusNode = FocusNode();
|
||||||
final _noteFocusNode = FocusNode();
|
|
||||||
final _cryptoFocus = FocusNode();
|
final _cryptoFocus = FocusNode();
|
||||||
final _baseFocus = FocusNode();
|
final _baseFocus = FocusNode();
|
||||||
|
|
||||||
|
String? _note;
|
||||||
|
|
||||||
Decimal? _amountToSend;
|
Decimal? _amountToSend;
|
||||||
Decimal? _cachedAmountToSend;
|
Decimal? _cachedAmountToSend;
|
||||||
String? _address;
|
String? _address;
|
||||||
|
@ -255,7 +255,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
sendToController.text = "";
|
sendToController.text = "";
|
||||||
cryptoAmountController.text = "";
|
cryptoAmountController.text = "";
|
||||||
baseAmountController.text = "";
|
baseAmountController.text = "";
|
||||||
noteController.text = "";
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -325,7 +324,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
context,
|
context,
|
||||||
rootNavigator: true,
|
rootNavigator: true,
|
||||||
).pop();
|
).pop();
|
||||||
txData["note"] = noteController.text;
|
txData["note"] = _note;
|
||||||
txData["address"] = _address;
|
txData["address"] = _address;
|
||||||
|
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -633,9 +632,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
|
|
||||||
// autofill notes field
|
// autofill notes field
|
||||||
if (results["message"] != null) {
|
if (results["message"] != null) {
|
||||||
noteController.text = results["message"]!;
|
_note = results["message"]!;
|
||||||
} else if (results["label"] != null) {
|
} else if (results["label"] != null) {
|
||||||
noteController.text = results["label"]!;
|
_note = results["label"]!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// autofill amount field
|
// autofill amount field
|
||||||
|
@ -783,7 +782,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
sendToController = TextEditingController();
|
sendToController = TextEditingController();
|
||||||
cryptoAmountController = TextEditingController();
|
cryptoAmountController = TextEditingController();
|
||||||
baseAmountController = TextEditingController();
|
baseAmountController = TextEditingController();
|
||||||
noteController = TextEditingController();
|
|
||||||
// feeController = TextEditingController();
|
// feeController = TextEditingController();
|
||||||
|
|
||||||
onCryptoAmountChanged = _cryptoAmountChanged;
|
onCryptoAmountChanged = _cryptoAmountChanged;
|
||||||
|
@ -828,10 +826,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
sendToController.dispose();
|
sendToController.dispose();
|
||||||
cryptoAmountController.dispose();
|
cryptoAmountController.dispose();
|
||||||
baseAmountController.dispose();
|
baseAmountController.dispose();
|
||||||
noteController.dispose();
|
|
||||||
// feeController.dispose();
|
// feeController.dispose();
|
||||||
|
|
||||||
_noteFocusNode.dispose();
|
|
||||||
_addressFocusNode.dispose();
|
_addressFocusNode.dispose();
|
||||||
_cryptoFocus.dispose();
|
_cryptoFocus.dispose();
|
||||||
_baseFocus.dispose();
|
_baseFocus.dispose();
|
||||||
|
@ -1298,73 +1294,73 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(
|
// const SizedBox(
|
||||||
height: 20,
|
// height: 20,
|
||||||
),
|
// ),
|
||||||
Text(
|
// Text(
|
||||||
"Note (optional)",
|
// "Note (optional)",
|
||||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
// style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
color: Theme.of(context)
|
// color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// .extension<StackColors>()!
|
||||||
.textFieldActiveSearchIconRight,
|
// .textFieldActiveSearchIconRight,
|
||||||
),
|
// ),
|
||||||
textAlign: TextAlign.left,
|
// textAlign: TextAlign.left,
|
||||||
),
|
// ),
|
||||||
const SizedBox(
|
// const SizedBox(
|
||||||
height: 10,
|
// height: 10,
|
||||||
),
|
// ),
|
||||||
ClipRRect(
|
// ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(
|
// borderRadius: BorderRadius.circular(
|
||||||
Constants.size.circularBorderRadius,
|
// Constants.size.circularBorderRadius,
|
||||||
),
|
// ),
|
||||||
child: TextField(
|
// child: TextField(
|
||||||
minLines: 1,
|
// minLines: 1,
|
||||||
maxLines: 5,
|
// maxLines: 5,
|
||||||
autocorrect: Util.isDesktop ? false : true,
|
// autocorrect: Util.isDesktop ? false : true,
|
||||||
enableSuggestions: Util.isDesktop ? false : true,
|
// enableSuggestions: Util.isDesktop ? false : true,
|
||||||
controller: noteController,
|
// controller: noteController,
|
||||||
focusNode: _noteFocusNode,
|
// focusNode: _noteFocusNode,
|
||||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
// style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
color: Theme.of(context)
|
// color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// .extension<StackColors>()!
|
||||||
.textFieldActiveText,
|
// .textFieldActiveText,
|
||||||
height: 1.8,
|
// height: 1.8,
|
||||||
),
|
// ),
|
||||||
onChanged: (_) => setState(() {}),
|
// onChanged: (_) => setState(() {}),
|
||||||
decoration: standardInputDecoration(
|
// decoration: standardInputDecoration(
|
||||||
"Type something...",
|
// "Type something...",
|
||||||
_noteFocusNode,
|
// _noteFocusNode,
|
||||||
context,
|
// context,
|
||||||
desktopMed: true,
|
// desktopMed: true,
|
||||||
).copyWith(
|
// ).copyWith(
|
||||||
contentPadding: const EdgeInsets.only(
|
// contentPadding: const EdgeInsets.only(
|
||||||
left: 16,
|
// left: 16,
|
||||||
top: 11,
|
// top: 11,
|
||||||
bottom: 12,
|
// bottom: 12,
|
||||||
right: 5,
|
// right: 5,
|
||||||
),
|
// ),
|
||||||
suffixIcon: noteController.text.isNotEmpty
|
// suffixIcon: noteController.text.isNotEmpty
|
||||||
? Padding(
|
// ? Padding(
|
||||||
padding: const EdgeInsets.only(right: 0),
|
// padding: const EdgeInsets.only(right: 0),
|
||||||
child: UnconstrainedBox(
|
// child: UnconstrainedBox(
|
||||||
child: Row(
|
// child: Row(
|
||||||
children: [
|
// children: [
|
||||||
TextFieldIconButton(
|
// TextFieldIconButton(
|
||||||
child: const XIcon(),
|
// child: const XIcon(),
|
||||||
onTap: () async {
|
// onTap: () async {
|
||||||
setState(() {
|
// setState(() {
|
||||||
noteController.text = "";
|
// noteController.text = "";
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
)
|
// )
|
||||||
: null,
|
// : null,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue