Merge pull request #1862 from vector-im/feature/bma/moreTests
Remove lambda default value
This commit is contained in:
commit
05ba424e75
49 changed files with 436 additions and 230 deletions
|
|
@ -32,8 +32,8 @@ import io.element.android.libraries.designsystem.theme.components.Text
|
|||
fun LabelledCheckbox(
|
||||
checked: Boolean,
|
||||
text: String,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onCheckedChange: (Boolean) -> Unit = {},
|
||||
enabled: Boolean = true,
|
||||
) {
|
||||
Row(
|
||||
|
|
@ -60,6 +60,7 @@ internal fun LabelledCheckboxPreview() = ElementThemedPreview { ContentToPreview
|
|||
private fun ContentToPreview() {
|
||||
LabelledCheckbox(
|
||||
checked = true,
|
||||
onCheckedChange = {},
|
||||
text = "Some text",
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ import io.element.android.libraries.theme.ElementTheme
|
|||
fun LabelledOutlinedTextField(
|
||||
label: String,
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
placeholder: String? = null,
|
||||
singleLine: Boolean = false,
|
||||
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
|
||||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
||||
onValueChange: (String) -> Unit = {},
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier,
|
||||
|
|
@ -72,11 +72,13 @@ internal fun LabelledOutlinedTextFieldPreview() = ElementPreview {
|
|||
LabelledOutlinedTextField(
|
||||
label = "Room name",
|
||||
value = "",
|
||||
onValueChange = {},
|
||||
placeholder = "e.g. Product Sprint",
|
||||
)
|
||||
LabelledOutlinedTextField(
|
||||
label = "Room name",
|
||||
value = "a room name",
|
||||
onValueChange = {},
|
||||
placeholder = "e.g. Product Sprint",
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ import io.element.android.libraries.theme.ElementTheme
|
|||
fun LabelledTextField(
|
||||
label: String,
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
placeholder: String? = null,
|
||||
singleLine: Boolean = false,
|
||||
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
|
||||
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
||||
onValueChange: (String) -> Unit = {},
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier,
|
||||
|
|
@ -72,11 +72,13 @@ internal fun LabelledTextFieldPreview() = ElementPreview {
|
|||
LabelledTextField(
|
||||
label = "Room name",
|
||||
value = "",
|
||||
onValueChange = {},
|
||||
placeholder = "e.g. Product Sprint",
|
||||
)
|
||||
LabelledTextField(
|
||||
label = "Room name",
|
||||
value = "a room name",
|
||||
onValueChange = {},
|
||||
placeholder = "e.g. Product Sprint",
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
|||
@Composable
|
||||
fun RetryDialog(
|
||||
content: String,
|
||||
onRetry: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
title: String = RetryDialogDefaults.title,
|
||||
retryText: String = RetryDialogDefaults.retryText,
|
||||
dismissText: String = RetryDialogDefaults.dismissText,
|
||||
onRetry: () -> Unit = {},
|
||||
onDismiss: () -> Unit = {},
|
||||
) {
|
||||
BasicAlertDialog(modifier = modifier, onDismissRequest = onDismiss) {
|
||||
RetryDialogContent(
|
||||
|
|
@ -54,12 +54,12 @@ fun RetryDialog(
|
|||
@Composable
|
||||
private fun RetryDialogContent(
|
||||
content: String,
|
||||
onRetry: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
title: String = RetryDialogDefaults.title,
|
||||
retryText: String = RetryDialogDefaults.retryText,
|
||||
dismissText: String = RetryDialogDefaults.dismissText,
|
||||
onRetry: () -> Unit = {},
|
||||
onDismiss: () -> Unit = {},
|
||||
) {
|
||||
SimpleAlertDialogContent(
|
||||
modifier = modifier,
|
||||
|
|
@ -85,6 +85,8 @@ internal fun RetryDialogPreview() {
|
|||
DialogPreview {
|
||||
RetryDialogContent(
|
||||
content = "Content",
|
||||
onRetry = {},
|
||||
onDismiss = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ private const val DEFAULT_GRAPHICS_LAYER_ALPHA: Float = 0.99F
|
|||
* @param playbackProgress The current playback progress, between 0 and 1.
|
||||
* @param showCursor Whether to show the cursor or not.
|
||||
* @param waveform The waveform to display. Use [FakeWaveformFactory] to generate a fake waveform.
|
||||
* @param onSeek Callback when the user seeks the waveform. Called with a value between 0 and 1.
|
||||
* @param modifier The modifier to be applied to the view.
|
||||
* @param seekEnabled Whether the user can seek the waveform or not.
|
||||
* @param onSeek Callback when the user seeks the waveform. Called with a value between 0 and 1.
|
||||
* @param brush The brush to use to draw the waveform.
|
||||
* @param progressBrush The brush to use to draw the progress.
|
||||
* @param cursorBrush The brush to use to draw the cursor.
|
||||
|
|
@ -74,9 +74,9 @@ fun WaveformPlaybackView(
|
|||
playbackProgress: Float,
|
||||
showCursor: Boolean,
|
||||
waveform: ImmutableList<Float>,
|
||||
onSeek: (progress: Float) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
seekEnabled: Boolean = true,
|
||||
onSeek: (progress: Float) -> Unit = {},
|
||||
brush: Brush = SolidColor(ElementTheme.colors.iconQuaternary),
|
||||
progressBrush: Brush = SolidColor(ElementTheme.colors.iconSecondary),
|
||||
cursorBrush: Brush = SolidColor(ElementTheme.colors.iconAccentTertiary),
|
||||
|
|
@ -183,18 +183,21 @@ internal fun WaveformPlaybackViewPreview() = ElementPreview {
|
|||
modifier = Modifier.height(34.dp),
|
||||
showCursor = false,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = persistentListOf(),
|
||||
)
|
||||
WaveformPlaybackView(
|
||||
modifier = Modifier.height(34.dp),
|
||||
showCursor = false,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = persistentListOf(0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 8f, 7f, 6f, 5f, 4f, 3f, 2f, 1f, 0f),
|
||||
)
|
||||
WaveformPlaybackView(
|
||||
modifier = Modifier.height(34.dp),
|
||||
showCursor = true,
|
||||
playbackProgress = 0.5f,
|
||||
onSeek = {},
|
||||
waveform = List(1024) { it / 1024f }.toPersistentList(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,13 +82,15 @@ private fun ContentToPreview() {
|
|||
PreferenceSwitch(
|
||||
title = "Switch",
|
||||
iconResourceId = CommonDrawables.ic_compound_threads,
|
||||
isChecked = true
|
||||
isChecked = true,
|
||||
onCheckedChange = {},
|
||||
)
|
||||
PreferenceSlide(
|
||||
title = "Slide",
|
||||
summary = "Summary",
|
||||
value = 0.75F,
|
||||
showIconAreaIfNoIcon = true,
|
||||
onValueChange = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ import io.element.android.libraries.theme.ElementTheme
|
|||
fun PreferenceCheckbox(
|
||||
title: String,
|
||||
isChecked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
supportingText: String? = null,
|
||||
enabled: Boolean = true,
|
||||
icon: ImageVector? = null,
|
||||
@DrawableRes iconResourceId: Int? = null,
|
||||
showIconAreaIfNoIcon: Boolean = false,
|
||||
onCheckedChange: (Boolean) -> Unit = {},
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
|
|
@ -104,14 +104,16 @@ private fun ContentToPreview() {
|
|||
title = "Checkbox",
|
||||
iconResourceId = CommonDrawables.ic_compound_threads,
|
||||
enabled = true,
|
||||
isChecked = true
|
||||
isChecked = true,
|
||||
onCheckedChange = {},
|
||||
)
|
||||
PreferenceCheckbox(
|
||||
title = "Checkbox with supporting text",
|
||||
supportingText = "Supporting text",
|
||||
iconResourceId = CommonDrawables.ic_compound_threads,
|
||||
enabled = true,
|
||||
isChecked = true
|
||||
isChecked = true,
|
||||
onCheckedChange = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ import io.element.android.libraries.theme.ElementTheme
|
|||
@Composable
|
||||
fun PreferencePage(
|
||||
title: String,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onBackPressed: () -> Unit = {},
|
||||
snackbarHost: @Composable () -> Unit = {},
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
|
|
@ -81,8 +81,8 @@ fun PreferencePage(
|
|||
@Composable
|
||||
private fun PreferenceTopAppBar(
|
||||
title: String,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onBackPressed: () -> Unit = {},
|
||||
) {
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
|
|
@ -105,7 +105,8 @@ private fun PreferenceTopAppBar(
|
|||
@Composable
|
||||
internal fun PreferenceViewPreview() = ElementPreview {
|
||||
PreferencePage(
|
||||
title = "Preference screen"
|
||||
title = "Preference screen",
|
||||
onBackPressed = {},
|
||||
) {
|
||||
PreferenceCategory(
|
||||
title = "Category title",
|
||||
|
|
@ -120,12 +121,14 @@ internal fun PreferenceViewPreview() = ElementPreview {
|
|||
title = "Switch",
|
||||
iconResourceId = CommonDrawables.ic_compound_threads,
|
||||
isChecked = true,
|
||||
onCheckedChange = {},
|
||||
)
|
||||
PreferenceDivider()
|
||||
PreferenceCheckbox(
|
||||
title = "Checkbox",
|
||||
iconResourceId = CommonDrawables.ic_compound_notifications,
|
||||
isChecked = true,
|
||||
onCheckedChange = {},
|
||||
)
|
||||
PreferenceDivider()
|
||||
PreferenceSlide(
|
||||
|
|
@ -133,6 +136,7 @@ internal fun PreferenceViewPreview() = ElementPreview {
|
|||
summary = "Summary",
|
||||
value = 0.75F,
|
||||
showIconAreaIfNoIcon = true,
|
||||
onValueChange = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ fun PreferenceSlide(
|
|||
title: String,
|
||||
@FloatRange(0.0, 1.0)
|
||||
value: Float,
|
||||
onValueChange: (Float) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
icon: ImageVector? = null,
|
||||
@DrawableRes iconResourceId: Int? = null,
|
||||
|
|
@ -49,7 +50,6 @@ fun PreferenceSlide(
|
|||
enabled: Boolean = true,
|
||||
summary: String? = null,
|
||||
steps: Int = 0,
|
||||
onValueChange: (Float) -> Unit = {},
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
|
|
@ -98,6 +98,7 @@ private fun ContentToPreview() {
|
|||
iconResourceId = CommonDrawables.ic_compound_user_profile,
|
||||
title = "Slide",
|
||||
summary = "Summary",
|
||||
value = 0.75F
|
||||
value = 0.75F,
|
||||
onValueChange = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ import io.element.android.libraries.theme.ElementTheme
|
|||
fun PreferenceSwitch(
|
||||
title: String,
|
||||
isChecked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
subtitle: String? = null,
|
||||
enabled: Boolean = true,
|
||||
icon: ImageVector? = null,
|
||||
@DrawableRes iconResourceId: Int? = null,
|
||||
showIconAreaIfNoIcon: Boolean = false,
|
||||
onCheckedChange: (Boolean) -> Unit = {},
|
||||
switchAlignment: Alignment.Vertical = Alignment.CenterVertically
|
||||
) {
|
||||
Row(
|
||||
|
|
@ -111,6 +111,7 @@ private fun ContentToPreview() {
|
|||
subtitle = "Subtitle Switch",
|
||||
iconResourceId = CommonDrawables.ic_compound_threads,
|
||||
enabled = true,
|
||||
isChecked = true
|
||||
isChecked = true,
|
||||
onCheckedChange = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue