Skip to content

Commit bd4295c

Browse files
committed
fix: move AllActivities to top navigation graph
1 parent 265ed4e commit bd4295c

File tree

5 files changed

+78
-26
lines changed

5 files changed

+78
-26
lines changed

app/src/main/java/to/bitkit/ui/ContentView.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import to.bitkit.ui.screens.transfer.external.LnurlChannelScreen
8888
import to.bitkit.ui.screens.wallets.HomeNav
8989
import to.bitkit.ui.screens.wallets.activity.ActivityDetailScreen
9090
import to.bitkit.ui.screens.wallets.activity.ActivityExploreScreen
91+
import to.bitkit.ui.screens.wallets.activity.AllActivityScreenWithTabBar
9192
import to.bitkit.ui.screens.wallets.activity.DateRangeSelectorSheet
9293
import to.bitkit.ui.screens.wallets.activity.TagSelectorSheet
9394
import to.bitkit.ui.screens.wallets.receive.ReceiveSheet
@@ -490,6 +491,11 @@ private fun RootNavHost(
490491
walletNavController = walletNavHostController,
491492
drawerState = drawerState
492493
)
494+
allActivity(
495+
activityListViewModel = activityListViewModel,
496+
appViewModel = appViewModel,
497+
navController = navController,
498+
)
493499
settings(navController, settingsViewModel)
494500
profile(navController, settingsViewModel)
495501
shop(navController, settingsViewModel, appViewModel)
@@ -759,6 +765,25 @@ private fun NavGraphBuilder.home(
759765
}
760766
}
761767

768+
private fun NavGraphBuilder.allActivity(
769+
activityListViewModel: ActivityListViewModel,
770+
appViewModel: AppViewModel,
771+
navController: NavHostController,
772+
) {
773+
composableWithDefaultTransitions<Routes.AllActivity> {
774+
AllActivityScreenWithTabBar(
775+
viewModel = activityListViewModel,
776+
appViewModel = appViewModel,
777+
onBack = {
778+
activityListViewModel.clearFilters()
779+
navController.navigateToHome()
780+
},
781+
onScanClick = { navController.navigateToScanner() },
782+
onActivityItemClick = { id -> navController.navigateToActivityItem(id) },
783+
)
784+
}
785+
}
786+
762787
private fun NavGraphBuilder.settings(
763788
navController: NavHostController,
764789
settingsViewModel: SettingsViewModel,
@@ -1385,6 +1410,12 @@ fun NavController.navigateToHome() {
13851410
}
13861411
}
13871412

1413+
fun NavController.navigateToAllActivity() {
1414+
navigate(Routes.AllActivity) {
1415+
launchSingleTop = true
1416+
}
1417+
}
1418+
13881419
/**
13891420
* Navigates to the specified route only if not already on that route.
13901421
*/
@@ -1845,4 +1876,7 @@ sealed interface Routes {
18451876

18461877
@Serializable
18471878
data object BackgroundPaymentsSettings : Routes
1879+
1880+
@Serializable
1881+
data object AllActivity : Routes
18481882
}

app/src/main/java/to/bitkit/ui/components/DrawerMenu.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ import kotlinx.coroutines.launch
4545
import to.bitkit.R
4646
import to.bitkit.ui.Routes
4747
import to.bitkit.ui.navigateIfNotCurrent
48+
import to.bitkit.ui.navigateToAllActivity
4849
import to.bitkit.ui.navigateToHome
49-
import to.bitkit.ui.screens.wallets.HomeRoutes
5050
import to.bitkit.ui.shared.util.blockPointerInputPassthrough
5151
import to.bitkit.ui.shared.util.clickableAlpha
5252
import to.bitkit.ui.theme.AppThemeSurface
@@ -156,11 +156,7 @@ private fun Menu(
156156
label = stringResource(R.string.wallet__drawer__activity),
157157
iconRes = R.drawable.ic_heartbeat,
158158
onClick = {
159-
if (walletNavController != null) {
160-
walletNavController.navigateIfNotCurrent(HomeRoutes.AllActivity)
161-
} else {
162-
rootNavController.navigateIfNotCurrent(Routes.Home)
163-
}
159+
rootNavController.navigateIfNotCurrent(Routes.AllActivity)
164160
scope.launch { drawerState.close() }
165161
},
166162
modifier = Modifier.testTag("DrawerActivity")

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import kotlinx.serialization.Serializable
2121
import to.bitkit.ui.components.Sheet
2222
import to.bitkit.ui.components.TabBar
2323
import to.bitkit.ui.navigateToActivityItem
24+
import to.bitkit.ui.navigateToAllActivity
2425
import to.bitkit.ui.navigateToScanner
2526
import to.bitkit.ui.navigateToTransferSavingsAvailability
2627
import to.bitkit.ui.navigateToTransferSavingsIntro
2728
import to.bitkit.ui.navigateToTransferSpendingAmount
2829
import to.bitkit.ui.navigateToTransferSpendingIntro
29-
import to.bitkit.ui.screens.wallets.activity.AllActivityScreen
3030
import to.bitkit.ui.utils.RequestNotificationPermissions
3131
import to.bitkit.ui.utils.Transitions
3232
import to.bitkit.viewmodels.ActivityListViewModel
@@ -122,7 +122,7 @@ private fun NavContent(
122122
SavingsWalletScreen(
123123
isGeoBlocked = isGeoBlocked,
124124
onchainActivities = onchainActivities.orEmpty(),
125-
onAllActivityButtonClick = { walletNavController.navigate(HomeRoutes.AllActivity) },
125+
onAllActivityButtonClick = { rootNavController.navigateToAllActivity() },
126126
onActivityItemClick = { rootNavController.navigateToActivityItem(it) },
127127
onEmptyActivityRowClick = { appViewModel.showSheet(Sheet.Receive) },
128128
onTransferToSpendingClick = {
@@ -144,7 +144,7 @@ private fun NavContent(
144144
SpendingWalletScreen(
145145
uiState = mainUiState,
146146
lightningActivities = lightningActivities.orEmpty(),
147-
onAllActivityButtonClick = { walletNavController.navigate(HomeRoutes.AllActivity) },
147+
onAllActivityButtonClick = { rootNavController.navigateToAllActivity() },
148148
onActivityItemClick = { rootNavController.navigateToActivityItem(it) },
149149
onEmptyActivityRowClick = { appViewModel.showSheet(Sheet.Receive) },
150150
onTransferToSavingsClick = {
@@ -157,19 +157,6 @@ private fun NavContent(
157157
onBackClick = { walletNavController.popBackStack() },
158158
)
159159
}
160-
composable<HomeRoutes.AllActivity>(
161-
enterTransition = { Transitions.slideInHorizontally },
162-
exitTransition = { Transitions.slideOutHorizontally },
163-
) {
164-
AllActivityScreen(
165-
viewModel = activityListViewModel,
166-
onBack = {
167-
activityListViewModel.clearFilters()
168-
walletNavController.popBackStack()
169-
},
170-
onActivityItemClick = { rootNavController.navigateToActivityItem(it) },
171-
)
172-
}
173160
}
174161
}
175162

@@ -182,7 +169,4 @@ object HomeRoutes {
182169

183170
@Serializable
184171
data object Spending
185-
186-
@Serializable
187-
data object AllActivity
188172
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import to.bitkit.ui.components.VerticalSpacer
9090
import to.bitkit.ui.components.WalletBalanceView
9191
import to.bitkit.ui.currencyViewModel
9292
import to.bitkit.ui.navigateToActivityItem
93+
import to.bitkit.ui.navigateToAllActivity
9394
import to.bitkit.ui.navigateToTransferFunding
9495
import to.bitkit.ui.navigateToTransferIntro
9596
import to.bitkit.ui.scaffold.AppAlertDialog
@@ -482,7 +483,7 @@ private fun Content(
482483
Spacer(modifier = Modifier.height(16.dp))
483484
ActivityListSimple(
484485
items = latestActivities,
485-
onAllActivityClick = { walletNavController.navigate(HomeRoutes.AllActivity) },
486+
onAllActivityClick = { rootNavController.navigateToAllActivity() },
486487
onActivityItemClick = { rootNavController.navigateToActivityItem(it) },
487488
onEmptyActivityRowClick = onClickEmptyActivityRow,
488489
)

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ import androidx.compose.ui.tooling.preview.Preview
2323
import androidx.compose.ui.unit.dp
2424
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2525
import com.synonym.bitkitcore.Activity
26+
import dev.chrisbanes.haze.hazeSource
2627
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
28+
import dev.chrisbanes.haze.rememberHazeState
2729
import to.bitkit.R
2830
import to.bitkit.ui.appViewModel
2931
import to.bitkit.ui.components.Sheet
32+
import to.bitkit.ui.components.TabBar
3033
import to.bitkit.ui.scaffold.AppTopBar
3134
import to.bitkit.ui.scaffold.DrawerNavIcon
3235
import to.bitkit.ui.screens.wallets.activity.components.ActivityListFilter
@@ -36,6 +39,7 @@ import to.bitkit.ui.screens.wallets.activity.utils.previewActivityItems
3639
import to.bitkit.ui.shared.util.screen
3740
import to.bitkit.ui.theme.AppThemeSurface
3841
import to.bitkit.viewmodels.ActivityListViewModel
42+
import to.bitkit.viewmodels.AppViewModel
3943

4044
@OptIn(ExperimentalMaterial3Api::class)
4145
@Composable
@@ -76,6 +80,39 @@ fun AllActivityScreen(
7680
)
7781
}
7882

83+
@OptIn(ExperimentalMaterial3Api::class, ExperimentalHazeMaterialsApi::class)
84+
@Composable
85+
fun AllActivityScreenWithTabBar(
86+
viewModel: ActivityListViewModel,
87+
appViewModel: AppViewModel,
88+
onBack: () -> Unit,
89+
onScanClick: () -> Unit,
90+
onActivityItemClick: (String) -> Unit,
91+
) {
92+
val hazeState = rememberHazeState()
93+
94+
Box(modifier = Modifier.fillMaxSize()) {
95+
Box(
96+
modifier = Modifier
97+
.fillMaxSize()
98+
.hazeSource(hazeState)
99+
) {
100+
AllActivityScreen(
101+
viewModel = viewModel,
102+
onBack = onBack,
103+
onActivityItemClick = onActivityItemClick,
104+
)
105+
}
106+
107+
TabBar(
108+
hazeState = hazeState,
109+
onSendClick = { appViewModel.showSheet(Sheet.Send()) },
110+
onReceiveClick = { appViewModel.showSheet(Sheet.Receive) },
111+
onScanClick = onScanClick,
112+
)
113+
}
114+
}
115+
79116
@Composable
80117
@OptIn(ExperimentalHazeMaterialsApi::class)
81118
private fun AllActivityScreenContent(

0 commit comments

Comments
 (0)