Skip to content

Commit

Permalink
Merge pull request #1095 from novasamatech/setup-staking-type-flow-base
Browse files Browse the repository at this point in the history
Setup staking type flow base
  • Loading branch information
antonijzelinskij authored Sep 11, 2023
2 parents 1191e1c + d0fca7d commit 11f47a3
Show file tree
Hide file tree
Showing 168 changed files with 3,651 additions and 755 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.lifecycle.asFlow
import androidx.navigation.NavController
import androidx.navigation.NavOptions
import io.novafoundation.nova.app.R
import io.novafoundation.nova.app.root.navigation.delayedNavigation.BackDelayedNavigation
import io.novafoundation.nova.app.root.navigation.delayedNavigation.NavComponentDelayedNavigation
import io.novafoundation.nova.app.root.presentation.RootRouter
import io.novafoundation.nova.common.navigation.DelayedNavigation
import io.novafoundation.nova.common.utils.getParcelableCompat
Expand Down Expand Up @@ -70,15 +72,8 @@ import io.novafoundation.nova.feature_onboarding_impl.presentation.welcome.Welco
import io.novafoundation.nova.feature_wallet_connect_impl.WalletConnectRouter
import io.novafoundation.nova.feature_wallet_connect_impl.presentation.sessions.list.WalletConnectSessionsPayload
import io.novafoundation.nova.splash.SplashRouter
import kotlinx.android.parcel.Parcelize
import kotlinx.coroutines.flow.Flow

@Parcelize
class NavComponentDelayedNavigation(val globalActionId: Int, val extras: Bundle? = null) : DelayedNavigation

@Parcelize
object BackDelayedNavigation : DelayedNavigation

class Navigator(
private val navigationHolder: NavigationHolder,
private val walletConnectDelegate: WalletConnectRouter,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.novafoundation.nova.app.root.navigation.delayedNavigation

import io.novafoundation.nova.common.navigation.DelayedNavigation
import kotlinx.android.parcel.Parcelize

@Parcelize
object BackDelayedNavigation : DelayedNavigation
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.novafoundation.nova.app.root.navigation.delayedNavigation

import android.os.Bundle
import io.novafoundation.nova.common.navigation.DelayedNavigation
import kotlinx.android.parcel.Parcelize

@Parcelize
class NavComponentDelayedNavigation(val globalActionId: Int, val extras: Bundle? = null) : DelayedNavigation
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import io.novafoundation.nova.feature_staking_impl.presentation.staking.start.la
import io.novafoundation.nova.feature_staking_impl.presentation.staking.start.landing.model.StartStakingLandingPayload
import io.novafoundation.nova.feature_staking_impl.presentation.staking.start.setupAmount.SetupAmountMultiStakingFragment
import io.novafoundation.nova.feature_staking_impl.presentation.staking.start.setupAmount.SetupAmountMultiStakingPayload
import io.novafoundation.nova.feature_staking_impl.presentation.staking.start.setupStakingType.SetupStakingTypeFragment
import io.novafoundation.nova.feature_staking_impl.presentation.staking.start.setupStakingType.SetupStakingTypePayload

class StartMultiStakingNavigator(
navigationHolder: NavigationHolder,
Expand All @@ -42,9 +44,10 @@ class StartMultiStakingNavigator(
args = SetupAmountMultiStakingFragment.getBundle(payload)
)

override fun openSetupStakingType() {
performNavigation(R.id.action_setupAmountMultiStakingFragment_to_setupStakingType)
}
override fun openSetupStakingType(payload: SetupStakingTypePayload) = performNavigation(
R.id.action_setupAmountMultiStakingFragment_to_setupStakingType,
args = SetupStakingTypeFragment.getArguments(payload)
)

override fun openConfirm(payload: ConfirmMultiStakingPayload) = performNavigation(
actionId = R.id.action_setupAmountMultiStakingFragment_to_confirmMultiStakingFragment,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.novafoundation.nova.app.root.navigation.staking.relaychain

import androidx.navigation.NavController
import io.novafoundation.nova.app.R
import io.novafoundation.nova.app.root.navigation.BaseNavigator
import io.novafoundation.nova.app.root.navigation.NavigationHolder
Expand All @@ -10,6 +11,9 @@ import io.novafoundation.nova.feature_staking_impl.presentation.payouts.confirm.
import io.novafoundation.nova.feature_staking_impl.presentation.payouts.confirm.model.ConfirmPayoutPayload
import io.novafoundation.nova.feature_staking_impl.presentation.payouts.detail.PayoutDetailsFragment
import io.novafoundation.nova.feature_staking_impl.presentation.payouts.model.PendingPayoutParcelable
import io.novafoundation.nova.feature_staking_impl.presentation.pools.selectPool.SelectPoolFragment
import io.novafoundation.nova.feature_staking_impl.presentation.pools.common.SelectingPoolPayload
import io.novafoundation.nova.feature_staking_impl.presentation.pools.searchPool.SearchPoolFragment
import io.novafoundation.nova.feature_staking_impl.presentation.staking.bond.confirm.ConfirmBondMoreFragment
import io.novafoundation.nova.feature_staking_impl.presentation.staking.bond.confirm.ConfirmBondMorePayload
import io.novafoundation.nova.feature_staking_impl.presentation.staking.bond.select.SelectBondMoreFragment
Expand All @@ -26,14 +30,21 @@ import io.novafoundation.nova.feature_staking_impl.presentation.staking.rewardDe
import io.novafoundation.nova.feature_staking_impl.presentation.staking.unbond.confirm.ConfirmUnbondFragment
import io.novafoundation.nova.feature_staking_impl.presentation.staking.unbond.confirm.ConfirmUnbondPayload
import io.novafoundation.nova.feature_staking_impl.presentation.story.StoryFragment
import io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.common.CustomValidatorsPayload
import io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.common.CustomValidatorsPayload.FlowType
import io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.review.ReviewCustomValidatorsFragment
import io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.select.SelectCustomValidatorsFragment
import io.novafoundation.nova.feature_staking_impl.presentation.validators.details.StakeTargetDetailsPayload
import io.novafoundation.nova.feature_staking_impl.presentation.validators.details.ValidatorDetailsFragment

class RelayStakingNavigator(
navigationHolder: NavigationHolder,
private val navigationHolder: NavigationHolder,
private val commonNavigator: Navigator,
) : BaseNavigator(navigationHolder), StakingRouter {

private val navController: NavController?
get() = navigationHolder.navController

override fun returnToStakingMain() = performNavigation(R.id.back_to_staking_main)

override fun openSwitchWallet() = commonNavigator.openSwitchWallet()
Expand Down Expand Up @@ -79,7 +90,19 @@ class RelayStakingNavigator(
}

override fun openSelectCustomValidators() {
performNavigation(R.id.action_startChangeValidatorsFragment_to_selectCustomValidatorsFragment)
val flowType = when (navigationHolder.navController?.currentDestination?.id) {
R.id.setupStakingType -> FlowType.SETUP_STAKING_VALIDATORS
else -> FlowType.CHANGE_STAKING_VALIDATORS
}
val payload = CustomValidatorsPayload(flowType)

performNavigation(
cases = arrayOf(
R.id.setupStakingType to R.id.action_setupStakingType_to_selectCustomValidatorsFragment,
R.id.startChangeValidatorsFragment to R.id.action_startChangeValidatorsFragment_to_selectCustomValidatorsFragment,
),
args = SelectCustomValidatorsFragment.getBundle(payload)
)
}

override fun openCustomValidatorsSettings() {
Expand All @@ -90,8 +113,11 @@ class RelayStakingNavigator(
performNavigation(R.id.action_selectCustomValidatorsFragment_to_searchCustomValidatorsFragment)
}

override fun openReviewCustomValidators() {
performNavigation(R.id.action_selectCustomValidatorsFragment_to_reviewCustomValidatorsFragment)
override fun openReviewCustomValidators(payload: CustomValidatorsPayload) {
performNavigation(
R.id.action_selectCustomValidatorsFragment_to_reviewCustomValidatorsFragment,
args = ReviewCustomValidatorsFragment.getBundle(payload)
)
}

override fun openConfirmStaking() {
Expand Down Expand Up @@ -153,6 +179,7 @@ class RelayStakingNavigator(
}

override fun openRebag() = performNavigation(R.id.action_stakingFragment_to_rebag)

override fun openDAppBrowser(url: String) = performNavigation(
actionId = R.id.action_mainFragment_to_dappBrowserGraph,
args = DAppBrowserFragment.getBundle(url)
Expand All @@ -161,4 +188,31 @@ class RelayStakingNavigator(
override fun openStakingPeriods() {
performNavigation(R.id.action_stakingFragment_to_staking_periods)
}

override fun openSetupStakingType() {
performNavigation(R.id.action_setupAmountMultiStakingFragment_to_setupStakingType)
}

override fun openSelectPool(payload: SelectingPoolPayload) {
val arguments = SelectPoolFragment.getBundle(payload)
performNavigation(R.id.action_setupStakingType_to_selectCustomPoolFragment, args = arguments)
}

override fun openSearchPool(payload: SelectingPoolPayload) {
val arguments = SearchPoolFragment.getBundle(payload)
performNavigation(R.id.action_selectPool_to_searchPoolFragment, args = arguments)
}

override fun finishSetupValidatorsFlow() {
performNavigation(R.id.action_back_to_setupAmountMultiStakingFragment)
}

override fun finishSetupPoolFlow() {
performNavigation(
cases = arrayOf(
R.id.searchPoolFragment to R.id.action_searchPool_to_setupAmountMultiStakingFragment,
R.id.selectPoolFragment to R.id.action_selectPool_to_setupAmountMultiStakingFragment,
)
)
}
}
67 changes: 67 additions & 0 deletions app/src/main/res/navigation/setup_staking_validators_graph.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/setup_staking_validators_graph"
app:startDestination="@id/selectCustomValidatorsFragment">

<fragment
android:id="@+id/selectCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.select.SelectCustomValidatorsFragment"
android:label="selectCustomValidatorsFragment"
tools:layout="@layout/fragment_select_custom_validators">

<action
android:id="@+id/action_selectCustomValidatorsFragment_to_reviewCustomValidatorsFragment"
app:destination="@id/reviewCustomValidatorsFragment"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />

<action
android:id="@+id/action_selectCustomValidatorsFragment_to_settingsCustomValidatorsFragment"
app:destination="@id/settingsCustomValidatorsFragment"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />

<action
android:id="@+id/action_selectCustomValidatorsFragment_to_searchCustomValidatorsFragment"
app:destination="@id/searchCustomValidatorsFragment"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment>

<fragment
android:id="@+id/settingsCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.settings.CustomValidatorsSettingsFragment"
android:label="settingsCustomValidatorsFragment"
tools:layout="@layout/fragment_custom_validators_settings" />

<fragment
android:id="@+id/searchCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.search.SearchCustomValidatorsFragment"
android:label="searchCustomValidatorsFragment"
tools:layout="@layout/fragment_search_custom_validators" />

<fragment
android:id="@+id/reviewCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.review.ReviewCustomValidatorsFragment"
android:label="reviewCustomValidatorsFragment"
tools:layout="@layout/fragment_select_custom_validators">

<action
android:id="@+id/action_back_to_setupAmountMultiStakingFragment"
app:enterAnim="@anim/fragment_close_enter"
app:exitAnim="@anim/fragment_close_exit"
app:popEnterAnim="@anim/fragment_open_enter"
app:popExitAnim="@anim/fragment_open_exit"
app:popUpTo="@id/setupAmountMultiStakingFragment" />

</fragment>

</navigation>
52 changes: 2 additions & 50 deletions app/src/main/res/navigation/staking_main_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,62 +187,13 @@

<action
android:id="@+id/action_startChangeValidatorsFragment_to_selectCustomValidatorsFragment"
app:destination="@id/selectCustomValidatorsFragment"
app:destination="@id/setup_staking_validators_graph"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment>

<fragment
android:id="@+id/selectCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.select.SelectCustomValidatorsFragment"
android:label="selectCustomValidatorsFragment"
tools:layout="@layout/fragment_select_custom_validators">

<action
android:id="@+id/action_selectCustomValidatorsFragment_to_reviewCustomValidatorsFragment"
app:destination="@id/reviewCustomValidatorsFragment"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />

<action
android:id="@+id/action_selectCustomValidatorsFragment_to_settingsCustomValidatorsFragment"
app:destination="@id/settingsCustomValidatorsFragment"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />

<action
android:id="@+id/action_selectCustomValidatorsFragment_to_searchCustomValidatorsFragment"
app:destination="@id/searchCustomValidatorsFragment"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment>

<fragment
android:id="@+id/settingsCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.settings.CustomValidatorsSettingsFragment"
android:label="settingsCustomValidatorsFragment"
tools:layout="@layout/fragment_custom_validators_settings" />

<fragment
android:id="@+id/searchCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.search.SearchCustomValidatorsFragment"
android:label="searchCustomValidatorsFragment"
tools:layout="@layout/fragment_search_custom_validators" />

<fragment
android:id="@+id/reviewCustomValidatorsFragment"
android:name="io.novafoundation.nova.feature_staking_impl.presentation.validators.change.custom.review.ReviewCustomValidatorsFragment"
android:label="reviewCustomValidatorsFragment"
tools:layout="@layout/fragment_select_custom_validators" />

<action
android:id="@+id/openConfirmStakingFragment"
app:destination="@id/confirmStakingFragment"
Expand Down Expand Up @@ -494,6 +445,7 @@

<include app:graph="@navigation/nomination_pools_unbond_graph" />

<include app:graph="@navigation/setup_staking_validators_graph" />

<fragment
android:id="@+id/nominationPoolsRedeemFragment"
Expand Down
Loading

0 comments on commit 11f47a3

Please sign in to comment.