Updated on 2026-08-14
This commit is contained in:
commit
b011e2152b
3 changed files with 48 additions and 49 deletions
|
|
@ -9,17 +9,12 @@ import com.tangem.common.doOnSuccess
|
|||
import com.tangem.common.extensions.guard
|
||||
import com.tangem.core.analytics.Analytics
|
||||
import com.tangem.datasource.connection.NetworkConnectionManager
|
||||
import com.tangem.tap.*
|
||||
import com.tangem.tap.common.analytics.events.AnalyticsParam
|
||||
import com.tangem.tap.common.analytics.events.Basic
|
||||
import com.tangem.tap.common.analytics.events.MainScreen
|
||||
import com.tangem.tap.common.analytics.events.Token
|
||||
import com.tangem.tap.common.extensions.copyToClipboard
|
||||
import com.tangem.tap.common.extensions.dispatchErrorNotification
|
||||
import com.tangem.tap.common.extensions.dispatchOnMain
|
||||
import com.tangem.tap.common.extensions.dispatchOpenUrl
|
||||
import com.tangem.tap.common.extensions.dispatchToastNotification
|
||||
import com.tangem.tap.common.extensions.isGreaterThan
|
||||
import com.tangem.tap.common.extensions.shareText
|
||||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
|
|
@ -35,14 +30,7 @@ import com.tangem.tap.features.wallet.models.Currency
|
|||
import com.tangem.tap.features.wallet.models.getSendableAmounts
|
||||
import com.tangem.tap.features.wallet.redux.WalletAction
|
||||
import com.tangem.tap.features.wallet.redux.WalletState
|
||||
import com.tangem.tap.preferencesStorage
|
||||
import com.tangem.tap.proxy.redux.DaggerGraphState
|
||||
import com.tangem.tap.scope
|
||||
import com.tangem.tap.store
|
||||
import com.tangem.tap.tangemSdkManager
|
||||
import com.tangem.tap.totalFiatBalanceCalculator
|
||||
import com.tangem.tap.userWalletsListManager
|
||||
import com.tangem.tap.walletStoresManager
|
||||
import com.tangem.utils.coroutines.ifActive
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -136,14 +124,14 @@ class WalletMiddleware {
|
|||
return
|
||||
}
|
||||
|
||||
store.dispatch(WalletAction.UpdateUserWalletArtwork(selectedWallet.walletId))
|
||||
|
||||
scope.launch {
|
||||
globalState.tapWalletManager.loadData(
|
||||
userWallet = selectedWallet,
|
||||
refresh = action is WalletAction.LoadData.Refresh,
|
||||
)
|
||||
}
|
||||
|
||||
store.dispatchOnMain(WalletAction.UpdateUserWalletArtwork(selectedWallet.walletId))
|
||||
}
|
||||
is WalletAction.CopyAddress -> {
|
||||
Analytics.send(Token.Receive.ButtonCopyAddress())
|
||||
|
|
|
|||
|
|
@ -199,26 +199,50 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber<W
|
|||
binding.toolbar.inflateMenu(R.menu.menu_wallet)
|
||||
}
|
||||
|
||||
setupNoInternetHandling(state)
|
||||
setupCardImage(state, isSaltPay)
|
||||
|
||||
if (!isSaltPay) showWarningsIfPresent(state.mainWarningsList)
|
||||
|
||||
binding.srlWallet.isRefreshing = state.state == ProgressState.Refreshing
|
||||
binding.srlWallet.setOnRefreshListener {
|
||||
if (state.state != ProgressState.Loading &&
|
||||
state.state != ProgressState.Refreshing
|
||||
) {
|
||||
setupPullToRefreshLayout(state)
|
||||
|
||||
binding.toolbar.setNavigationIcon(
|
||||
if (state.canSaveUserWallets) R.drawable.ic_wallet_24 else R.drawable.ic_tap_card_24,
|
||||
)
|
||||
}
|
||||
|
||||
private fun setupPullToRefreshLayout(state: WalletState) {
|
||||
setupErrorPullToRefreshState(state)
|
||||
|
||||
binding.pullToRefreshLayout.isRefreshing = state.state == ProgressState.Refreshing
|
||||
|
||||
binding.pullToRefreshLayout.setOnRefreshListener {
|
||||
if (state.state != ProgressState.Loading && state.state != ProgressState.Refreshing) {
|
||||
refreshWalletData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val navigationIconRes = if (state.canSaveUserWallets) {
|
||||
R.drawable.ic_wallet_24
|
||||
private fun setupErrorPullToRefreshState(state: WalletState) {
|
||||
if (state.state == ProgressState.Error) {
|
||||
when (state.error) {
|
||||
ErrorType.NoInternetConnection -> {
|
||||
isNetworkConnectionError.value = true
|
||||
binding.pullToRefreshLayout.isRefreshing = false
|
||||
|
||||
(activity as? MainActivity)?.showSnackbar(
|
||||
text = R.string.wallet_notification_no_internet,
|
||||
buttonTitle = R.string.common_retry,
|
||||
)
|
||||
// because was added logic of autoupdate mainscreen data, remove retry
|
||||
// TODO("remove comment after release 4.6")
|
||||
// { store.dispatch(WalletAction.LoadData) }
|
||||
}
|
||||
else -> isNetworkConnectionError.value = false
|
||||
}
|
||||
} else {
|
||||
R.drawable.ic_tap_card_24
|
||||
isNetworkConnectionError.value = false
|
||||
(activity as? MainActivity)?.dismissSnackbar()
|
||||
}
|
||||
binding.toolbar.setNavigationIcon(navigationIconRes)
|
||||
}
|
||||
|
||||
private fun refreshWalletData() {
|
||||
|
|
@ -231,27 +255,6 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber<W
|
|||
binding.rvWarningMessages.show(warnings.isNotEmpty())
|
||||
}
|
||||
|
||||
private fun setupNoInternetHandling(state: WalletState) {
|
||||
if (state.state == ProgressState.Error) {
|
||||
if (state.error == ErrorType.NoInternetConnection) {
|
||||
isNetworkConnectionError.value = true
|
||||
binding.srlWallet.isRefreshing = false
|
||||
(activity as? MainActivity)?.showSnackbar(
|
||||
text = R.string.wallet_notification_no_internet,
|
||||
buttonTitle = R.string.common_retry,
|
||||
)
|
||||
// because was added logic of autoupdate mainscreen data, remove retry
|
||||
// TODO("remove comment after release 4.6")
|
||||
// { store.dispatch(WalletAction.LoadData) }
|
||||
} else {
|
||||
isNetworkConnectionError.value = false
|
||||
}
|
||||
} else {
|
||||
isNetworkConnectionError.value = false
|
||||
(activity as? MainActivity)?.dismissSnackbar()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCardImage(state: WalletState, isSaltPay: Boolean) {
|
||||
// TODO: SaltPay: remove hardCode
|
||||
if (isSaltPay) {
|
||||
|
|
@ -283,7 +286,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber<W
|
|||
(activity as? MainActivity)?.dismissSnackbar()
|
||||
} else {
|
||||
isNetworkConnectionError.value = true
|
||||
binding.srlWallet.isRefreshing = false
|
||||
binding.pullToRefreshLayout.isRefreshing = false
|
||||
(activity as? MainActivity)?.showSnackbar(
|
||||
text = R.string.wallet_notification_no_internet,
|
||||
buttonTitle = R.string.common_retry,
|
||||
|
|
@ -316,6 +319,14 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), SafeStoreSubscriber<W
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
message = "Deprecated in Java",
|
||||
replaceWith = ReplaceWith(
|
||||
"if (store.state.walletState.shouldShowDetails) inflater.inflate(R.menu.menu_wallet, menu)",
|
||||
"com.tangem.tap.store",
|
||||
"com.tangem.wallet.R",
|
||||
),
|
||||
)
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
if (store.state.walletState.shouldShowDetails) inflater.inflate(R.menu.menu_wallet, menu)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/srl_wallet"
|
||||
android:id="@+id/pull_to_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue