Skip to content

Commit

Permalink
Pass action for which user needs to buy subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Dec 18, 2024
1 parent b467bef commit ea7a3ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseComposeFragment
import io.horizontalsystems.bankwallet.core.requireInput
import io.horizontalsystems.bankwallet.core.setNavigationResultX
import io.horizontalsystems.bankwallet.core.slideFromRightForResult
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
Expand All @@ -26,7 +26,7 @@ import kotlinx.parcelize.Parcelize
class BuySubscriptionFragment : BaseComposeFragment() {
@Composable
override fun GetContent(navController: NavController) {
BuySubscriptionScreen(navController, requireActivity())
BuySubscriptionScreen(navController, navController.requireInput())
}

@Parcelize
Expand All @@ -37,8 +37,13 @@ class BuySubscriptionFragment : BaseComposeFragment() {
}

@Composable
private fun BuySubscriptionScreen(navController: NavController, activity: FragmentActivity) {
val viewModel = viewModel<BuySubscriptionViewModel>()
private fun BuySubscriptionScreen(
navController: NavController,
input: BuySubscriptionFragment.Input,
) {
val viewModel = viewModel<BuySubscriptionViewModel> {
BuySubscriptionViewModel(input.action)
}

val uiState = viewModel.uiState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package io.horizontalsystems.bankwallet.modules.usersubscription

import androidx.lifecycle.viewModelScope
import io.horizontalsystems.bankwallet.core.ViewModelUiState
import io.horizontalsystems.subscriptions.core.IPaidAction
import io.horizontalsystems.subscriptions.core.Subscription
import io.horizontalsystems.subscriptions.core.UserSubscriptionManager
import kotlinx.coroutines.launch

class BuySubscriptionViewModel : ViewModelUiState<BuySubscriptionUiState>() {
class BuySubscriptionViewModel(action: IPaidAction) : ViewModelUiState<BuySubscriptionUiState>() {
private var subscriptions = listOf<Subscription>()

init {
Expand Down

0 comments on commit ea7a3ac

Please sign in to comment.