diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BaseTokenManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BaseTokenManager.kt index 1a9e948ddb..5ca2a60a8a 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BaseTokenManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BaseTokenManager.kt @@ -36,7 +36,13 @@ class BaseTokenManager( setBaseToken(tokens.getOrNull(indexOfNext) ?: tokens.firstOrNull()) } - fun setBaseToken(token: Token?) { + fun setBaseTokenQueryId(tokenQueryId: String) { + val token = TokenQuery.fromId(tokenQueryId)?.let { coinManager.getToken(it) } ?: tokens.first() + + setBaseToken(token) + } + + private fun setBaseToken(token: Token?) { this.token = token localStorage.balanceTotalCoinUid = token?.coin?.uid @@ -45,10 +51,4 @@ class BaseTokenManager( } } - fun setBaseTokenQueryId(tokenQueryId: String) { - val token = TokenQuery.fromId(tokenQueryId)?.let { coinManager.getToken(it) } ?: tokens.first() - - setBaseToken(token) - } - } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceFragment.kt index 4282d15e1f..4623bf4d27 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceFragment.kt @@ -24,7 +24,6 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue import androidx.compose.material.Surface -import androidx.compose.material.Text import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -40,7 +39,6 @@ import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation.NavController import io.horizontalsystems.bankwallet.R @@ -48,8 +46,6 @@ import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme import io.horizontalsystems.bankwallet.ui.compose.Select import io.horizontalsystems.bankwallet.ui.compose.components.AlertGroup -import io.horizontalsystems.bankwallet.ui.compose.components.AlertHeader -import io.horizontalsystems.bankwallet.ui.compose.components.AlertItem import io.horizontalsystems.bankwallet.ui.compose.components.AppBar import io.horizontalsystems.bankwallet.ui.compose.components.B2 import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryTransparent @@ -94,7 +90,6 @@ fun AppearanceScreen(navController: NavController) { var openThemeSelector by rememberSaveable { mutableStateOf(false) } var openLaunchPageSelector by rememberSaveable { mutableStateOf(false) } var openBalanceValueSelector by rememberSaveable { mutableStateOf(false) } - var openBalanceConversionSelector by rememberSaveable { mutableStateOf(false) } Surface(color = ComposeAppTheme.colors.tyler) { ModalBottomSheetLayout( @@ -202,13 +197,6 @@ fun AppearanceScreen(navController: NavController) { value = uiState.selectedBalanceViewType.title.getString(), onClick = { openBalanceValueSelector = true } ) - }, - { - MenuItemWithDialog( - R.string.Appearance_BalanceConversion, - value = uiState.baseTokenOptions.selected?.coin?.code ?: "", - onClick = { openBalanceConversionSelector = true } - ) } ) ) @@ -259,33 +247,6 @@ fun AppearanceScreen(navController: NavController) { { openBalanceValueSelector = false } ) } - if (openBalanceConversionSelector) { - Dialog(onDismissRequest = { - openBalanceConversionSelector = false - }) { - Column( - modifier = Modifier - .padding(horizontal = 20.dp) - .clip(RoundedCornerShape(16.dp)) - ) { - AlertHeader(R.string.Appearance_BalanceConversion) - uiState.baseTokenOptions.options.forEach { option -> - AlertItem( - onClick = { - viewModel.onEnterBaseToken(option) - openBalanceConversionSelector = false - } - ) { - Text( - option.coin.code, - color = if (option == uiState.baseTokenOptions.selected) ComposeAppTheme.colors.jacob else ComposeAppTheme.colors.leah, - style = ComposeAppTheme.typography.body, - ) - } - } - } - } - } } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceModule.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceModule.kt index 19c785e362..f03a31fcf9 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceModule.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceModule.kt @@ -20,7 +20,6 @@ object AppearanceModule { launchScreenService, appIconService, themeService, - App.baseTokenManager, App.balanceViewTypeManager, App.localStorage, ) as T diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceViewModel.kt index 829819ccc9..c9fd20df12 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/appearance/AppearanceViewModel.kt @@ -3,30 +3,24 @@ package io.horizontalsystems.bankwallet.modules.settings.appearance import androidx.lifecycle.viewModelScope import io.horizontalsystems.bankwallet.core.ILocalStorage import io.horizontalsystems.bankwallet.core.ViewModelUiState -import io.horizontalsystems.bankwallet.core.managers.BaseTokenManager import io.horizontalsystems.bankwallet.entities.LaunchPage import io.horizontalsystems.bankwallet.modules.balance.BalanceViewType import io.horizontalsystems.bankwallet.modules.balance.BalanceViewTypeManager import io.horizontalsystems.bankwallet.modules.theme.ThemeService import io.horizontalsystems.bankwallet.modules.theme.ThemeType import io.horizontalsystems.bankwallet.ui.compose.Select -import io.horizontalsystems.bankwallet.ui.compose.SelectOptional -import io.horizontalsystems.marketkit.models.Token import kotlinx.coroutines.launch - class AppearanceViewModel( private val launchScreenService: LaunchScreenService, private val appIconService: AppIconService, private val themeService: ThemeService, - private val baseTokenManager: BaseTokenManager, private val balanceViewTypeManager: BalanceViewTypeManager, private val localStorage: ILocalStorage, ) : ViewModelUiState() { private var launchScreenOptions = launchScreenService.optionsFlow.value private var appIconOptions = appIconService.optionsFlow.value private var themeOptions = themeService.optionsFlow.value - private var baseTokenOptions = buildBaseTokenSelect(baseTokenManager.baseTokenFlow.value) private var marketsTabHidden = !localStorage.marketsTabEnabled private var balanceTabButtonsHidden = !localStorage.balanceTabButtonsEnabled private var balanceViewTypeOptions = @@ -51,12 +45,6 @@ class AppearanceViewModel( handleUpdatedThemeOptions(it) } } - viewModelScope.launch { - baseTokenManager.baseTokenFlow - .collect { baseToken -> - handleUpdatedBaseToken(buildBaseTokenSelect(baseToken)) - } - } viewModelScope.launch { balanceViewTypeManager.balanceViewTypeFlow .collect { @@ -69,7 +57,6 @@ class AppearanceViewModel( launchScreenOptions = launchScreenOptions, appIconOptions = appIconOptions, themeOptions = themeOptions, - baseTokenOptions = baseTokenOptions, balanceViewTypeOptions = balanceViewTypeOptions, marketsTabHidden = marketsTabHidden, balanceTabButtonsHidden = balanceTabButtonsHidden, @@ -78,10 +65,6 @@ class AppearanceViewModel( selectedBalanceViewType = balanceViewTypeManager.balanceViewType, ) - private fun buildBaseTokenSelect(token: Token?): SelectOptional { - return SelectOptional(token, baseTokenManager.tokens) - } - private fun buildBalanceViewTypeSelect(value: BalanceViewType): Select { return Select(value, balanceViewTypeManager.viewTypes) } @@ -106,11 +89,6 @@ class AppearanceViewModel( emitState() } - private fun handleUpdatedBaseToken(baseTokenOptions: SelectOptional) { - this.baseTokenOptions = baseTokenOptions - emitState() - } - fun onEnterLaunchPage(launchPage: LaunchPage) { launchScreenService.setLaunchScreen(launchPage) } @@ -123,10 +101,6 @@ class AppearanceViewModel( themeService.setThemeType(themeType) } - fun onEnterBaseToken(token: Token) { - baseTokenManager.setBaseToken(token) - } - fun onEnterBalanceViewType(viewType: BalanceViewType) { balanceViewTypeManager.setViewType(viewType) } @@ -154,7 +128,6 @@ data class AppearanceUIState( val launchScreenOptions: Select, val appIconOptions: Select, val themeOptions: Select, - val baseTokenOptions: SelectOptional, val balanceViewTypeOptions: Select, val marketsTabHidden: Boolean, val balanceTabButtonsHidden: Boolean,