From 3a8c24eb73dd4d82aa0ed2f9948d5bb6b9b5c9ae Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 18 Jun 2024 11:47:30 +0600 Subject: [PATCH 1/6] Increase version name to "0.40.0" --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9c19be8dca..c22170efcc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,8 @@ android { compileSdk compile_sdk_version minSdkVersion min_sdk_version targetSdkVersion compile_sdk_version - versionCode 110 - versionName "0.39.0" + versionCode 111 + versionName "0.40.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ksp { From 409b8350c379653979ad1b1c119c33aa142e4c72 Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 18 Jun 2024 12:19:10 +0600 Subject: [PATCH 2/6] Replace page column with Scaffold --- .../modules/addtoken/AddTokenFragment.kt | 45 +-- .../modules/balance/ui/BalanceForAccount.kt | 113 ++++--- .../BaseCurrencySettingsFragment.kt | 73 +++-- .../bankwallet/modules/coin/CoinFragment.kt | 195 +++++------ .../investments/CoinInvestmentsFragment.kt | 81 +++-- .../modules/coin/ranks/CoinRankFragment.kt | 28 +- .../coin/reports/CoinReportsFragment.kt | 85 ++--- .../coin/treasuries/CoinTreasuriesFragment.kt | 140 ++++---- .../modules/contacts/screen/AddressScreen.kt | 126 ++++---- .../modules/contacts/screen/ContactScreen.kt | 51 +-- .../modules/contacts/screen/ContactsScreen.kt | 200 ++++++------ .../bankwallet/modules/main/MainFragment.kt | 135 ++++---- .../evmprivatekey/EvmPrivateKeyFragment.kt | 84 ++--- .../recoveryphrase/RecoveryPhraseFragment.kt | 89 ++--- .../ShowExtendedKeyFragment.kt | 250 +++++++------- .../market/filters/MarketFiltersFragment.kt | 13 +- .../restoreblockchains/RestoreBlockchains.kt | 52 +-- .../advanced/SendBtcAdvancedSettingsScreen.kt | 64 ++-- .../settings/appearance/AppearanceFragment.kt | 304 +++++++++--------- .../bankwallet/ui/compose/HSSwipeRefresh.kt | 3 +- 20 files changed, 1165 insertions(+), 966 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/addtoken/AddTokenFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/addtoken/AddTokenFragment.kt index 7d74f7e56a..02b9678401 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/addtoken/AddTokenFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/addtoken/AddTokenFragment.kt @@ -1,16 +1,13 @@ package io.horizontalsystems.bankwallet.modules.addtoken import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.Icon +import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState @@ -38,9 +35,11 @@ import io.horizontalsystems.bankwallet.ui.compose.components.AppBar import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection import io.horizontalsystems.bankwallet.ui.compose.components.FormsInput import io.horizontalsystems.bankwallet.ui.compose.components.FormsInputStateWarning +import io.horizontalsystems.bankwallet.ui.compose.components.HSpacer import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.body_leah import io.horizontalsystems.bankwallet.ui.compose.components.subhead1_grey import io.horizontalsystems.core.SnackbarDuration @@ -116,26 +115,30 @@ private fun AddTokenScreen( } } - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.AddToken_Title), - navigationIcon = { - HsBackButton(onClick = closeScreen) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Button_Add), - onClick = viewModel::onAddClick, - enabled = uiState.addButtonEnabled + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.AddToken_Title), + navigationIcon = { + HsBackButton(onClick = closeScreen) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Button_Add), + onClick = viewModel::onAddClick, + enabled = uiState.addButtonEnabled + ) ) ) - ) + }, + ) { innerPaddings -> Column( modifier = Modifier - .weight(1f) + .padding(innerPaddings) .verticalScroll(rememberScrollState()) ) { - Spacer(modifier = Modifier.height(12.dp)) + VSpacer(12.dp) CellUniversalLawrenceSection( listOf { @@ -149,7 +152,7 @@ private fun AddTokenScreen( painter = painterResource(R.drawable.ic_blocks_24), contentDescription = null ) - Spacer(modifier = Modifier.width(16.dp)) + HSpacer(16.dp) body_leah( text = stringResource(R.string.AddToken_Blockchain), modifier = Modifier.weight(1f) @@ -167,7 +170,7 @@ private fun AddTokenScreen( } ) - Spacer(modifier = Modifier.height(32.dp)) + VSpacer(32.dp) FormsInput( modifier = Modifier.padding(horizontal = 16.dp), @@ -179,7 +182,7 @@ private fun AddTokenScreen( viewModel.onEnterText(it) } - Spacer(modifier = Modifier.height(32.dp)) + VSpacer(32.dp) uiState.tokenInfo?.let { tokenInfo -> CellUniversalLawrenceSection( diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceForAccount.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceForAccount.kt index 9cdea92a93..d85d30f2ef 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceForAccount.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceForAccount.kt @@ -6,14 +6,16 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.animation.Crossfade import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -119,56 +121,75 @@ fun BalanceForAccount(navController: NavController, accountViewItem: AccountView ) } ) { - Column { - AppBar( - title = { - BalanceTitleRow(navController, accountViewItem.name) - }, - menuItems = buildList { - if (accountViewItem.type.supportsWalletConnect) { - add( - MenuItem( - title = TranslatableString.ResString(R.string.WalletConnect_NewConnect), - icon = R.drawable.ic_qr_scan_20, - onClick = { - when (val state = viewModel.getWalletConnectSupportState()) { - WCManager.SupportState.Supported -> { - qrScannerLauncher.launch(QRScannerActivity.getScanQrIntent(context, true)) - - stat(page = StatPage.Balance, event = StatEvent.Open(StatPage.ScanQrCode)) - } - - WCManager.SupportState.NotSupportedDueToNoActiveAccount -> { - navController.slideFromBottom(R.id.wcErrorNoAccountFragment) - } - - is WCManager.SupportState.NotSupportedDueToNonBackedUpAccount -> { - val text = Translator.getString(R.string.WalletConnect_Error_NeedBackup) - navController.slideFromBottom( - R.id.backupRequiredDialog, - BackupRequiredDialog.Input(state.account, text) - ) - - stat(page = StatPage.Balance, event = StatEvent.Open(StatPage.BackupRequired)) - } - - is WCManager.SupportState.NotSupported -> { - navController.slideFromBottom( - R.id.wcAccountTypeNotSupportedDialog, - WCAccountTypeNotSupportedDialog.Input(state.accountTypeDescription) - ) + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = { + BalanceTitleRow(navController, accountViewItem.name) + }, + menuItems = buildList { + if (accountViewItem.type.supportsWalletConnect) { + add( + MenuItem( + title = TranslatableString.ResString(R.string.WalletConnect_NewConnect), + icon = R.drawable.ic_qr_scan_20, + onClick = { + when (val state = + viewModel.getWalletConnectSupportState()) { + WCManager.SupportState.Supported -> { + qrScannerLauncher.launch( + QRScannerActivity.getScanQrIntent(context, true) + ) + + stat( + page = StatPage.Balance, + event = StatEvent.Open(StatPage.ScanQrCode) + ) + } + + WCManager.SupportState.NotSupportedDueToNoActiveAccount -> { + navController.slideFromBottom(R.id.wcErrorNoAccountFragment) + } + + is WCManager.SupportState.NotSupportedDueToNonBackedUpAccount -> { + val text = + Translator.getString(R.string.WalletConnect_Error_NeedBackup) + navController.slideFromBottom( + R.id.backupRequiredDialog, + BackupRequiredDialog.Input(state.account, text) + ) + + stat( + page = StatPage.Balance, + event = StatEvent.Open(StatPage.BackupRequired) + ) + } + + is WCManager.SupportState.NotSupported -> { + navController.slideFromBottom( + R.id.wcAccountTypeNotSupportedDialog, + WCAccountTypeNotSupportedDialog.Input(state.accountTypeDescription) + ) + } } } - } + ) ) - ) + } } - } - ) - + ) + } + ) { paddingValues -> val uiState = viewModel.uiState - Crossfade(uiState.viewState, label = "") { viewState -> + Crossfade( + targetState = uiState.viewState, + modifier = Modifier + .padding(paddingValues) + .fillMaxSize(), + label = "" + ) { viewState -> when (viewState) { ViewState.Success -> { val balanceViewItems = uiState.balanceViewItems @@ -178,7 +199,7 @@ fun BalanceForAccount(navController: NavController, accountViewItem: AccountView accountViewItem, navController, uiState, - viewModel.totalUiState + viewModel.totalUiState, ) } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/basecurrency/BaseCurrencySettingsFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/basecurrency/BaseCurrencySettingsFragment.kt index 3490de4ffc..6fe5c91dcd 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/basecurrency/BaseCurrencySettingsFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/basecurrency/BaseCurrencySettingsFragment.kt @@ -1,8 +1,23 @@ package io.horizontalsystems.bankwallet.modules.basecurrency -import androidx.compose.foundation.* -import androidx.compose.foundation.layout.* -import androidx.compose.material.* +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.ModalBottomSheetLayout +import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold +import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.rememberCoroutineScope @@ -18,7 +33,17 @@ import androidx.navigation.NavController import io.horizontalsystems.bankwallet.R import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme -import io.horizontalsystems.bankwallet.ui.compose.components.* +import io.horizontalsystems.bankwallet.ui.compose.components.AppBar +import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryTransparent +import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow +import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection +import io.horizontalsystems.bankwallet.ui.compose.components.HeaderText +import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton +import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal +import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer +import io.horizontalsystems.bankwallet.ui.compose.components.body_leah +import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey import io.horizontalsystems.bankwallet.ui.extensions.BottomSheetHeader import kotlinx.coroutines.launch @@ -80,29 +105,32 @@ private fun BaseCurrencyScreen( ) } ) { - Column( - modifier = Modifier.background(color = ComposeAppTheme.colors.tyler) - ) { - AppBar( - title = stringResource(R.string.SettingsCurrency_Title), - navigationIcon = { - HsBackButton(onClick = { navController.popBackStack() }) - } - ) + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.SettingsCurrency_Title), + navigationIcon = { + HsBackButton(onClick = { navController.popBackStack() }) + } + ) + } + ) { paddingValues -> Column( - Modifier.verticalScroll(rememberScrollState()) + Modifier + .verticalScroll(rememberScrollState()) + .padding(paddingValues) ) { - Spacer(Modifier.height(12.dp)) + VSpacer(12.dp) CellUniversalLawrenceSection(viewModel.popularItems) { item -> CurrencyCell( item.currency.code, item.currency.symbol, item.currency.flag, - item.selected, - { viewModel.onSelectBaseCurrency(item.currency) } - ) + item.selected + ) { viewModel.onSelectBaseCurrency(item.currency) } } - Spacer(Modifier.height(24.dp)) + VSpacer(24.dp) HeaderText( stringResource(R.string.SettingsCurrency_Other) ) @@ -111,11 +139,10 @@ private fun BaseCurrencyScreen( item.currency.code, item.currency.symbol, item.currency.flag, - item.selected, - { viewModel.onSelectBaseCurrency(item.currency) } - ) + item.selected + ) { viewModel.onSelectBaseCurrency(item.currency) } } - Spacer(Modifier.height(24.dp)) + VSpacer(24.dp) } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/CoinFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/CoinFragment.kt index bdb54b9bd3..f967bc02ce 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/CoinFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/CoinFragment.kt @@ -2,10 +2,11 @@ package io.horizontalsystems.bankwallet.modules.coin import android.os.Parcelable import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier @@ -92,114 +93,128 @@ fun CoinTabs( val coroutineScope = rememberCoroutineScope() val view = LocalView.current - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = viewModel.fullCoin.coin.code, - navigationIcon = { - HsBackButton(onClick = { navController.popBackStack() }) - }, - menuItems = buildList { - if (viewModel.isWatchlistEnabled) { - if (viewModel.isFavorite) { - add( - MenuItem( - title = TranslatableString.ResString(R.string.CoinPage_Unfavorite), - icon = R.drawable.ic_filled_star_24, - tint = ComposeAppTheme.colors.jacob, - onClick = { - viewModel.onUnfavoriteClick() - - stat(page = StatPage.CoinPage, event = StatEvent.RemoveFromWatchlist(viewModel.fullCoin.coin.uid)) - } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = viewModel.fullCoin.coin.code, + navigationIcon = { + HsBackButton(onClick = { navController.popBackStack() }) + }, + menuItems = buildList { + if (viewModel.isWatchlistEnabled) { + if (viewModel.isFavorite) { + add( + MenuItem( + title = TranslatableString.ResString(R.string.CoinPage_Unfavorite), + icon = R.drawable.ic_filled_star_24, + tint = ComposeAppTheme.colors.jacob, + onClick = { + viewModel.onUnfavoriteClick() + + stat( + page = StatPage.CoinPage, + event = StatEvent.RemoveFromWatchlist(viewModel.fullCoin.coin.uid) + ) + } + ) ) - ) - } else { - add( - MenuItem( - title = TranslatableString.ResString(R.string.CoinPage_Favorite), - icon = R.drawable.ic_star_24, - onClick = { - viewModel.onFavoriteClick() - - stat(page = StatPage.CoinPage, event = StatEvent.AddToWatchlist(viewModel.fullCoin.coin.uid)) - } + } else { + add( + MenuItem( + title = TranslatableString.ResString(R.string.CoinPage_Favorite), + icon = R.drawable.ic_star_24, + onClick = { + viewModel.onFavoriteClick() + + stat( + page = StatPage.CoinPage, + event = StatEvent.AddToWatchlist(viewModel.fullCoin.coin.uid) + ) + } + ) ) - ) + } } } - } - ) - - val selectedTab = tabs[pagerState.currentPage] - val tabItems = tabs.map { - TabItem(stringResource(id = it.titleResId), it == selectedTab, it) + ) } - Tabs(tabItems, onClick = { tab -> - coroutineScope.launch { - pagerState.scrollToPage(tab.ordinal) + ) { innerPaddings -> + Column( + modifier = Modifier.padding(innerPaddings) + ) { + val selectedTab = tabs[pagerState.currentPage] + val tabItems = tabs.map { + TabItem(stringResource(id = it.titleResId), it == selectedTab, it) + } + Tabs(tabItems, onClick = { tab -> + coroutineScope.launch { + pagerState.scrollToPage(tab.ordinal) - stat(page = StatPage.CoinPage, event = StatEvent.SwitchTab(tab.statTab)) + stat(page = StatPage.CoinPage, event = StatEvent.SwitchTab(tab.statTab)) - if (tab == CoinModule.Tab.Details && viewModel.shouldShowSubscriptionInfo()) { - viewModel.subscriptionInfoShown() + if (tab == CoinModule.Tab.Details && viewModel.shouldShowSubscriptionInfo()) { + viewModel.subscriptionInfoShown() - delay(1000) - navController.slideFromBottom(R.id.subscriptionInfoFragment) - } - } - }) - - HorizontalPager( - state = pagerState, - userScrollEnabled = false - ) { page -> - when (tabs[page]) { - CoinModule.Tab.Overview -> { - CoinOverviewScreen( - fullCoin = viewModel.fullCoin, - navController = navController - ) + delay(1000) + navController.slideFromBottom(R.id.subscriptionInfoFragment) + } } + }) + + HorizontalPager( + state = pagerState, + userScrollEnabled = false + ) { page -> + when (tabs[page]) { + CoinModule.Tab.Overview -> { + CoinOverviewScreen( + fullCoin = viewModel.fullCoin, + navController = navController + ) + } - CoinModule.Tab.Market -> { - CoinMarketsScreen(fullCoin = viewModel.fullCoin) - } + CoinModule.Tab.Market -> { + CoinMarketsScreen(fullCoin = viewModel.fullCoin) + } - CoinModule.Tab.Details -> { - CoinAnalyticsScreen( - fullCoin = viewModel.fullCoin, - navController = navController, - fragmentManager = fragmentManager - ) + CoinModule.Tab.Details -> { + CoinAnalyticsScreen( + fullCoin = viewModel.fullCoin, + navController = navController, + fragmentManager = fragmentManager + ) + } } -// CoinModule.Tab.Tweets -> { -// CoinTweetsScreen(fullCoin = viewModel.fullCoin) -// } } - } - viewModel.successMessage?.let { - HudHelper.showSuccessMessage(view, it) + viewModel.successMessage?.let { + HudHelper.showSuccessMessage(view, it) - viewModel.onSuccessMessageShown() + viewModel.onSuccessMessageShown() + } } } } @Composable fun CoinNotFound(coinUid: String, navController: NavController) { - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = coinUid, - navigationIcon = { - HsBackButton(onClick = { navController.popBackStack() }) - } - ) - - ListEmptyView( - text = stringResource(R.string.CoinPage_CoinNotFound, coinUid), - icon = R.drawable.ic_not_available - ) - - } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = coinUid, + navigationIcon = { + HsBackButton(onClick = { navController.popBackStack() }) + } + ) + }, + content = { + ListEmptyView( + paddingValues = it, + text = stringResource(R.string.CoinPage_CoinNotFound, coinUid), + icon = R.drawable.ic_not_available + ) + } + ) } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/investments/CoinInvestmentsFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/investments/CoinInvestmentsFragment.kt index 5ffb780597..d735bbd4e9 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/investments/CoinInvestmentsFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/investments/CoinInvestmentsFragment.kt @@ -3,9 +3,7 @@ package io.horizontalsystems.bankwallet.modules.coin.investments import android.os.Parcelable import androidx.compose.animation.Crossfade import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -14,6 +12,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -78,50 +77,64 @@ private fun CoinInvestmentsScreen( val isRefreshing by viewModel.isRefreshingLiveData.observeAsState(false) val viewItems by viewModel.viewItemsLiveData.observeAsState() - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.CoinPage_FundsInvested), - navigationIcon = { - HsBackButton(onClick = onClickNavigation) - } - ) - + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.CoinPage_FundsInvested), + navigationIcon = { + HsBackButton(onClick = onClickNavigation) + } + ) + } + ) { innerPadding -> HSSwipeRefresh( refreshing = isRefreshing, - onRefresh = viewModel::refresh - ) { - Crossfade(viewState) { viewState -> - when (viewState) { - ViewState.Loading -> { - Loading() - } + modifier = Modifier + .padding(innerPadding) + .fillMaxSize(), + onRefresh = viewModel::refresh, + content = { + Crossfade(viewState, label = "") { viewState -> + when (viewState) { + ViewState.Loading -> { + Loading() + } - is ViewState.Error -> { - ListErrorView(stringResource(R.string.SyncError), viewModel::onErrorClick) - } + is ViewState.Error -> { + ListErrorView( + stringResource(R.string.SyncError), + viewModel::onErrorClick + ) + } - ViewState.Success -> { - LazyColumn(modifier = Modifier.fillMaxSize()) { - viewItems?.forEach { viewItem -> - item { - CoinInvestmentHeader(viewItem.amount, viewItem.info) + ViewState.Success -> { + LazyColumn(modifier = Modifier.fillMaxSize()) { + viewItems?.forEach { viewItem -> + item { + CoinInvestmentHeader(viewItem.amount, viewItem.info) - Spacer(modifier = Modifier.height(12.dp)) - } - item { - CellSingleLineLawrenceSection(viewItem.fundViewItems) { fundViewItem -> - CoinInvestmentFund(fundViewItem) { onClickFundUrl(fundViewItem.url) } + Spacer(modifier = Modifier.height(12.dp)) + } + item { + CellSingleLineLawrenceSection(viewItem.fundViewItems) { fundViewItem -> + CoinInvestmentFund(fundViewItem) { + onClickFundUrl( + fundViewItem.url + ) + } + } + Spacer(modifier = Modifier.height(24.dp)) } - Spacer(modifier = Modifier.height(24.dp)) } } } - } - null -> {} + null -> {} + } } } - } + ) } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/ranks/CoinRankFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/ranks/CoinRankFragment.kt index 7513520197..5f7ecd473b 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/ranks/CoinRankFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/ranks/CoinRankFragment.kt @@ -3,7 +3,6 @@ package io.horizontalsystems.bankwallet.modules.coin.ranks import androidx.compose.animation.Crossfade import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer @@ -19,6 +18,7 @@ import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Divider +import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -105,17 +105,25 @@ private fun CoinRankScreen( val uiState = viewModel.uiState val viewItems = viewModel.uiState.rankViewItems - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Button_Close), - icon = R.drawable.ic_close, - onClick = { navController.popBackStack() } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Button_Close), + icon = R.drawable.ic_close, + onClick = { navController.popBackStack() } + ) ) ) - ) - Crossfade(uiState.viewState, label = "") { viewItemState -> + } + ) { padding -> + Crossfade( + targetState = uiState.viewState, + modifier = Modifier.padding(padding), + label = "" + ) { viewItemState -> when (viewItemState) { ViewState.Loading -> { Loading() diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/reports/CoinReportsFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/reports/CoinReportsFragment.kt index 5dea81fb86..046c2c1cc2 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/reports/CoinReportsFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/reports/CoinReportsFragment.kt @@ -2,13 +2,13 @@ package io.horizontalsystems.bankwallet.modules.coin.reports import android.os.Parcelable import androidx.compose.animation.Crossfade -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -62,51 +62,62 @@ private fun CoinReportsScreen( val isRefreshing by viewModel.isRefreshingLiveData.observeAsState(false) val reportViewItems by viewModel.reportViewItemsLiveData.observeAsState() - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.CoinPage_Reports), - navigationIcon = { - HsBackButton(onClick = onClickNavigation) - } - ) + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.CoinPage_Reports), + navigationIcon = { + HsBackButton(onClick = onClickNavigation) + } + ) + } + ) { padding -> HSSwipeRefresh( refreshing = isRefreshing, - onRefresh = viewModel::refresh - ) { - Crossfade(viewState) { viewState -> - when (viewState) { - ViewState.Loading -> { - Loading() - } + modifier = Modifier + .padding(padding) + .fillMaxSize(), + onRefresh = viewModel::refresh, + content = { + Crossfade(viewState, label = "") { viewState -> + when (viewState) { + ViewState.Loading -> { + Loading() + } - is ViewState.Error -> { - ListErrorView(stringResource(R.string.SyncError), viewModel::onErrorClick) - } + is ViewState.Error -> { + ListErrorView( + stringResource(R.string.SyncError), + viewModel::onErrorClick + ) + } - ViewState.Success -> { - LazyColumn(modifier = Modifier.fillMaxSize()) { - reportViewItems?.let { - items(it) { report -> - Spacer(modifier = Modifier.height(12.dp)) - CellNews( - source = report.author, - title = report.title, - body = report.body, - date = report.date, - ) { - onClickReportUrl(report.url) + ViewState.Success -> { + LazyColumn(modifier = Modifier.fillMaxSize()) { + reportViewItems?.let { + items(it) { report -> + Spacer(modifier = Modifier.height(12.dp)) + CellNews( + source = report.author, + title = report.title, + body = report.body, + date = report.date, + ) { + onClickReportUrl(report.url) + } + } + item { + Spacer(modifier = Modifier.height(12.dp)) } - } - item { - Spacer(modifier = Modifier.height(12.dp)) } } } - } - null -> {} + null -> {} + } } } - } + ) } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/treasuries/CoinTreasuriesFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/treasuries/CoinTreasuriesFragment.kt index 8ba8c6b920..64eccffc85 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/treasuries/CoinTreasuriesFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/treasuries/CoinTreasuriesFragment.kt @@ -1,18 +1,17 @@ package io.horizontalsystems.bankwallet.modules.coin.treasuries import androidx.compose.animation.Crossfade -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -43,6 +42,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.ListErrorView import io.horizontalsystems.bankwallet.ui.compose.components.MarketCoinFirstRow import io.horizontalsystems.bankwallet.ui.compose.components.SectionItemBorderedRowUniversalClear import io.horizontalsystems.bankwallet.ui.compose.components.SortMenu +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_jacob @@ -64,87 +64,101 @@ class CoinTreasuriesFragment : BaseComposeFragment() { val viewState by viewModel.viewStateLiveData.observeAsState() val isRefreshing by viewModel.isRefreshingLiveData.observeAsState(false) val treasuriesData by viewModel.coinTreasuriesLiveData.observeAsState() - val chainSelectorDialogState by viewModel.treasuryTypeSelectorDialogStateLiveData.observeAsState(TvlModule.SelectorDialogState.Closed) + val chainSelectorDialogState by viewModel.treasuryTypeSelectorDialogStateLiveData.observeAsState( + TvlModule.SelectorDialogState.Closed + ) - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.CoinPage_Treasuries), - navigationIcon = { - HsBackButton(onClick = { findNavController().popBackStack() }) - } - ) + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.CoinPage_Treasuries), + navigationIcon = { + HsBackButton(onClick = { findNavController().popBackStack() }) + } + ) + } + ) { paddingValues -> HSSwipeRefresh( refreshing = isRefreshing, + modifier = Modifier.padding(paddingValues), onRefresh = { viewModel.refresh() - } - ) { - Crossfade(viewState) { viewState -> - when (viewState) { - ViewState.Loading -> { - Loading() - } - - is ViewState.Error -> { - ListErrorView(stringResource(R.string.SyncError), viewModel::onErrorClick) - } + }, + content = { + Crossfade(viewState, label = "") { viewState -> + when (viewState) { + ViewState.Loading -> { + Loading() + } - ViewState.Success -> { - LazyColumn(modifier = Modifier.fillMaxSize()) { - treasuriesData?.let { treasuriesData -> - item { - CoinTreasuriesMenu( - treasuryTypeSelect = treasuriesData.treasuryTypeSelect, - sortDescending = treasuriesData.sortDescending, - onClickTreasuryTypeSelector = viewModel::onClickTreasuryTypeSelector, - onToggleSortType = viewModel::onToggleSortType - ) - } + is ViewState.Error -> { + ListErrorView( + stringResource(R.string.SyncError), + viewModel::onErrorClick + ) + } - items(treasuriesData.coinTreasuries) { item -> - SectionItemBorderedRowUniversalClear( - borderBottom = true - ) { - HsImage( - url = item.fundLogoUrl, - modifier = Modifier - .padding(end = 16.dp) - .size(32.dp) + ViewState.Success -> { + LazyColumn(modifier = Modifier.fillMaxSize()) { + treasuriesData?.let { treasuriesData -> + item { + CoinTreasuriesMenu( + treasuryTypeSelect = treasuriesData.treasuryTypeSelect, + sortDescending = treasuriesData.sortDescending, + onClickTreasuryTypeSelector = viewModel::onClickTreasuryTypeSelector, + onToggleSortType = viewModel::onToggleSortType ) - Column( - modifier = Modifier.fillMaxWidth() + } + + items(treasuriesData.coinTreasuries) { item -> + SectionItemBorderedRowUniversalClear( + borderBottom = true ) { - MarketCoinFirstRow(item.fund, item.amount) - Spacer(modifier = Modifier.height(3.dp)) - CoinTreasurySecondRow(item.country, item.amountInCurrency) + HsImage( + url = item.fundLogoUrl, + modifier = Modifier + .padding(end = 16.dp) + .size(32.dp) + ) + Column( + modifier = Modifier.fillMaxWidth() + ) { + MarketCoinFirstRow(item.fund, item.amount) + VSpacer(3.dp) + CoinTreasurySecondRow( + item.country, + item.amountInCurrency + ) + } } } - } - item { - Spacer(modifier = Modifier.height(32.dp)) - CellFooter(text = stringResource(id = R.string.CoinPage_Treasuries_PoweredBy)) + item { + VSpacer(32.dp) + CellFooter(text = stringResource(id = R.string.CoinPage_Treasuries_PoweredBy)) + } } } } - } - null -> {} + null -> {} + } } - } - // chain selector dialog - when (val option = chainSelectorDialogState) { - is CoinTreasuriesModule.SelectorDialogState.Opened -> { - AlertGroup( - R.string.CoinPage_Treasuries_FilterTitle, - option.select, - viewModel::onSelectTreasuryType, - viewModel::onTreasuryTypeSelectorDialogDismiss - ) + // chain selector dialog + when (val option = chainSelectorDialogState) { + is CoinTreasuriesModule.SelectorDialogState.Opened -> { + AlertGroup( + R.string.CoinPage_Treasuries_FilterTitle, + option.select, + viewModel::onSelectTreasuryType, + viewModel::onTreasuryTypeSelectorDialogDismiss + ) + } } } - } + ) } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/AddressScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/AddressScreen.kt index 01cb885358..dbb2ae703e 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/AddressScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/AddressScreen.kt @@ -1,6 +1,5 @@ package io.horizontalsystems.bankwallet.modules.contacts.screen -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -11,6 +10,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope @@ -31,6 +31,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.FormsInput import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.body_lucian import io.horizontalsystems.bankwallet.ui.compose.components.subhead1_leah import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey @@ -71,74 +72,79 @@ fun AddressScreen( ) } ) { - Column( - modifier = Modifier - .fillMaxSize() - .background(color = ComposeAppTheme.colors.tyler) - ) { - AppBar( - title = uiState.headerTitle.getString(), - navigationIcon = { - HsBackButton(onNavigateToBack) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Button_Done), - enabled = uiState.doneEnabled, - onClick = { - uiState.addressState?.dataOrNull?.let { - onDone(ContactAddress(uiState.blockchain, it.hex)) + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = uiState.headerTitle.getString(), + navigationIcon = { + HsBackButton(onNavigateToBack) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Button_Done), + enabled = uiState.doneEnabled, + onClick = { + uiState.addressState?.dataOrNull?.let { + onDone(ContactAddress(uiState.blockchain, it.hex)) + } } - } + ) ) ) - ) - - Spacer(modifier = Modifier.height(12.dp)) + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + ) { + Spacer(modifier = Modifier.height(12.dp)) - CellUniversalLawrenceSection( - listOf { - RowUniversal( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp), - onClick = if (uiState.canChangeBlockchain) onNavigateToBlockchainSelector else null - ) { - subhead2_grey( - text = stringResource(R.string.AddToken_Blockchain), - modifier = Modifier.weight(1f) - ) - subhead1_leah( - text = uiState.blockchain.name, - modifier = Modifier.padding(horizontal = 8.dp) - ) - if (uiState.canChangeBlockchain) { - Icon( - painter = painterResource(id = R.drawable.ic_down_arrow_20), - contentDescription = null, - tint = ComposeAppTheme.colors.grey + CellUniversalLawrenceSection( + listOf { + RowUniversal( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + onClick = if (uiState.canChangeBlockchain) onNavigateToBlockchainSelector else null + ) { + subhead2_grey( + text = stringResource(R.string.AddToken_Blockchain), + modifier = Modifier.weight(1f) + ) + subhead1_leah( + text = uiState.blockchain.name, + modifier = Modifier.padding(horizontal = 8.dp) ) + if (uiState.canChangeBlockchain) { + Icon( + painter = painterResource(id = R.drawable.ic_down_arrow_20), + contentDescription = null, + tint = ComposeAppTheme.colors.grey + ) + } } } - } - ) + ) - Spacer(modifier = Modifier.height(32.dp)) + VSpacer(32.dp) - FormsInput( - modifier = Modifier.padding(horizontal = 16.dp), - initial = uiState.address, - hint = stringResource(R.string.Contacts_AddressHint), - state = uiState.addressState, - qrScannerEnabled = true, - ) { - viewModel.onEnterAddress(it) - } - if (uiState.showDelete) { - Spacer(modifier = Modifier.height(32.dp)) - DeleteAddressButton { - coroutineScope.launch { - modalBottomSheetState.show() + FormsInput( + modifier = Modifier.padding(horizontal = 16.dp), + initial = uiState.address, + hint = stringResource(R.string.Contacts_AddressHint), + state = uiState.addressState, + qrScannerEnabled = true, + ) { + viewModel.onEnterAddress(it) + } + if (uiState.showDelete) { + VSpacer(32.dp) + DeleteAddressButton { + coroutineScope.launch { + modalBottomSheetState.show() + } } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactScreen.kt index 1743a9dc14..4d50b72f6a 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactScreen.kt @@ -2,10 +2,8 @@ package io.horizontalsystems.bankwallet.modules.contacts.screen import androidx.activity.compose.BackHandler import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -17,6 +15,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -56,6 +55,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.body_jacob import io.horizontalsystems.bankwallet.ui.compose.components.body_leah import io.horizontalsystems.bankwallet.ui.compose.components.body_lucian @@ -155,29 +155,32 @@ fun ContactScreen( } } - Column( - modifier = Modifier - .fillMaxSize() - .background(color = ComposeAppTheme.colors.tyler) - ) { - AppBar( - title = uiState.headerTitle.getString(), - navigationIcon = { - HsBackButton { - confirmNavigateToBack() - } - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Button_Save), - enabled = uiState.saveEnabled, - onClick = viewModel::onSave + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = uiState.headerTitle.getString(), + navigationIcon = { + HsBackButton { + confirmNavigateToBack() + } + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Button_Save), + enabled = uiState.saveEnabled, + onClick = viewModel::onSave + ) ) ) - ) - - Column(modifier = Modifier.verticalScroll(rememberScrollState())) { - Spacer(Modifier.height(12.dp)) + } + ) { paddingValues -> + Column( + modifier = Modifier + .padding(paddingValues) + .verticalScroll(rememberScrollState()) + ) { + VSpacer(12.dp) FormsInput( modifier = Modifier .focusRequester(focusRequester) @@ -210,7 +213,7 @@ fun ContactScreen( } ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactsScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactsScreen.kt index e6b2671adf..95311667ba 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactsScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/contacts/screen/ContactsScreen.kt @@ -4,10 +4,9 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.Image -import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -17,6 +16,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -48,6 +48,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.ScreenMessageWithAc import io.horizontalsystems.bankwallet.ui.compose.components.SearchBar import io.horizontalsystems.bankwallet.ui.compose.components.SelectorDialogCompose import io.horizontalsystems.bankwallet.ui.compose.components.SelectorItem +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.body_leah import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey import io.horizontalsystems.core.SnackbarDuration @@ -166,112 +167,120 @@ fun ContactsScreen( } ) { - Column( - modifier = Modifier - .fillMaxSize() - .background(color = ComposeAppTheme.colors.tyler) - ) { - SearchBar( - title = stringResource(R.string.Contacts), - searchHintText = stringResource(R.string.Market_Search_Hint), - menuItems = buildList { - if (uiState.showAddContact) { - add( - MenuItem( - title = TranslatableString.ResString(R.string.Contacts_NewContact), - icon = R.drawable.icon_user_plus, - tint = ComposeAppTheme.colors.jacob, - onClick = onNavigateToCreateContact + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + SearchBar( + title = stringResource(R.string.Contacts), + searchHintText = stringResource(R.string.Market_Search_Hint), + menuItems = buildList { + if (uiState.showAddContact) { + add( + MenuItem( + title = TranslatableString.ResString(R.string.Contacts_NewContact), + icon = R.drawable.icon_user_plus, + tint = ComposeAppTheme.colors.jacob, + onClick = onNavigateToCreateContact + ) ) - ) - } - if (uiState.showMoreOptions) { - add( - MenuItem( - title = TranslatableString.ResString(R.string.Contacts_ActionMore), - icon = R.drawable.ic_more2_20, - tint = ComposeAppTheme.colors.jacob, - enabled = true, - onClick = { - showMoreSelectorDialog = true - } + } + if (uiState.showMoreOptions) { + add( + MenuItem( + title = TranslatableString.ResString(R.string.Contacts_ActionMore), + icon = R.drawable.ic_more2_20, + tint = ComposeAppTheme.colors.jacob, + enabled = true, + onClick = { + showMoreSelectorDialog = true + } + ) ) - ) + } + }, + onClose = onNavigateToBack, + onSearchTextChanged = { text -> + viewModel.onEnterQuery(text) } - }, - onClose = onNavigateToBack, - onSearchTextChanged = { text -> - viewModel.onEnterQuery(text) - } - ) - if (uiState.contacts.isNotEmpty()) { - Column(modifier = Modifier.verticalScroll(rememberScrollState())) { - Spacer(Modifier.height(12.dp)) - CellUniversalLawrenceSection(uiState.contacts) { contact -> - Contact(contact) { - if (viewModel.shouldShowReplaceWarning(contact)) { - coroutineScope.launch { - bottomSheetType = ContactsScreenBottomSheetType.ReplaceAddressConfirmation - selectedContact = contact - bottomSheetState.show() + ) + } + ) { paddingValues -> + Box( + modifier = Modifier + .fillMaxWidth() + .padding(paddingValues) + ) { + if (uiState.contacts.isNotEmpty()) { + Column(modifier = Modifier.verticalScroll(rememberScrollState())) { + VSpacer(12.dp) + CellUniversalLawrenceSection(uiState.contacts) { contact -> + Contact(contact) { + if (viewModel.shouldShowReplaceWarning(contact)) { + coroutineScope.launch { + bottomSheetType = + ContactsScreenBottomSheetType.ReplaceAddressConfirmation + selectedContact = contact + bottomSheetState.show() + } + } else { + onNavigateToContact(contact) } - } else { - onNavigateToContact(contact) } } + VSpacer(32.dp) } - Spacer(Modifier.height(32.dp)) - } - } else { - if (uiState.searchMode) { - ListEmptyView( - text = stringResource(R.string.EmptyResults), - icon = R.drawable.ic_not_found - ) } else { - ScreenMessageWithAction( - text = stringResource(R.string.Contacts_NoContacts), - icon = R.drawable.icon_user_plus - ) { - ButtonPrimaryYellow( - modifier = Modifier - .padding(horizontal = 48.dp) - .fillMaxWidth(), - title = stringResource(R.string.Contacts_AddNewContact), - onClick = onNavigateToCreateContact + if (uiState.searchMode) { + ListEmptyView( + text = stringResource(R.string.EmptyResults), + icon = R.drawable.ic_not_found ) + } else { + ScreenMessageWithAction( + text = stringResource(R.string.Contacts_NoContacts), + icon = R.drawable.icon_user_plus + ) { + ButtonPrimaryYellow( + modifier = Modifier + .padding(horizontal = 48.dp) + .fillMaxWidth(), + title = stringResource(R.string.Contacts_AddNewContact), + onClick = onNavigateToCreateContact + ) + } } } - } - if (showMoreSelectorDialog) { - SelectorDialogCompose( - title = stringResource(R.string.Contacts_ActionMore), - items = ContactsModule.ContactsAction.values().map { - (SelectorItem(stringResource(it.title), false, it)) - }, - onDismissRequest = { - showMoreSelectorDialog = false - }, - onSelectItem = { action -> - when (action) { - ContactsModule.ContactsAction.Restore -> { - if (viewModel.shouldShowRestoreWarning()) { - coroutineScope.launch { - bottomSheetType = ContactsScreenBottomSheetType.RestoreContactsConfirmation - bottomSheetState.show() + if (showMoreSelectorDialog) { + SelectorDialogCompose( + title = stringResource(R.string.Contacts_ActionMore), + items = ContactsModule.ContactsAction.values().map { + (SelectorItem(stringResource(it.title), false, it)) + }, + onDismissRequest = { + showMoreSelectorDialog = false + }, + onSelectItem = { action -> + when (action) { + ContactsModule.ContactsAction.Restore -> { + if (viewModel.shouldShowRestoreWarning()) { + coroutineScope.launch { + bottomSheetType = + ContactsScreenBottomSheetType.RestoreContactsConfirmation + bottomSheetState.show() + } + } else { + restoreLauncher.launch(arrayOf("application/json")) } - } else { - restoreLauncher.launch(arrayOf("application/json")) } - } - ContactsModule.ContactsAction.Backup -> { - App.pinComponent.keepUnlocked() - backupLauncher.launch(viewModel.backupFileName) + ContactsModule.ContactsAction.Backup -> { + App.pinComponent.keepUnlocked() + backupLauncher.launch(viewModel.backupFileName) + } } - } - }) + }) + } } } } @@ -291,7 +300,12 @@ fun Contact( text = contact.name, maxLines = 1 ) - subhead2_grey(text = stringResource(R.string.Contacts_AddressesCount, contact.addresses.size)) + subhead2_grey( + text = stringResource( + R.string.Contacts_AddressesCount, + contact.addresses.size + ) + ) } Image( modifier = Modifier.size(20.dp), diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainFragment.kt index 1e85bc4152..ab26473d10 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainFragment.kt @@ -153,83 +153,87 @@ private fun MainScreen( ) }, ) { - Box(Modifier.fillMaxSize()) { - Scaffold( - backgroundColor = ComposeAppTheme.colors.tyler, - bottomBar = { - Column { - if (uiState.torEnabled) { - TorStatusView() - } - HsBottomNavigation( - backgroundColor = ComposeAppTheme.colors.tyler, - elevation = 10.dp - ) { - uiState.mainNavItems.forEach { item -> - HsBottomNavigationItem( - icon = { - BadgedIcon(item.badge) { - Icon( - painter = painterResource(item.mainNavItem.iconRes), - contentDescription = stringResource(item.mainNavItem.titleRes) - ) - } - }, - selected = item.selected, - enabled = item.enabled, - selectedContentColor = ComposeAppTheme.colors.jacob, - unselectedContentColor = if (item.enabled) ComposeAppTheme.colors.grey else ComposeAppTheme.colors.grey50, - onClick = { - viewModel.onSelect(item.mainNavItem) + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + bottomBar = { + Column { + if (uiState.torEnabled) { + TorStatusView() + } + HsBottomNavigation( + backgroundColor = ComposeAppTheme.colors.tyler, + elevation = 10.dp + ) { + uiState.mainNavItems.forEach { item -> + HsBottomNavigationItem( + icon = { + BadgedIcon(item.badge) { + Icon( + painter = painterResource(item.mainNavItem.iconRes), + contentDescription = stringResource(item.mainNavItem.titleRes) + ) + } + }, + selected = item.selected, + enabled = item.enabled, + selectedContentColor = ComposeAppTheme.colors.jacob, + unselectedContentColor = if (item.enabled) ComposeAppTheme.colors.grey else ComposeAppTheme.colors.grey50, + onClick = { + viewModel.onSelect(item.mainNavItem) - stat(page = StatPage.Main, event = StatEvent.SwitchTab(item.mainNavItem.statTab)) - }, - onLongClick = { - if (item.mainNavItem == MainNavigation.Balance) { - coroutineScope.launch { - modalBottomSheetState.show() + stat( + page = StatPage.Main, + event = StatEvent.SwitchTab(item.mainNavItem.statTab) + ) + }, + onLongClick = { + if (item.mainNavItem == MainNavigation.Balance) { + coroutineScope.launch { + modalBottomSheetState.show() - stat(page = StatPage.Main, event = StatEvent.Open(StatPage.SwitchWallet)) - } + stat( + page = StatPage.Main, + event = StatEvent.Open(StatPage.SwitchWallet) + ) } } - ) - } + } + ) } } } - ) { - BackHandler(enabled = modalBottomSheetState.isVisible) { - coroutineScope.launch { - modalBottomSheetState.hide() - } + } + ) { + BackHandler(enabled = modalBottomSheetState.isVisible) { + coroutineScope.launch { + modalBottomSheetState.hide() } - Column(modifier = Modifier.padding(it)) { - LaunchedEffect(key1 = selectedPage, block = { - pagerState.scrollToPage(selectedPage) - }) + } + Column(modifier = Modifier.padding(it)) { + LaunchedEffect(key1 = selectedPage, block = { + pagerState.scrollToPage(selectedPage) + }) - HorizontalPager( - modifier = Modifier.weight(1f), - state = pagerState, - userScrollEnabled = false, - verticalAlignment = Alignment.Top - ) { page -> - when (uiState.mainNavItems[page].mainNavItem) { - MainNavigation.Market -> MarketScreen(fragmentNavController) - MainNavigation.Balance -> BalanceScreen(fragmentNavController) - MainNavigation.Transactions -> TransactionsScreen( - fragmentNavController, - transactionsViewModel - ) + HorizontalPager( + modifier = Modifier.weight(1f), + state = pagerState, + userScrollEnabled = false, + verticalAlignment = Alignment.Top + ) { page -> + when (uiState.mainNavItems[page].mainNavItem) { + MainNavigation.Market -> MarketScreen(fragmentNavController) + MainNavigation.Balance -> BalanceScreen(fragmentNavController) + MainNavigation.Transactions -> TransactionsScreen( + fragmentNavController, + transactionsViewModel + ) - MainNavigation.Settings -> SettingsScreen(fragmentNavController) - } + MainNavigation.Settings -> SettingsScreen(fragmentNavController) } } } - HideContentBox(uiState.contentHidden) } + HideContentBox(uiState.contentHidden) } if (uiState.showWhatsNew) { @@ -304,7 +308,10 @@ private fun HideContentBox(contentHidden: Boolean) { } else { Modifier } - Box(Modifier.fillMaxSize().then(backgroundModifier)) + Box( + Modifier + .fillMaxSize() + .then(backgroundModifier)) } @Composable diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/evmprivatekey/EvmPrivateKeyFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/evmprivatekey/EvmPrivateKeyFragment.kt index 03eb160288..3b1aa6ef8e 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/evmprivatekey/EvmPrivateKeyFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/evmprivatekey/EvmPrivateKeyFragment.kt @@ -1,17 +1,15 @@ package io.horizontalsystems.bankwallet.modules.manageaccount.evmprivatekey import android.os.Parcelable -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope @@ -37,6 +35,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.AppBar import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.helpers.TextHelper import io.horizontalsystems.core.helpers.HudHelper import kotlinx.coroutines.launch @@ -91,44 +90,57 @@ private fun EvmPrivateKeyScreen( ) } ) { - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.EvmPrivateKey_Title), - navigationIcon = { - HsBackButton(onClick = navController::popBackStack) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Info_Title), - icon = R.drawable.ic_info_24, - onClick = { - FaqManager.showFaqPage(navController, FaqManager.faqPathPrivateKeys) - - stat(page = StatPage.EvmPrivateKey, event = StatEvent.Open(StatPage.Info)) - } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.EvmPrivateKey_Title), + navigationIcon = { + HsBackButton(onClick = navController::popBackStack) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Info_Title), + icon = R.drawable.ic_info_24, + onClick = { + FaqManager.showFaqPage(navController, FaqManager.faqPathPrivateKeys) + stat( + page = StatPage.EvmPrivateKey, + event = StatEvent.Open(StatPage.Info) + ) + } + ) ) ) - ) - + } + ) { paddingValues -> Column( - modifier = Modifier - .weight(1f) - .verticalScroll(rememberScrollState()), - verticalArrangement = Arrangement.Top + modifier = Modifier.padding(paddingValues), ) { - Spacer(Modifier.height(12.dp)) - TextImportantWarning( - modifier = Modifier.padding(horizontal = 16.dp), - text = stringResource(R.string.PrivateKeys_NeverShareWarning) - ) - Spacer(Modifier.height(24.dp)) - HidableContent(evmPrivateKey, stringResource(R.string.EvmPrivateKey_ShowPrivateKey)) { - stat(page = StatPage.EvmPrivateKey, event = StatEvent.ToggleHidden) + Column( + modifier = Modifier + .weight(1f) + .verticalScroll(rememberScrollState()), + verticalArrangement = Arrangement.Top + ) { + VSpacer(12.dp) + TextImportantWarning( + modifier = Modifier.padding(horizontal = 16.dp), + text = stringResource(R.string.PrivateKeys_NeverShareWarning) + ) + VSpacer(24.dp) + HidableContent( + evmPrivateKey, + stringResource(R.string.EvmPrivateKey_ShowPrivateKey) + ) { + stat(page = StatPage.EvmPrivateKey, event = StatEvent.ToggleHidden) + } } - } - ActionButton(R.string.Alert_Copy) { - coroutineScope.launch { - sheetState.show() + + ActionButton(R.string.Alert_Copy) { + coroutineScope.launch { + sheetState.show() + } } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/recoveryphrase/RecoveryPhraseFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/recoveryphrase/RecoveryPhraseFragment.kt index fb77129149..6e63e520d3 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/recoveryphrase/RecoveryPhraseFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/recoveryphrase/RecoveryPhraseFragment.kt @@ -1,16 +1,13 @@ package io.horizontalsystems.bankwallet.modules.manageaccount.recoveryphrase -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -43,6 +40,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.AppBar import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.helpers.TextHelper import io.horizontalsystems.core.helpers.HudHelper import kotlinx.coroutines.launch @@ -95,49 +93,56 @@ private fun RecoveryPhraseScreen( ) } ) { - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.RecoveryPhrase_Title), - navigationIcon = { - HsBackButton(onClick = navController::popBackStack) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Info_Title), - icon = R.drawable.ic_info_24, - onClick = { - FaqManager.showFaqPage(navController, FaqManager.faqPathPrivateKeys) - - stat(page = StatPage.RecoveryPhrase, event = StatEvent.Open(StatPage.Info)) - } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.RecoveryPhrase_Title), + navigationIcon = { + HsBackButton(onClick = navController::popBackStack) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Info_Title), + icon = R.drawable.ic_info_24, + onClick = { + FaqManager.showFaqPage(navController, FaqManager.faqPathPrivateKeys) + stat( + page = StatPage.RecoveryPhrase, + event = StatEvent.Open(StatPage.Info) + ) + } + ) ) ) - ) - + } + ) { paddingValues -> Column( - modifier = Modifier - .weight(1f) - .verticalScroll(rememberScrollState()), - verticalArrangement = Arrangement.Top + modifier = Modifier.padding(paddingValues), ) { - Spacer(Modifier.height(12.dp)) - TextImportantWarning( - modifier = Modifier.padding(horizontal = 16.dp), - text = stringResource(R.string.PrivateKeys_NeverShareWarning) - ) - Spacer(Modifier.height(24.dp)) - var hidden by remember { mutableStateOf(true) } - SeedPhraseList(viewModel.wordsNumbered, hidden) { - hidden = !hidden - - stat(page = StatPage.RecoveryPhrase, event = StatEvent.ToggleHidden) + Column( + modifier = Modifier + .weight(1f) + .verticalScroll(rememberScrollState()), + ) { + VSpacer(12.dp) + TextImportantWarning( + modifier = Modifier.padding(horizontal = 16.dp), + text = stringResource(R.string.PrivateKeys_NeverShareWarning) + ) + VSpacer(24.dp) + var hidden by remember { mutableStateOf(true) } + SeedPhraseList(viewModel.wordsNumbered, hidden) { + hidden = !hidden + stat(page = StatPage.RecoveryPhrase, event = StatEvent.ToggleHidden) + } + VSpacer(24.dp) + PassphraseCell(viewModel.passphrase, hidden) } - Spacer(Modifier.height(24.dp)) - PassphraseCell(viewModel.passphrase, hidden) - } - ActionButton(R.string.Alert_Copy) { - coroutineScope.launch { - sheetState.show() + ActionButton(R.string.Alert_Copy) { + coroutineScope.launch { + sheetState.show() + } } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/showextendedkey/ShowExtendedKeyFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/showextendedkey/ShowExtendedKeyFragment.kt index 230276f805..e5d8fdfd73 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/showextendedkey/ShowExtendedKeyFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/manageaccount/showextendedkey/ShowExtendedKeyFragment.kt @@ -1,13 +1,11 @@ package io.horizontalsystems.bankwallet.modules.manageaccount.showextendedkey import android.os.Parcelable -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState @@ -16,6 +14,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -56,6 +55,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal import io.horizontalsystems.bankwallet.ui.compose.components.SelectorDialogCompose import io.horizontalsystems.bankwallet.ui.compose.components.SelectorItem import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.body_leah import io.horizontalsystems.bankwallet.ui.compose.components.subhead1_grey import io.horizontalsystems.bankwallet.ui.helpers.TextHelper @@ -133,144 +133,154 @@ private fun ShowExtendedKeyScreen( ) } ) { - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = viewModel.title.getString(), - navigationIcon = { - HsBackButton(onClick = navController::popBackStack) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Info_Title), - icon = R.drawable.ic_info_24, - onClick = { - FaqManager.showFaqPage(navController, FaqManager.faqPathPrivateKeys) - - viewModel.logEvent(StatEvent.Open(StatPage.Info)) - } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = viewModel.title.getString(), + navigationIcon = { + HsBackButton(onClick = navController::popBackStack) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Info_Title), + icon = R.drawable.ic_info_24, + onClick = { + FaqManager.showFaqPage(navController, FaqManager.faqPathPrivateKeys) + viewModel.logEvent(StatEvent.Open(StatPage.Info)) + } + ) ) ) - ) - + } + ) { paddingValues -> Column( - modifier = Modifier - .weight(1f) - .verticalScroll(rememberScrollState()), - verticalArrangement = Arrangement.Top + modifier = Modifier.padding(paddingValues), ) { - Spacer(Modifier.height(12.dp)) + Column( + modifier = Modifier + .weight(1f) + .verticalScroll(rememberScrollState()), + verticalArrangement = Arrangement.Top + ) { + VSpacer(12.dp) - if (viewModel.displayKeyType.isPrivate) { - TextImportantWarning( - modifier = Modifier.padding(horizontal = 16.dp), - text = stringResource(R.string.PrivateKeys_NeverShareWarning) - ) - Spacer(Modifier.height(24.dp)) - } - - var showBlockchainSelectorDialog by remember { mutableStateOf(false) } - var showPurposeSelectorDialog by remember { mutableStateOf(false) } - var showAccountSelectorDialog by remember { mutableStateOf(false) } - - val menuItems = buildList<@Composable () -> Unit> { - add { - MenuItem( - title = stringResource(R.string.ExtendedKey_Purpose), - value = viewModel.purpose.name, - onClick = if (viewModel.displayKeyType == DisplayKeyType.Bip32RootKey || viewModel.displayKeyType.isDerivable) { - { showPurposeSelectorDialog = true } - } else { - null - } + if (viewModel.displayKeyType.isPrivate) { + TextImportantWarning( + modifier = Modifier.padding(horizontal = 16.dp), + text = stringResource(R.string.PrivateKeys_NeverShareWarning) ) + VSpacer(24.dp) } - if (viewModel.displayKeyType.isDerivable) { + + var showBlockchainSelectorDialog by remember { mutableStateOf(false) } + var showPurposeSelectorDialog by remember { mutableStateOf(false) } + var showAccountSelectorDialog by remember { mutableStateOf(false) } + + val menuItems = buildList<@Composable () -> Unit> { add { MenuItem( - title = stringResource(R.string.ExtendedKey_Blockchain), - value = viewModel.blockchain.name, - onClick = { showBlockchainSelectorDialog = true } + title = stringResource(R.string.ExtendedKey_Purpose), + value = viewModel.purpose.name, + onClick = if (viewModel.displayKeyType == DisplayKeyType.Bip32RootKey || viewModel.displayKeyType.isDerivable) { + { showPurposeSelectorDialog = true } + } else { + null + } ) } - add { - MenuItem( - title = stringResource(R.string.ExtendedKey_Account), - value = viewModel.account.toString(), - infoButtonClick = { - navController.slideFromBottom(R.id.кeyAccountInfoFragment) - }, - onClick = { showAccountSelectorDialog = true } - ) + if (viewModel.displayKeyType.isDerivable) { + add { + MenuItem( + title = stringResource(R.string.ExtendedKey_Blockchain), + value = viewModel.blockchain.name, + onClick = { showBlockchainSelectorDialog = true } + ) + } + add { + MenuItem( + title = stringResource(R.string.ExtendedKey_Account), + value = viewModel.account.toString(), + infoButtonClick = { + navController.slideFromBottom(R.id.кeyAccountInfoFragment) + }, + onClick = { showAccountSelectorDialog = true } + ) + } } } - } - if (menuItems.isNotEmpty()) { - CellUniversalLawrenceSection(menuItems) - } - - Spacer(Modifier.height(32.dp)) - if (viewModel.displayKeyType.isPrivate) { - HidableContent(viewModel.extendedKey, stringResource(R.string.ExtendedKey_TapToShowPrivateKey)) { - viewModel.logEvent(StatEvent.ToggleHidden) + if (menuItems.isNotEmpty()) { + CellUniversalLawrenceSection(menuItems) } - } else { - HidableContent(viewModel.extendedKey) - } - if (showPurposeSelectorDialog) { - SelectorDialogCompose( - title = stringResource(R.string.ExtendedKey_Purpose), - items = viewModel.purposes.map { - SelectorItem(it.name, it == viewModel.purpose, it) - }, - onDismissRequest = { - showPurposeSelectorDialog = false - }, - onSelectItem = { - viewModel.set(it) + VSpacer(32.dp) + if (viewModel.displayKeyType.isPrivate) { + HidableContent( + viewModel.extendedKey, + stringResource(R.string.ExtendedKey_TapToShowPrivateKey) + ) { + viewModel.logEvent(StatEvent.ToggleHidden) } - ) - } - if (showBlockchainSelectorDialog) { - SelectorDialogCompose( - title = stringResource(R.string.ExtendedKey_Blockchain), - items = viewModel.blockchains.map { - SelectorItem(it.name, it == viewModel.blockchain, it) - }, - onDismissRequest = { - showBlockchainSelectorDialog = false - }, - onSelectItem = { - viewModel.set(it) - } - ) + } else { + HidableContent(viewModel.extendedKey) + } + + if (showPurposeSelectorDialog) { + SelectorDialogCompose( + title = stringResource(R.string.ExtendedKey_Purpose), + items = viewModel.purposes.map { + SelectorItem(it.name, it == viewModel.purpose, it) + }, + onDismissRequest = { + showPurposeSelectorDialog = false + }, + onSelectItem = { + viewModel.set(it) + } + ) + } + if (showBlockchainSelectorDialog) { + SelectorDialogCompose( + title = stringResource(R.string.ExtendedKey_Blockchain), + items = viewModel.blockchains.map { + SelectorItem(it.name, it == viewModel.blockchain, it) + }, + onDismissRequest = { + showBlockchainSelectorDialog = false + }, + onSelectItem = { + viewModel.set(it) + } + ) + } + if (showAccountSelectorDialog) { + SelectorDialogCompose( + title = stringResource(R.string.ExtendedKey_Account), + items = viewModel.accounts.map { + SelectorItem(it.toString(), it == viewModel.account, it) + }, + onDismissRequest = { + showAccountSelectorDialog = false + }, + onSelectItem = { + viewModel.set(it) + } + ) + } } - if (showAccountSelectorDialog) { - SelectorDialogCompose( - title = stringResource(R.string.ExtendedKey_Account), - items = viewModel.accounts.map { - SelectorItem(it.toString(), it == viewModel.account, it) - }, - onDismissRequest = { - showAccountSelectorDialog = false - }, - onSelectItem = { - viewModel.set(it) + + ActionButton(R.string.Alert_Copy) { + if (viewModel.displayKeyType.isPrivate) { + coroutineScope.launch { + sheetState.show() } - ) - } - } - ActionButton(R.string.Alert_Copy) { - if (viewModel.displayKeyType.isPrivate) { - coroutineScope.launch { - sheetState.show() - } - } else { - TextHelper.copyText(viewModel.extendedKey) - HudHelper.showSuccessMessage(view, R.string.Hud_Text_Copied) + } else { + TextHelper.copyText(viewModel.extendedKey) + HudHelper.showSuccessMessage(view, R.string.Hud_Text_Copied) - viewModel.logEvent(StatEvent.Copy(StatEntity.Key)) + viewModel.logEvent(StatEvent.Copy(StatEntity.Key)) + } } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/filters/MarketFiltersFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/filters/MarketFiltersFragment.kt index 1d1011b0f3..a1b1f566c3 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/filters/MarketFiltersFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/filters/MarketFiltersFragment.kt @@ -17,7 +17,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue -import androidx.compose.material.Surface +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -107,8 +107,9 @@ private fun AdvancedSearchScreen( ) }, ) { - Surface(color = ComposeAppTheme.colors.tyler) { - Column { + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { AppBar( title = stringResource(R.string.Market_Filters), navigationIcon = { @@ -121,7 +122,11 @@ private fun AdvancedSearchScreen( ) ), ) - + } + ) { paddingValues -> + Column( + modifier = Modifier.padding(paddingValues) + ) { Column( modifier = Modifier .weight(1f) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/restoreaccount/restoreblockchains/RestoreBlockchains.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/restoreaccount/restoreblockchains/RestoreBlockchains.kt index 83aa1e1f29..5e845120d4 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/restoreaccount/restoreblockchains/RestoreBlockchains.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/restoreaccount/restoreblockchains/RestoreBlockchains.kt @@ -2,7 +2,6 @@ package io.horizontalsystems.bankwallet.modules.restoreaccount.restoreblockchain import android.widget.Toast import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -10,7 +9,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material.Divider @@ -18,6 +16,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -45,6 +44,7 @@ import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme import io.horizontalsystems.bankwallet.ui.compose.TranslatableString import io.horizontalsystems.bankwallet.ui.compose.components.AppBar import io.horizontalsystems.bankwallet.ui.compose.components.CellMultilineClear +import io.horizontalsystems.bankwallet.ui.compose.components.HSpacer import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.HsIconButton import io.horizontalsystems.bankwallet.ui.compose.components.HsSwitch @@ -153,24 +153,29 @@ fun ManageWalletsScreen( } }, ) { - Column( - modifier = Modifier.background(color = ComposeAppTheme.colors.tyler) - ) { - AppBar( - title = stringResource(R.string.Restore_Title), - navigationIcon = { - HsBackButton(onClick = onBackClick) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Button_Restore), - onClick = { viewModel.onRestore() }, - enabled = doneButtonEnabled - ) - ), - ) - - LazyColumn { + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.Restore_Title), + navigationIcon = { + HsBackButton(onClick = onBackClick) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Button_Restore), + onClick = { viewModel.onRestore() }, + enabled = doneButtonEnabled + ) + ), + ) + } + ) { paddingValues -> + LazyColumn( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + ) { item { Spacer(modifier = Modifier.height(12.dp)) Divider( @@ -208,7 +213,7 @@ fun ManageWalletsScreen( modifier = Modifier.padding(top = 1.dp) ) } - Spacer(Modifier.width(12.dp)) + HSpacer(12.dp) if (viewItem.hasSettings) { HsIconButton( onClick = { viewModel.onClickSettings(viewItem.item) } @@ -233,7 +238,10 @@ fun ManageWalletsScreen( } } -private fun onItemClick(viewItem: CoinViewItem, viewModel: RestoreBlockchainsViewModel) { +private fun onItemClick( + viewItem: CoinViewItem, + viewModel: RestoreBlockchainsViewModel +) { if (viewItem.enabled) { viewModel.disable(viewItem.item) } else { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/advanced/SendBtcAdvancedSettingsScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/advanced/SendBtcAdvancedSettingsScreen.kt index c954a58785..5b19856cfb 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/advanced/SendBtcAdvancedSettingsScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/advanced/SendBtcAdvancedSettingsScreen.kt @@ -1,6 +1,5 @@ package io.horizontalsystems.bankwallet.modules.send.bitcoin.advanced -import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box @@ -16,6 +15,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -51,6 +51,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantError import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.body_leah import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey import io.horizontalsystems.bankwallet.ui.extensions.BottomSheetHeader @@ -101,25 +102,33 @@ fun SendBtcAdvancedSettingsScreen( ) }, ) { - Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) { - AppBar( - title = stringResource(R.string.Send_Advanced), - navigationIcon = { - HsBackButton(onClick = { navController.popBackStack() }) - }, - menuItems = listOf( - MenuItem( - title = TranslatableString.ResString(R.string.Button_Reset), - onClick = { - sendBitcoinViewModel.reset() - viewModel.reset() - } + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { + AppBar( + title = stringResource(R.string.Send_Advanced), + navigationIcon = { + HsBackButton(onClick = { navController.popBackStack() }) + }, + menuItems = listOf( + MenuItem( + title = TranslatableString.ResString(R.string.Button_Reset), + onClick = { + sendBitcoinViewModel.reset() + viewModel.reset() + } + ) ) ) - ) - Column(modifier = Modifier.verticalScroll(rememberScrollState())) { + } + ) { paddingValues -> + Column( + modifier = Modifier + .padding(paddingValues) + .verticalScroll(rememberScrollState()) + ) { - Spacer(modifier = Modifier.height(12.dp)) + VSpacer(12.dp) CellUniversalLawrenceSection( listOf { HSFeeRaw( @@ -133,8 +142,8 @@ fun SendBtcAdvancedSettingsScreen( } ) - if(feeRateVisible) { - Spacer(modifier = Modifier.height(24.dp)) + if (feeRateVisible) { + VSpacer(24.dp) EvmSettingsInput( title = stringResource(R.string.FeeSettings_FeeRate), info = stringResource(R.string.FeeSettings_FeeRate_Info), @@ -157,7 +166,7 @@ fun SendBtcAdvancedSettingsScreen( ) } - Spacer(modifier = Modifier.height(24.dp)) + VSpacer(24.dp) TransactionDataSortSettings( navController, viewModel.uiState.transactionSortTitle, @@ -168,7 +177,7 @@ fun SendBtcAdvancedSettingsScreen( } if (lockTimeEnabled) { - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf { HSHodlerInput( @@ -185,7 +194,7 @@ fun SendBtcAdvancedSettingsScreen( ) } - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf { UtxoSwitch( @@ -198,7 +207,7 @@ fun SendBtcAdvancedSettingsScreen( text = stringResource(R.string.Send_Utxo_Description), ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection { RbfSwitch( enabled = viewModel.uiState.rbfEnabled, @@ -212,12 +221,16 @@ fun SendBtcAdvancedSettingsScreen( feeRateCaution?.let { FeeRateCaution( - modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 12.dp), + modifier = Modifier.padding( + start = 16.dp, + end = 16.dp, + top = 12.dp + ), feeRateCaution = it ) } - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) } } } @@ -362,6 +375,7 @@ fun FeeRateCaution(modifier: Modifier, feeRateCaution: HSCaution) { text = feeRateCaution.getDescription() ?: "" ) } + HSCaution.Type.Warning -> { TextImportantWarning( modifier = modifier, 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 daad2da520..d6ccb2e482 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 @@ -23,7 +23,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue -import androidx.compose.material.Surface +import androidx.compose.material.Scaffold import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -92,21 +92,22 @@ fun AppearanceScreen(navController: NavController) { var openBalanceValueSelector by rememberSaveable { mutableStateOf(false) } var openPriceChangeIntervalSelector by rememberSaveable { mutableStateOf(false) } - Surface(color = ComposeAppTheme.colors.tyler) { - ModalBottomSheetLayout( - sheetState = sheetState, - sheetBackgroundColor = ComposeAppTheme.colors.transparent, - sheetContent = { - AppCloseWarningBottomSheet( - onCloseClick = { scope.launch { sheetState.hide() } }, - onChangeClick = { - selectedAppIcon?.let { viewModel.onEnterAppIcon(it) } - scope.launch { sheetState.hide() } - } - ) - } - ) { - Column { + ModalBottomSheetLayout( + sheetState = sheetState, + sheetBackgroundColor = ComposeAppTheme.colors.transparent, + sheetContent = { + AppCloseWarningBottomSheet( + onCloseClick = { scope.launch { sheetState.hide() } }, + onChangeClick = { + selectedAppIcon?.let { viewModel.onEnterAppIcon(it) } + scope.launch { sheetState.hide() } + } + ) + } + ) { + Scaffold( + backgroundColor = ComposeAppTheme.colors.tyler, + topBar = { AppBar( title = stringResource(R.string.Settings_Appearance), navigationIcon = { @@ -114,160 +115,161 @@ fun AppearanceScreen(navController: NavController) { }, menuItems = listOf(), ) + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .padding(paddingValues), + ) { + VSpacer(height = 12.dp) + CellUniversalLawrenceSection( + listOf { + MenuItemWithDialog( + R.string.Settings_Theme, + value = uiState.selectedTheme.title.getString(), + onClick = { openThemeSelector = true } + ) + } + ) + + VSpacer(24.dp) - Column( - modifier = Modifier - .fillMaxSize() - .verticalScroll(rememberScrollState()), - ) { - VSpacer(height = 12.dp) - CellUniversalLawrenceSection( - listOf { + HeaderText(text = stringResource(id = R.string.Appearance_MarketsTab)) + CellUniversalLawrenceSection( + listOf( + { + RowUniversal( + modifier = Modifier.padding(horizontal = 16.dp), + ) { + body_leah( + text = stringResource(id = R.string.Appearance_HideMarketsTab), + modifier = Modifier + .weight(1f) + .padding(end = 16.dp) + ) + HsSwitch( + checked = uiState.marketsTabHidden, + onCheckedChange = { + viewModel.onSetMarketTabsHidden(it) + } + ) + } + }, + { MenuItemWithDialog( - R.string.Settings_Theme, - value = uiState.selectedTheme.title.getString(), - onClick = { openThemeSelector = true } + R.string.Appearance_PriceChangeInterval, + value = uiState.priceChangeInterval.title.getString(), + onClick = { openPriceChangeIntervalSelector = true } ) } ) + ) - VSpacer(24.dp) - - HeaderText(text = stringResource(id = R.string.Appearance_MarketsTab)) - CellUniversalLawrenceSection( - listOf ( - { - RowUniversal( - modifier = Modifier.padding(horizontal = 16.dp), - ) { - body_leah( - text = stringResource(id = R.string.Appearance_HideMarketsTab), - modifier = Modifier - .weight(1f) - .padding(end = 16.dp) - ) - HsSwitch( - checked = uiState.marketsTabHidden, - onCheckedChange = { - viewModel.onSetMarketTabsHidden(it) - } - ) - } - }, - { + AnimatedVisibility(visible = !uiState.marketsTabHidden) { + Column { + VSpacer(32.dp) + CellUniversalLawrenceSection( + listOf { MenuItemWithDialog( - R.string.Appearance_PriceChangeInterval, - value = uiState.priceChangeInterval.title.getString(), - onClick = { openPriceChangeIntervalSelector = true } + R.string.Settings_LaunchScreen, + value = uiState.selectedLaunchScreen.title.getString(), + onClick = { openLaunchPageSelector = true } ) } ) - ) - - AnimatedVisibility(visible = !uiState.marketsTabHidden) { - Column { - VSpacer(32.dp) - CellUniversalLawrenceSection( - listOf { - MenuItemWithDialog( - R.string.Settings_LaunchScreen, - value = uiState.selectedLaunchScreen.title.getString(), - onClick = { openLaunchPageSelector = true } - ) - } - ) - } } + } - VSpacer(24.dp) - HeaderText(text = stringResource(id = R.string.Appearance_BalanceTab)) - CellUniversalLawrenceSection( - listOf( - { - RowUniversal( - modifier = Modifier.padding(horizontal = 16.dp), - ) { - body_leah( - text = stringResource(id = R.string.Appearance_HideBalanceTabButtons), - modifier = Modifier - .weight(1f) - .padding(end = 16.dp) - ) - HsSwitch( - checked = uiState.balanceTabButtonsHidden, - onCheckedChange = { - viewModel.onSetBalanceTabButtonsHidden(it) - } - ) - } - }, - { - MenuItemWithDialog( - R.string.Appearance_BalanceValue, - value = uiState.selectedBalanceViewType.title.getString(), - onClick = { openBalanceValueSelector = true } + VSpacer(24.dp) + HeaderText(text = stringResource(id = R.string.Appearance_BalanceTab)) + CellUniversalLawrenceSection( + listOf( + { + RowUniversal( + modifier = Modifier.padding(horizontal = 16.dp), + ) { + body_leah( + text = stringResource(id = R.string.Appearance_HideBalanceTabButtons), + modifier = Modifier + .weight(1f) + .padding(end = 16.dp) + ) + HsSwitch( + checked = uiState.balanceTabButtonsHidden, + onCheckedChange = { + viewModel.onSetBalanceTabButtonsHidden(it) + } ) } - ) + }, + { + MenuItemWithDialog( + R.string.Appearance_BalanceValue, + value = uiState.selectedBalanceViewType.title.getString(), + onClick = { openBalanceValueSelector = true } + ) + } ) + ) - VSpacer(24.dp) - HeaderText(text = stringResource(id = R.string.Appearance_AppIcon)) - AppIconSection(uiState.appIconOptions) { - scope.launch { - selectedAppIcon = it - sheetState.show() - } + VSpacer(24.dp) + HeaderText(text = stringResource(id = R.string.Appearance_AppIcon)) + AppIconSection(uiState.appIconOptions) { + scope.launch { + selectedAppIcon = it + sheetState.show() } - - VSpacer(32.dp) } + + VSpacer(32.dp) } - //Dialogs - if (openThemeSelector) { - AlertGroup( - R.string.Settings_Theme, - uiState.themeOptions, - { selected -> - viewModel.onEnterTheme(selected) - openThemeSelector = false - }, - { openThemeSelector = false } - ) - } - if (openLaunchPageSelector) { - AlertGroup( - R.string.Settings_LaunchScreen, - uiState.launchScreenOptions, - { selected -> - viewModel.onEnterLaunchPage(selected) - openLaunchPageSelector = false - }, - { openLaunchPageSelector = false } - ) - } - if (openBalanceValueSelector) { - AlertGroup( - R.string.Appearance_BalanceValue, - uiState.balanceViewTypeOptions, - { selected -> - viewModel.onEnterBalanceViewType(selected) - openBalanceValueSelector = false - }, - { openBalanceValueSelector = false } - ) - } - if (openPriceChangeIntervalSelector) { - AlertGroup( - R.string.Appearance_PriceChangeInterval, - uiState.priceChangeIntervalOptions, - { selected -> - viewModel.onSetPriceChangeInterval(selected) - openPriceChangeIntervalSelector = false - }, - { openPriceChangeIntervalSelector = false } - ) - } + } + //Dialogs + if (openThemeSelector) { + AlertGroup( + R.string.Settings_Theme, + uiState.themeOptions, + { selected -> + viewModel.onEnterTheme(selected) + openThemeSelector = false + }, + { openThemeSelector = false } + ) + } + if (openLaunchPageSelector) { + AlertGroup( + R.string.Settings_LaunchScreen, + uiState.launchScreenOptions, + { selected -> + viewModel.onEnterLaunchPage(selected) + openLaunchPageSelector = false + }, + { openLaunchPageSelector = false } + ) + } + if (openBalanceValueSelector) { + AlertGroup( + R.string.Appearance_BalanceValue, + uiState.balanceViewTypeOptions, + { selected -> + viewModel.onEnterBalanceViewType(selected) + openBalanceValueSelector = false + }, + { openBalanceValueSelector = false } + ) + } + if (openPriceChangeIntervalSelector) { + AlertGroup( + R.string.Appearance_PriceChangeInterval, + uiState.priceChangeIntervalOptions, + { selected -> + viewModel.onSetPriceChangeInterval(selected) + openPriceChangeIntervalSelector = false + }, + { openPriceChangeIntervalSelector = false } + ) } } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/ui/compose/HSSwipeRefresh.kt b/app/src/main/java/io/horizontalsystems/bankwallet/ui/compose/HSSwipeRefresh.kt index 80a9a91b61..ddba609d36 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/ui/compose/HSSwipeRefresh.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/ui/compose/HSSwipeRefresh.kt @@ -14,13 +14,14 @@ import androidx.compose.ui.Modifier @Composable fun HSSwipeRefresh( refreshing: Boolean, + modifier: Modifier = Modifier, onRefresh: () -> Unit, content: @Composable () -> Unit, ) { val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh) Box( - modifier = Modifier + modifier = modifier .fillMaxSize() .pullRefresh(pullRefreshState) ) { From aefa779a9c5474923a0e5988170f4ed23b0eaab5 Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 6 Jun 2024 16:24:03 +0600 Subject: [PATCH 3/6] Replace Listener with Coroutine Flow in BackgroundManager --- .../horizontalsystems/bankwallet/core/App.kt | 10 ++-- .../core/adapters/BitcoinBaseAdapter.kt | 44 +++++++++------ .../managers/BackgroundStateChangeListener.kt | 29 ---------- .../core/managers/BalanceHiddenManager.kt | 22 +++++--- .../core/managers/ConnectivityManager.kt | 31 ++++++++--- .../bankwallet/core/managers/EvmKitManager.kt | 39 +++++++------- .../core/managers/SolanaKitManager.kt | 46 ++++++++-------- .../core/managers/TronKitManager.kt | 50 ++++++++--------- .../bankwallet/core/stats/StatsManager.kt | 20 +++++++ .../favorites/MarketFavoritesService.kt | 16 +++--- .../market/overview/MarketOverviewService.kt | 16 +++--- .../modules/market/posts/MarketPostService.kt | 19 ++++--- .../bankwallet/modules/pin/PinComponent.kt | 32 +++++++++-- .../core/BackgroundManager.kt | 53 ++++++++----------- .../io/horizontalsystems/core/Interfaces.kt | 3 +- 15 files changed, 239 insertions(+), 191 deletions(-) delete mode 100644 app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BackgroundStateChangeListener.kt diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt index b202c98ba1..7cf9d25ef5 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt @@ -26,7 +26,6 @@ import io.horizontalsystems.bankwallet.core.managers.AccountCleaner import io.horizontalsystems.bankwallet.core.managers.AccountManager import io.horizontalsystems.bankwallet.core.managers.AdapterManager import io.horizontalsystems.bankwallet.core.managers.AppVersionManager -import io.horizontalsystems.bankwallet.core.managers.BackgroundStateChangeListener import io.horizontalsystems.bankwallet.core.managers.BackupManager import io.horizontalsystems.bankwallet.core.managers.BalanceHiddenManager import io.horizontalsystems.bankwallet.core.managers.BaseTokenManager @@ -141,7 +140,6 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory { lateinit var btcBlockchainManager: BtcBlockchainManager lateinit var wordsManager: WordsManager lateinit var networkManager: INetworkManager - lateinit var backgroundStateChangeListener: BackgroundStateChangeListener lateinit var appConfigProvider: AppConfigProvider lateinit var adapterManager: IAdapterManager lateinit var transactionAdapterManager: TransactionAdapterManager @@ -358,13 +356,11 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory { pinComponent = PinComponent( pinSettingsStorage = pinSettingsStorage, userManager = userManager, - pinDbStorage = PinDbStorage(appDatabase.pinDao()) + pinDbStorage = PinDbStorage(appDatabase.pinDao()), + backgroundManager = backgroundManager ) - statsManager = StatsManager(appDatabase.statsDao(), localStorage, marketKit, appConfigProvider) - backgroundStateChangeListener = BackgroundStateChangeListener(pinComponent, statsManager).apply { - backgroundManager.registerListener(this) - } + statsManager = StatsManager(appDatabase.statsDao(), localStorage, marketKit, appConfigProvider, backgroundManager) rateAppManager = RateAppManager(walletManager, adapterManager, localStorage) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt index 5c138a9add..da5a53bae2 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt @@ -32,6 +32,7 @@ import io.horizontalsystems.bitcoincore.storage.FullTransaction import io.horizontalsystems.bitcoincore.storage.UnspentOutput import io.horizontalsystems.bitcoincore.storage.UnspentOutputInfo import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.hodler.HodlerOutputData import io.horizontalsystems.hodler.HodlerPlugin import io.horizontalsystems.marketkit.models.Token @@ -40,6 +41,11 @@ import io.reactivex.Flowable import io.reactivex.Observable import io.reactivex.Single import io.reactivex.subjects.PublishSubject +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch import java.math.BigDecimal import java.math.RoundingMode import java.util.Date @@ -47,28 +53,16 @@ import java.util.Date abstract class BitcoinBaseAdapter( open val kit: AbstractKit, open val syncMode: BitcoinCore.SyncMode, - backgroundManager: BackgroundManager, + private val backgroundManager: BackgroundManager, val wallet: Wallet, private val confirmationsThreshold: Int, protected val decimal: Int = 8 -) : IAdapter, ITransactionsAdapter, IBalanceAdapter, IReceiveAdapter, BackgroundManager.Listener { +) : IAdapter, ITransactionsAdapter, IBalanceAdapter, IReceiveAdapter { - init { - backgroundManager.registerListener(this) - } + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) abstract val satoshisInBitcoin: BigDecimal - override fun willEnterForeground() { - super.willEnterForeground() - kit.onEnterForeground() - } - - override fun didEnterBackground() { - super.didEnterBackground() - kit.onEnterBackground() - } - // // Adapter implementation // @@ -173,10 +167,12 @@ abstract class BitcoinBaseAdapter( override fun start() { kit.start() + subscribeToEvents() } override fun stop() { kit.stop() + scope.cancel() } override fun refresh() { @@ -215,6 +211,24 @@ abstract class BitcoinBaseAdapter( } } + private fun subscribeToEvents() { + scope.launch { + backgroundManager.stateFlow.collect { state -> + when (state) { + BackgroundManagerState.EnterForeground -> { + kit.onEnterForeground() + } + BackgroundManagerState.EnterBackground -> { + kit.onEnterBackground() + } + BackgroundManagerState.AllActivitiesDestroyed -> { + + } + } + } + } + } + override fun getRawTransaction(transactionHash: String): String? { return kit.getRawTransaction(transactionHash) } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BackgroundStateChangeListener.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BackgroundStateChangeListener.kt deleted file mode 100644 index 1272c6c349..0000000000 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BackgroundStateChangeListener.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.horizontalsystems.bankwallet.core.managers - -import android.app.Activity -import io.horizontalsystems.bankwallet.core.stats.StatsManager -import io.horizontalsystems.bankwallet.modules.keystore.KeyStoreActivity -import io.horizontalsystems.bankwallet.modules.lockscreen.LockScreenActivity -import io.horizontalsystems.core.BackgroundManager -import io.horizontalsystems.core.IPinComponent - -class BackgroundStateChangeListener( - private val pinComponent: IPinComponent, - private val statsManager: StatsManager -) : BackgroundManager.Listener { - - override fun willEnterForeground(activity: Activity) { - pinComponent.willEnterForeground(activity) - - statsManager.sendStats() - } - - override fun didEnterBackground() { - pinComponent.didEnterBackground() - } - - override fun onAllActivitiesDestroyed() { - pinComponent.lock() - } - -} diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt index da49f21eb2..95a36233a3 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt @@ -2,14 +2,19 @@ package io.horizontalsystems.bankwallet.core.managers import io.horizontalsystems.bankwallet.core.ILocalStorage import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch class BalanceHiddenManager( private val localStorage: ILocalStorage, backgroundManager: BackgroundManager, -): BackgroundManager.Listener { +) { val balanceHidden: Boolean get() = localStorage.balanceHidden @@ -20,9 +25,16 @@ class BalanceHiddenManager( private val _balanceHiddenFlow = MutableStateFlow(localStorage.balanceHidden) val balanceHiddenFlow = _balanceHiddenFlow.asStateFlow() + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) init { - backgroundManager.registerListener(this) + scope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterBackground && balanceAutoHide) { + setBalanceHidden(true) + } + } + } if (balanceAutoHide) { setBalanceHidden(true) @@ -42,12 +54,6 @@ class BalanceHiddenManager( } } - override fun didEnterBackground() { - if (balanceAutoHide) { - setBalanceHidden(true) - } - } - private fun setBalanceHidden(hidden: Boolean) { localStorage.balanceHidden = hidden _balanceHiddenFlow.update { localStorage.balanceHidden } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt index 222cc65318..caf0f0b392 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt @@ -7,18 +7,23 @@ import android.net.NetworkCapabilities import android.net.NetworkRequest import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.reactivex.subjects.PublishSubject +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.launch -class ConnectivityManager(backgroundManager: BackgroundManager) : BackgroundManager.Listener { +class ConnectivityManager(backgroundManager: BackgroundManager) { private val connectivityManager: ConnectivityManager by lazy { App.instance.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager } - + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val _networkAvailabilityFlow = MutableSharedFlow(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) @@ -32,11 +37,24 @@ class ConnectivityManager(backgroundManager: BackgroundManager) : BackgroundMana private var hasConnection = false init { - backgroundManager.registerListener(this) + scope.launch { + backgroundManager.stateFlow.collect { state -> + when (state) { + BackgroundManagerState.EnterForeground -> { + willEnterForeground() + } + BackgroundManagerState.EnterBackground -> { + didEnterBackground() + } + BackgroundManagerState.AllActivitiesDestroyed -> { + //do nothing + } + } + } + } } - override fun willEnterForeground() { - super.willEnterForeground() + private fun willEnterForeground() { setInitialValues() try { connectivityManager.unregisterNetworkCallback(callback) @@ -46,8 +64,7 @@ class ConnectivityManager(backgroundManager: BackgroundManager) : BackgroundMana connectivityManager.registerNetworkCallback(NetworkRequest.Builder().build(), callback) } - override fun didEnterBackground() { - super.didEnterBackground() + private fun didEnterBackground() { try { connectivityManager.unregisterNetworkCallback(callback) } catch (e: Exception) { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmKitManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmKitManager.kt index 3ea7de6b6c..1558b449d8 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmKitManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/EvmKitManager.kt @@ -8,6 +8,7 @@ import io.horizontalsystems.bankwallet.core.supportedNftTypes import io.horizontalsystems.bankwallet.entities.Account import io.horizontalsystems.bankwallet.entities.AccountType import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.erc20kit.core.Erc20Kit import io.horizontalsystems.ethereumkit.core.EthereumKit import io.horizontalsystems.ethereumkit.core.signer.Signer @@ -30,20 +31,20 @@ import io.reactivex.subjects.BehaviorSubject import io.reactivex.subjects.PublishSubject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.rx2.asFlow import java.net.URI class EvmKitManager( val chain: Chain, - backgroundManager: BackgroundManager, + private val backgroundManager: BackgroundManager, private val syncSourceManager: EvmSyncSourceManager -) : BackgroundManager.Listener { +) { private val coroutineScope = CoroutineScope(Dispatchers.Default) + private var job: Job? = null init { - backgroundManager.registerListener(this) - coroutineScope.launch { syncSourceManager.syncSourceObservable.asFlow().collect { blockchain -> handleUpdateNetwork(blockchain) @@ -91,6 +92,7 @@ class EvmKitManager( evmKitWrapper = createKitInstance(accountType, account, blockchainType) useCount = 0 currentAccount = account + subscribeToEvents() } useCount++ @@ -178,25 +180,26 @@ class EvmKitManager( } } + private fun subscribeToEvents(){ + job = coroutineScope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + evmKitWrapper?.evmKit?.let { kit -> + Handler(Looper.getMainLooper()).postDelayed({ + kit.refresh() + }, 1000) + } + } + } + } + } + private fun stopEvmKit() { + job?.cancel() evmKitWrapper?.evmKit?.stop() evmKitWrapper = null currentAccount = null } - - // - // BackgroundManager.Listener - // - - override fun willEnterForeground() { - this.evmKitWrapper?.evmKit?.let { kit -> - Handler(Looper.getMainLooper()).postDelayed({ - kit.refresh() - }, 1000) - } - } - - override fun didEnterBackground() = Unit } val RpcSource.uris: List diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/SolanaKitManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/SolanaKitManager.kt index 53939f271d..0903090d20 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/SolanaKitManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/SolanaKitManager.kt @@ -8,6 +8,7 @@ import io.horizontalsystems.bankwallet.core.providers.AppConfigProvider import io.horizontalsystems.bankwallet.entities.Account import io.horizontalsystems.bankwallet.entities.AccountType import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.solanakit.Signer import io.horizontalsystems.solanakit.SolanaKit import io.reactivex.Observable @@ -22,10 +23,12 @@ class SolanaKitManager( private val appConfigProvider: AppConfigProvider, private val rpcSourceManager: SolanaRpcSourceManager, private val walletManager: SolanaWalletManager, - backgroundManager: BackgroundManager -) : BackgroundManager.Listener { + private val backgroundManager: BackgroundManager +) { private val coroutineScope = CoroutineScope(Dispatchers.Default) + private var backgroundEventListenerJob: Job? = null + private var rpcUpdatedJob: Job? = null private var tokenAccountJob: Job? = null var solanaKitWrapper: SolanaKitWrapper? = null @@ -41,16 +44,6 @@ class SolanaKitManager( val statusInfo: Map? get() = solanaKitWrapper?.solanaKit?.statusInfo() - init { - backgroundManager.registerListener(this) - - coroutineScope.launch { - rpcSourceManager.rpcSourceUpdateObservable.asFlow().collect { - handleUpdateNetwork() - } - } - } - private fun handleUpdateNetwork() { stopKit() @@ -75,6 +68,7 @@ class SolanaKitManager( else -> throw UnsupportedAccountException() } startKit() + subscribeToEvents() useCount = 0 currentAccount = account } @@ -135,6 +129,8 @@ class SolanaKitManager( solanaKitWrapper = null currentAccount = null tokenAccountJob?.cancel() + backgroundEventListenerJob?.cancel() + rpcUpdatedJob?.cancel() } private fun startKit() { @@ -148,19 +144,25 @@ class SolanaKitManager( } } - // - // BackgroundManager.Listener - // - - override fun willEnterForeground() { - this.solanaKitWrapper?.solanaKit?.let { kit -> - Handler(Looper.getMainLooper()).postDelayed({ - kit.refresh() - }, 1000) + private fun subscribeToEvents() { + backgroundEventListenerJob = coroutineScope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + solanaKitWrapper?.solanaKit?.let { kit -> + Handler(Looper.getMainLooper()).postDelayed({ + kit.refresh() + }, 1000) + } + } + } + } + rpcUpdatedJob = coroutineScope.launch { + rpcSourceManager.rpcSourceUpdateObservable.asFlow().collect { + handleUpdateNetwork() + } } } - override fun didEnterBackground() = Unit } class SolanaKitWrapper(val solanaKit: SolanaKit, val signer: Signer?) \ No newline at end of file diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt index 40c097c1f5..2be5af2144 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt @@ -8,18 +8,26 @@ import io.horizontalsystems.bankwallet.core.providers.AppConfigProvider import io.horizontalsystems.bankwallet.entities.Account import io.horizontalsystems.bankwallet.entities.AccountType import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.tronkit.TronKit import io.horizontalsystems.tronkit.models.Address import io.horizontalsystems.tronkit.network.Network import io.horizontalsystems.tronkit.transaction.Signer +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch class TronKitManager( private val appConfigProvider: AppConfigProvider, - backgroundManager: BackgroundManager -) : BackgroundManager.Listener { + private val backgroundManager: BackgroundManager +) { + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private var job: Job? = null private val network = Network.Mainnet private val _kitStartedFlow = MutableStateFlow(false) val kitStartedFlow: StateFlow = _kitStartedFlow @@ -38,14 +46,10 @@ class TronKitManager( val statusInfo: Map? get() = tronKitWrapper?.tronKit?.statusInfo() - init { - backgroundManager.registerListener(this) - } - @Synchronized fun getTronKitWrapper(account: Account): TronKitWrapper { if (this.tronKitWrapper != null && currentAccount != account) { - stopKit() + stop() } if (this.tronKitWrapper == null) { @@ -61,7 +65,7 @@ class TronKitManager( else -> throw UnsupportedAccountException() } - startKit() + start() useCount = 0 currentAccount = account } @@ -111,34 +115,32 @@ class TronKitManager( useCount -= 1 if (useCount < 1) { - stopKit() + stop() } } } - private fun stopKit() { + private fun stop() { tronKitWrapper?.tronKit?.stop() + job?.cancel() tronKitWrapper = null currentAccount = null } - private fun startKit() { + private fun start() { tronKitWrapper?.tronKit?.start() - } - - // - // BackgroundManager.Listener - // - - override fun willEnterForeground() { - this.tronKitWrapper?.tronKit?.let { kit -> - Handler(Looper.getMainLooper()).postDelayed({ - kit.refresh() - }, 1000) + job = scope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + tronKitWrapper?.tronKit?.let { kit -> + Handler(Looper.getMainLooper()).postDelayed({ + kit.refresh() + }, 1000) + } + } + } } } - - override fun didEnterBackground() = Unit } class TronKitWrapper(val tronKit: TronKit, val signer: Signer?) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt index 4f7d1e7cec..38e065d8c6 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt @@ -30,12 +30,18 @@ import io.horizontalsystems.bankwallet.modules.settings.appearance.PriceChangeIn import io.horizontalsystems.bankwallet.modules.theme.ThemeType import io.horizontalsystems.bankwallet.modules.transactionInfo.options.SpeedUpCancelType import io.horizontalsystems.bankwallet.modules.transactions.FilterTransactionType +import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.core.toHexString import io.horizontalsystems.hdwalletkit.HDExtendedKey import io.horizontalsystems.marketkit.models.HsTimePeriod +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch import java.time.Instant import java.util.concurrent.Executors @@ -48,7 +54,21 @@ class StatsManager( private val localStorage: ILocalStorage, private val marketKit: MarketKitWrapper, private val appConfigProvider: AppConfigProvider, + private val backgroundManager: BackgroundManager, ) { + + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + + init { + scope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + sendStats() + } + } + } + } + var uiStatsEnabled = getInitialUiStatsEnabled() private set diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/favorites/MarketFavoritesService.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/favorites/MarketFavoritesService.kt index 0b51b4a4c7..8c877d250e 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/favorites/MarketFavoritesService.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/favorites/MarketFavoritesService.kt @@ -10,6 +10,7 @@ import io.horizontalsystems.bankwallet.modules.market.category.MarketItemWrapper import io.horizontalsystems.bankwallet.modules.market.filters.TimePeriod import io.horizontalsystems.bankwallet.modules.market.sort import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.marketkit.models.Analytics import io.reactivex.Observable import io.reactivex.subjects.BehaviorSubject @@ -38,7 +39,7 @@ class MarketFavoritesService( private val currencyManager: CurrencyManager, private val backgroundManager: BackgroundManager, private val priceManager: PriceManager -) : BackgroundManager.Listener { +) { private val coroutineScope = CoroutineScope(Dispatchers.Default) private var favoritesJob: Job? = null private var marketItems: List = listOf() @@ -121,10 +122,6 @@ class MarketFavoritesService( } } - override fun willEnterForeground() { - fetch() - } - fun removeFavorite(uid: String) { repository.removeFavorite(uid) } @@ -137,7 +134,13 @@ class MarketFavoritesService( } fun start() { - backgroundManager.registerListener(this) + coroutineScope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + fetch() + } + } + } coroutineScope.launch { currencyManager.baseCurrencyUpdatedSignal.asFlow().collect { @@ -167,7 +170,6 @@ class MarketFavoritesService( } fun stop() { - backgroundManager.unregisterListener(this) coroutineScope.cancel() } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/overview/MarketOverviewService.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/overview/MarketOverviewService.kt index dd6a57ab04..96d5dc2dce 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/overview/MarketOverviewService.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/overview/MarketOverviewService.kt @@ -6,6 +6,7 @@ import io.horizontalsystems.bankwallet.modules.market.TimeDuration import io.horizontalsystems.bankwallet.modules.market.TopMarket import io.horizontalsystems.bankwallet.modules.market.topcoins.MarketTopMoversRepository import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.marketkit.models.MarketOverview import io.horizontalsystems.marketkit.models.TopMovers import io.reactivex.subjects.BehaviorSubject @@ -22,7 +23,7 @@ class MarketOverviewService( private val marketKit: MarketKitWrapper, private val backgroundManager: BackgroundManager, private val currencyManager: CurrencyManager -) : BackgroundManager.Listener { +) { private val coroutineScope = CoroutineScope(Dispatchers.Default) private var topMoversJob: Job? = null private var marketOverviewJob: Job? = null @@ -67,7 +68,13 @@ class MarketOverviewService( } fun start() { - backgroundManager.registerListener(this) + coroutineScope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + forceRefresh() + } + } + } coroutineScope.launch { currencyManager.baseCurrencyUpdatedSignal.asFlow().collect { @@ -79,14 +86,9 @@ class MarketOverviewService( } fun stop() { - backgroundManager.unregisterListener(this) coroutineScope.cancel() } - override fun willEnterForeground() { - forceRefresh() - } - fun refresh() { forceRefresh() } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/posts/MarketPostService.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/posts/MarketPostService.kt index 83ad41ddd2..3de4c03f65 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/posts/MarketPostService.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/market/posts/MarketPostService.kt @@ -3,6 +3,7 @@ package io.horizontalsystems.bankwallet.modules.market.posts import io.horizontalsystems.bankwallet.core.managers.MarketKitWrapper import io.horizontalsystems.bankwallet.entities.DataState import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.marketkit.models.Post import io.reactivex.Observable import io.reactivex.subjects.BehaviorSubject @@ -16,7 +17,7 @@ import kotlinx.coroutines.rx2.await class MarketPostService( private val marketKit: MarketKitWrapper, private val backgroundManager: BackgroundManager, -) : BackgroundManager.Listener { +) { private val coroutineScope = CoroutineScope(Dispatchers.Default) private var job: Job? = null @@ -24,10 +25,6 @@ class MarketPostService( val stateObservable: Observable>> get() = stateSubject - init { - backgroundManager.registerListener(this) - } - private fun fetchPosts() { job?.cancel() job = coroutineScope.launch { @@ -40,17 +37,19 @@ class MarketPostService( } } - override fun willEnterForeground() { - fetchPosts() - } - fun start() { fetchPosts() + coroutineScope.launch { + backgroundManager.stateFlow.collect { state -> + if (state == BackgroundManagerState.EnterForeground) { + fetchPosts() + } + } + } } fun stop() { coroutineScope.cancel() - backgroundManager.unregisterListener(this) } fun refresh() { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt index 0795b8085b..5bef457592 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt @@ -1,22 +1,48 @@ package io.horizontalsystems.bankwallet.modules.pin -import android.app.Activity import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.bankwallet.core.managers.UserManager import io.horizontalsystems.bankwallet.modules.pin.core.LockManager import io.horizontalsystems.bankwallet.modules.pin.core.PinDbStorage import io.horizontalsystems.bankwallet.modules.pin.core.PinManager +import io.horizontalsystems.core.BackgroundManager +import io.horizontalsystems.core.BackgroundManagerState import io.horizontalsystems.core.IPinComponent import io.horizontalsystems.core.IPinSettingsStorage import io.reactivex.BackpressureStrategy import io.reactivex.Flowable +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.launch class PinComponent( private val pinSettingsStorage: IPinSettingsStorage, private val userManager: UserManager, - private val pinDbStorage: PinDbStorage + private val pinDbStorage: PinDbStorage, + private val backgroundManager: BackgroundManager ) : IPinComponent { + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + + init { + scope.launch { + backgroundManager.stateFlow.collect { state -> + when (state) { + BackgroundManagerState.EnterForeground -> { + willEnterForeground() + } + BackgroundManagerState.EnterBackground -> { + didEnterBackground() + } + BackgroundManagerState.AllActivitiesDestroyed -> { + lock() + } + } + } + } + } + private val pinManager: PinManager by lazy { PinManager(pinDbStorage) } @@ -106,7 +132,7 @@ class PinComponent( appLockManager.updateLastExitDate() } - override fun willEnterForeground(activity: Activity) { + override fun willEnterForeground() { appLockManager.willEnterForeground() } diff --git a/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt b/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt index f39097199f..83eec365bb 100644 --- a/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt +++ b/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt @@ -3,46 +3,32 @@ package io.horizontalsystems.core import android.app.Activity import android.app.Application import android.os.Bundle +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.launch class BackgroundManager(application: Application) : Application.ActivityLifecycleCallbacks { + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val _stateFlow: MutableSharedFlow = MutableSharedFlow() + val stateFlow: SharedFlow + get() = _stateFlow + init { application.registerActivityLifecycleCallbacks(this) } - interface Listener { - fun willEnterForeground(activity: Activity) {} - fun willEnterForeground() {} - fun didEnterBackground() {} - fun onAllActivitiesDestroyed() {} - } - private var foregroundActivityCount: Int = 0 private var aliveActivityCount: Int = 0 - private var listeners: MutableList = ArrayList() - - @Synchronized - fun registerListener(listener: Listener) { - listeners.add(listener) - } - - @Synchronized - fun unregisterListener(listener: Listener) { - listeners.remove(listener) - } - - val inForeground: Boolean - get() = foregroundActivityCount > 0 - - val inBackground: Boolean - get() = foregroundActivityCount == 0 @Synchronized override fun onActivityStarted(activity: Activity) { if (foregroundActivityCount == 0) { - listeners.forEach { listener -> - listener.willEnterForeground(activity) - listener.willEnterForeground() + scope.launch { + _stateFlow.emit(BackgroundManagerState.EnterForeground) } } foregroundActivityCount++ @@ -54,10 +40,9 @@ class BackgroundManager(application: Application) : Application.ActivityLifecycl if (foregroundActivityCount == 0) { //App is in background - listeners.forEach { listener -> - listener.didEnterBackground() + scope.launch { + _stateFlow.emit(BackgroundManagerState.EnterBackground) } - } } @@ -71,8 +56,8 @@ class BackgroundManager(application: Application) : Application.ActivityLifecycl aliveActivityCount-- if (aliveActivityCount == 0) { - listeners.forEach { listener -> - listener.onAllActivitiesDestroyed() + scope.launch { + _stateFlow.emit(BackgroundManagerState.AllActivitiesDestroyed) } } } @@ -84,3 +69,7 @@ class BackgroundManager(application: Application) : Application.ActivityLifecycl override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} } + +enum class BackgroundManagerState { + EnterForeground, EnterBackground, AllActivitiesDestroyed +} \ No newline at end of file diff --git a/core/src/main/java/io/horizontalsystems/core/Interfaces.kt b/core/src/main/java/io/horizontalsystems/core/Interfaces.kt index e0535e2382..26598e0305 100644 --- a/core/src/main/java/io/horizontalsystems/core/Interfaces.kt +++ b/core/src/main/java/io/horizontalsystems/core/Interfaces.kt @@ -1,6 +1,5 @@ package io.horizontalsystems.core -import android.app.Activity import io.reactivex.Flowable import java.util.Date import javax.crypto.SecretKey @@ -37,7 +36,7 @@ interface IPinComponent { val isLocked: Boolean val pinSetFlowable: Flowable - fun willEnterForeground(activity: Activity) + fun willEnterForeground() fun didEnterBackground() fun setPin(pin: String) fun setDuressPin(pin: String) From 54a94ef6e0981903d9a97ef7baea0e3e4370566e Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 18 Jun 2024 15:16:00 +0600 Subject: [PATCH 4/6] Use `CoroutineScope(Dispatchers.Default)` for scope creation --- .../bankwallet/core/adapters/BitcoinBaseAdapter.kt | 3 +-- .../bankwallet/core/managers/BalanceHiddenManager.kt | 3 +-- .../bankwallet/core/managers/ConnectivityManager.kt | 3 +-- .../bankwallet/core/managers/CurrencyManager.kt | 3 +-- .../bankwallet/core/managers/TronKitManager.kt | 3 +-- .../io/horizontalsystems/bankwallet/core/stats/StatsManager.kt | 3 +-- .../bankwallet/modules/chart/ChartIndicatorManager.kt | 3 +-- .../bankwallet/modules/coin/coinmarkets/CoinMarketsService.kt | 3 +-- .../horizontalsystems/bankwallet/modules/pin/PinComponent.kt | 3 +-- .../main/java/io/horizontalsystems/core/BackgroundManager.kt | 3 +-- 10 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt index da5a53bae2..57beb31356 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BitcoinBaseAdapter.kt @@ -43,7 +43,6 @@ import io.reactivex.Single import io.reactivex.subjects.PublishSubject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import java.math.BigDecimal @@ -59,7 +58,7 @@ abstract class BitcoinBaseAdapter( protected val decimal: Int = 8 ) : IAdapter, ITransactionsAdapter, IBalanceAdapter, IReceiveAdapter { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) abstract val satoshisInBitcoin: BigDecimal diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt index 95a36233a3..05d419b932 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/BalanceHiddenManager.kt @@ -5,7 +5,6 @@ import io.horizontalsystems.core.BackgroundManager import io.horizontalsystems.core.BackgroundManagerState import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update @@ -25,7 +24,7 @@ class BalanceHiddenManager( private val _balanceHiddenFlow = MutableStateFlow(localStorage.balanceHidden) val balanceHiddenFlow = _balanceHiddenFlow.asStateFlow() - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) init { scope.launch { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt index caf0f0b392..c46205e307 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/ConnectivityManager.kt @@ -11,7 +11,6 @@ import io.horizontalsystems.core.BackgroundManagerState import io.reactivex.subjects.PublishSubject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow @@ -23,7 +22,7 @@ class ConnectivityManager(backgroundManager: BackgroundManager) { private val connectivityManager: ConnectivityManager by lazy { App.instance.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager } - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) private val _networkAvailabilityFlow = MutableSharedFlow(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/CurrencyManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/CurrencyManager.kt index 9f40fcd48d..09cd88a9e8 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/CurrencyManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/CurrencyManager.kt @@ -6,7 +6,6 @@ import io.horizontalsystems.bankwallet.entities.Currency import io.reactivex.subjects.PublishSubject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.asSharedFlow @@ -14,7 +13,7 @@ import kotlinx.coroutines.launch class CurrencyManager(private val localStorage: ILocalStorage, private val appConfigProvider: AppConfigProvider) { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) private val _baseCurrencyUpdatedFlow: MutableSharedFlow = MutableSharedFlow() val baseCurrencyUpdatedFlow: SharedFlow = _baseCurrencyUpdatedFlow.asSharedFlow() diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt index 2be5af2144..b10178194f 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TronKitManager.kt @@ -16,7 +16,6 @@ import io.horizontalsystems.tronkit.transaction.Signer import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update @@ -26,7 +25,7 @@ class TronKitManager( private val appConfigProvider: AppConfigProvider, private val backgroundManager: BackgroundManager ) { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) private var job: Job? = null private val network = Network.Mainnet private val _kitStartedFlow = MutableStateFlow(false) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt index 38e065d8c6..86ad74054f 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/stats/StatsManager.kt @@ -37,7 +37,6 @@ import io.horizontalsystems.hdwalletkit.HDExtendedKey import io.horizontalsystems.marketkit.models.HsTimePeriod import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update @@ -57,7 +56,7 @@ class StatsManager( private val backgroundManager: BackgroundManager, ) { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.IO) init { scope.launch { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/chart/ChartIndicatorManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/chart/ChartIndicatorManager.kt index a6749d0a20..325cdd40bb 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/chart/ChartIndicatorManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/chart/ChartIndicatorManager.kt @@ -4,7 +4,6 @@ import io.horizontalsystems.bankwallet.core.ILocalStorage import io.horizontalsystems.chartview.models.ChartIndicator import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.launch @@ -14,7 +13,7 @@ class ChartIndicatorManager( private val chartIndicatorSettingsDao: ChartIndicatorSettingsDao, private val localStorage: ILocalStorage ) { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) val isEnabled: Boolean get() = localStorage.chartIndicatorsEnabled private val _isEnabledFlow : MutableSharedFlow = MutableSharedFlow() diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/coinmarkets/CoinMarketsService.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/coinmarkets/CoinMarketsService.kt index 585dabb7aa..0ffca46038 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/coinmarkets/CoinMarketsService.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/coin/coinmarkets/CoinMarketsService.kt @@ -9,7 +9,6 @@ import io.horizontalsystems.marketkit.models.MarketTicker import io.reactivex.subjects.BehaviorSubject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import kotlinx.coroutines.rx2.await @@ -19,7 +18,7 @@ class CoinMarketsService( private val currencyManager: CurrencyManager, private val marketKit: MarketKitWrapper, ) { - private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val coroutineScope = CoroutineScope(Dispatchers.IO) private var marketTickers = listOf() private var verifiedType: VerifiedType = VerifiedType.All diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt index 5bef457592..abbc22ed41 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinComponent.kt @@ -13,7 +13,6 @@ import io.reactivex.BackpressureStrategy import io.reactivex.Flowable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch class PinComponent( @@ -23,7 +22,7 @@ class PinComponent( private val backgroundManager: BackgroundManager ) : IPinComponent { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) init { scope.launch { diff --git a/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt b/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt index 83eec365bb..ff360275f1 100644 --- a/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt +++ b/core/src/main/java/io/horizontalsystems/core/BackgroundManager.kt @@ -5,14 +5,13 @@ import android.app.Application import android.os.Bundle import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.launch class BackgroundManager(application: Application) : Application.ActivityLifecycleCallbacks { - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + private val scope = CoroutineScope(Dispatchers.Default) private val _stateFlow: MutableSharedFlow = MutableSharedFlow() val stateFlow: SharedFlow get() = _stateFlow From 38440cbb13ec64958defe3c1aeff913bd6434405 Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 18 Jun 2024 15:58:50 +0600 Subject: [PATCH 5/6] Update UtxoExpertMode page --- .../modules/send/bitcoin/SendBitcoinScreen.kt | 4 - .../utxoexpert/UtxoExpertModeScreen.kt | 116 ++++++--------- .../utxoexpert/UtxoExpertModeViewModel.kt | 133 +++++++----------- app/src/main/res/values/strings.xml | 3 + 4 files changed, 94 insertions(+), 162 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/SendBitcoinScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/SendBitcoinScreen.kt index 1cdddf6e74..06c076ff8e 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/SendBitcoinScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/SendBitcoinScreen.kt @@ -100,10 +100,6 @@ fun SendBitcoinNavHost( UtxoExpertModeScreen( adapter = viewModel.adapter, token = viewModel.wallet.token, - address = viewModel.uiState.address, - memo = viewModel.uiState.memo, - value = viewModel.uiState.amount, - feeRate = viewModel.uiState.feeRate, customUnspentOutputs = viewModel.customUnspentOutputs, updateUnspentOutputs = { viewModel.updateCustomUnspentOutputs(it) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeScreen.kt index eb9ff47112..db27ba133b 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeScreen.kt @@ -1,8 +1,10 @@ package io.horizontalsystems.bankwallet.modules.send.bitcoin.utxoexpert import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -10,6 +12,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Divider import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -21,33 +24,26 @@ import androidx.lifecycle.viewmodel.compose.viewModel import io.horizontalsystems.bankwallet.R import io.horizontalsystems.bankwallet.core.ISendBitcoinAdapter import io.horizontalsystems.bankwallet.core.shorten -import io.horizontalsystems.bankwallet.entities.Address -import io.horizontalsystems.bankwallet.modules.evmfee.ButtonsGroupWithShade import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme import io.horizontalsystems.bankwallet.ui.compose.components.AppBar -import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow +import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondaryTransparent +import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection import io.horizontalsystems.bankwallet.ui.compose.components.HSpacer import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.HsCheckbox import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal import io.horizontalsystems.bankwallet.ui.compose.components.SectionItemBorderedRowUniversalClear -import io.horizontalsystems.bankwallet.ui.compose.components.SectionUniversalItem import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_leah import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_lucian import io.horizontalsystems.bitcoincore.storage.UnspentOutputInfo import io.horizontalsystems.marketkit.models.Token -import java.math.BigDecimal @Composable fun UtxoExpertModeScreen( adapter: ISendBitcoinAdapter, token: Token, - address: Address?, - memo: String?, - value: BigDecimal?, - feeRate: Int?, customUnspentOutputs: List?, updateUnspentOutputs: (List) -> Unit, onBackClick: () -> Unit @@ -57,10 +53,6 @@ fun UtxoExpertModeScreen( factory = UtxoExpertModeModule.Factory( adapter, token, - address, - memo, - value, - feeRate, customUnspentOutputs ) ) @@ -83,13 +75,11 @@ fun UtxoExpertModeScreen( .padding(it) .fillMaxSize() ) { - Column( - modifier = Modifier.background(ComposeAppTheme.colors.lawrence) - ) { - UtxoInfoSection( - uiState.sendToInfo, - uiState.changeInfo, - uiState.feeInfo, + CellUniversalLawrenceSection { + UtxoInfoCell( + title = stringResource(R.string.Send_Utxo_AvailableBalance), + value = uiState.availableBalanceInfo.value, + subValue = uiState.availableBalanceInfo.subValue ) } Box( @@ -103,14 +93,39 @@ fun UtxoExpertModeScreen( } ) } - ButtonsGroupWithShade { - ButtonPrimaryYellow( - modifier = Modifier - .fillMaxWidth() - .padding(start = 16.dp, end = 16.dp), - title = stringResource(R.string.Button_Done), - onClick = onBackClick, + Box( + modifier = Modifier + .height(62.dp) + .fillMaxWidth() + ){ + Divider( + modifier = Modifier.fillMaxWidth(), + thickness = 1.dp, + color = ComposeAppTheme.colors.steel10 ) + Row( + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxSize(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + ButtonSecondaryTransparent( + title = stringResource(id = R.string.Send_Utxo_UnselectAll), + enabled = uiState.unselectAllIsEnabled, + onClick = { + viewModel.unselectAll() + updateUnspentOutputs(viewModel.customOutputs) + } + ) + ButtonSecondaryTransparent( + title = stringResource(id = R.string.Send_Utxo_SelectAll), + onClick = { + viewModel.selectAll() + updateUnspentOutputs(viewModel.customOutputs) + } + ) + } } } } @@ -150,53 +165,9 @@ private fun UtxoList( } } -@Composable -private fun UtxoInfoSection( - sendToInfo: UtxoExpertModeModule.InfoItem, - changeInfo: UtxoExpertModeModule.InfoItem?, - feeInfo: UtxoExpertModeModule.InfoItem -) { - val infoItems = buildList<@Composable () -> Unit> { - add { - UtxoInfoCell( - title = stringResource(R.string.Send_Utxo_SendTo), - subtitle = sendToInfo.subTitle, - value = sendToInfo.value, - subValue = sendToInfo.subValue - ) - } - changeInfo?.let { - add { - UtxoInfoCell( - title = stringResource(R.string.Send_Utxo_Change), - subtitle = changeInfo.subTitle, - value = changeInfo.value, - subValue = changeInfo.subValue - ) - } - } - add { - UtxoInfoCell( - title = stringResource(R.string.Send_Fee), - subtitle = feeInfo.subTitle, - value = feeInfo.value, - subValue = feeInfo.subValue - ) - } - } - infoItems.forEachIndexed { index, composable -> - SectionUniversalItem( - borderTop = index != 0, - ) { - composable() - } - } -} - @Composable private fun UtxoInfoCell( title: String, - subtitle: String?, value: String?, subValue: String? ) { @@ -211,9 +182,6 @@ private fun UtxoInfoCell( modifier = Modifier.weight(1f) ) { subhead2_leah(text = title) - subtitle?.let { - subhead2_grey(text = it) - } } Column( horizontalAlignment = Alignment.End diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeViewModel.kt index c05b300842..6fbe9d478f 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/bitcoin/utxoexpert/UtxoExpertModeViewModel.kt @@ -7,9 +7,7 @@ import cash.z.ecc.android.sdk.ext.collectWith import io.horizontalsystems.bankwallet.core.App import io.horizontalsystems.bankwallet.core.ISendBitcoinAdapter import io.horizontalsystems.bankwallet.core.ViewModelUiState -import io.horizontalsystems.bankwallet.core.shorten import io.horizontalsystems.bankwallet.core.toHexString -import io.horizontalsystems.bankwallet.entities.Address import io.horizontalsystems.bankwallet.modules.xrate.XRateService import io.horizontalsystems.bitcoincore.storage.UnspentOutputInfo import io.horizontalsystems.core.helpers.DateHelper @@ -20,30 +18,16 @@ import java.util.Date class UtxoExpertModeViewModel( private val adapter: ISendBitcoinAdapter, private val token: Token, - private val address: Address?, - private val memo: String?, - private val feeRate: Int?, - initialValue: BigDecimal?, initialCustomUnspentOutputs: List?, xRateService: XRateService, ) : ViewModelUiState() { - private var value = initialValue ?: BigDecimal.ZERO private var unspentOutputViewItems = listOf() private var selectedUnspentOutputs = listOf() private var coinRate = xRateService.getRate(token.coin.uid) - private var sendToInfo = UtxoExpertModeModule.InfoItem( - subTitle = address?.hex?.shorten(), - value = App.numberFormatter.formatCoinFull(value, token.coin.code, token.decimals), - subValue = coinRate?.let { rate -> - rate.copy(value = value.times(rate.value)).getFormattedFull() - } ?: "", - ) - private var changeInfo: UtxoExpertModeModule.InfoItem? = null - private var feeInfo = UtxoExpertModeModule.InfoItem( - subTitle = null, - value = null, - subValue = null, + private var availableBalanceInfo = UtxoExpertModeModule.InfoItem( + value = App.numberFormatter.formatCoinFull(BigDecimal.ZERO, token.coin.code, token.decimals), + subValue = "", ) val customOutputs: List @@ -57,73 +41,33 @@ class UtxoExpertModeViewModel( coinRate = it setUnspentOutputViewItems() } + setAvailableBalanceInfo() setUnspentOutputViewItems() - if (selectedUnspentOutputs.isNotEmpty()) { - updateFee() - } emitState() } override fun createState() = UtxoExpertModeModule.UiState( - sendToInfo = sendToInfo, - changeInfo = changeInfo, - feeInfo = feeInfo, + availableBalanceInfo = availableBalanceInfo, utxoItems = unspentOutputViewItems, + unselectAllIsEnabled = selectedUnspentOutputs.isNotEmpty(), ) private fun getUnspentId(unspentOutputInfo: UnspentOutputInfo) = "${unspentOutputInfo.transactionHash.toHexString()}-${unspentOutputInfo.outputIndex}" - fun onUnspentOutputClicked(id: String) { - selectedUnspentOutputs = if (selectedUnspentOutputs.contains(id)) { - selectedUnspentOutputs.filter { it != id } - } else { - selectedUnspentOutputs + id + private fun setAvailableBalanceInfo() { + var totalCoinValue = BigDecimal.ZERO + adapter.unspentOutputs.map { utxo -> + val utxoId = getUnspentId(utxo) + if (selectedUnspentOutputs.isEmpty() || selectedUnspentOutputs.contains(utxoId)) { + totalCoinValue += utxo.value.toBigDecimal().movePointLeft(token.decimals) + } } - unspentOutputViewItems = unspentOutputViewItems.map { utxo -> - utxo.copy(selected = selectedUnspentOutputs.contains(utxo.id)) - } - updateFee() - emitState() - } - - private fun updateFee() { - val feeRateNonNull = feeRate ?: return - val bitcoinFeeInfo = adapter.bitcoinFeeInfo( - amount = value, - feeRate = feeRateNonNull, - address = address?.hex, - memo = memo, - unspentOutputs = customOutputs, - pluginData = null, - ) - val fee = bitcoinFeeInfo?.fee - if (fee == null) { - feeInfo = feeInfo.copy( - value = null, - subValue = null, - ) - changeInfo = null - return - } - feeInfo = feeInfo.copy( - value = App.numberFormatter.formatCoinFull(fee, token.coin.code, token.decimals), + availableBalanceInfo = availableBalanceInfo.copy( + value = App.numberFormatter.formatCoinFull(totalCoinValue, token.coin.code, token.decimals), subValue = coinRate?.let { rate -> - rate.copy(value = fee.times(rate.value)).getFormattedFull() + rate.copy(value = totalCoinValue.times(rate.value)).getFormattedFull() } ?: "", ) - changeInfo = if (bitcoinFeeInfo.changeAddress != null && bitcoinFeeInfo.changeValue != null) { - val value = bitcoinFeeInfo.changeValue - UtxoExpertModeModule.InfoItem( - subTitle = bitcoinFeeInfo.changeAddress.stringValue.shorten(), - value = App.numberFormatter.formatCoinFull(value, token.coin.code, token.decimals), - subValue = coinRate?.let { rate -> - rate.copy(value = value.times(rate.value)).getFormattedFull() - } ?: "", - ) - } else { - null - } - emitState() } private fun setUnspentOutputViewItems() { @@ -144,6 +88,37 @@ class UtxoExpertModeViewModel( } } + private fun updateUtxoSelectedState() { + unspentOutputViewItems = unspentOutputViewItems.map { utxo -> + utxo.copy(selected = selectedUnspentOutputs.contains(utxo.id)) + } + } + + fun onUnspentOutputClicked(id: String) { + selectedUnspentOutputs = if (selectedUnspentOutputs.contains(id)) { + selectedUnspentOutputs.filter { it != id } + } else { + selectedUnspentOutputs + id + } + updateUtxoSelectedState() + setAvailableBalanceInfo() + emitState() + } + + fun unselectAll() { + selectedUnspentOutputs = listOf() + updateUtxoSelectedState() + setAvailableBalanceInfo() + emitState() + } + + fun selectAll() { + selectedUnspentOutputs = unspentOutputViewItems.map { it.id } + updateUtxoSelectedState() + setAvailableBalanceInfo() + emitState() + } + } object UtxoExpertModeModule { @@ -152,20 +127,12 @@ object UtxoExpertModeModule { class Factory( private val adapter: ISendBitcoinAdapter, private val token: Token, - private val address: Address?, - private val memo: String?, - private val value: BigDecimal?, - private val feeRate: Int?, private val customUnspentOutputs: List?, ) : ViewModelProvider.Factory { override fun create(modelClass: Class): T { return UtxoExpertModeViewModel( adapter = adapter, token = token, - address = address, - memo = memo, - feeRate = feeRate, - initialValue = value, initialCustomUnspentOutputs = customUnspentOutputs, xRateService = XRateService(App.marketKit, App.currencyManager.baseCurrency) ) as T @@ -173,14 +140,12 @@ object UtxoExpertModeModule { } data class UiState( - val sendToInfo: InfoItem, - val changeInfo: InfoItem?, - val feeInfo: InfoItem, + val availableBalanceInfo: InfoItem, val utxoItems: List, + val unselectAllIsEnabled: Boolean, ) data class InfoItem( - val subTitle: String?, val value: String?, val subValue: String?, ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d22f74b04c..6559e69253 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -472,6 +472,9 @@ This option allows you to resend a stuck transaction by increasing the amount of the fee. Enabled Disabled + Available Balance + Unsellect All + Sellect All Confirm Domain From 1821e3562cff1cc21da4d3e6a29e9b62e531e5ac Mon Sep 17 00:00:00 2001 From: chyngyz Date: Thu, 20 Jun 2024 12:56:56 +0600 Subject: [PATCH 6/6] Add '0x' prefix to transactionHash in WC send transaction response --- .../WCSendEthereumTransactionRequestViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/walletconnect/request/sendtransaction/WCSendEthereumTransactionRequestViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/walletconnect/request/sendtransaction/WCSendEthereumTransactionRequestViewModel.kt index e5d87e34d8..cd5d625d50 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/walletconnect/request/sendtransaction/WCSendEthereumTransactionRequestViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/walletconnect/request/sendtransaction/WCSendEthereumTransactionRequestViewModel.kt @@ -9,6 +9,7 @@ import io.horizontalsystems.bankwallet.core.ViewModelUiState import io.horizontalsystems.bankwallet.core.ethereum.CautionViewItem import io.horizontalsystems.bankwallet.core.ethereum.EvmCoinServiceFactory import io.horizontalsystems.bankwallet.core.providers.Translator +import io.horizontalsystems.bankwallet.core.toHexString import io.horizontalsystems.bankwallet.modules.multiswap.sendtransaction.SendTransactionData import io.horizontalsystems.bankwallet.modules.multiswap.sendtransaction.SendTransactionServiceEvm import io.horizontalsystems.bankwallet.modules.multiswap.sendtransaction.SendTransactionServiceState @@ -20,7 +21,6 @@ import io.horizontalsystems.bankwallet.modules.sendevmtransaction.ValueType import io.horizontalsystems.bankwallet.modules.sendevmtransaction.ViewItem import io.horizontalsystems.bankwallet.modules.walletconnect.WCDelegate import io.horizontalsystems.bankwallet.modules.walletconnect.request.WCChainData -import io.horizontalsystems.core.toHexString import io.horizontalsystems.ethereumkit.models.TransactionData import io.horizontalsystems.marketkit.models.BlockchainType import kotlinx.coroutines.Dispatchers