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