Skip to content

Commit

Permalink
Add dropdown to pick lambda url with conditional textfield to enter u…
Browse files Browse the repository at this point in the history
…rl manually
  • Loading branch information
mdmohsin7 committed Feb 20, 2024
1 parent 7147ea5 commit 97a435b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
6 changes: 5 additions & 1 deletion lib/model/user_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Setting {
String? host;
String? path;
String? nodeId;
bool? customLambdaServer;
String? lambdaServer;
String? rune;

Expand All @@ -17,7 +18,8 @@ class Setting {
this.host,
this.path,
this.nodeId,
this.lambdaServer = "https://lnlambda.lnmetrics.info",
this.customLambdaServer,
this.lambdaServer,
this.rune}) {
clientMode = ClientProvider.getClientByDefPlatform().first;
}
Expand Down Expand Up @@ -56,6 +58,7 @@ class Setting {
'nodeId': nodeId,
'host': host,
'rune': rune,
'customLambdaServer': customLambdaServer,
'lambdaServer': lambdaServer,
};
}
Expand All @@ -73,6 +76,7 @@ class Setting {
return path != null;
case ClientMode.lnlambda:
return nodeId != null &&
customLambdaServer != null &&
lambdaServer != null &&
rune != null &&
host != null;
Expand Down
2 changes: 2 additions & 0 deletions lib/model/user_setting.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 40 additions & 8 deletions lib/views/setting/lnlambda_setting_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,48 @@ class _LnlambdaSettingViewState extends State<LnlambdaSettingView> {
),
),
const Text("Lambda Server"),
TextFormField(
controller: TextEditingController(text: setting.lambdaServer),
onChanged: (text) {
setting.lambdaServer = text;
DropdownButtonFormField(
value: setting.customLambdaServer == null
? null
: setting.customLambdaServer == true
? 'custom'
: setting.lambdaServer,
items: const [
DropdownMenuItem(
value: 'https://lnlambda.lnmetrics.info',
child: Text("https://lnlambda.lnmetrics.info"),
),
DropdownMenuItem(
value: 'custom',
child: Text("Enter lambda server url manually"),
),
],
onChanged: (value) {
setState(() {
if (value == 'custom') {
setting.customLambdaServer = true;
} else {
setting.customLambdaServer = false;
setting.lambdaServer = value as String;
}
});
},
decoration: const InputDecoration(
label: Text("lnlambda server url"),
border: OutlineInputBorder(),
),
),
() {
if (setting.customLambdaServer == true) {
return TextFormField(
controller: TextEditingController(text: setting.lambdaServer),
onChanged: (text) {
setting.lambdaServer = text;
},
decoration: const InputDecoration(
label: Text("lnlambda server url"),
border: OutlineInputBorder(),
),
);
}
return const SizedBox();
}(),
const Text("Rune"),
TextFormField(
controller: TextEditingController(text: setting.rune ?? ''),
Expand Down

0 comments on commit 97a435b

Please sign in to comment.