Updated on 2026-08-14
This commit is contained in:
commit
23a9ec5ba8
2 changed files with 18 additions and 1 deletions
|
|
@ -1,7 +1,11 @@
|
|||
package com.tangem.tap.common.compose.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
|
||||
@Composable
|
||||
fun LazyListState.OnBottomReached(loadMoreThreshold: Int, loadMore: () -> Unit) {
|
||||
|
|
@ -17,4 +21,15 @@ fun LazyListState.OnBottomReached(loadMoreThreshold: Int, loadMore: () -> Unit)
|
|||
LaunchedEffect(shouldLoadMore) {
|
||||
if (shouldLoadMore) loadMore()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LazyListState.HideKeyboardOnScroll() {
|
||||
val context = LocalContext.current
|
||||
val view = LocalView.current
|
||||
LaunchedEffect(firstVisibleItemIndex) {
|
||||
val inputMethodManager =
|
||||
context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.tap.common.compose.extensions.HideKeyboardOnScroll
|
||||
import com.tangem.tap.common.compose.extensions.OnBottomReached
|
||||
import com.tangem.tap.domain.tokens.Currency
|
||||
import com.tangem.tap.features.tokens.redux.ContractAddress
|
||||
|
|
@ -44,6 +45,8 @@ fun ListOfCurrencies(
|
|||
}
|
||||
|
||||
val listState = rememberLazyListState()
|
||||
listState.HideKeyboardOnScroll()
|
||||
listState.OnBottomReached(loadMoreThreshold = 40) { onLoadMore() }
|
||||
|
||||
LazyColumn(
|
||||
state = listState,
|
||||
|
|
@ -67,7 +70,6 @@ fun ListOfCurrencies(
|
|||
)
|
||||
}
|
||||
}
|
||||
listState.OnBottomReached(loadMoreThreshold = 40) { onLoadMore() }
|
||||
}
|
||||
|
||||
val Currency.fullName: String
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue