mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
feat: language fragment to jetpack compose
- added orders to the test rule to avoid retries error in tests. - renamed content lambda to "navigationIcon". - removed redundant "Experimental api" from kiwixSearchView. - added appropriate text size for kiwixSearchView.
This commit is contained in:
parent
1fc4e505a2
commit
90830da5ca
@ -37,6 +37,8 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.kiwix.kiwixmobile.core.utils.LanguageUtils.Companion.handleLocaleChange
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import org.kiwix.kiwixmobile.core.utils.TestingUtils.COMPOSE_TEST_RULE_ORDER
|
||||
import org.kiwix.kiwixmobile.core.utils.TestingUtils.RETRY_RULE_ORDER
|
||||
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
||||
import org.kiwix.kiwixmobile.testutils.RetryRule
|
||||
import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs
|
||||
@ -46,10 +48,11 @@ import org.kiwix.kiwixmobile.utils.StandardActions
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LanguageFragmentTest {
|
||||
@get:Rule
|
||||
val retryTestRule = RetryRule()
|
||||
@Rule(order = RETRY_RULE_ORDER)
|
||||
@JvmField
|
||||
val retryRule = RetryRule()
|
||||
|
||||
@get:Rule
|
||||
@get:Rule(order = COMPOSE_TEST_RULE_ORDER)
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
private val permissions =
|
||||
|
@ -91,7 +91,7 @@ class LanguageFragment : BaseFragment() {
|
||||
searchText = it
|
||||
languageViewModel.actions.offer(Action.Filter(it))
|
||||
},
|
||||
content = {
|
||||
navigationIcon = {
|
||||
NavigationIcon(
|
||||
iconItem = if (isSearchActive) {
|
||||
IconItem.Vector(Icons.AutoMirrored.Filled.ArrowBack)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.kiwix.kiwixmobile.language
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.calculateEndPadding
|
||||
@ -46,6 +47,7 @@ import org.kiwix.kiwixmobile.language.viewmodel.LanguageViewModel
|
||||
import org.kiwix.kiwixmobile.language.viewmodel.State
|
||||
import org.kiwix.kiwixmobile.language.viewmodel.State.Content
|
||||
|
||||
@SuppressLint("ComposableLambdaParameterNaming")
|
||||
@Composable
|
||||
fun LanguageScreen(
|
||||
searchText: String,
|
||||
@ -54,7 +56,7 @@ fun LanguageScreen(
|
||||
actionMenuItemList: List<ActionMenuItem>,
|
||||
onClearClick: () -> Unit,
|
||||
onAppBarValueChange: (String) -> Unit,
|
||||
content: @Composable() () -> Unit,
|
||||
navigationIcon: @Composable() () -> Unit = {}
|
||||
) {
|
||||
val state by languageViewModel.state.observeAsState(State.Loading)
|
||||
val listState: LazyListState = rememberLazyListState()
|
||||
@ -63,7 +65,7 @@ fun LanguageScreen(
|
||||
Scaffold(topBar = {
|
||||
KiwixAppBar(
|
||||
titleId = R.string.select_languages,
|
||||
navigationIcon = content,
|
||||
navigationIcon = navigationIcon,
|
||||
actionMenuItems = actionMenuItemList,
|
||||
searchBar = if (isSearchActive) {
|
||||
{ modifier ->
|
||||
|
@ -18,9 +18,9 @@
|
||||
|
||||
package org.kiwix.kiwixmobile.core.ui.components
|
||||
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -31,9 +31,11 @@ import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun KiwixSearchView(
|
||||
modifier: Modifier,
|
||||
@ -59,7 +61,17 @@ fun KiwixSearchView(
|
||||
.focusRequester(focusRequester),
|
||||
singleLine = true,
|
||||
value = value,
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(R.string.search_label),
|
||||
color = Color.LightGray,
|
||||
fontSize = ComposeDimens.EIGHTEEN_SP
|
||||
)
|
||||
},
|
||||
colors = colors,
|
||||
textStyle = TextStyle.Default.copy(
|
||||
fontSize = ComposeDimens.EIGHTEEN_SP
|
||||
),
|
||||
onValueChange = {
|
||||
onValueChange(it.replace("\n", ""))
|
||||
},
|
||||
|
@ -56,6 +56,7 @@ object ComposeDimens {
|
||||
// Font Sizes
|
||||
val TWENTY_FOUR_SP = 24.sp
|
||||
val FOURTEEN_SP = 14.sp
|
||||
val EIGHTEEN_SP = 18.sp
|
||||
|
||||
// Default letter spacing in text according to theme
|
||||
val DEFAULT_LETTER_SPACING = 0.0333.em
|
||||
|
Loading…
x
Reference in New Issue
Block a user