Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2457146
refactor: Move HomeActivityList to its own file
ovitrif May 14, 2025
2f78b80
fix: Refresh activityListViewModel tags after adding tag
ovitrif May 14, 2025
8d28540
feat: Activity filter custom icons
ovitrif May 14, 2025
75beab2
refactor: Rename ActivityViewModel file to ActivityListViewModel
ovitrif May 14, 2025
bfe0280
fix: Show 'no items' text when activity filter yields no results
ovitrif May 14, 2025
0d059d6
fix: Hide keyboard when opening filter sheets
ovitrif May 14, 2025
43b2366
refactor: Add preview for ActivityListFilter
ovitrif May 14, 2025
15b58a4
fix: Make tab container have transparent bg
ovitrif May 14, 2025
9fc6f14
feat: Add linear gradient to header
ovitrif May 14, 2025
1404fd6
fix: Slide animation on activity detail to full screen
ovitrif May 14, 2025
294d364
feat: Localizable activity filter tabs text
ovitrif May 14, 2025
b77d884
chore: Cleanup and reformat AllActivityScreen code
ovitrif May 15, 2025
4a31632
feat: Swipe horizontally to change filter tabs
ovitrif May 15, 2025
b6abd4c
refactor: Extract swipeToChangeTab modifier
ovitrif May 15, 2025
e637f2d
refactor: Lift logic out of ActivityListFilter
ovitrif May 15, 2025
96edb9e
fix: Activity list top padding & headers style
ovitrif May 15, 2025
6a14e0a
refactor: Extract activity components and unify naming
ovitrif May 15, 2025
0aa529a
fix: Remove list top padding on savings & spending screens
ovitrif May 15, 2025
e563a4b
refactor: Extract preview activity items to their own file
ovitrif May 15, 2025
9e7b239
feat: Truncate long caption in activity list items
ovitrif May 15, 2025
f8918af
chore: Reformat code
ovitrif May 15, 2025
77aeaa4
refactor: Cleanup filter header background code
ovitrif May 15, 2025
5b44a61
chore: Add preview for all activity screen
ovitrif May 15, 2025
88d569d
fix: Date range filter zero results
ovitrif May 15, 2025
8815a5a
fix: Total amount on activity explore
ovitrif May 15, 2025
3eb7675
refactor: Run activity details methods on bgDispatcher
ovitrif May 15, 2025
8c5f7ca
fix: Add preimage to LN activity items
ovitrif May 15, 2025
561acd4
fix: Add fee to LN activity and calculate it for amount
ovitrif May 15, 2025
ff90211
fix: Activity list filtered with zero results UI
ovitrif May 15, 2025
9731b87
fix: Broken activity details navigation when list is filtered
ovitrif May 15, 2025
887a871
refactor: Run activity list methods on bgDispatcher
ovitrif May 15, 2025
cdfa3b4
feat: Clear filters when leaving activity list screen
ovitrif May 15, 2025
49237a3
fix: Retain state on activity date filter
ovitrif May 15, 2025
d5d37d3
feat: Filter activity by selected tab
ovitrif May 15, 2025
0331eff
Merge branch 'master' into feat/activity-filter
ovitrif May 15, 2025
ed8cea6
refactor: Use bgDispatcher always in activityListViewModel
ovitrif May 15, 2025
f1e557f
chore: Cleanup related to activity.totalValue()
ovitrif May 15, 2025
5e7b3e6
chore: Cleanup in filter sheets
ovitrif May 15, 2025
10321c0
Merge branch 'master' into feat/activity-filter
ovitrif May 16, 2025
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
20 changes: 20 additions & 0 deletions app/src/main/java/to/bitkit/ext/Activities.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
package to.bitkit.ext

import uniffi.bitkitcore.Activity
import uniffi.bitkitcore.PaymentType

fun Activity.rawId(): String = when (this) {
is Activity.Lightning -> v1.id
is Activity.Onchain -> v1.id
}

/**
* Calculates the total value of an activity based on its type.
*
* For `Lightning` activity, the total value = `value + fee`.
*
* For `Onchain` activity:
* - If it is a send, the total value = `value + fee`.
* - Otherwise it's equal to `value`.
*
* @return The total value as an `ULong`.
*/
fun Activity.totalValue() = when(this) {
is Activity.Lightning -> v1.value + (v1.fee ?: 0u)
is Activity.Onchain -> when (v1.txType) {
PaymentType.SENT -> v1.value + v1.fee
else -> v1.value
}
}
9 changes: 5 additions & 4 deletions app/src/main/java/to/bitkit/services/CoreService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ class ActivityService(
txType = payment.direction.toPaymentType(),
status = state,
value = payment.amountSats ?: 0u,
fee = null, // TODO
invoice = "lnbc123", // TODO
fee = (payment.feePaidMsat ?: 0u) / 1000u,
invoice = "lnbc123_todo", // TODO
message = "",
timestamp = payment.latestUpdateTimestamp,
preimage = null,
preimage = kind.preimage,
createdAt = payment.latestUpdateTimestamp,
updatedAt = payment.latestUpdateTimestamp,
)
Expand Down Expand Up @@ -370,7 +370,8 @@ class ActivityService(
"Gift for mom",
"Split dinner bill",
"Monthly rent",
"Gym membership"
"Gym membership",
"Very long invoice message to test truncation in list",
)

repeat(count) { i ->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/to/bitkit/ui/components/Text.kt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ fun CaptionB(
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colorScheme.primary,
textAlign: TextAlign = TextAlign.Start,
maxLines: Int = Int.MAX_VALUE,
overflow: TextOverflow = if (maxLines == 1) TextOverflow.Ellipsis else TextOverflow.Clip,
) {
Text(
text = text,
Expand All @@ -363,6 +365,8 @@ fun CaptionB(
textAlign = textAlign,
),
modifier = modifier,
maxLines = maxLines,
overflow = overflow,
)
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import to.bitkit.ui.navigateToTransferSavingsIntro
import to.bitkit.ui.navigateToTransferSpendingAmount
import to.bitkit.ui.navigateToTransferSpendingIntro
import to.bitkit.ui.scaffold.AppScaffold
import to.bitkit.ui.screens.wallets.activity.HomeActivityList
import to.bitkit.ui.screens.wallets.activity.components.ActivityListSimple
import to.bitkit.ui.screens.wallets.activity.AllActivityScreen
import to.bitkit.ui.screens.wallets.activity.DateRangeSelectorSheet
import to.bitkit.ui.screens.wallets.activity.TagSelectorSheet
Expand Down Expand Up @@ -272,7 +272,7 @@ private fun HomeContentView(
Spacer(modifier = Modifier.height(16.dp))
val activity = activityListViewModel ?: return@Column
val latestActivities by activity.latestActivities.collectAsStateWithLifecycle()
HomeActivityList(
ActivityListSimple(
items = latestActivities,
onAllActivityClick = { walletNavController.navigate(HomeRoutes.AllActivity) },
onActivityItemClick = { rootNavController.navigateToActivityItem(it) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import to.bitkit.ui.components.EmptyStateView
import to.bitkit.ui.components.SecondaryButton
import to.bitkit.ui.scaffold.AppTopBar
import to.bitkit.ui.scaffold.ScreenColumn
import to.bitkit.ui.screens.wallets.activity.ActivityListWithHeaders
import to.bitkit.ui.screens.wallets.activity.components.ActivityListGrouped
import to.bitkit.ui.theme.AppThemeSurface
import to.bitkit.ui.theme.Colors
import to.bitkit.ui.utils.withAccent
Expand Down Expand Up @@ -88,10 +88,10 @@ fun SavingsWalletScreen(
)
}
)
Spacer(modifier = Modifier.height(16.dp))

val activity = activityListViewModel ?: return@Column
val onchainActivities by activity.onchainActivities.collectAsState()
ActivityListWithHeaders(
ActivityListGrouped(
items = onchainActivities,
showFooter = true,
onAllActivityButtonClick = onAllActivityButtonClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import to.bitkit.ui.components.EmptyStateView
import to.bitkit.ui.components.SecondaryButton
import to.bitkit.ui.scaffold.AppTopBar
import to.bitkit.ui.scaffold.ScreenColumn
import to.bitkit.ui.screens.wallets.activity.ActivityListWithHeaders
import to.bitkit.ui.screens.wallets.activity.components.ActivityListGrouped
import to.bitkit.ui.theme.AppThemeSurface
import to.bitkit.ui.theme.Colors
import to.bitkit.ui.utils.withAccent
Expand Down Expand Up @@ -100,12 +100,11 @@ fun SpendingWalletScreen(
)
}
)
Spacer(modifier = Modifier.height(16.dp))
}

val activity = activityListViewModel ?: return@Column
val lightningActivities by activity.lightningActivities.collectAsState()
ActivityListWithHeaders(
ActivityListGrouped(
items = lightningActivities,
showFooter = true,
onAllActivityButtonClick = onAllActivityButtonClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import to.bitkit.ext.ellipsisMiddle
import to.bitkit.ext.rawId
import to.bitkit.ext.toActivityItemDate
import to.bitkit.ext.toActivityItemTime
import to.bitkit.ext.totalValue
import to.bitkit.models.Toast
import to.bitkit.ui.Routes
import to.bitkit.ui.appViewModel
Expand All @@ -50,7 +51,6 @@ import to.bitkit.ui.components.TagButton
import to.bitkit.ui.components.Title
import to.bitkit.ui.scaffold.AppTopBar
import to.bitkit.ui.scaffold.CloseNavIcon
import to.bitkit.ui.scaffold.ScreenColumn
import to.bitkit.ui.screens.wallets.activity.components.ActivityAddTagSheet
import to.bitkit.ui.screens.wallets.activity.components.ActivityIcon
import to.bitkit.ui.shared.util.clickableAlpha
Expand Down Expand Up @@ -89,7 +89,9 @@ fun ActivityDetailScreen(
detailViewModel.setActivity(item)
}

ScreenColumn {
Column(
modifier = Modifier.background(Colors.Black)
) {
AppTopBar(
titleText = stringResource(item.getScreenTitleRes()),
onBackClick = onBackClick,
Expand All @@ -111,6 +113,7 @@ fun ActivityDetailScreen(
)
if (showAddTagSheet) {
ActivityAddTagSheet(
listViewModel = listViewModel,
activityViewModel = detailViewModel,
onDismiss = { showAddTagSheet = false },
)
Expand Down Expand Up @@ -142,13 +145,6 @@ private fun ActivityDetailContent(
else -> item.v1.timestamp
}
}
val value = when (item) {
is Activity.Lightning -> item.v1.value
is Activity.Onchain -> when {
isSent -> item.v1.value + item.v1.fee
else -> item.v1.value
}
}
val paymentValue = when (item) {
is Activity.Lightning -> item.v1.value
is Activity.Onchain -> item.v1.value
Expand All @@ -171,7 +167,7 @@ private fun ActivityDetailContent(
.padding(vertical = 16.dp)
) {
BalanceHeaderView(
sats = value.toLong(),
sats = item.totalValue().toLong(),
prefix = amountPrefix,
showBitcoinSymbol = false,
modifier = Modifier.weight(1f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import to.bitkit.R
import to.bitkit.env.Env
import to.bitkit.ext.ellipsisMiddle
import to.bitkit.ext.rawId
import to.bitkit.ext.totalValue
import to.bitkit.models.Toast
import to.bitkit.ui.Routes
import to.bitkit.ui.appViewModel
Expand Down Expand Up @@ -129,17 +130,13 @@ private fun ActivityExploreContent(
.fillMaxWidth()
.padding(vertical = 16.dp)
) {
val value = when (item) {
is Activity.Lightning -> item.v1.value
is Activity.Onchain -> item.v1.value
}
val isSent = when (item) {
is Activity.Lightning -> item.v1.txType == PaymentType.SENT
is Activity.Onchain -> item.v1.txType == PaymentType.SENT
}
val amountPrefix = if (isSent) "-" else "+"
BalanceHeaderView(
sats = value.toLong(),
sats = item.totalValue().toLong(),
prefix = amountPrefix,
showBitcoinSymbol = false,
modifier = Modifier.weight(1f),
Expand Down
Loading