Skip to content

Commit 9f04fab

Browse files
committed
(android) Fix back button behaviour for lnurl actions
Specifically, for a LN withdrawal, a successful withdraw should not lead back to the scanner screen (which will reattempt the withdraw) but to the home screen.
1 parent f40642c commit 9f04fab

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/LnurlAuthView.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ fun LnurlAuthView(
3939
model: Scan.Model.LnurlAuthFlow,
4040
onBackClick: () -> Unit,
4141
onLoginClick: (Scan.Intent.LnurlAuthFlow) -> Unit,
42-
onAuthSchemeInfoClick: () -> Unit
42+
onAuthSchemeInfoClick: () -> Unit,
43+
onAuthDone: () -> Unit,
4344
) {
4445
var showHowItWorks by remember { mutableStateOf(false) }
4546
val prefAuthScheme by userPrefs.getLnurlAuthScheme.collectAsState(initial = null)
@@ -131,7 +132,7 @@ fun LnurlAuthView(
131132
Text(text = stringResource(id = R.string.lnurl_auth_success, model.auth.initialUrl.host), textAlign = TextAlign.Center)
132133
}
133134
Spacer(Modifier.height(32.dp))
134-
FilledButton(text = stringResource(id = R.string.btn_ok), icon = R.drawable.ic_check, onClick = onBackClick)
135+
FilledButton(text = stringResource(id = R.string.btn_ok), icon = R.drawable.ic_check, onClick = onAuthDone)
135136
}
136137
}
137138
}

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/LnurlWithdrawView.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import fr.acinq.phoenix.data.lnurl.LnurlError
4444
@Composable
4545
fun LnurlWithdrawView(
4646
model: Scan.Model.LnurlWithdrawFlow,
47-
onBackClick: () -> Unit,
4847
onWithdrawClick: (Scan.Intent.LnurlWithdrawFlow) -> Unit,
4948
onFeeManagementClick: () -> Unit,
49+
onWithdrawDone: () -> Unit,
5050
) {
5151
val context = LocalContext.current
5252
val prefUnit = preferredAmountUnit
@@ -57,7 +57,7 @@ fun LnurlWithdrawView(
5757
var amountErrorMessage by remember { mutableStateOf("") }
5858

5959
SplashLayout(
60-
header = { DefaultScreenHeader(onBackClick = onBackClick) },
60+
header = { DefaultScreenHeader(onBackClick = onWithdrawDone) },
6161
topContent = {
6262
Text(text = annotatedStringResource(R.string.lnurl_withdraw_header, model.lnurlWithdraw.initialUrl.host), textAlign = TextAlign.Center)
6363
Spacer(modifier = Modifier.height(16.dp))
@@ -131,7 +131,7 @@ fun LnurlWithdrawView(
131131
textAlign = TextAlign.Center
132132
)
133133
Spacer(Modifier.height(12.dp))
134-
BorderButton(text = stringResource(id = R.string.btn_ok), icon = R.drawable.ic_check_circle, onClick = onBackClick)
134+
BorderButton(text = stringResource(id = R.string.btn_ok), icon = R.drawable.ic_check_circle, onClick = onWithdrawDone)
135135
}
136136
}
137137
}

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/ScanDataView.kt

+13-2
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,21 @@ fun ScanDataView(
162162
)
163163
}
164164
is Scan.Model.LnurlAuthFlow -> {
165-
LnurlAuthView(model = model, onBackClick = onBackClick, onLoginClick = { postIntent(it) }, onAuthSchemeInfoClick = onAuthSchemeInfoClick)
165+
LnurlAuthView(
166+
model = model,
167+
onBackClick = onBackClick,
168+
onLoginClick = { postIntent(it) },
169+
onAuthSchemeInfoClick = onAuthSchemeInfoClick,
170+
onAuthDone = onProcessingFinished,
171+
)
166172
}
167173
is Scan.Model.LnurlWithdrawFlow -> {
168-
LnurlWithdrawView(model = model, onBackClick = onBackClick, onWithdrawClick = { postIntent(it) }, onFeeManagementClick = onFeeManagementClick)
174+
LnurlWithdrawView(
175+
model = model,
176+
onWithdrawClick = { postIntent(it) },
177+
onFeeManagementClick = onFeeManagementClick,
178+
onWithdrawDone = onProcessingFinished,
179+
)
169180
}
170181
}
171182
}

0 commit comments

Comments
 (0)