move tx note field to confirm tx page on desktop

This commit is contained in:
julian 2022-11-30 11:36:58 -06:00
parent 93e44a4475
commit 7641539bf7
2 changed files with 206 additions and 111 deletions

View file

@ -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_close_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_white_container.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 {
const ConfirmTransactionView({
@ -60,6 +63,9 @@ class _ConfirmTransactionViewState
late final String routeOnSuccessName;
late final bool isDesktop;
late final FocusNode _noteFocusNode;
late final TextEditingController noteController;
Future<void> _attemptSend(BuildContext context) async {
unawaited(
showDialog<dynamic>(
@ -72,7 +78,7 @@ class _ConfirmTransactionViewState
),
);
final note = transactionInfo["note"] as String? ?? "";
final note = noteController.text;
final manager =
ref.read(walletsChangeNotifierProvider).getManager(walletId);
@ -194,9 +200,20 @@ class _ConfirmTransactionViewState
transactionInfo = widget.transactionInfo;
walletId = widget.walletId;
routeOnSuccessName = widget.routeOnSuccessName;
_noteFocusNode = FocusNode();
noteController = TextEditingController();
noteController.text = transactionInfo["note"] as String? ?? "";
super.initState();
}
@override
void dispose() {
noteController.dispose();
_noteFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final managerProvider = ref.watch(walletsChangeNotifierProvider
@ -563,50 +580,132 @@ class _ConfirmTransactionViewState
],
),
),
Container(
height: 1,
color: Theme.of(context)
.extension<StackColors>()!
.background,
),
Padding(
padding: const EdgeInsets.all(12),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Note",
style: STextStyles.desktopTextExtraExtraSmall(
context),
),
const SizedBox(
height: 2,
),
Text(
transactionInfo["note"] as String,
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
),
)
],
),
),
// Container(
// height: 1,
// color: Theme.of(context)
// .extension<StackColors>()!
// .background,
// ),
// Padding(
// padding: const EdgeInsets.all(12),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Note",
// style: STextStyles.desktopTextExtraExtraSmall(
// context),
// ),
// const SizedBox(
// height: 2,
// ),
// Text(
// transactionInfo["note"] as String,
// style: STextStyles.desktopTextExtraExtraSmall(
// context)
// .copyWith(
// color: Theme.of(context)
// .extension<StackColors>()!
// .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)
Padding(
padding: const EdgeInsets.only(
left: 32,
),
child: Text(
"Transaction fee (estimated)",
"Transaction fee",
style: STextStyles.desktopTextExtraExtraSmall(context),
),
),

View file

@ -71,16 +71,16 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
late TextEditingController sendToController;
late TextEditingController cryptoAmountController;
late TextEditingController baseAmountController;
late TextEditingController noteController;
// late TextEditingController feeController;
late final SendViewAutoFillData? _data;
final _addressFocusNode = FocusNode();
final _noteFocusNode = FocusNode();
final _cryptoFocus = FocusNode();
final _baseFocus = FocusNode();
String? _note;
Decimal? _amountToSend;
Decimal? _cachedAmountToSend;
String? _address;
@ -255,7 +255,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
sendToController.text = "";
cryptoAmountController.text = "";
baseAmountController.text = "";
noteController.text = "";
});
},
),
@ -325,7 +324,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
context,
rootNavigator: true,
).pop();
txData["note"] = noteController.text;
txData["note"] = _note;
txData["address"] = _address;
unawaited(
@ -633,9 +632,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
// autofill notes field
if (results["message"] != null) {
noteController.text = results["message"]!;
_note = results["message"]!;
} else if (results["label"] != null) {
noteController.text = results["label"]!;
_note = results["label"]!;
}
// autofill amount field
@ -783,7 +782,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
sendToController = TextEditingController();
cryptoAmountController = TextEditingController();
baseAmountController = TextEditingController();
noteController = TextEditingController();
// feeController = TextEditingController();
onCryptoAmountChanged = _cryptoAmountChanged;
@ -828,10 +826,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
sendToController.dispose();
cryptoAmountController.dispose();
baseAmountController.dispose();
noteController.dispose();
// feeController.dispose();
_noteFocusNode.dispose();
_addressFocusNode.dispose();
_cryptoFocus.dispose();
_baseFocus.dispose();
@ -1298,73 +1294,73 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
}
},
),
const SizedBox(
height: 20,
),
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: Util.isDesktop ? false : true,
enableSuggestions: Util.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,
// ),
// 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: Util.isDesktop ? false : true,
// enableSuggestions: Util.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,
),