minor context fix [skip ci]

OmarHatem committed Mar 11, 2026 at 04:42 UTC b219e4a0c2414fd2b5a433dfcabb4535841c0520
2 files changed +101 -81
lib/new-ui/widgets/send_page/send_address_input.dart
+29 -13
@@ -21,7 +21,8 @@ class NewSendAddressInput extends StatefulWidget {
21 required this.onEditingComplete,
22 this.bottomPadding = false,
23 this.validator,
24 - this.focusNode, this.displayName,
24 + this.focusNode,
25 + this.displayName,
26 });
27
28 final TextEditingController addressController;
@@ -49,11 +50,14 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
50 super.initState();
51 node = widget.focusNode ?? FocusNode();
52 node!.addListener(_onFocusChange);
52 - widget.addressController.addListener(()=>formFieldKey.currentState?.didChange(widget.addressController.text));
53 + widget.addressController
54 + .addListener(() => formFieldKey.currentState?.didChange(widget.addressController.text));
55 }
56
57 void _onFocusChange() {
56 - setState(() {});
58 + if (mounted) {
59 + setState(() {});
60 + }
61 }
62
63 @override
@@ -67,7 +71,7 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
71 child: FormField<String>(
72 key: formFieldKey,
73 validator: widget.validator,
70 - builder: (state)=>Column(
74 + builder: (state) => Column(
75 crossAxisAlignment: CrossAxisAlignment.start,
76 children: [
77 Container(
@@ -81,9 +85,11 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
85 children: [
86 TextField(
87 focusNode: widget.focusNode,
84 - onSubmitted: (val)=> FocusScope.of(context).unfocus(),
88 + onSubmitted: (val) => FocusScope.of(context).unfocus(),
89 onChanged: state.didChange,
86 - onEditingComplete: (){widget.onEditingComplete();},
90 + onEditingComplete: () {
91 + widget.onEditingComplete();
92 + },
93 onTapOutside: (_) {
94 widget.onEditingComplete();
95 },
@@ -97,12 +103,15 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
103 child: IgnorePointer(
104 child: AnimatedOpacity(
105 duration: Duration(milliseconds: 150),
100 - opacity: (widget.focusNode == null || widget.focusNode!.hasFocus || widget.addressController.text.isEmpty) ? 0 : 1,
106 + opacity: (widget.focusNode == null ||
107 + widget.focusNode!.hasFocus ||
108 + widget.addressController.text.isEmpty)
109 + ? 0
110 + : 1,
111 child: SendAddressOverlay(
112 address: widget.addressController.text,
113 displayName: widget.displayName,
104 - )
105 - ),
114 + )),
115 ),
116 ),
117 ],
@@ -133,8 +142,14 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
142 ],
143 ),
144 ),
136 - if(state.hasError)
137 - Padding(padding: EdgeInsets.only(top:6,left: 8),child: Text(state.errorText!, style: TextStyle(fontSize:12,color: Theme.of(context).colorScheme.error),),)
145 + if (state.hasError)
146 + Padding(
147 + padding: EdgeInsets.only(top: 6, left: 8),
148 + child: Text(
149 + state.errorText!,
150 + style: TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.error),
151 + ),
152 + )
153 ],
154 ),
155 ),
@@ -143,7 +158,7 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
158
159 Future<void> _presentQRScanner(BuildContext context) async {
160 bool isCameraPermissionGranted =
146 - await PermissionHandler.checkPermission(Permission.camera, context);
161 + await PermissionHandler.checkPermission(Permission.camera, context);
162 if (!isCameraPermissionGranted) return;
163 final code = await presentQRScanner(context);
164 if (code == null) return;
@@ -221,7 +236,8 @@ class SendAddressOverlay extends StatelessWidget {
236 children: [
237 if (showDisplayName)
238 Text(
224 - displayName!,maxLines: 1,
239 + displayName!,
240 + maxLines: 1,
241 overflow: TextOverflow.ellipsis,
242 style: primaryTextStyle,
243 ),
lib/new-ui/widgets/swap_page/swap_confirm_sheet.dart
+72 -68
@@ -36,7 +36,6 @@ class SwapConfirmSheet extends StatefulWidget {
36 }
37
38 class _SwapConfirmSheetState extends State<SwapConfirmSheet> {
39 -
39 void beginSend() async {
40 final sendVM = widget.exchangeTradeViewModel.sendViewModel;
41
@@ -79,52 +78,54 @@ class _SwapConfirmSheetState extends State<SwapConfirmSheet> {
78 @override
79 Widget build(BuildContext context) {
80 return PopScope(
82 - onPopInvokedWithResult: (didPop, result) {
83 - Navigator.of(context, rootNavigator: true).pop();
84 - },
85 - child: Container(
86 - decoration: BoxDecoration(
87 - color: Theme.of(context).colorScheme.surface,
88 - borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
89 - ),
90 - child: SafeArea(
91 - child: Observer(
92 - builder: (_) {
93 - final commited = widget.exchangeTradeViewModel.sendViewModel.state is TransactionCommitted;
94 - return Stack(
95 - fit: StackFit.loose,
96 - children: [
97 - Positioned.fill(
98 - child: AnimatedSlide(
99 - offset: commited ? Offset.zero : const Offset(1, 0),
100 - duration: const Duration(milliseconds: 300),
101 - curve: Curves.easeOutCubic,
102 - child: const TransactionCommitedScreen(),
103 - )),
104 - AnimatedSlide(
105 - offset: commited ? const Offset(-1, 0) : Offset.zero,
106 - duration: const Duration(milliseconds: 300),
107 - curve: Curves.easeOutCubic,
108 - child: SwapTransactionDetails(
109 - exchangeViewModel: widget.exchangeViewModel,
110 - exchangeTradeViewModel: widget.exchangeTradeViewModel,
111 - receiveAmount: widget.receiveAmount,
81 + onPopInvokedWithResult: (didPop, result) {
82 + Navigator.of(context, rootNavigator: true).pop();
83 + },
84 + child: Container(
85 + decoration: BoxDecoration(
86 + color: Theme.of(context).colorScheme.surface,
87 + borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
88 + ),
89 + child: SafeArea(
90 + child: Observer(
91 + builder: (_) {
92 + final commited =
93 + widget.exchangeTradeViewModel.sendViewModel.state is TransactionCommitted;
94 + return Stack(
95 + fit: StackFit.loose,
96 + children: [
97 + Positioned.fill(
98 + child: AnimatedSlide(
99 + offset: commited ? Offset.zero : const Offset(1, 0),
100 + duration: const Duration(milliseconds: 300),
101 + curve: Curves.easeOutCubic,
102 + child: const TransactionCommitedScreen(),
103 + )),
104 + AnimatedSlide(
105 + offset: commited ? const Offset(-1, 0) : Offset.zero,
106 + duration: const Duration(milliseconds: 300),
107 + curve: Curves.easeOutCubic,
108 + child: SwapTransactionDetails(
109 + exchangeViewModel: widget.exchangeViewModel,
110 + exchangeTradeViewModel: widget.exchangeTradeViewModel,
111 + receiveAmount: widget.receiveAmount,
112 + ),
113 ),
113 - ),
114 - ],
115 - );
116 - },
114 + ],
115 + );
116 + },
117 + ),
118 ),
118 - ),
119 - ));
119 + ));
120 }
121 -
122 -
121 }
122
125 -
123 class SwapTransactionDetails extends StatelessWidget {
127 - const SwapTransactionDetails({super.key, required this.exchangeViewModel, required this.exchangeTradeViewModel, required this.receiveAmount});
124 + const SwapTransactionDetails(
125 + {super.key,
126 + required this.exchangeViewModel,
127 + required this.exchangeTradeViewModel,
128 + required this.receiveAmount});
129
130 final ExchangeViewModel exchangeViewModel;
131 final ExchangeTradeViewModel exchangeTradeViewModel;
@@ -144,7 +145,7 @@ class SwapTransactionDetails extends StatelessWidget {
145 onTrailingPressed: Navigator.of(context).maybePop,
146 ),
147 SafeArea(
147 - top:false,
148 + top: false,
149 child: Padding(
150 padding: const EdgeInsets.symmetric(horizontal: 16.0),
151 child: Column(
@@ -161,13 +162,13 @@ class SwapTransactionDetails extends StatelessWidget {
162 trailingText: exchangeTradeViewModel.trade.amountFormatted() +
163 " " +
164 (exchangeViewModel.depositCurrency.title)),
164 - if(exchangeTradeViewModel.sendViewModel.pendingTransaction != null)
165 + if (exchangeTradeViewModel.sendViewModel.pendingTransaction != null)
166 ListItemRegularRow(
167 showArrow: false,
168 keyValue: "fee",
169 label: S.of(context).fee,
170 trailingText:
170 - "${exchangeTradeViewModel.sendViewModel.pendingTransaction?.feeFormatted} (${exchangeTradeViewModel.pendingTransactionFeeFiatAmountFormatted})"),
171 + "${exchangeTradeViewModel.sendViewModel.pendingTransaction?.feeFormatted} (${exchangeTradeViewModel.pendingTransactionFeeFiatAmountFormatted})"),
172 ListItemRegularRow(
173 keyValue: "sender",
174 label: S.of(context).from,
@@ -182,14 +183,15 @@ class SwapTransactionDetails extends StatelessWidget {
183 keyValue: "receive value",
184 label: exchangeViewModel.receiveCurrency.fullName ?? "",
185 iconPath: exchangeViewModel.receiveCurrency.iconPath ?? "",
185 - trailingText: (receiveAmount) +
186 - " " +
187 - (exchangeViewModel.receiveCurrency.title)),
186 + trailingText:
187 + (receiveAmount) + " " + (exchangeViewModel.receiveCurrency.title)),
188 ListItemRegularRow(
189 keyValue: "receiver",
190 label: S.of(context).to,
191 showArrow: false,
192 - trailingText: exchangeViewModel.receiveAddressDisplayName ?? middleTruncate(exchangeTradeViewModel.trade.payoutAddress ?? "", 8, 8))
192 + trailingText: exchangeViewModel.receiveAddressDisplayName ??
193 + middleTruncate(
194 + exchangeTradeViewModel.trade.payoutAddress ?? "", 8, 8))
195 ],
196 "${S.of(context).swap_id} (${S.of(context).tap_to_copy})": [
197 ListItemRegularRow(
@@ -201,14 +203,15 @@ class SwapTransactionDetails extends StatelessWidget {
203 iconPath: exchangeTradeViewModel.trade.provider.image,
204 trailingIconPath: "assets/new-ui/copy.svg",
205 trailingText: exchangeTradeViewModel.trade.id,
204 - truncateTrailingText: !exchangeTradeViewModel.trade.provider.isCentralized),
205 - if(exchangeTradeViewModel.trade.provider == ExchangeProviderDescription.trocador)
206 + truncateTrailingText:
207 + !exchangeTradeViewModel.trade.provider.isCentralized),
208 + if (exchangeTradeViewModel.trade.provider ==
209 + ExchangeProviderDescription.trocador)
210 ListItemRegularRow(
211 showArrow: false,
212 keyValue: "trocador provider name",
213 label: "Trocador ${S.of(context).provider}",
210 - trailingText: exchangeTradeViewModel.trade.providerName??""
211 - )
214 + trailingText: exchangeTradeViewModel.trade.providerName ?? "")
215 ]
216 }),
217 ),
@@ -216,12 +219,12 @@ class SwapTransactionDetails extends StatelessWidget {
219 padding: const EdgeInsets.only(bottom: 8.0),
220 child: exchangeViewModel.isSendFromExternal
221 ? NewPrimaryButton(
219 - onPressed: ()=>_showExternalSendModal(context),
220 - text: S.of(context).continue_text,
221 - color: Theme.of(context).colorScheme.primary,
222 - textColor: Theme.of(context).colorScheme.onPrimary)
222 + onPressed: () => _showExternalSendModal(context),
223 + text: S.of(context).continue_text,
224 + color: Theme.of(context).colorScheme.primary,
225 + textColor: Theme.of(context).colorScheme.onPrimary)
226 : SendConfirmBottomWidget(
224 - sendViewModel: exchangeTradeViewModel.sendViewModel),
227 + sendViewModel: exchangeTradeViewModel.sendViewModel),
228 ),
229 ],
230 ),
@@ -232,16 +235,17 @@ class SwapTransactionDetails extends StatelessWidget {
235 }
236
237 void _showExternalSendModal(BuildContext context) {
235 - showMaterialModalBottomSheet(
236 - context: context,
237 - builder: (context) {
238 - return SwapSendExternalModal(
239 - amount: exchangeTradeViewModel.trade.amount,
240 - exchangeTradeViewModel: exchangeTradeViewModel,
241 - from: exchangeTradeViewModel.trade.from ?? exchangeViewModel.depositCurrency,
242 - to: exchangeTradeViewModel.trade.to ?? exchangeViewModel.receiveCurrency,
243 - address: exchangeTradeViewModel.trade.inputAddress ?? "");
244 - });
238 + if (context.mounted) {
239 + showMaterialModalBottomSheet(
240 + context: context,
241 + builder: (context) {
242 + return SwapSendExternalModal(
243 + amount: exchangeTradeViewModel.trade.amount,
244 + exchangeTradeViewModel: exchangeTradeViewModel,
245 + from: exchangeTradeViewModel.trade.from ?? exchangeViewModel.depositCurrency,
246 + to: exchangeTradeViewModel.trade.to ?? exchangeViewModel.receiveCurrency,
247 + address: exchangeTradeViewModel.trade.inputAddress ?? "");
248 + });
249 + }
250 }
246 -
251 }