Skip to content

Commit e5b067f

Browse files
authored
Merge pull request #273 from synonymdev/feat/self-send
Activity self-send UI
2 parents 74de74c + c82a2db commit e5b067f

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

app/src/main/java/to/bitkit/ext/Activities.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fun Activity.totalValue() = when(this) {
2828
}
2929

3030
fun Activity.canBeBoosted() = when (this) {
31-
is Activity.Onchain -> !v1.confirmed && v1.doesExist && !v1.isBoosted && !v1.isTransfer
31+
is Activity.Onchain -> !v1.confirmed && v1.doesExist && !v1.isBoosted && !v1.isTransfer && v1.value > 0uL
3232
else -> false
3333
}
3434

app/src/main/java/to/bitkit/ui/screens/wallets/activity/ActivityDetailScreen.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fun ActivityDetailScreen(
157157
app.toast(
158158
type = Toast.ToastType.ERROR,
159159
title = context.getString(R.string.wallet__send_fee_error),
160-
description = "Unable to increase the fee any further. Otherwise, it will exceed half the current input balance" //TODO CREATE STRING RESOURCE
160+
description = "Unable to increase the fee any further. Otherwise, it will exceed half the current input balance" // TODO CREATE STRING RESOURCE
161161
)
162162
},
163163
onMinFee = {
@@ -206,6 +206,7 @@ private fun ActivityDetailContent(
206206
is Activity.Lightning -> item.v1.fee
207207
is Activity.Onchain -> item.v1.fee
208208
}
209+
val isSelfSend = isSent && paymentValue == 0uL
209210

210211
Column(
211212
modifier = Modifier
@@ -226,7 +227,7 @@ private fun ActivityDetailContent(
226227
forceShowBalance = true,
227228
modifier = Modifier.weight(1f)
228229
)
229-
ActivityIcon(activity = item, size = 48.dp)
230+
ActivityIcon(activity = item, size = 48.dp) // TODO Display the user avatar when selfsend
230231
}
231232

232233
Spacer(modifier = Modifier.height(16.dp))
@@ -289,7 +290,11 @@ private fun ActivityDetailContent(
289290
) {
290291
Column(modifier = Modifier.weight(1f)) {
291292
Caption13Up(
292-
text = stringResource(R.string.wallet__activity_payment),
293+
text = if (isSelfSend) {
294+
"Sent to myself" // TODO translation
295+
} else {
296+
stringResource(R.string.wallet__activity_payment)
297+
},
293298
color = Colors.White64,
294299
modifier = Modifier.padding(top = 16.dp, bottom = 8.dp)
295300
)
@@ -406,6 +411,7 @@ private fun ActivityDetailContent(
406411
text = stringResource(R.string.wallet__activity_assign),
407412
size = ButtonSize.Small,
408413
onClick = { /* TODO: Implement assign functionality */ },
414+
enabled = !isSelfSend,
409415
icon = {
410416
Icon(
411417
painter = painterResource(R.drawable.ic_user_plus),
@@ -436,7 +442,13 @@ private fun ActivityDetailContent(
436442
modifier = Modifier.fillMaxWidth()
437443
) {
438444
PrimaryButton(
439-
text = stringResource(if (item.isBoosted()) R.string.wallet__activity_boosted else R.string.wallet__activity_boost),
445+
text = stringResource(
446+
if (item.isBoosted()) {
447+
R.string.wallet__activity_boosted
448+
} else {
449+
R.string.wallet__activity_boost
450+
}
451+
),
440452
size = ButtonSize.Small,
441453
onClick = onClickBoost,
442454
enabled = item.canBeBoosted(),

app/src/main/java/to/bitkit/viewmodels/ActivityDetailViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class ActivityDetailViewModel @Inject constructor(
2424
@BgDispatcher private val bgDispatcher: CoroutineDispatcher,
2525
private val addressChecker: AddressChecker,
2626
private val coreService: CoreService,
27-
private val lightningRepo: LightningRepo,
2827
private val settingsStore: SettingsStore,
2928
) : ViewModel() {
3029
private val _txDetails = MutableStateFlow<TxDetails?>(null)

0 commit comments

Comments
 (0)