Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bruig: Hide advanced fields for need in/out channel screens #150

Merged
merged 1 commit into from Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
133 changes: 87 additions & 46 deletions bruig/flutterui/bruig/lib/screens/needs_in_channel.dart
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:golib_plugin/golib_plugin.dart';
import 'package:golib_plugin/util.dart';
import 'package:tuple/tuple.dart';
import 'package:bruig/components/empty_widget.dart';

class NeedsInChannelScreen extends StatefulWidget {
final AppNotifications ntfns;
Expand Down Expand Up @@ -37,6 +38,7 @@ class _NeedsInChannelScreenState extends State<NeedsInChannelScreen> {
TextEditingController certCtrl = TextEditingController();
AmountEditingController amountCtrl = AmountEditingController();
String preventMsg = "";
bool showAdvanced = false;

void getNewAddress() async {
try {
Expand Down Expand Up @@ -154,6 +156,18 @@ cNPr8Y+sSs2MHf6xMNBQzV4KuIlPIg==
}
}

void showAdvancedArea() {
setState(() {
showAdvanced = true;
});
}

void hideAdvancedArea() {
setState(() {
showAdvanced = false;
});
}

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -247,7 +261,7 @@ messages. It is only required in order to receive payments from other users.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${formatDCR(atomsToDCR(maxOutAmount))}",
formatDCR(atomsToDCR(maxOutAmount)),
style: TextStyle(
color: darkTextColor,
fontSize: 13,
Expand All @@ -266,7 +280,7 @@ messages. It is only required in order to receive payments from other users.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${formatDCR(atomsToDCR(maxInAmount))}",
formatDCR(atomsToDCR(maxInAmount)),
style: TextStyle(
color: darkTextColor,
fontSize: 13,
Expand All @@ -284,7 +298,7 @@ messages. It is only required in order to receive payments from other users.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${numPendingChannels}",
"$numPendingChannels",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
Expand All @@ -302,59 +316,86 @@ messages. It is only required in order to receive payments from other users.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${numChannels}",
"$numChannels",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300))
]),
const SizedBox(height: 10),
preventMsg == ""
? LoadingScreenButton(
empty: true,
onPressed: showAdvanced
? hideAdvancedArea
: showAdvancedArea,
text: showAdvanced
? "Hide Advanced"
: "Show Advanced",
)
: Empty(),
const SizedBox(height: 10),
preventMsg == ""
? Expanded(
child: SimpleInfoGrid([
Tuple2(
Text("LP Server Address",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
TextField(
controller: serverCtrl,
decoration: const InputDecoration(
hintText: "https://lpd-server:port"),
)),
Tuple2(
Text("LP Server Cert",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
TextField(
controller: certCtrl,
maxLines: null,
keyboardType: TextInputType.multiline,
)),
Tuple2(
Text("Amount",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
SizedBox(
width: 150,
child: dcrInput(controller: amountCtrl),
)),
Tuple2(
const SizedBox(height: 50),
LoadingScreenButton(
onPressed:
!loading ? requestRecvCapacity : null,
text: "Request Inbound Channel",
))
]))
child: ListView(
shrinkWrap: true,
padding: const EdgeInsets.all(15.0),
children: <Widget>[
SimpleInfoGrid([
Tuple2(
Text("Amount",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
SizedBox(
width: 150,
child:
dcrInput(controller: amountCtrl),
)),
Tuple2(
const SizedBox(height: 50),
LoadingScreenButton(
onPressed: !loading
? requestRecvCapacity
: null,
text: "Request Inbound Channel",
))
]),
showAdvanced
? SimpleInfoGrid([
Tuple2(
Text("LP Server Address",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight:
FontWeight.w300)),
TextField(
controller: serverCtrl,
decoration: const InputDecoration(
hintText:
"https://lpd-server:port"),
)),
Tuple2(
Text("LP Server Cert",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight:
FontWeight.w300)),
TextField(
controller: certCtrl,
maxLines: null,
keyboardType:
TextInputType.multiline,
)),
])
: const Empty(),
]))
: Expanded(
child: Column(children: [
SizedBox(height: 30),
const SizedBox(height: 30),
Text(
preventMsg,
style: TextStyle(color: textColor),
Expand Down
108 changes: 73 additions & 35 deletions bruig/flutterui/bruig/lib/screens/needs_out_channel.dart
Expand Up @@ -37,6 +37,7 @@ class _NeedsOutChannelScreenState extends State<NeedsOutChannelScreen> {
TextEditingController peerCtrl = TextEditingController();
AmountEditingController amountCtrl = AmountEditingController();
String preventMsg = "foo";
bool showAdvanced = false;

void getNewAddress() async {
try {
Expand Down Expand Up @@ -147,6 +148,18 @@ open channels to other LN nodes.''';
}
}

void showAdvancedArea() {
setState(() {
showAdvanced = true;
});
}

void hideAdvancedArea() {
setState(() {
showAdvanced = false;
});
}

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -239,7 +252,7 @@ the wallet seed is NOT sufficient to restore their state.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${formatDCR(atomsToDCR(walletBalance))}",
formatDCR(atomsToDCR(walletBalance)),
style: TextStyle(
color: darkTextColor,
fontSize: 13,
Expand All @@ -258,7 +271,7 @@ the wallet seed is NOT sufficient to restore their state.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${formatDCR(atomsToDCR(maxOutAmount))}",
formatDCR(atomsToDCR(maxOutAmount)),
style: TextStyle(
color: darkTextColor,
fontSize: 13,
Expand All @@ -276,7 +289,7 @@ the wallet seed is NOT sufficient to restore their state.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${numPendingChannels}",
"$numPendingChannels",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
Expand All @@ -294,50 +307,75 @@ the wallet seed is NOT sufficient to restore their state.
fontWeight: FontWeight.w300)),
Text(
textAlign: TextAlign.right,
"${numChannels}",
"$numChannels",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300))
]),
const SizedBox(height: 10),
preventMsg == ""
? SimpleInfoGrid([
Tuple2(
Text("Peer ID and Address",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
TextField(
controller: peerCtrl,
decoration: const InputDecoration(
hintText: "node-pub-key@addr:port"),
)),
Tuple2(
Text("Amount",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
SizedBox(
width: 150,
child: dcrInput(controller: amountCtrl),
)),
Tuple2(
const SizedBox(height: 50),
LoadingScreenButton(
onPressed: !loading ? openChannel : null,
text: "Request Outbound Channel",
))
])
? LoadingScreenButton(
empty: true,
onPressed: showAdvanced
? hideAdvancedArea
: showAdvancedArea,
text: showAdvanced
? "Hide Advanced"
: "Show Advanced",
)
: const Empty(),
const SizedBox(height: 10),
preventMsg == ""
? Expanded(
child: ListView(
shrinkWrap: true,
padding: const EdgeInsets.all(15.0),
children: <Widget>[
SimpleInfoGrid([
Tuple2(
Text("Amount",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight: FontWeight.w300)),
SizedBox(
width: 150,
child:
dcrInput(controller: amountCtrl),
)),
Tuple2(
const SizedBox(height: 50),
LoadingScreenButton(
onPressed:
!loading ? openChannel : null,
text: "Request Outbound Channel",
))
]),
showAdvanced
? SimpleInfoGrid([
Tuple2(
Text("Peer ID and Address",
style: TextStyle(
color: darkTextColor,
fontSize: 13,
fontWeight:
FontWeight.w300)),
TextField(
controller: peerCtrl,
decoration: const InputDecoration(
hintText:
"node-pub-key@addr:port"),
)),
])
: const Empty(),
]))
: Expanded(
child: Column(children: [
SizedBox(height: 30),
const SizedBox(height: 30),
Text(preventMsg,
style: TextStyle(color: textColor))
])),
const Expanded(child: Empty()),
LoadingScreenButton(
onPressed: () => Navigator.of(context).pop(),
text: "Skip",
Expand Down