Skip to content

Commit

Permalink
Merge pull request #1198 from radixdlt/fix/ABW-3788-dapp-details-cta
Browse files Browse the repository at this point in the history
[ABW-3788] - Hide buttons on dapp details dialog when opened from tx review
  • Loading branch information
giannis-rdx authored Sep 16, 2024
2 parents c08c0a0 + 155b858 commit 4351a69
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private fun DAppDetailsDialogContent(
validatedWebsite = state.validatedWebsite,
personaList = state.authorizedPersonas,
isShowLockerDepositsChecked = state.isShowLockerDepositsChecked,
isReadOnly = state.isReadOnly,
onFungibleTokenClick = onFungibleClick,
onNonFungibleClick = onNonFungibleClick,
onDeleteDapp = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ import rdx.works.core.domain.resources.Resource

private const val ROUTE = "dApp_details_dialog"
private const val ARG_DAPP_DEFINITION_ADDRESS = "dApp_definition_address"
private const val ARG_READ_ONLY = "read_only"

fun NavController.dAppDetailsDialog(
dAppDefinitionAddress: AccountAddress
dAppDefinitionAddress: AccountAddress,
isReadOnly: Boolean = false
) {
navigate(route = "$ROUTE/${dAppDefinitionAddress.string}")
navigate(route = "$ROUTE/${dAppDefinitionAddress.string}/$isReadOnly")
}

internal class DAppDetailsDialogArgs(
val dAppDefinitionAddress: AccountAddress
val dAppDefinitionAddress: AccountAddress,
val isReadOnly: Boolean
) {
constructor(savedStateHandle: SavedStateHandle) : this(
dAppDefinitionAddress = AccountAddress.init(requireNotNull(savedStateHandle[ARG_DAPP_DEFINITION_ADDRESS]))
dAppDefinitionAddress = AccountAddress.init(requireNotNull(savedStateHandle[ARG_DAPP_DEFINITION_ADDRESS])),
isReadOnly = savedStateHandle[ARG_READ_ONLY] ?: false
)
}

Expand All @@ -36,10 +40,13 @@ fun NavGraphBuilder.dAppDetailsDialog(
onDismiss: () -> Unit
) {
dialog(
route = "$ROUTE/{$ARG_DAPP_DEFINITION_ADDRESS}",
route = "$ROUTE/{$ARG_DAPP_DEFINITION_ADDRESS}/{$ARG_READ_ONLY}",
arguments = listOf(
navArgument(ARG_DAPP_DEFINITION_ADDRESS) {
type = NavType.StringType
},
navArgument(ARG_READ_ONLY) {
type = NavType.BoolType
}
),
dialogProperties = DialogProperties(usePlatformDefaultWidth = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class DAppDetailsDialogViewModel @Inject constructor(
private lateinit var authorizedDapp: AuthorizedDapp

override fun initialState(): State = State(
dAppDefinitionAddress = args.dAppDefinitionAddress
dAppDefinitionAddress = args.dAppDefinitionAddress,
isReadOnly = args.isReadOnly
)

init {
Expand Down Expand Up @@ -112,7 +113,8 @@ class DAppDetailsDialogViewModel @Inject constructor(
val isWebsiteValidating: Boolean = false,
val authorizedPersonas: ImmutableList<Persona> = persistentListOf(),
val uiMessage: UiMessage? = null,
val isShowLockerDepositsChecked: Boolean = false
val isShowLockerDepositsChecked: Boolean = false,
val isReadOnly: Boolean = false
) : UiState

sealed interface Event : OneOffEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ fun NavigationHost(
)
},
onDAppClick = { dApp ->
navController.dAppDetailsDialog(dAppDefinitionAddress = dApp.dAppAddress)
navController.dAppDetailsDialog(
dAppDefinitionAddress = dApp.dAppAddress,
isReadOnly = true
)
},
onInfoClick = { glossaryItem ->
navController.infoDialog(glossaryItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private fun DappDetailContent(
validatedWebsite = state.validatedWebsite,
personaList = state.authorizedPersonas,
isShowLockerDepositsChecked = state.isShowLockerDepositsChecked,
isReadOnly = false,
onPersonaClick = { persona ->
onPersonaClick(persona)
scope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fun DappDetails(
validatedWebsite: String?,
personaList: ImmutableList<Persona>,
isShowLockerDepositsChecked: Boolean,
isReadOnly: Boolean,
onPersonaClick: ((Persona) -> Unit)?,
onFungibleTokenClick: (Resource.FungibleResource) -> Unit,
onNonFungibleClick: (Resource.NonFungibleResource) -> Unit,
Expand Down Expand Up @@ -195,37 +196,39 @@ fun DappDetails(
Spacer(modifier = Modifier.height(spacerHeight))
}
}
item {
Spacer(modifier = Modifier.height(dimensions.paddingLarge))
if (!isReadOnly) {
item {
Spacer(modifier = Modifier.height(dimensions.paddingLarge))

SwitchSettingsItem(
modifier = Modifier
.background(RadixTheme.colors.defaultBackground)
.fillMaxWidth()
.padding(horizontal = dimensions.paddingDefault),
titleRes = R.string.authorizedDapps_dAppDetails_depositsTitle,
subtitleRes = R.string.authorizedDapps_dAppDetails_depositsHidden,
icon = null,
subtitleTextColor = RadixTheme.colors.gray2,
checked = isShowLockerDepositsChecked,
onCheckedChange = onShowLockerDepositsCheckedChange
)
SwitchSettingsItem(
modifier = Modifier
.background(RadixTheme.colors.defaultBackground)
.fillMaxWidth()
.padding(horizontal = dimensions.paddingDefault),
titleRes = R.string.authorizedDapps_dAppDetails_depositsTitle,
subtitleRes = R.string.authorizedDapps_dAppDetails_depositsHidden,
icon = null,
subtitleTextColor = RadixTheme.colors.gray2,
checked = isShowLockerDepositsChecked,
onCheckedChange = onShowLockerDepositsCheckedChange
)

Spacer(modifier = Modifier.height(dimensions.paddingLarge))
Spacer(modifier = Modifier.height(dimensions.paddingLarge))

HorizontalDivider(
color = RadixTheme.colors.gray4,
modifier = Modifier.padding(horizontal = dimensions.paddingDefault)
)
HorizontalDivider(
color = RadixTheme.colors.gray4,
modifier = Modifier.padding(horizontal = dimensions.paddingDefault)
)

Spacer(modifier = Modifier.height(dimensions.paddingLarge))
Spacer(modifier = Modifier.height(dimensions.paddingLarge))

WarningButton(
modifier = Modifier
.padding(horizontal = dimensions.paddingDefault),
text = stringResource(R.string.authorizedDapps_dAppDetails_forgetDapp),
onClick = onDeleteDapp
)
WarningButton(
modifier = Modifier
.padding(horizontal = dimensions.paddingDefault),
text = stringResource(R.string.authorizedDapps_dAppDetails_forgetDapp),
onClick = onDeleteDapp
)
}
}
}
}
Expand Down

0 comments on commit 4351a69

Please sign in to comment.