Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow click on fungibles & NFTs from dApp details sheets #765

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ fun NavigationHost(
}
)
dAppDetailsDialog(
onFungibleClick = {
navController.fungibleAssetDialog(resourceAddress = it.resourceAddress)
},
onNonFungibleClick = {
navController.nonFungibleAssetDialog(resourceAddress = it.resourceAddress)
},
onDismiss = {
navController.popBackStack()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.babylon.wallet.android.R
import com.babylon.wallet.android.designsystem.theme.RadixTheme
import com.babylon.wallet.android.domain.model.resources.Resource
import com.babylon.wallet.android.presentation.settings.authorizeddapps.dappdetail.DAppWebsiteAddressRow
import com.babylon.wallet.android.presentation.settings.authorizeddapps.dappdetail.DappDefinitionAddressRow
import com.babylon.wallet.android.presentation.ui.composables.BottomSheetDialogWrapper
Expand All @@ -39,12 +40,16 @@ import com.babylon.wallet.android.presentation.ui.modifier.radixPlaceholder
@Composable
fun DAppDetailsDialog(
viewModel: DAppDetailsDialogViewModel,
onFungibleClick: (Resource.FungibleResource) -> Unit,
onNonFungibleClick: (Resource.NonFungibleResource) -> Unit,
onDismiss: () -> Unit
) {
val state by viewModel.state.collectAsState()
DAppDetailsDialogContent(
state = state,
onMessageShown = viewModel::onMessageShown,
onFungibleClick = onFungibleClick,
onNonFungibleClick = onNonFungibleClick,
onDismiss = onDismiss
)
}
Expand All @@ -53,6 +58,8 @@ fun DAppDetailsDialog(
private fun DAppDetailsDialogContent(
modifier: Modifier = Modifier,
state: DAppDetailsDialogViewModel.State,
onFungibleClick: (Resource.FungibleResource) -> Unit,
onNonFungibleClick: (Resource.NonFungibleResource) -> Unit,
onMessageShown: () -> Unit,
onDismiss: () -> Unit
) {
Expand Down Expand Up @@ -142,7 +149,8 @@ private fun DAppDetailsDialogContent(
GrayBackgroundWrapper {
FungibleCard(
fungible = resource,
showChevron = false
showChevron = false,
onClick = { onFungibleClick(resource) }
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
}
Expand All @@ -154,7 +162,7 @@ private fun DAppDetailsDialogContent(
modifier = Modifier
.fillMaxWidth()
.padding(RadixTheme.dimensions.paddingDefault),
text = stringResource(id = R.string.authorizedDapps_dAppDetails_tokens),
text = stringResource(id = R.string.authorizedDapps_dAppDetails_nfts),
style = RadixTheme.typography.body1Regular,
color = RadixTheme.colors.gray2,
textAlign = TextAlign.Start
Expand All @@ -165,7 +173,8 @@ private fun DAppDetailsDialogContent(
GrayBackgroundWrapper {
NonFungibleCard(
nonFungible = resource,
showChevron = false
showChevron = false,
onClick = { onNonFungibleClick(resource) }
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.dialog
import androidx.navigation.navArgument
import com.babylon.wallet.android.domain.model.resources.Resource

private const val ROUTE = "dApp_details_dialog"
private const val ARG_DAPP_DEFINITION_ADDRESS = "dApp_definition_address"
Expand All @@ -28,6 +29,8 @@ internal class DAppDetailsDialogArgs(
}

fun NavGraphBuilder.dAppDetailsDialog(
onFungibleClick: (Resource.FungibleResource) -> Unit,
onNonFungibleClick: (Resource.NonFungibleResource) -> Unit,
onDismiss: () -> Unit
) {
dialog(
Expand All @@ -41,6 +44,8 @@ fun NavGraphBuilder.dAppDetailsDialog(
) {
DAppDetailsDialog(
viewModel = hiltViewModel(),
onFungibleClick = onFungibleClick,
onNonFungibleClick = onNonFungibleClick,
onDismiss = onDismiss
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.babylon.wallet.android.presentation.ui.composables.card

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -28,14 +29,18 @@ fun FungibleCard(
fungible: Resource.FungibleResource,
modifier: Modifier = Modifier,
showChevron: Boolean = true,
elevation: Dp = 8.dp
elevation: Dp = 8.dp,
onClick: (() -> Unit)? = null
) {
Row(
modifier = modifier
.shadow(elevation = elevation, shape = RadixTheme.shapes.roundedRectMedium)
.clip(RadixTheme.shapes.roundedRectMedium)
.fillMaxWidth()
.background(RadixTheme.colors.white, shape = RadixTheme.shapes.roundedRectMedium)
.clickable(enabled = onClick != null) {
onClick?.invoke()
}
.padding(
horizontal = RadixTheme.dimensions.paddingLarge,
vertical = RadixTheme.dimensions.paddingDefault
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.babylon.wallet.android.presentation.ui.composables.card

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -28,14 +29,18 @@ fun NonFungibleCard(
nonFungible: Resource.NonFungibleResource,
modifier: Modifier = Modifier,
showChevron: Boolean = true,
elevation: Dp = 8.dp
elevation: Dp = 8.dp,
onClick: (() -> Unit)? = null,
) {
Row(
modifier = modifier
.shadow(elevation = elevation, shape = RadixTheme.shapes.roundedRectMedium)
.clip(RadixTheme.shapes.roundedRectMedium)
.fillMaxWidth()
.background(RadixTheme.colors.white, shape = RadixTheme.shapes.roundedRectMedium)
.clickable(enabled = onClick != null) {
onClick?.invoke()
}
.padding(
horizontal = RadixTheme.dimensions.paddingLarge,
vertical = RadixTheme.dimensions.paddingDefault
Expand Down