Skip to content

Commit

Permalink
🧪 Remove default values on Overridable Composable functions
Browse files Browse the repository at this point in the history
And remove previews for now...
  • Loading branch information
SimonMarquis committed Jan 25, 2024
1 parent a2c2467 commit ef77975
Showing 1 changed file with 17 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.IconButtonColors
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.IconToggleButtonColors
import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -67,13 +66,8 @@ import com.adevinta.spark.components.menu.DropdownMenuItem
import com.adevinta.spark.components.spacer.Spacer
import com.adevinta.spark.components.surface.Surface
import com.adevinta.spark.components.text.Text
import com.adevinta.spark.icons.EyeFill
import com.adevinta.spark.icons.EyeOffFill
import com.adevinta.spark.icons.QuestionOutline
import com.adevinta.spark.icons.SparkIcon
import com.adevinta.spark.icons.SparkIcons
import com.adevinta.spark.tokens.SparkColors
import kotlin.random.Random
import androidx.compose.material3.FilledTonalButton as MaterialButton

/**
Expand All @@ -90,11 +84,11 @@ public interface AddonScope {
public fun Button(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
icon: SparkIcon? = null,
isLoading: Boolean = false,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
modifier: Modifier,
enabled: Boolean,
icon: SparkIcon?,
isLoading: Boolean,
interactionSource: MutableInteractionSource,
) {
MaterialButton(
onClick = onClick,
Expand Down Expand Up @@ -143,7 +137,7 @@ public interface AddonScope {
public fun TextFieldIcon(
icon: SparkIcon,
contentDescription: String?,
modifier: Modifier = Modifier,
modifier: Modifier,
) {
Icon(
modifier = modifier.size(16.dp),
Expand All @@ -163,10 +157,10 @@ public interface AddonScope {
onClick: () -> Unit,
icon: SparkIcon,
contentDescription: String?,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
modifier: Modifier,
enabled: Boolean,
colors: IconButtonColors,
interactionSource: MutableInteractionSource,
) {
IconButton(
onClick = onClick,
Expand Down Expand Up @@ -196,10 +190,10 @@ public interface AddonScope {
unCheckedIcon: SparkIcon,
checkedIcon: SparkIcon,
contentDescription: String?,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: IconToggleButtonColors = IconButtonDefaults.iconToggleButtonColors(),
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
modifier: Modifier,
enabled: Boolean,
colors: IconToggleButtonColors,
interactionSource: MutableInteractionSource,
) {
IconToggleButton(
checked = checked,
Expand All @@ -225,7 +219,7 @@ public interface AddonScope {
@Composable
public fun TextFieldText(
text: String,
modifier: Modifier = Modifier,
modifier: Modifier,
) {
Text(
modifier = modifier,
Expand All @@ -247,8 +241,8 @@ public interface AddonScope {
onExpandedChange: (Boolean) -> Unit,
onDismissRequest: () -> Unit,
dropdownLabel: @Composable RowScope.() -> Unit,
modifier: Modifier = Modifier,
properties: PopupProperties = PopupProperties(),
modifier: Modifier,
properties: PopupProperties,
popupDropdownContent: @Composable ColumnScope.() -> Unit,
) {
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = onExpandedChange) {
Expand Down Expand Up @@ -327,128 +321,3 @@ private fun TextFieldWithDropdownPreview() {
}
}
}

@Preview
@Composable
private fun TextFieldWithButtonPreview() {
var isLoading by remember { mutableStateOf(false) }
PreviewTheme {
TextField(
value = "AA-123-BB",
label = "Plate number",
onValueChange = {},
trailingContent = {
Button(
text = "Validate",
modifier = Modifier,
onClick = { isLoading = !isLoading },
isLoading = isLoading,
)
},
)
}
}

@Preview
@Composable
private fun TextFieldWithIconPreview() {
PreviewTheme {
TextField(
value = "AA-123-BB",
label = "Plate number",
onValueChange = {},
trailingContent = {
TextFieldIcon(
icon = SparkIcons.QuestionOutline,
modifier = Modifier,
contentDescription = "",
)
},
)
}
}

@Preview
@Composable
private fun TextFieldWithIconButtonPreview() {
PreviewTheme {
var value by remember {
mutableStateOf("AA-123-BB")
}
TextField(
value = value,
label = "Plate number",
onValueChange = {},
trailingContent = {
TextFieldIconButton(
modifier = Modifier,
icon = SparkIcons.EyeOffFill,
contentDescription = "",
onClick = { value = Random.nextInt(0, 8000).toString() },
)
},
)
}
}

@Preview
@Composable
private fun TextFieldWithIconToggleButtonPreview() {
PreviewTheme {
var checked by remember {
mutableStateOf(false)
}
TextField(
value = "AA-123-BB",
label = "Plate number",
onValueChange = {},
trailingContent = {
TextFieldIconToggleButton(
modifier = Modifier,
checked = checked,
checkedIcon = SparkIcons.EyeFill,
unCheckedIcon = SparkIcons.EyeOffFill,
contentDescription = "",
onCheckedChange = { checked = it },
)
},
)
TextField(
value = "AA-123-BB",
label = "Plate number",
onValueChange = {},
trailingContent = {
TextFieldIconToggleButton(
modifier = Modifier,
checked = !checked,
checkedIcon = SparkIcons.EyeFill,
unCheckedIcon = SparkIcons.EyeOffFill,
contentDescription = "",
onCheckedChange = { checked = it },
)
},
)
}
}

@Preview
@Composable
private fun TextFieldWithPrefixSuffixButtonPreview() {
PreviewTheme {
TextField(
value = "www.adevinta.com",
label = "Url",
onValueChange = {},
leadingContent = {
TextFieldText(
text = "https://",
)
},
trailingContent = {
TextFieldText(
text = ".com",
)
},
)
}
}

0 comments on commit ef77975

Please sign in to comment.