Skip to content

Commit

Permalink
Close until main balance screen on Done button click
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Sep 4, 2023
1 parent 157e1bb commit f8df38e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.core.slideFromRight
import io.horizontalsystems.bankwallet.entities.Wallet
import io.horizontalsystems.bankwallet.modules.receive.address.ReceiveAddressFragment
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
Expand All @@ -35,6 +35,7 @@ fun AddressFormatSelectScreen(
navController: NavController,
addressFormatItems: List<AddressFormatItem>,
description: String,
popupDestinationId: Int?,
) {
ComposeAppTheme {
Scaffold(
Expand Down Expand Up @@ -64,9 +65,12 @@ fun AddressFormatSelectScreen(
title = item.title,
subtitle = item.subtitle,
onClick = {
navController.slideFromBottom(
navController.slideFromRight(
R.id.receiveFragment,
bundleOf(ReceiveAddressFragment.WALLET_KEY to item.wallet)
bundleOf(
ReceiveAddressFragment.WALLET_KEY to item.wallet,
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY to popupDestinationId,
)
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.core.os.bundleOf
import androidx.lifecycle.viewmodel.compose.viewModel
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseFragment
import io.horizontalsystems.bankwallet.modules.receive.address.ReceiveAddressFragment
import io.horizontalsystems.core.findNavController
import io.horizontalsystems.core.helpers.HudHelper

Expand All @@ -30,6 +31,9 @@ class BchAddressTypeSelectFragment : BaseFragment() {
setContent {
val navController = findNavController()
val coinUid = arguments?.getString("coinUid")
val popupDestinationId = arguments?.getInt(
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY
)

if (coinUid == null) {
HudHelper.showErrorMessage(LocalView.current, R.string.Error_ParameterNotSet)
Expand All @@ -41,14 +45,20 @@ class BchAddressTypeSelectFragment : BaseFragment() {
AddressFormatSelectScreen(
navController,
viewModel.items,
stringResource(R.string.Balance_Receive_AddressFormat_RecommendedAddressType)
stringResource(R.string.Balance_Receive_AddressFormat_RecommendedAddressType),
popupDestinationId
)
}
}
}
}

companion object {
fun prepareParams(coinUid: String) = bundleOf("coinUid" to coinUid)
fun prepareParams(coinUid: String, popupDestinationId: Int?): Bundle {
return bundleOf(
"coinUid" to coinUid,
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY to popupDestinationId
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.core.os.bundleOf
import androidx.lifecycle.viewmodel.compose.viewModel
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseFragment
import io.horizontalsystems.bankwallet.modules.receive.address.ReceiveAddressFragment
import io.horizontalsystems.core.findNavController
import io.horizontalsystems.core.helpers.HudHelper

Expand All @@ -30,6 +31,9 @@ class DerivationSelectFragment : BaseFragment() {
setContent {
val navController = findNavController()
val coinUid = arguments?.getString("coinUid")
val popupDestinationId = arguments?.getInt(
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY
)

if (coinUid == null) {
HudHelper.showErrorMessage(LocalView.current, R.string.Error_ParameterNotSet)
Expand All @@ -41,14 +45,20 @@ class DerivationSelectFragment : BaseFragment() {
AddressFormatSelectScreen(
navController,
viewModel.items,
stringResource(R.string.Balance_Receive_AddressFormat_RecommendedDerivation)
stringResource(R.string.Balance_Receive_AddressFormat_RecommendedDerivation),
popupDestinationId
)
}
}
}
}

companion object {
fun prepareParams(coinUid: String) = bundleOf("coinUid" to coinUid)
fun prepareParams(coinUid: String, popupDestinationId: Int?): Bundle {
return bundleOf(
"coinUid" to coinUid,
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY to popupDestinationId
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseFragment
import io.horizontalsystems.bankwallet.core.description
import io.horizontalsystems.bankwallet.core.imageUrl
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.core.slideFromRight
import io.horizontalsystems.bankwallet.modules.receive.address.ReceiveAddressFragment
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.TranslatableString
Expand Down Expand Up @@ -59,27 +59,36 @@ class NetworkSelectFragment : BaseFragment() {
setContent {
val navController = findNavController()
val coinUid = arguments?.getString("coinUid")
val popupDestinationId = arguments?.getInt(
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY
)

if (coinUid == null) {
HudHelper.showErrorMessage(LocalView.current, R.string.Error_ParameterNotSet)
navController.popBackStack()
} else {
NetworkSelectScreen(navController, coinUid)
NetworkSelectScreen(navController, coinUid, popupDestinationId)
}

}
}
}

companion object {
fun prepareParams(coinUid: String) = bundleOf("coinUid" to coinUid)
fun prepareParams(coinUid: String, popupDestinationId: Int?): Bundle {
return bundleOf(
"coinUid" to coinUid,
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY to popupDestinationId
)
}
}
}

@Composable
fun NetworkSelectScreen(
navController: NavController,
coinUid: String,
popupDestinationId: Int?,
) {
val viewModel = viewModel<NetworkSelectViewModel>(factory = NetworkSelectViewModel.Factory(coinUid))

Expand Down Expand Up @@ -114,9 +123,12 @@ fun NetworkSelectScreen(
subtitle = blockchain.description,
imageUrl = blockchain.type.imageUrl,
onClick = {
navController.slideFromBottom(
navController.slideFromRight(
R.id.receiveFragment,
bundleOf(ReceiveAddressFragment.WALLET_KEY to wallet)
bundleOf(
ReceiveAddressFragment.WALLET_KEY to wallet,
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY to popupDestinationId,
)
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseFragment
import io.horizontalsystems.bankwallet.core.imagePlaceholder
import io.horizontalsystems.bankwallet.core.imageUrl
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.core.slideFromRight
import io.horizontalsystems.bankwallet.modules.receive.address.ReceiveAddressFragment
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
Expand Down Expand Up @@ -96,29 +95,34 @@ fun ReceiveTokenSelectScreen(navController: NavController) {
coinIconUrl = coin.imageUrl,
coinIconPlaceholder = coin.imagePlaceholder,
onClick = {
val popupDestinationId = navController.currentDestination?.id

when (val coinActiveWalletsType = viewModel.getCoinActiveWalletsType(coin)) {
CoinActiveWalletsType.MultipleAddressTypes -> {
navController.slideFromRight(
R.id.receiveBchAddressTypeSelectFragment,
BchAddressTypeSelectFragment.prepareParams(coin.uid)
BchAddressTypeSelectFragment.prepareParams(coin.uid, popupDestinationId)
)
}
CoinActiveWalletsType.MultipleDerivations -> {
navController.slideFromRight(
R.id.receiveDerivationSelectFragment,
DerivationSelectFragment.prepareParams(coin.uid)
DerivationSelectFragment.prepareParams(coin.uid, popupDestinationId)
)
}
CoinActiveWalletsType.MultipleBlockchains -> {
navController.slideFromRight(
R.id.receiveNetworkSelectFragment,
NetworkSelectFragment.prepareParams(coin.uid)
NetworkSelectFragment.prepareParams(coin.uid, popupDestinationId)
)
}
is CoinActiveWalletsType.Single -> {
navController.slideFromBottom(
navController.slideFromRight(
R.id.receiveFragment,
bundleOf(ReceiveAddressFragment.WALLET_KEY to coinActiveWalletsType.wallet)
bundleOf(
ReceiveAddressFragment.WALLET_KEY to coinActiveWalletsType.wallet,
ReceiveAddressFragment.POPUP_DESTINATION_ID_KEY to popupDestinationId,
)
)
}

Expand Down

0 comments on commit f8df38e

Please sign in to comment.