minor context fix [skip ci]

This commit is contained in:
OmarHatem
2026-03-11 04:42:07 +02:00
parent 084fd6bb1e
commit b219e4a0c2
2 changed files with 102 additions and 82 deletions
@@ -21,7 +21,8 @@ class NewSendAddressInput extends StatefulWidget {
required this.onEditingComplete,
this.bottomPadding = false,
this.validator,
this.focusNode, this.displayName,
this.focusNode,
this.displayName,
});
final TextEditingController addressController;
@@ -49,11 +50,14 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
super.initState();
node = widget.focusNode ?? FocusNode();
node!.addListener(_onFocusChange);
widget.addressController.addListener(()=>formFieldKey.currentState?.didChange(widget.addressController.text));
widget.addressController
.addListener(() => formFieldKey.currentState?.didChange(widget.addressController.text));
}
void _onFocusChange() {
setState(() {});
if (mounted) {
setState(() {});
}
}
@override
@@ -67,7 +71,7 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
child: FormField<String>(
key: formFieldKey,
validator: widget.validator,
builder: (state)=>Column(
builder: (state) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
@@ -81,9 +85,11 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
children: [
TextField(
focusNode: widget.focusNode,
onSubmitted: (val)=> FocusScope.of(context).unfocus(),
onSubmitted: (val) => FocusScope.of(context).unfocus(),
onChanged: state.didChange,
onEditingComplete: (){widget.onEditingComplete();},
onEditingComplete: () {
widget.onEditingComplete();
},
onTapOutside: (_) {
widget.onEditingComplete();
},
@@ -97,12 +103,15 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
child: IgnorePointer(
child: AnimatedOpacity(
duration: Duration(milliseconds: 150),
opacity: (widget.focusNode == null || widget.focusNode!.hasFocus || widget.addressController.text.isEmpty) ? 0 : 1,
opacity: (widget.focusNode == null ||
widget.focusNode!.hasFocus ||
widget.addressController.text.isEmpty)
? 0
: 1,
child: SendAddressOverlay(
address: widget.addressController.text,
displayName: widget.displayName,
)
),
)),
),
),
],
@@ -133,8 +142,14 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
],
),
),
if(state.hasError)
Padding(padding: EdgeInsets.only(top:6,left: 8),child: Text(state.errorText!, style: TextStyle(fontSize:12,color: Theme.of(context).colorScheme.error),),)
if (state.hasError)
Padding(
padding: EdgeInsets.only(top: 6, left: 8),
child: Text(
state.errorText!,
style: TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.error),
),
)
],
),
),
@@ -143,7 +158,7 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
Future<void> _presentQRScanner(BuildContext context) async {
bool isCameraPermissionGranted =
await PermissionHandler.checkPermission(Permission.camera, context);
await PermissionHandler.checkPermission(Permission.camera, context);
if (!isCameraPermissionGranted) return;
final code = await presentQRScanner(context);
if (code == null) return;
@@ -221,7 +236,8 @@ class SendAddressOverlay extends StatelessWidget {
children: [
if (showDisplayName)
Text(
displayName!,maxLines: 1,
displayName!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: primaryTextStyle,
),
@@ -36,7 +36,6 @@ class SwapConfirmSheet extends StatefulWidget {
}
class _SwapConfirmSheetState extends State<SwapConfirmSheet> {
void beginSend() async {
final sendVM = widget.exchangeTradeViewModel.sendViewModel;
@@ -79,52 +78,54 @@ class _SwapConfirmSheetState extends State<SwapConfirmSheet> {
@override
Widget build(BuildContext context) {
return PopScope(
onPopInvokedWithResult: (didPop, result) {
Navigator.of(context, rootNavigator: true).pop();
},
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
child: SafeArea(
child: Observer(
builder: (_) {
final commited = widget.exchangeTradeViewModel.sendViewModel.state is TransactionCommitted;
return Stack(
fit: StackFit.loose,
children: [
Positioned.fill(
child: AnimatedSlide(
offset: commited ? Offset.zero : const Offset(1, 0),
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
child: const TransactionCommitedScreen(),
)),
AnimatedSlide(
offset: commited ? const Offset(-1, 0) : Offset.zero,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
child: SwapTransactionDetails(
exchangeViewModel: widget.exchangeViewModel,
exchangeTradeViewModel: widget.exchangeTradeViewModel,
receiveAmount: widget.receiveAmount,
),
),
],
);
},
onPopInvokedWithResult: (didPop, result) {
Navigator.of(context, rootNavigator: true).pop();
},
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
),
));
child: SafeArea(
child: Observer(
builder: (_) {
final commited =
widget.exchangeTradeViewModel.sendViewModel.state is TransactionCommitted;
return Stack(
fit: StackFit.loose,
children: [
Positioned.fill(
child: AnimatedSlide(
offset: commited ? Offset.zero : const Offset(1, 0),
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
child: const TransactionCommitedScreen(),
)),
AnimatedSlide(
offset: commited ? const Offset(-1, 0) : Offset.zero,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
child: SwapTransactionDetails(
exchangeViewModel: widget.exchangeViewModel,
exchangeTradeViewModel: widget.exchangeTradeViewModel,
receiveAmount: widget.receiveAmount,
),
),
],
);
},
),
),
));
}
}
class SwapTransactionDetails extends StatelessWidget {
const SwapTransactionDetails({super.key, required this.exchangeViewModel, required this.exchangeTradeViewModel, required this.receiveAmount});
const SwapTransactionDetails(
{super.key,
required this.exchangeViewModel,
required this.exchangeTradeViewModel,
required this.receiveAmount});
final ExchangeViewModel exchangeViewModel;
final ExchangeTradeViewModel exchangeTradeViewModel;
@@ -144,7 +145,7 @@ class SwapTransactionDetails extends StatelessWidget {
onTrailingPressed: Navigator.of(context).maybePop,
),
SafeArea(
top:false,
top: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
@@ -161,13 +162,13 @@ class SwapTransactionDetails extends StatelessWidget {
trailingText: exchangeTradeViewModel.trade.amountFormatted() +
" " +
(exchangeViewModel.depositCurrency.title)),
if(exchangeTradeViewModel.sendViewModel.pendingTransaction != null)
if (exchangeTradeViewModel.sendViewModel.pendingTransaction != null)
ListItemRegularRow(
showArrow: false,
keyValue: "fee",
label: S.of(context).fee,
trailingText:
"${exchangeTradeViewModel.sendViewModel.pendingTransaction?.feeFormatted} (${exchangeTradeViewModel.pendingTransactionFeeFiatAmountFormatted})"),
"${exchangeTradeViewModel.sendViewModel.pendingTransaction?.feeFormatted} (${exchangeTradeViewModel.pendingTransactionFeeFiatAmountFormatted})"),
ListItemRegularRow(
keyValue: "sender",
label: S.of(context).from,
@@ -182,14 +183,15 @@ class SwapTransactionDetails extends StatelessWidget {
keyValue: "receive value",
label: exchangeViewModel.receiveCurrency.fullName ?? "",
iconPath: exchangeViewModel.receiveCurrency.iconPath ?? "",
trailingText: (receiveAmount) +
" " +
(exchangeViewModel.receiveCurrency.title)),
trailingText:
(receiveAmount) + " " + (exchangeViewModel.receiveCurrency.title)),
ListItemRegularRow(
keyValue: "receiver",
label: S.of(context).to,
showArrow: false,
trailingText: exchangeViewModel.receiveAddressDisplayName ?? middleTruncate(exchangeTradeViewModel.trade.payoutAddress ?? "", 8, 8))
trailingText: exchangeViewModel.receiveAddressDisplayName ??
middleTruncate(
exchangeTradeViewModel.trade.payoutAddress ?? "", 8, 8))
],
"${S.of(context).swap_id} (${S.of(context).tap_to_copy})": [
ListItemRegularRow(
@@ -201,14 +203,15 @@ class SwapTransactionDetails extends StatelessWidget {
iconPath: exchangeTradeViewModel.trade.provider.image,
trailingIconPath: "assets/new-ui/copy.svg",
trailingText: exchangeTradeViewModel.trade.id,
truncateTrailingText: !exchangeTradeViewModel.trade.provider.isCentralized),
if(exchangeTradeViewModel.trade.provider == ExchangeProviderDescription.trocador)
truncateTrailingText:
!exchangeTradeViewModel.trade.provider.isCentralized),
if (exchangeTradeViewModel.trade.provider ==
ExchangeProviderDescription.trocador)
ListItemRegularRow(
showArrow: false,
keyValue: "trocador provider name",
label: "Trocador ${S.of(context).provider}",
trailingText: exchangeTradeViewModel.trade.providerName??""
)
trailingText: exchangeTradeViewModel.trade.providerName ?? "")
]
}),
),
@@ -216,12 +219,12 @@ class SwapTransactionDetails extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 8.0),
child: exchangeViewModel.isSendFromExternal
? NewPrimaryButton(
onPressed: ()=>_showExternalSendModal(context),
text: S.of(context).continue_text,
color: Theme.of(context).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary)
onPressed: () => _showExternalSendModal(context),
text: S.of(context).continue_text,
color: Theme.of(context).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary)
: SendConfirmBottomWidget(
sendViewModel: exchangeTradeViewModel.sendViewModel),
sendViewModel: exchangeTradeViewModel.sendViewModel),
),
],
),
@@ -232,16 +235,17 @@ class SwapTransactionDetails extends StatelessWidget {
}
void _showExternalSendModal(BuildContext context) {
showMaterialModalBottomSheet(
context: context,
builder: (context) {
return SwapSendExternalModal(
amount: exchangeTradeViewModel.trade.amount,
exchangeTradeViewModel: exchangeTradeViewModel,
from: exchangeTradeViewModel.trade.from ?? exchangeViewModel.depositCurrency,
to: exchangeTradeViewModel.trade.to ?? exchangeViewModel.receiveCurrency,
address: exchangeTradeViewModel.trade.inputAddress ?? "");
});
if (context.mounted) {
showMaterialModalBottomSheet(
context: context,
builder: (context) {
return SwapSendExternalModal(
amount: exchangeTradeViewModel.trade.amount,
exchangeTradeViewModel: exchangeTradeViewModel,
from: exchangeTradeViewModel.trade.from ?? exchangeViewModel.depositCurrency,
to: exchangeTradeViewModel.trade.to ?? exchangeViewModel.receiveCurrency,
address: exchangeTradeViewModel.trade.inputAddress ?? "");
});
}
}
}