Skip to content

Commit

Permalink
Scroll to top when loading the market for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang committed Sep 19, 2024
1 parent 3e9bfab commit a741c3a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -41,6 +42,9 @@ fun Preview_DydxMarketAssetListView() {
}

object DydxMarketAssetListView : DydxComponent {

private var firstTime = true

data class ViewState(
val localizer: LocalizerProtocol,
val items: List<DydxMarketAssetItemView.ViewState>,
Expand Down Expand Up @@ -139,7 +143,10 @@ object DydxMarketAssetListView : DydxComponent {
)
}

if (state.scrollToTop) {
if (state.scrollToTop || firstTime) {
if (firstTime) {
firstTime = false
}
scope.launch {
listState.animateScrollToItem(0)
}
Expand Down

0 comments on commit a741c3a

Please sign in to comment.