-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from grodnoroads/1.2.8
1.2.8
- Loading branch information
Showing
47 changed files
with
870 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ndation/core/src/main/kotlin/com/egoriku/grodnoroads/foundation/core/AutoScrollLazyRow.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.egoriku.grodnoroads.foundation.core | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.lazy.LazyListScope | ||
import androidx.compose.foundation.lazy.LazyListState | ||
import androidx.compose.foundation.lazy.LazyRow | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun AutoScrollLazyRow( | ||
state: LazyListState = rememberLazyListState(), | ||
contentPadding: PaddingValues = PaddingValues(horizontal = 20.dp), | ||
horizontalArrangement: Arrangement.Horizontal = Arrangement.spacedBy(8.dp), | ||
indexToScroll: Int, | ||
content: LazyListScope.() -> Unit | ||
) { | ||
LaunchedEffect(indexToScroll) { | ||
state.animateScrollToItem(indexToScroll) | ||
} | ||
|
||
LazyRow( | ||
state = state, | ||
contentPadding = contentPadding, | ||
horizontalArrangement = horizontalArrangement, | ||
content = content | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
...n/core/src/main/kotlin/com/egoriku/grodnoroads/foundation/core/HorizontalScrollableRow.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.egoriku.grodnoroads.foundation.core | ||
|
||
import androidx.compose.foundation.horizontalScroll | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun HorizontalScrollableRow( | ||
paddingValues: PaddingValues = PaddingValues(horizontal = 20.dp), | ||
horizontalArrangement: Arrangement.HorizontalOrVertical = Arrangement.spacedBy(8.dp), | ||
content: @Composable RowScope.() -> Unit | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.horizontalScroll(rememberScrollState()) | ||
.padding(paddingValues), | ||
horizontalArrangement = horizontalArrangement, | ||
content = content | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...ation/uikit/src/main/kotlin/com/egoriku/grodnoroads/foundation/uikit/OutlinedTextField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.egoriku.grodnoroads.foundation.uikit | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.KeyboardActions | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.focus.onFocusChanged | ||
import androidx.compose.ui.unit.dp | ||
import com.egoriku.grodnoroads.foundation.core.rememberMutableState | ||
import com.egoriku.grodnoroads.foundation.preview.GrodnoRoadsPreview | ||
|
||
@Composable | ||
fun OutlinedTextField( | ||
value: String, | ||
onValueChange: (String) -> Unit, | ||
label: String, | ||
modifier: Modifier = Modifier, | ||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default, | ||
keyboardActions: KeyboardActions = KeyboardActions.Default, | ||
supportingText: String? = null, | ||
onFocusChange: () -> Unit | ||
) { | ||
var isFirstFocus by rememberMutableState { true } | ||
|
||
OutlinedTextField( | ||
modifier = modifier | ||
.onFocusChanged { focusState -> | ||
when { | ||
isFirstFocus -> isFirstFocus = false | ||
!focusState.isFocused -> onFocusChange() | ||
} | ||
}, | ||
value = value, | ||
onValueChange = onValueChange, | ||
label = label, | ||
keyboardOptions = keyboardOptions, | ||
keyboardActions = keyboardActions, | ||
supportingText = supportingText, | ||
) | ||
} | ||
|
||
@Composable | ||
fun OutlinedTextField( | ||
value: String, | ||
onValueChange: (String) -> Unit, | ||
label: String, | ||
modifier: Modifier = Modifier, | ||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default, | ||
keyboardActions: KeyboardActions = KeyboardActions.Default, | ||
supportingText: String? = null | ||
) { | ||
androidx.compose.material3.OutlinedTextField( | ||
modifier = modifier.fillMaxWidth(), | ||
keyboardOptions = keyboardOptions, | ||
keyboardActions = keyboardActions, | ||
value = value, | ||
shape = RoundedCornerShape(16.dp), | ||
singleLine = true, | ||
onValueChange = onValueChange, | ||
label = { Text(text = label) }, | ||
supportingText = when { | ||
supportingText != null -> { | ||
{ | ||
Text( | ||
text = supportingText, | ||
color = MaterialTheme.colorScheme.error | ||
) | ||
} | ||
} | ||
else -> null | ||
} | ||
) | ||
} | ||
|
||
@GrodnoRoadsPreview | ||
@Composable | ||
private fun OutlinedTextFieldPreview() { | ||
Column( | ||
modifier = Modifier.padding(16.dp), | ||
verticalArrangement = Arrangement.spacedBy(16.dp) | ||
) { | ||
OutlinedTextField( | ||
value = "Text", | ||
onValueChange = {}, | ||
label = "Label", | ||
) | ||
OutlinedTextField( | ||
value = "Text", | ||
onValueChange = {}, | ||
label = "Label", | ||
supportingText = "Error text" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.