Skip to content

Commit

Permalink
Bump Abacus and app version (#278)
Browse files Browse the repository at this point in the history
Also a couple of minor UI fixes.
  • Loading branch information
ruixhuang authored Dec 3, 2024
1 parent 7ca8e1c commit 35908e6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext.ktlintVersion = '0.48.0'
ext.kotlinVersion = '1.9.24'
ext.androidApplicationVersion = '8.7.2'
ext.androidApplicationVersion = '8.7.3'

repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion v4/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
minSdkVersion parent.minSdkVersion
targetSdkVersion parent.targetSdkVersion
versionCode 10000
versionName "1.12.2"
versionName "1.12.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
2 changes: 1 addition & 1 deletion v4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ext {
compileSdkVersion = 34

// App dependencies
abacusVersion = '1.13.34'
abacusVersion = '1.13.39'
carteraVersion = '0.1.15'
kollectionsVersion = '2.0.16'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ object DydxMarketInfoView : DydxComponent {
val statsTabSelection: DydxMarketStatsTabView.Selection = DydxMarketStatsTabView.Selection.Statistics,
val accountTabSelection: DydxMarketAccountTabView.Selection = DydxMarketAccountTabView.Selection.Position,
val tileSelection: DydxMarketTilesView.TileType = DydxMarketTilesView.TileType.PRICE,
val scrollToTop: Boolean = false,
val scrollToIndex: Int? = null,
) {
companion object {
Expand Down Expand Up @@ -194,10 +193,6 @@ object DydxMarketInfoView : DydxComponent {
scope.launch {
listState.animateScrollToItem(state.scrollToIndex)
}
} else if (state.scrollToTop) {
scope.launch {
listState.animateScrollToItem(0)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package exchange.dydx.trading.feature.market.marketinfo

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import exchange.dydx.abacus.protocols.LocalizerProtocol
import exchange.dydx.abacus.utils.CoroutineTimer
import exchange.dydx.trading.common.DydxViewModel
import exchange.dydx.trading.feature.market.marketinfo.components.tabs.DydxMarketAccountTabView
import exchange.dydx.trading.feature.market.marketinfo.components.tabs.DydxMarketStatsTabView
Expand All @@ -13,6 +15,8 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import javax.inject.Inject

@HiltViewModel
Expand All @@ -25,13 +29,27 @@ class DydxMarketInfoViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
) : ViewModel(), DydxViewModel {

private val scrollToTopFlow = MutableStateFlow<Boolean>(false)

init {
mutableMarketInfoStream.update(marketId = savedStateHandle["marketId"])

val currentSection: String? = savedStateHandle["currentSection"]
if (currentSection != null) {
accountTabFlow.value = DydxMarketAccountTabView.Selection.valueOf(currentSection)
}

tileFlow
.distinctUntilChanged()
.onEach {
// trigger scroll to top
scrollToTopFlow.value = true
CoroutineTimer.instance.schedule(0.1, repeat = null) {
scrollToTopFlow.value = false
return@schedule false
}
}
.launchIn(viewModelScope)
}

override fun onCleared() {
Expand All @@ -40,45 +58,34 @@ class DydxMarketInfoViewModel @Inject constructor(
mutableMarketInfoStream.update(marketId = null)
}

private var currentStatsTabSelection: DydxMarketStatsTabView.Selection? = null
private var currentAccountTabSelection: DydxMarketAccountTabView.Selection? = null
private var currentTile: DydxMarketTilesView.Tile? = null

val state: Flow<DydxMarketInfoView.ViewState?> =
combine(
statsTabFlow,
accountTabFlow,
tileFlow,
) { statsTabSelection, accountTabSelection, tileSelection ->
scrollToTopFlow,
) { statsTabSelection, accountTabSelection, tileSelection, scrollToTop ->
createViewState(
statsTabSelection = statsTabSelection,
accountTabSelection = accountTabSelection,
tileSelection = tileSelection,
statTabChanged = currentStatsTabSelection != statsTabSelection && currentStatsTabSelection != null,
accountTabChanged = currentAccountTabSelection != accountTabSelection && currentAccountTabSelection != null,
tileChanged = currentTile != tileSelection && currentTile != null,
).also {
currentStatsTabSelection = statsTabSelection
currentAccountTabSelection = accountTabSelection
currentTile = tileSelection
}
scrollToTop = scrollToTop,
)
}
.distinctUntilChanged()

private fun createViewState(
statsTabSelection: DydxMarketStatsTabView.Selection,
accountTabSelection: DydxMarketAccountTabView.Selection,
tileSelection: DydxMarketTilesView.Tile,
statTabChanged: Boolean,
accountTabChanged: Boolean,
tileChanged: Boolean,
scrollToTop: Boolean,
): DydxMarketInfoView.ViewState {
return DydxMarketInfoView.ViewState(
localizer = localizer,
statsTabSelection = statsTabSelection,
tileSelection = tileSelection.type,
accountTabSelection = accountTabSelection,
scrollToIndex = if (tileChanged) 0 else null,
scrollToIndex = if (scrollToTop) 0 else null,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ object DydxMarketPositionView : DydxComponent {
modifier = Modifier,
) {
Text(
modifier = Modifier.weight(1f),
text = state.sharedMarketPositionViewState?.size ?: "-",
style = TextStyle.dydxDefault
.themeFont(
Expand All @@ -400,7 +401,7 @@ object DydxMarketPositionView : DydxComponent {
}

Text(
text = state.sharedMarketPositionViewState?.margin ?: "-",
text = state.sharedMarketPositionViewState?.notionalTotal ?: "-",
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class EthereumInteractor(
) {
executor.submit {
try {
val balance = web3j.ethGetBalance(address, DefaultBlockParameterName.LATEST).send()
val balance = web3j.ethGetBalance(address, DefaultBlockParameterName.LATEST).send().balance
runOnMainThread {
completion(null, balance.balance)
completion(null, balance)
}
} catch (e: Exception) {
runOnMainThread {
Expand Down

0 comments on commit 35908e6

Please sign in to comment.