mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Feat: Language fragment to jetpack compose screen
- screen refinement - removed redundant code
This commit is contained in:
parent
d32de91060
commit
620b8b1549
@ -25,8 +25,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
@ -37,7 +35,6 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Modifier
|
||||
@ -47,7 +44,6 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import kotlinx.coroutines.launch
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.ui.components.KiwixAppBar
|
||||
import org.kiwix.kiwixmobile.core.ui.components.NavigationIcon
|
||||
@ -82,12 +78,6 @@ fun LanguageScreen(
|
||||
var isSearchActive by remember { mutableStateOf(false) }
|
||||
var updateListState by remember { mutableStateOf(false) }
|
||||
val listState: LazyListState = rememberLazyListState()
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val scrollToTop = {
|
||||
coroutineScope.launch {
|
||||
listState.scrollToItem(0)
|
||||
}
|
||||
}
|
||||
|
||||
KiwixTheme {
|
||||
Scaffold(
|
||||
@ -110,7 +100,6 @@ fun LanguageScreen(
|
||||
filterText(searchText)
|
||||
} else {
|
||||
onNavigationClick()
|
||||
scrollToTop()
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -165,9 +154,7 @@ fun LanguageScreen(
|
||||
filterText(it)
|
||||
},
|
||||
testTag = SEARCH_FIELD_TESTING_TAG,
|
||||
hint = stringResource(R.string.search_label),
|
||||
keyboardOptions = KeyboardOptions.Default,
|
||||
keyboardActions = KeyboardActions.Default
|
||||
hint = stringResource(R.string.search_label)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
@ -23,8 +23,6 @@ import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
@ -45,8 +43,6 @@ import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
@ -59,9 +55,7 @@ fun AppBarTextField(
|
||||
value: String,
|
||||
hint: String,
|
||||
testTag: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
onValueChange: (String) -> Unit
|
||||
) {
|
||||
val interactionSource = remember(::MutableInteractionSource)
|
||||
val textStyle = LocalTextStyle.current
|
||||
@ -100,10 +94,7 @@ fun AppBarTextField(
|
||||
interactionSource = interactionSource,
|
||||
colors = colors
|
||||
)
|
||||
.focusRequester(focusRequester)
|
||||
.semantics {
|
||||
contentDescription = "searchField"
|
||||
},
|
||||
.focusRequester(focusRequester),
|
||||
value = textFieldValue,
|
||||
onValueChange = {
|
||||
textFieldValue = it
|
||||
@ -111,8 +102,6 @@ fun AppBarTextField(
|
||||
},
|
||||
textStyle = textStyle.copy(color = Color.White),
|
||||
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
|
||||
keyboardOptions = keyboardOptions,
|
||||
keyboardActions = keyboardActions,
|
||||
interactionSource = interactionSource,
|
||||
singleLine = true,
|
||||
decorationBox = { innerTextField ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user