Skip to content

Commit

Permalink
Merge pull request #778 from radixdlt/bugfix/ABW-2897-dashboard-links
Browse files Browse the repository at this point in the history
Dashboard link bugs
  • Loading branch information
micbakos-rdx authored Jan 31, 2024
2 parents c44540b + 0e2740a commit 5121f27
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import rdx.works.profile.derivation.model.NetworkId

data class ActionableAddress(
val address: String,
val truncateAddress: Boolean = true
val truncateAddress: Boolean = true,
val isVisitableInDashboard: Boolean = true
) {

val type: Type? = Type.from(address)
Expand All @@ -25,6 +26,8 @@ data class ActionableAddress(
}

fun toDashboardUrl(networkId: NetworkId): String? {
if (!isVisitableInDashboard) return null

val addressUrlEncoded = address.encodeUtf8()
val suffix = when (type) {
is Type.LocalId -> return null
Expand Down Expand Up @@ -53,7 +56,8 @@ data class ActionableAddress(
ACCOUNT(HRP.ACCOUNT),
VALIDATOR(HRP.VALIDATOR),
TRANSACTION(HRP.TRANSACTION),
COMPONENT(HRP.COMPONENT);
COMPONENT(HRP.COMPONENT),
POOL(HRP.POOL);

companion object {
private object HRP {
Expand All @@ -62,6 +66,7 @@ data class ActionableAddress(
const val PACKAGE = "package"
const val VALIDATOR = "validator"
const val COMPONENT = "component"
const val POOL = "pool"
const val TRANSACTION = "txid"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ fun FungibleDialogContent(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = RadixTheme.dimensions.paddingSmall),
address = resourceAddress
address = resourceAddress,
isNewlyCreatedEntity = isNewlyCreated
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ fun NonFungibleAssetDialogContent(
ActionableAddressView(
modifier = Modifier.padding(start = RadixTheme.dimensions.paddingDefault),
address = item.globalAddress,
visitableInDashboard = !isNewlyCreated,
textStyle = RadixTheme.typography.body1HighImportance,
textColor = RadixTheme.colors.gray1
)
Expand Down Expand Up @@ -208,7 +209,8 @@ fun NonFungibleAssetDialogContent(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = RadixTheme.dimensions.paddingXLarge),
address = resourceAddress
address = resourceAddress,
isNewlyCreatedEntity = isNewlyCreated
)
if (!asset?.resource?.name.isNullOrBlank() && localId != null) {
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,18 @@ fun ActionableAddressView(
address: String,
modifier: Modifier = Modifier,
truncateAddress: Boolean = true,
visitableInDashboard: Boolean = true,
textStyle: TextStyle = LocalTextStyle.current,
textColor: Color = Color.Unspecified,
iconColor: Color = textColor
) {
val actionableAddress = resolveAddress(address = address, truncateAddress = truncateAddress)
val actionableAddress = remember(address, truncateAddress, visitableInDashboard) {
ActionableAddress(
address = address,
truncateAddress = truncateAddress,
isVisitableInDashboard = visitableInDashboard
)
}
val context = LocalContext.current
val scope = rememberCoroutineScope()

Expand Down Expand Up @@ -303,12 +310,6 @@ fun ActionableAddressView(
}
}

@Composable
private fun resolveAddress(
address: String,
truncateAddress: Boolean
): ActionableAddress = remember(address) { ActionableAddress(address, truncateAddress) }

private data class PopupActions(
val primary: PopupActionItem,
val secondary: List<PopupActionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import com.babylon.wallet.android.presentation.ui.composables.ActionableAddressV
fun AddressRow(
modifier: Modifier = Modifier,
label: String = stringResource(id = R.string.assetDetails_resourceAddress),
address: String
address: String,
isNewlyCreatedEntity: Boolean = false
) {
Row(
modifier,
Expand All @@ -30,6 +31,7 @@ fun AddressRow(

ActionableAddressView(
address = address,
visitableInDashboard = !isNewlyCreatedEntity,
textStyle = RadixTheme.typography.body1HighImportance,
textColor = RadixTheme.colors.gray1,
iconColor = RadixTheme.colors.gray2
Expand Down

0 comments on commit 5121f27

Please sign in to comment.