Skip to content

Commit

Permalink
Change bottom bar button visibility & texts per feedback
Browse files Browse the repository at this point in the history
Show close button only for invalid invoices
  • Loading branch information
erdemyerebasmaz committed Nov 7, 2024
1 parent 0e653ec commit 587e10a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class _EnterPaymentInfoPageState extends State<EnterPaymentInfoPage> {
String errorMessage = "";
ModalRoute? _loaderRoute;

@override
void initState() {
super.initState();
_paymentInfoController.addListener(() {
setState(() {});
});
}

@override
Widget build(BuildContext context) {
final texts = context.texts();
Expand Down Expand Up @@ -89,14 +97,13 @@ class _EnterPaymentInfoPageState extends State<EnterPaymentInfoPage> {
),
),
),
bottomNavigationBar: SingleButtonBottomBar(
text: _paymentInfoController.text.isNotEmpty && errorMessage.isEmpty
? texts.payment_info_dialog_action_approve
: texts.payment_info_dialog_action_cancel,
onPressed: _paymentInfoController.text.isNotEmpty && errorMessage.isEmpty
? _onApprovePressed
: () => Navigator.pop(context),
),
bottomNavigationBar: _paymentInfoController.text.isNotEmpty
? SingleButtonBottomBar(
stickToBottom: true,
text: texts.withdraw_funds_action_next,
onPressed: _onApprovePressed,
)
: const SizedBox.shrink(),
);
}

Expand Down Expand Up @@ -157,7 +164,7 @@ class _EnterPaymentInfoPageState extends State<EnterPaymentInfoPage> {
if (_formKey.currentState!.validate()) {
_setLoading(false);
if (mounted) Navigator.pop(context);
inputCubit.addIncomingInput(_paymentInfoController.text, InputSource.inputField);
inputCubit.addIncomingInput(_paymentInfoController.text.trim(), InputSource.inputField);
}
} catch (error) {
_setLoading(false);
Expand All @@ -167,6 +174,8 @@ class _EnterPaymentInfoPageState extends State<EnterPaymentInfoPage> {
errorMessage = context.texts().payment_info_dialog_error;
});
}
} finally {
_setLoading(false);
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/routes/lnurl/payment/lnurl_payment_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class LnUrlPaymentPageState extends State<LnUrlPaymentPage> {
},
),
),
if (errorMessage.isNotEmpty) ...[
if (!_isFormEnabled || _isFixedAmount && errorMessage.isNotEmpty) ...[
const SizedBox(height: 8.0),
AutoSizeText(
errorMessage,
Expand Down Expand Up @@ -359,7 +359,7 @@ class LnUrlPaymentPageState extends State<LnUrlPaymentPage> {
_fetchLightningLimits();
},
)
: errorMessage.isNotEmpty
: !_isFormEnabled || _isFixedAmount && errorMessage.isNotEmpty
? SingleButtonBottomBar(
stickToBottom: true,
text: texts.qr_code_dialog_action_close,
Expand All @@ -370,7 +370,7 @@ class LnUrlPaymentPageState extends State<LnUrlPaymentPage> {
: !_isFixedAmount
? SingleButtonBottomBar(
stickToBottom: true,
text: texts.lnurl_fetch_invoice_action_continue,
text: texts.withdraw_funds_action_next,
onPressed: () async {
if (_formKey.currentState?.validate() ?? false) {
await _openConfirmationPage();
Expand All @@ -380,7 +380,7 @@ class LnUrlPaymentPageState extends State<LnUrlPaymentPage> {
: _prepareResponse != null
? SingleButtonBottomBar(
stickToBottom: true,
text: texts.lnurl_payment_page_action_pay,
text: texts.bottom_action_bar_send,
onPressed: () async {
Navigator.pop(context, _prepareResponse);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/receive_payment/lnurl/lnurl_withdraw_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class LnUrlWithdrawPageState extends State<LnUrlWithdrawPage> {
_fetchLightningLimits();
},
)
: errorMessage.isNotEmpty
: !_isFormEnabled || _isFixedAmount && errorMessage.isNotEmpty
? SingleButtonBottomBar(
stickToBottom: true,
text: texts.qr_code_dialog_action_close,
Expand Down

0 comments on commit 587e10a

Please sign in to comment.