Skip to content

Commit

Permalink
Merge pull request #1711 from novasamatech/fix/portfolio-view
Browse files Browse the repository at this point in the history
Fix/portfolio view
  • Loading branch information
antonijzelinskij authored Nov 8, 2024
2 parents 5dd90a0 + 7bd70da commit 5eb56ec
Show file tree
Hide file tree
Showing 53 changed files with 277 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,17 @@ class Navigator(
}

override fun openSwapNetworks(payload: NetworkSwapFlowPayload) {
navController?.navigate(R.id.action_swapFlow_to_swapFlowNetwork, NetworkSwapFlowFragment.createPayload(payload))
navController?.navigate(R.id.action_selectAssetSwapFlowFragment_to_swapFlowNetworkFragment, NetworkSwapFlowFragment.createPayload(payload))
}

override fun openBuyNetworks(payload: NetworkFlowPayload) {
navController?.navigate(R.id.action_buyFlow_to_buyFlowNetwork, NetworkFlowFragment.createPayload(payload))
}

override fun returnToMainSwapScreen() {
navController?.navigate(R.id.action_return_to_swap_settings)
}

override fun openSwapFlow() {
val payload = SwapFlowPayload.InitialSelecting
navController?.navigate(R.id.action_mainFragment_to_swapFlow, AssetSwapFlowFragment.getBundle(payload))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class SwapNavigator(

override fun selectAssetIn(selectedAsset: AssetPayload?) {
val payload = SwapFlowPayload.ReselectAssetIn(selectedAsset)
navigationHolder.navController?.navigate(R.id.action_swapMainSettingsFragment_to_swapFlow, AssetSwapFlowFragment.getBundle(payload))
navigationHolder.navController?.navigate(R.id.action_swapSettingsFragment_to_select_swap_token_graph, AssetSwapFlowFragment.getBundle(payload))
}

override fun selectAssetOut(selectedAsset: AssetPayload?) {
val payload = SwapFlowPayload.ReselectAssetOut(selectedAsset)
navigationHolder.navController?.navigate(R.id.action_swapMainSettingsFragment_to_swapFlow, AssetSwapFlowFragment.getBundle(payload))
navigationHolder.navController?.navigate(R.id.action_swapSettingsFragment_to_select_swap_token_graph, AssetSwapFlowFragment.getBundle(payload))
}

override fun openSendCrossChain(destination: AssetPayload, recipientAddress: String?) {
Expand Down
26 changes: 4 additions & 22 deletions app/src/main/res/navigation/main_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@

<action
android:id="@+id/action_open_swapSetupAmount"
app:destination="@id/start_swap_graph"
app:destination="@id/start_swap_nav_graph"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
Expand Down Expand Up @@ -479,7 +479,7 @@

<action
android:id="@+id/action_mainFragment_to_swapFlow"
app:destination="@id/swapFlowFragment"
app:destination="@id/select_swap_token_nav_graph"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
Expand Down Expand Up @@ -937,21 +937,6 @@

</fragment>

<fragment
android:id="@+id/swapFlowFragment"
android:name="io.novafoundation.nova.feature_assets.presentation.swap.asset.AssetSwapFlowFragment"
android:label="AssetSwapFlowFragment" >

<action
android:id="@+id/action_swapFlow_to_swapFlowNetwork"
app:destination="@id/swapFlowNetworkFragment"
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/sendFlowNetworkFragment"
android:name="io.novafoundation.nova.feature_assets.presentation.send.flow.network.NetworkSendFlowFragment"
Expand All @@ -967,11 +952,6 @@
android:name="io.novafoundation.nova.feature_assets.presentation.buy.flow.network.NetworkBuyFlowFragment"
android:label="NetworkBuyFlowFragment" />

<fragment
android:id="@+id/swapFlowNetworkFragment"
android:name="io.novafoundation.nova.feature_assets.presentation.swap.network.NetworkSwapFlowFragment"
android:label="NetworkBuyFlowFragment" />

<fragment
android:id="@+id/walletConnectScanFragment"
android:name="io.novafoundation.nova.feature_wallet_connect_impl.presentation.scan.WalletConnectScanFragment"
Expand Down Expand Up @@ -1062,4 +1042,6 @@

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

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

</navigation>
33 changes: 33 additions & 0 deletions app/src/main/res/navigation/select_swap_token_nav_graph.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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"
app:startDestination="@id/selectAssetSwapFlowFragment"
android:id="@+id/select_swap_token_nav_graph">

<fragment
android:id="@+id/selectAssetSwapFlowFragment"
android:name="io.novafoundation.nova.feature_assets.presentation.swap.asset.AssetSwapFlowFragment"
android:label="AssetSwapFlowFragment">

<action
android:id="@+id/action_selectAssetSwapFlowFragment_to_swapFlowNetworkFragment"
app:destination="@id/swapFlowNetworkFragment"
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/swapFlowNetworkFragment"
android:name="io.novafoundation.nova.feature_assets.presentation.swap.network.NetworkSwapFlowFragment"
android:label="NetworkSwapFlowFragment" />

<action
android:id="@+id/action_return_to_swap_settings"
app:popUpTo="@id/swapSettingsFragment"
app:enterAnim="@anim/fragment_close_enter"
app:exitAnim="@anim/fragment_close_exit"
app:popEnterAnim="@anim/fragment_open_enter"
app:popExitAnim="@anim/fragment_open_exit" />
</navigation>
17 changes: 7 additions & 10 deletions app/src/main/res/navigation/start_swap_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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/start_swap_graph"
android:id="@+id/start_swap_nav_graph"
app:startDestination="@id/swapSettingsFragment">

<fragment
Expand All @@ -19,16 +19,16 @@
app:popExitAnim="@anim/fragment_close_exit" />

<action
android:id="@+id/action_swapMainSettingsFragment_to_swapFlow"
app:destination="@id/selectAssetSwapFlowFragment"
android:id="@+id/action_swapMainSettingsFragment_to_swapOptionsFragment"
app:destination="@id/swapOptionsFragment"
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_swapMainSettingsFragment_to_swapOptionsFragment"
app:destination="@id/swapOptionsFragment"
android:id="@+id/action_swapSettingsFragment_to_select_swap_token_graph"
app:destination="@id/select_swap_token_nav_graph"
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
Expand All @@ -53,14 +53,11 @@

</fragment>

<fragment
android:id="@+id/selectAssetSwapFlowFragment"
android:name="io.novafoundation.nova.feature_assets.presentation.swap.asset.AssetSwapFlowFragment"
android:label="AssetSwapFlowFragment" />

<fragment
android:id="@+id/swapOptionsFragment"
android:name="io.novafoundation.nova.feature_swap_impl.presentation.options.SwapOptionsFragment"
android:label="SwapOptionsFragment" />

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

</navigation>
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {
buildConfigField "String", "APP_UPDATE_SOURCE_LINK", "\"https://play.google.com/store/apps/details?id=io.novafoundation.nova.market\""

buildConfigField "String", "ASSET_COLORED_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/colored\""
buildConfigField "String", "ASSET_WHITE_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white\""
buildConfigField "String", "ASSET_WHITE_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/v1\""
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import io.novafoundation.nova.common.data.secrets.v2.SecretStoreV2
import io.novafoundation.nova.common.data.storage.Preferences
import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferences
import io.novafoundation.nova.common.di.modules.Caching
import io.novafoundation.nova.common.domain.interactor.AssetViewModeInteractor
import io.novafoundation.nova.common.interfaces.ActivityIntentProvider
import io.novafoundation.nova.common.interfaces.BuildTypeProvider
import io.novafoundation.nova.common.interfaces.FileCache
Expand Down Expand Up @@ -192,4 +193,6 @@ interface CommonApi {
fun assetsIconModeService(): AssetsIconModeRepository

fun assetIconProvider(): AssetIconProvider

fun assetViewModeInteractor(): AssetViewModeInteractor
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferences
import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferencesImpl
import io.novafoundation.nova.common.data.storage.encrypt.EncryptionUtil
import io.novafoundation.nova.common.di.scope.ApplicationScope
import io.novafoundation.nova.common.domain.interactor.AssetViewModeInteractor
import io.novafoundation.nova.common.domain.interactor.RealAssetViewModeInteractor
import io.novafoundation.nova.common.interfaces.FileCache
import io.novafoundation.nova.common.interfaces.FileProvider
import io.novafoundation.nova.common.interfaces.InternalFileSystemCache
Expand Down Expand Up @@ -359,6 +361,12 @@ class CommonModule {
@ApplicationScope
fun provideAssetsViewModeRepository(preferences: Preferences): AssetsViewModeRepository = RealAssetsViewModeRepository(preferences)

@Provides
@ApplicationScope
fun provideAssetViewModeInteractor(repository: AssetsViewModeRepository): AssetViewModeInteractor {
return RealAssetViewModeInteractor(repository)
}

@Provides
@ApplicationScope
fun provideAssetsIconModeRepository(preferences: Preferences): AssetsIconModeRepository = RealAssetsIconModeRepository(preferences)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.novafoundation.nova.common.domain.interactor

import io.novafoundation.nova.common.data.model.AssetViewMode
import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository
import kotlinx.coroutines.flow.Flow

interface AssetViewModeInteractor {

fun getAssetViewMode(): AssetViewMode

fun assetsViewModeFlow(): Flow<AssetViewMode>

suspend fun setAssetsViewMode(assetsViewMode: AssetViewMode)
}

class RealAssetViewModeInteractor(
private val assetsViewModeRepository: AssetsViewModeRepository
) : AssetViewModeInteractor {
override fun getAssetViewMode(): AssetViewMode {
return assetsViewModeRepository.getAssetViewMode()
}

override fun assetsViewModeFlow(): Flow<AssetViewMode> {
return assetsViewModeRepository.assetsViewModeFlow()
}

override suspend fun setAssetsViewMode(assetsViewMode: AssetViewMode) {
assetsViewModeRepository.setAssetsViewMode(assetsViewMode)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RealAssetIconProvider(
}

override fun getAssetIconOrFallback(iconName: String, iconMode: AssetIconMode): Icon {
val iconUrl = when (assetsIconModeRepository.getIconMode()) {
val iconUrl = when (iconMode) {
AssetIconMode.COLORED -> "$coloredBaseUrl/$iconName"
AssetIconMode.WHITE -> "$whiteBaseUrl/$iconName"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import io.novafoundation.nova.common.utils.makeVisible

sealed class Icon {

class FromLink(val data: String) : Icon()
data class FromLink(val data: String) : Icon()

class FromDrawable(val data: Drawable) : Icon()
data class FromDrawable(val data: Drawable) : Icon()

class FromDrawableRes(@DrawableRes val res: Int) : Icon()
data class FromDrawableRes(@DrawableRes val res: Int) : Icon()
}

typealias ExtraImageRequestBuilding = ImageRequest.Builder.() -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import androidx.recyclerview.widget.RecyclerView
import io.novafoundation.nova.common.R
import io.novafoundation.nova.common.utils.DialogExtensions
import io.novafoundation.nova.common.utils.WithContextExtensions
import io.novafoundation.nova.common.utils.setTextOrHide
import io.novafoundation.nova.common.utils.setVisible
import io.novafoundation.nova.common.view.bottomSheet.BaseBottomSheet
import kotlinx.android.synthetic.main.bottom_sheet_dynamic_list.dynamicListSheetContent
import kotlinx.android.synthetic.main.bottom_sheet_dynamic_list.dynamicListSheetHeader
import kotlinx.android.synthetic.main.bottom_sheet_dynamic_list.dynamicListSheetItemContainer
import kotlinx.android.synthetic.main.bottom_sheet_dynamic_list.dynamicListSheetRightAction
import kotlinx.android.synthetic.main.bottom_sheet_dynamic_list.dynamicListSheetSubtitle
import kotlinx.android.synthetic.main.bottom_sheet_dynamic_list.dynamicListSheetTitle

typealias ClickHandler<T> = (BaseDynamicListBottomSheet, T) -> Unit
Expand Down Expand Up @@ -56,6 +58,10 @@ abstract class BaseDynamicListBottomSheet(context: Context) :
dynamicListSheetTitle.text = title
}

fun setSubtitle(subtitle: CharSequence?) {
dynamicListSheetSubtitle.setTextOrHide(subtitle)
}

final override fun setTitle(titleId: Int) {
dynamicListSheetTitle.setText(titleId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class OperationListItem @kotlin.jvm.JvmOverloads constructor(
fun setIconStyle(iconStyle: IconStyle) {
when (iconStyle) {
IconStyle.BORDERED_CIRCLE -> {
icon.setPadding(6.dp)
icon.setBackgroundResource(R.drawable.bg_icon_container_on_color)
icon.setImageTintRes(R.color.icon_secondary)
}
Expand Down
12 changes: 7 additions & 5 deletions common/src/main/res/drawable/ic_nova.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M11.8099,1.152C11.8556,0.9493 12.1444,0.9493 12.1901,1.152L13.608,7.4464C13.9387,8.9147 15.0853,10.0613 16.5536,10.392L22.848,11.8099C23.0507,11.8556 23.0507,12.1444 22.848,12.1901L16.5536,13.608C15.0853,13.9387 13.9387,15.0853 13.608,16.5536L12.1901,22.848C12.1444,23.0507 11.8556,23.0507 11.8099,22.848L10.392,16.5536C10.0613,15.0853 8.9147,13.9387 7.4464,13.608L1.152,12.1901C0.9493,12.1444 0.9493,11.8556 1.152,11.8099L7.4464,10.392C8.9147,10.0613 10.0613,8.9147 10.392,7.4464L11.8099,1.152Z"
android:fillColor="#ffffff"/>
android:viewportWidth="48"
android:viewportHeight="48">

<path
android:fillColor="#ffffff"
android:pathData="M42,23.527V24.473C39.059,24.938 32.752,26.028 29.65,27.214C28.544,27.638 27.663,28.512 27.23,29.61C26.036,32.695 24.938,39.043 24.473,42H23.527C23.054,39.051 21.964,32.703 20.77,29.61C20.337,28.504 19.456,27.63 18.35,27.214C15.248,26.028 8.941,24.938 6,24.473V23.527C8.941,23.062 15.248,21.972 18.35,20.786C19.456,20.361 20.337,19.488 20.77,18.39C21.964,15.304 23.062,8.957 23.527,6H24.473C24.946,8.949 26.036,15.296 27.23,18.39C27.663,19.496 28.544,20.369 29.65,20.786C32.752,21.972 39.059,23.062 42,23.527Z" />

</vector>
9 changes: 9 additions & 0 deletions common/src/main/res/drawable/ic_receive_history.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M9.271,16.213C8.774,15.717 7.969,15.717 7.472,16.213C6.976,16.709 6.976,17.513 7.472,18.009L15.101,25.628C15.598,26.124 16.403,26.124 16.899,25.628L24.528,18.009C25.024,17.513 25.024,16.709 24.528,16.213C24.031,15.717 23.226,15.717 22.73,16.213L17.271,21.664V7.267C17.271,6.565 16.702,6 16,6C15.298,6 14.729,6.565 14.729,7.267V21.664L9.271,16.213Z"
android:fillColor="#ffffff"/>
</vector>
9 changes: 9 additions & 0 deletions common/src/main/res/drawable/ic_send_history.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M22.629,15.787C23.126,16.283 23.931,16.283 24.428,15.787C24.924,15.291 24.924,14.487 24.428,13.991L16.799,6.372C16.302,5.876 15.498,5.876 15.001,6.372L7.372,13.991C6.876,14.487 6.876,15.291 7.372,15.787C7.869,16.283 8.674,16.283 9.17,15.787L14.629,10.335L14.629,24.733C14.629,25.435 15.198,26 15.9,26C16.602,26 17.171,25.435 17.171,24.733L17.171,10.335L22.629,15.787Z"
android:fillColor="#ffffff"/>
</vector>
10 changes: 10 additions & 0 deletions common/src/main/res/drawable/ic_staking_history.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M22.233,7.101C24.113,7.88 25.163,8.985 25.2,10.219V11C25.2,11.287 24.966,11.736 24.542,12.102C24.042,12.537 23.299,12.965 22.395,13.34C20.469,14.139 18.022,14.616 15.85,14.616C13.677,14.616 11.231,14.141 9.305,13.342C8.401,12.967 7.658,12.538 7.158,12.104C6.734,11.736 6.5,11.286 6.5,11L6.504,10.212C6.542,8.981 7.593,7.878 9.471,7.101C11.187,6.391 13.452,6 15.85,6C18.248,6 20.513,6.391 22.233,7.101ZM8.751,22.295C10.843,23.16 13.497,23.678 15.85,23.678C18.203,23.678 20.857,23.16 22.949,22.295C23.669,21.993 24.292,21.517 24.81,21.121L24.911,21.044C24.938,21.024 24.969,21.012 25.003,21.008C25.036,21.005 25.07,21.011 25.1,21.026C25.13,21.041 25.155,21.064 25.173,21.092C25.191,21.12 25.2,21.153 25.2,21.186V21.748C25.2,23.001 24.144,24.125 22.227,24.91C20.511,25.613 18.247,26 15.85,26C13.453,26 11.188,25.613 9.473,24.91C7.556,24.124 6.5,23.001 6.5,21.748V21.186C6.5,21.153 6.509,21.12 6.527,21.092C6.545,21.064 6.57,21.041 6.6,21.026C6.63,21.011 6.664,21.005 6.697,21.008C6.731,21.012 6.762,21.024 6.789,21.044L6.885,21.118C7.404,21.514 8.028,21.992 8.751,22.295ZM22.949,14.66C20.857,15.528 18.203,16.044 15.85,16.044C13.497,16.044 10.843,15.528 8.751,14.66C8.025,14.358 7.398,13.877 6.878,13.478L6.789,13.41C6.762,13.39 6.73,13.377 6.697,13.374C6.663,13.371 6.629,13.377 6.599,13.392C6.569,13.408 6.544,13.431 6.526,13.459C6.509,13.488 6.5,13.521 6.5,13.554V14.928C6.5,15.214 6.734,15.575 7.158,15.943C7.658,16.378 8.401,16.806 9.305,17.181C11.231,17.979 13.677,18.455 15.85,18.455C18.022,18.455 20.469,17.978 22.395,17.18C23.299,16.804 24.042,16.376 24.542,15.941C24.966,15.574 25.2,15.214 25.2,14.928V13.554C25.2,13.521 25.191,13.488 25.173,13.46C25.155,13.432 25.13,13.409 25.1,13.394C25.07,13.379 25.036,13.373 25.003,13.376C24.969,13.379 24.938,13.392 24.911,13.412L24.811,13.488C24.293,13.884 23.67,14.361 22.949,14.66ZM15.85,19.884C18.203,19.884 20.857,19.366 22.949,18.5C23.67,18.199 24.293,17.723 24.811,17.327C24.845,17.301 24.878,17.276 24.911,17.251C24.938,17.23 24.969,17.218 25.003,17.215C25.036,17.212 25.07,17.218 25.1,17.232C25.13,17.247 25.155,17.27 25.173,17.298C25.191,17.327 25.2,17.359 25.2,17.393V18.723C25.2,19.007 24.966,19.368 24.542,19.736C24.042,20.171 23.299,20.599 22.395,20.974C20.469,21.773 18.023,22.25 15.85,22.25C13.677,22.25 11.231,21.773 9.305,20.975C8.401,20.6 7.658,20.172 7.157,19.737C6.734,19.369 6.5,19.009 6.5,18.723V17.393C6.5,17.359 6.509,17.326 6.527,17.298C6.544,17.27 6.57,17.247 6.6,17.232C6.63,17.217 6.663,17.211 6.697,17.214C6.73,17.217 6.762,17.229 6.789,17.25C6.82,17.274 6.852,17.298 6.884,17.322C7.403,17.72 8.028,18.198 8.751,18.5C10.843,19.366 13.497,19.884 15.85,19.884Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>
Loading

0 comments on commit 5eb56ec

Please sign in to comment.