Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

fixed issue 2938 #2976

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions screen/accounts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation(projects.temp.oldDesign)
implementation(projects.temp.legacyCode)
implementation(projects.shared.data)
implementation(projects.shared.commonUi)

testImplementation(projects.shared.testing)
}
11 changes: 11 additions & 0 deletions screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -29,6 +30,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.ivy.common.ui.rememberScrollPositionListState
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.legacy.IvyWalletPreview
Expand Down Expand Up @@ -74,6 +76,14 @@ private fun BoxWithConstraintsScope.UI(
val nav = navigation()
val ivyContext = com.ivy.legacy.ivyWalletCtx()

var listState = rememberLazyListState()
if (!state.accountsData.isEmpty()){
listState = rememberScrollPositionListState(
key = "accounts_lazy_column",
initialFirstVisibleItemIndex = ivyContext.accountsListState?.firstVisibleItemIndex ?: 0,
initialFirstVisibleItemScrollOffset = ivyContext.accountsListState?.firstVisibleItemScrollOffset ?: 0
)
}
LazyColumn(
modifier = Modifier
.fillMaxSize()
Expand All @@ -89,6 +99,7 @@ private fun BoxWithConstraintsScope.UI(
ivyContext.selectMainTab(com.ivy.legacy.data.model.MainTab.HOME)
}
),
state = listState,
) {
item {
Spacer(Modifier.height(32.dp))
Expand Down
1 change: 1 addition & 0 deletions screen/categories/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation(projects.shared.navigation)
implementation(projects.temp.legacyCode)
implementation(projects.shared.data)
implementation(projects.shared.commonUi)

testImplementation(projects.shared.testing)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -38,6 +39,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.ivy.common.ui.rememberScrollPositionListState
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.legacy.datamodel.Category
Expand Down Expand Up @@ -90,12 +92,23 @@ private fun BoxWithConstraintsScope.UI(
onEvent: (CategoriesScreenEvent) -> Unit = {}
) {
val nav = navigation()

val ivyContext = com.ivy.legacy.ivyWalletCtx()

var listState = rememberLazyListState()
if (!state.categories.isEmpty()){
listState = rememberScrollPositionListState(
key = "categories_lazy_column",
initialFirstVisibleItemIndex = ivyContext.categoriesListState?.firstVisibleItemIndex ?: 0,
initialFirstVisibleItemScrollOffset = ivyContext.categoriesListState?.firstVisibleItemScrollOffset ?: 0
)
}

LazyColumn(
modifier = Modifier
.fillMaxSize()
.statusBarsPadding()
.navigationBarsPadding(),
state = listState
) {
item {
Spacer(Modifier.height(32.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ class IvyWalletCtx @Inject constructor() : IvyContext() {
@Deprecated("Legacy code. Don't use it, please.")
var transactionsListState: LazyListState? = null

@Deprecated("Legacy code. Don't use it, please.")
var accountsListState: LazyListState? = null

@Deprecated("Legacy code. Don't use it, please.")
var categoriesListState: LazyListState? = null

@Deprecated("Legacy code. Don't use it, please.")
var mainTab by mutableStateOf(com.ivy.legacy.data.model.MainTab.HOME)
private set
Expand Down Expand Up @@ -143,5 +149,7 @@ class IvyWalletCtx @Inject constructor() : IvyContext() {
startDayOfMonth = 1
isPremium = true
transactionsListState = null
accountsListState= null
categoriesListState = null
}
}
Loading