Skip to content

Commit

Permalink
refactor: Set Compose modifier as first optional parameter (#210)
Browse files Browse the repository at this point in the history
For Jetpack Compose components, update parameters order so that mandatory parameters come before modifier parameters.
  • Loading branch information
nicolashaan authored Jan 4, 2024
1 parent 570ea02 commit d633db0
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Upcoming

### Breaking Changes

- [VMD] Change parameters order for some Compose components

### Updates

- Gradle to `8.4`
Expand Down
32 changes: 16 additions & 16 deletions trikot-viewmodels-declarative/compose/api/compose.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDContent

@Composable
fun <C : VMDContent> VMDButton(
modifier: Modifier = Modifier,
viewModel: VMDButtonViewModel<C>,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.Center,
propagateMinConstraints: Boolean = false,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDNoContent

@Composable
fun VMDCheckbox(
viewModel: VMDToggleViewModel<VMDNoContent>,
modifier: Modifier = Modifier,
componentModifier: Modifier = Modifier,
viewModel: VMDToggleViewModel<VMDNoContent>,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: CheckboxColors = CheckboxDefaults.colors()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsStat

@Composable
fun VMDCircularProgressIndicator(
modifier: Modifier = Modifier,
viewModel: VMDProgressViewModel,
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colors.primary,
strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth,
backgroundColor: Color = Color.Transparent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import androidx.compose.ui.Modifier

@Composable
fun VMDLabeledComponent(
modifier: Modifier = Modifier,
label: @Composable RowScope.() -> Unit,
content: @Composable RowScope.() -> Unit
content: @Composable RowScope.() -> Unit,
modifier: Modifier = Modifier
) {
Row(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDIdentifiableContent

@Composable
fun <C : VMDIdentifiableContent> VMDLazyColumn(
modifier: Modifier = Modifier,
viewModel: VMDListViewModel<C>,
modifier: Modifier = Modifier,
state: LazyListState = rememberLazyListState(),
contentPadding: PaddingValues = PaddingValues(0.dp),
reverseLayout: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDIdentifiableContent

@Composable
fun <C : VMDIdentifiableContent> VMDLazyRow(
modifier: Modifier = Modifier,
viewModel: VMDListViewModel<C>,
modifier: Modifier = Modifier,
state: LazyListState = rememberLazyListState(),
contentPadding: PaddingValues = PaddingValues(0.dp),
reverseLayout: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsStat

@Composable
fun VMDLinearProgressIndicator(
modifier: Modifier = Modifier,
viewModel: VMDProgressViewModel,
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colors.primary,
backgroundColor: Color = color.copy(alpha = ProgressIndicatorDefaults.IndicatorBackgroundOpacity)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDIdentifiableContent
@Deprecated("Use either VMDLazyColumn instead")
@Composable
fun <C : VMDIdentifiableContent> VMDList(
modifier: Modifier = Modifier,
viewModel: VMDListViewModel<C>,
modifier: Modifier = Modifier,
state: LazyListState = rememberLazyListState(),
contentPadding: PaddingValues = PaddingValues(0.dp),
reverseLayout: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDNoContent

@Composable
fun VMDSwitch(
viewModel: VMDToggleViewModel<VMDNoContent>,
modifier: Modifier = Modifier,
componentModifier: Modifier = Modifier,
viewModel: VMDToggleViewModel<VMDNoContent>,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: SwitchColors = SwitchDefaults.colors()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsStat

@Composable
fun VMDText(
modifier: Modifier = Modifier,
viewModel: VMDTextViewModel,
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
fontSize: TextUnit = TextUnit.Unspecified,
fontStyle: FontStyle? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.viewmodel.internal.Forma

@Composable
fun VMDTextField(
modifier: Modifier = Modifier,
viewModel: VMDTextFieldViewModel,
modifier: Modifier = Modifier,
textStyle: TextStyle = LocalTextStyle.current,
placeHolderStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsStat

@Composable
fun VMDCircularProgressIndicator(
modifier: Modifier = Modifier,
viewModel: VMDProgressViewModel,
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colorScheme.primary,
strokeWidth: Dp = ProgressIndicatorDefaults.CircularStrokeWidth,
trackColor: Color = ProgressIndicatorDefaults.circularTrackColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsStat

@Composable
fun VMDLinearProgressIndicator(
modifier: Modifier = Modifier,
viewModel: VMDProgressViewModel,
modifier: Modifier = Modifier,
color: Color = ProgressIndicatorDefaults.linearColor,
trackColor: Color = ProgressIndicatorDefaults.linearTrackColor
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import com.mirego.trikot.viewmodels.declarative.content.VMDNoContent

@Composable
fun VMDSwitch(
viewModel: VMDToggleViewModel<VMDNoContent>,
modifier: Modifier = Modifier,
componentModifier: Modifier = Modifier,
viewModel: VMDToggleViewModel<VMDNoContent>,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: SwitchColors = SwitchDefaults.colors()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.extensions.observeAsStat

@Composable
fun VMDText(
modifier: Modifier = Modifier,
viewModel: VMDTextViewModel,
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
fontSize: TextUnit = TextUnit.Unspecified,
fontStyle: FontStyle? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import com.mirego.trikot.viewmodels.declarative.compose.viewmodel.internal.Forma

@Composable
fun VMDTextField(
modifier: Modifier = Modifier,
viewModel: VMDTextFieldViewModel,
modifier: Modifier = Modifier,
textStyle: TextStyle = LocalTextStyle.current,
placeHolderStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
Expand Down

0 comments on commit d633db0

Please sign in to comment.