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

feat: Make lnlambda.lnmetrics.info default lamdaServer url #143

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/components/bottomsheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class CLNBottomSheet {
},
child: Text(
'$display msats',
textScaleFactor: 1.0,
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
Expand Down
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,
this.customLambdaServer = false,
this.lambdaServer = "https://lnlambda.lnmetrics.info",
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.

2 changes: 1 addition & 1 deletion lib/views/pay/pay_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _PayViewState extends State<PayView> {
Future<void> payInvoice(String boltString) async {
try {
await widget.provider.get<AppApi>().payInvoice(invoice: boltString);
if (context.mounted) {
if (mounted) {
PopUp.showPopUp(
context, 'Payment Successful', 'Payment successfully sent', false);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/views/request/request_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class _RequestViewState extends State<RequestView> {
)
: Text(
value,
textScaleFactor: 1.0,
textScaler: const TextScaler.linear(1.0),
style: const TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
Expand Down
45 changes: 37 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,45 @@ class _LnlambdaSettingViewState extends State<LnlambdaSettingView> {
),
),
const Text("Lambda Server"),
TextFormField(
controller: TextEditingController(text: setting.lambdaServer ?? ''),
onChanged: (text) {
setting.lambdaServer = text;
DropdownButtonFormField(
value:
setting.customLambdaServer! ? '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
17 changes: 9 additions & 8 deletions lib/views/setting/setting_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,19 @@ class _SettingViewState extends State<SettingView> {
children: [
ElevatedButton(
onPressed: () async {
if (setting.isValid()) {
if (setting.isValid() && context.mounted) {
await saveSettings(setting: setting);
await ManagerAPIProvider.registerClientFromSetting(
setting, widget.provider);
// https://stackoverflow.com/questions/68871880/do-not-use-buildcontexts-across-async-gaps
if (!mounted) return;
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => HomeView(
provider: widget.provider,
)),
(Route<dynamic> route) => false);
if (context.mounted) {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => HomeView(
provider: widget.provider,
)),
(Route<dynamic> route) => false);
}
} else {
PopUp.showPopUp(
context,
Expand Down