Skip to content

Commit

Permalink
Merge pull request #694 from radixdlt/feature/debug-mode-profile
Browse files Browse the repository at this point in the history
Inspect raw profile in debug mode
  • Loading branch information
micbakos-rdx authored Dec 8, 2023
2 parents ed74045 + cc032e0 commit 412919d
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sealed interface SettingsItem {
data class Personas(val showBackupSecurityPrompt: Boolean = false) : TopLevelSettings
data class AccountSecurityAndSettings(val showNotificationWarning: Boolean) : TopLevelSettings
data object AppSettings : TopLevelSettings
data object DebugSettings : TopLevelSettings

@StringRes
fun descriptionRes(): Int {
Expand All @@ -25,6 +26,7 @@ sealed interface SettingsItem {
is Personas -> R.string.settings_personas
is AccountSecurityAndSettings -> R.string.settings_accountSecurityAndSettings
is AppSettings -> R.string.settings_appSettings
is DebugSettings -> R.string.settings_debugSettings
}
}

Expand All @@ -35,6 +37,7 @@ sealed interface SettingsItem {
is Personas -> DSR.ic_personas
is AccountSecurityAndSettings -> DSR.ic_security
is AppSettings -> DSR.ic_app_settings
is DebugSettings -> DSR.ic_app_settings
else -> null
}
}
Expand Down Expand Up @@ -96,4 +99,28 @@ sealed interface SettingsItem {
}
}
}

sealed interface DebugSettingsItem {
data object InspectProfile : DebugSettingsItem

@StringRes
fun descriptionRes(): Int {
return when (this) {
InspectProfile -> R.string.settings_debugSettings_inspectProfile
}
}

@DrawableRes
fun getIcon(): Int? { // add rest of icons
return when (this) {
InspectProfile -> com.babylon.wallet.android.designsystem.R.drawable.ic_personas
}
}

companion object {
fun values() = setOf(
InspectProfile
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.babylon.wallet.android.BuildConfig
import com.babylon.wallet.android.presentation.navigation.Screen
import com.babylon.wallet.android.presentation.settings.accountsecurity.accountSecurityNavGraph
import com.babylon.wallet.android.presentation.settings.accountsecurity.accountSecurityScreen
Expand All @@ -14,6 +15,7 @@ import com.babylon.wallet.android.presentation.settings.appsettings.appSettingsS
import com.babylon.wallet.android.presentation.settings.appsettings.linkedconnectors.linkedConnectorsScreen
import com.babylon.wallet.android.presentation.settings.authorizeddapps.authorizedDAppsScreen
import com.babylon.wallet.android.presentation.settings.authorizeddapps.dappdetail.dAppDetailScreen
import com.babylon.wallet.android.presentation.settings.debug.debugSettings
import com.babylon.wallet.android.presentation.settings.personas.createpersona.personasScreen
import com.babylon.wallet.android.presentation.settings.personas.personaedit.personaEditScreen
import com.babylon.wallet.android.presentation.status.assets.fungible.fungibleAssetDialog
Expand Down Expand Up @@ -52,6 +54,9 @@ fun NavGraphBuilder.settingsNavGraph(
)
accountSecurityNavGraph(navController)
appSettingsNavGraph(navController)
if (BuildConfig.EXPERIMENTAL_FEATURES_ENABLED) {
debugSettings(navController)
}
}
}

Expand Down Expand Up @@ -89,6 +94,10 @@ private fun NavGraphBuilder.settingsAll(navController: NavController) {
is SettingsItem.TopLevelSettings.AppSettings -> {
navController.appSettingsScreen()
}

is SettingsItem.TopLevelSettings.DebugSettings -> {
navController.debugSettings()
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.babylon.wallet.android.domain.usecases.settings.MarkImportOlympiaWall
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.AccountSecurityAndSettings
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.AppSettings
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.AuthorizedDapps
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.DebugSettings
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.ImportOlympiaWallet
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.LinkToConnector
import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.Personas
Expand Down Expand Up @@ -43,8 +44,9 @@ class SettingsViewModel @Inject constructor(
AuthorizedDapps,
Personas(),
AccountSecurityAndSettings(showNotificationWarning = false),
AppSettings
)
AppSettings,
if (EXPERIMENTAL_FEATURES_ENABLED) DebugSettings else null
).mapNotNull { it }

val state: StateFlow<SettingsUiState> = combine(
getProfileUseCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private fun AppSettingsContent(
// color = RadixTheme.colors.gray2
// )
// }
appSettings.forEachIndexed { index, appSettingsItem ->
appSettings.forEach { appSettingsItem ->
item {
when (appSettingsItem) {
is SettingsItem.AppSettingsItem.DeveloperMode -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.babylon.wallet.android.presentation.settings.debug

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.EnterTransition
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.babylon.wallet.android.presentation.settings.SettingsItem.DebugSettingsItem.InspectProfile
import com.babylon.wallet.android.presentation.settings.debug.profile.inspectProfile

const val ROUTE_DEBUG_SETTINGS_SCREEN = "settings_debug_settings_screen"
const val ROUTE_DEBUG_SETTINGS_GRAPH = "settings_debug_settings_graph"

fun NavController.debugSettings() {
navigate(ROUTE_DEBUG_SETTINGS_SCREEN) {
launchSingleTop = true
}
}

fun NavGraphBuilder.debugSettings(
navController: NavController
) {
navigation(
startDestination = ROUTE_DEBUG_SETTINGS_SCREEN,
route = ROUTE_DEBUG_SETTINGS_GRAPH
) {
composable(
route = ROUTE_DEBUG_SETTINGS_SCREEN,
enterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
exitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
},
popExitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
},
popEnterTransition = {
EnterTransition.None
}
) {
DebugSettingsScreen(
onBackClick = {
navController.popBackStack()
},
onItemClick = { item ->
when (item) {
InspectProfile -> navController.inspectProfile()
}
}
)
}
inspectProfile(
onBackClick = {
navController.popBackStack()
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.babylon.wallet.android.presentation.settings.debug

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.babylon.wallet.android.R
import com.babylon.wallet.android.designsystem.theme.RadixTheme
import com.babylon.wallet.android.presentation.settings.SettingsItem
import com.babylon.wallet.android.presentation.ui.composables.DefaultSettingsItem
import com.babylon.wallet.android.presentation.ui.composables.RadixCenteredTopAppBar

@Composable
fun DebugSettingsScreen(
modifier: Modifier = Modifier,
onBackClick: () -> Unit,
onItemClick: (SettingsItem.DebugSettingsItem) -> Unit
) {
Scaffold(
modifier = modifier,
topBar = {
RadixCenteredTopAppBar(
title = stringResource(R.string.settings_debugSettings),
onBackClick = onBackClick,
windowInsets = WindowInsets.statusBars
)
},
containerColor = RadixTheme.colors.defaultBackground
) { padding ->
Column(
modifier = Modifier.padding(padding),
horizontalAlignment = Alignment.Start
) {
HorizontalDivider(color = RadixTheme.colors.gray5)
LazyColumn(modifier = Modifier.fillMaxSize()) {
SettingsItem.DebugSettingsItem.values().forEachIndexed { index, appSettingsItem ->
item {
DefaultSettingsItem(
title = stringResource(id = appSettingsItem.descriptionRes()),
icon = appSettingsItem.getIcon(),
onClick = {
onItemClick(appSettingsItem)
}
)
HorizontalDivider(color = RadixTheme.colors.gray5)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.babylon.wallet.android.presentation.settings.debug.profile

import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable

private const val ROUTE = "inspect_profile"

fun NavController.inspectProfile() {
navigate(route = ROUTE)
}

fun NavGraphBuilder.inspectProfile(
onBackClick: () -> Unit
) {
composable(
route = ROUTE,
enterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
exitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
}
) {
InspectProfileScreen(
viewModel = hiltViewModel(),
onBackClick = onBackClick
)
}
}
Loading

0 comments on commit 412919d

Please sign in to comment.