Skip to content

Commit f124bd7

Browse files
committed
chore(app): Remind about minimum collateral when receiving on-chain funds
1 parent a465877 commit f124bd7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: mobile/lib/features/wallet/receive_screen.dart

+39
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:get_10101/common/custom_app_bar.dart';
88
import 'package:get_10101/common/amount_text.dart';
99
import 'package:get_10101/common/application/switch.dart';
1010
import 'package:get_10101/common/color.dart';
11+
import 'package:get_10101/common/dlc_channel_change_notifier.dart';
1112
import 'package:get_10101/common/domain/model.dart';
1213
import 'package:get_10101/common/scrollable_safe_area.dart';
1314
import 'package:get_10101/common/secondary_action_button.dart';
@@ -49,6 +50,7 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
4950
super.initState();
5051
_createPaymentRequest(amount, description)
5152
.then((paymentRequest) => setState(() => _paymentRequest = paymentRequest));
53+
context.read<DlcChannelChangeNotifier>().refreshDlcChannels();
5254
}
5355

5456
String rawInvoice() {
@@ -63,6 +65,11 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
6365
Widget build(BuildContext context) {
6466
final bridge.Config config = context.read<bridge.Config>();
6567

68+
final balance =
69+
context.watch<WalletChangeNotifier>().walletInfo.balances.onChain ?? Amount.zero();
70+
final hasDlcChannel = context.watch<DlcChannelChangeNotifier>().hasDlcChannel();
71+
const minBalance = 275000;
72+
6673
if (_paymentRequest == null) {
6774
return Scaffold(
6875
appBar: AppBar(title: const Text("Receive funds")),
@@ -202,6 +209,34 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
202209
BitcoinAddress(
203210
address: _paymentRequest == null ? "" : _paymentRequest!.address,
204211
),
212+
const SizedBox(height: 20),
213+
Visibility(
214+
visible: !hasDlcChannel && balance.sats < minBalance,
215+
child: Container(
216+
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
217+
decoration: BoxDecoration(
218+
border: Border.all(color: tenTenOnePurple),
219+
color: Colors.white,
220+
borderRadius: BorderRadius.circular(10)),
221+
child: Row(
222+
mainAxisAlignment: MainAxisAlignment.start,
223+
children: [
224+
const Icon(
225+
Icons.info,
226+
color: tenTenOnePurple,
227+
size: 22,
228+
),
229+
const SizedBox(width: 10),
230+
Expanded(
231+
child: Text(
232+
"Receive around ${formatSats(Amount(minBalance))} to be able to trade.",
233+
softWrap: true,
234+
style: const TextStyle(fontSize: 16),
235+
),
236+
)
237+
],
238+
)),
239+
),
205240
]),
206241
)));
207242
}
@@ -548,6 +583,7 @@ class _InvoiceDrawerScreen extends State<InvoiceDrawerScreen> {
548583
color: Colors.grey.shade300,
549584
borderRadius: BorderRadius.circular(4)),
550585
child: InvoiceInputField(
586+
keyboardType: TextInputType.number,
551587
onChanged: (value) => {
552588
setState(() {
553589
_amount = int.parse(value);
@@ -631,6 +667,7 @@ class InvoiceInputField extends StatelessWidget {
631667
final String hintText;
632668
final List<TextInputFormatter>? inputFormatters;
633669
final String value;
670+
final TextInputType? keyboardType;
634671
final Widget? prefixIcon;
635672
final Widget? suffixIcon;
636673

@@ -640,6 +677,7 @@ class InvoiceInputField extends StatelessWidget {
640677
required this.hintText,
641678
required this.inputFormatters,
642679
required this.value,
680+
this.keyboardType,
643681
this.prefixIcon,
644682
this.suffixIcon,
645683
});
@@ -648,6 +686,7 @@ class InvoiceInputField extends StatelessWidget {
648686
Widget build(BuildContext context) {
649687
return TextFormField(
650688
initialValue: value,
689+
keyboardType: keyboardType,
651690
decoration: InputDecoration(
652691
border: InputBorder.none,
653692
hintText: hintText,

0 commit comments

Comments
 (0)