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
|
|
@ -68,19 +68,19 @@ import io.element.android.libraries.testtags.TestTags
|
|||
import io.element.android.libraries.testtags.testTag
|
||||
import io.element.android.libraries.textcomposer.components.ComposerOptionsButton
|
||||
import io.element.android.libraries.textcomposer.components.DismissTextFormattingButton
|
||||
import io.element.android.libraries.textcomposer.components.VoiceMessageRecorderButton
|
||||
import io.element.android.libraries.textcomposer.components.SendButton
|
||||
import io.element.android.libraries.textcomposer.components.TextFormatting
|
||||
import io.element.android.libraries.textcomposer.components.VoiceMessageDeleteButton
|
||||
import io.element.android.libraries.textcomposer.components.VoiceMessagePreview
|
||||
import io.element.android.libraries.textcomposer.components.VoiceMessageRecorderButton
|
||||
import io.element.android.libraries.textcomposer.components.VoiceMessageRecording
|
||||
import io.element.android.libraries.textcomposer.components.textInputRoundedCornerShape
|
||||
import io.element.android.libraries.textcomposer.mentions.rememberMentionSpanProvider
|
||||
import io.element.android.libraries.textcomposer.model.Message
|
||||
import io.element.android.libraries.textcomposer.model.MessageComposerMode
|
||||
import io.element.android.libraries.textcomposer.model.VoiceMessageRecorderEvent
|
||||
import io.element.android.libraries.textcomposer.model.Suggestion
|
||||
import io.element.android.libraries.textcomposer.model.VoiceMessagePlayerEvent
|
||||
import io.element.android.libraries.textcomposer.model.VoiceMessageRecorderEvent
|
||||
import io.element.android.libraries.textcomposer.model.VoiceMessageState
|
||||
import io.element.android.libraries.theme.ElementTheme
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
|
@ -101,20 +101,20 @@ fun TextComposer(
|
|||
enableTextFormatting: Boolean,
|
||||
enableVoiceMessages: Boolean,
|
||||
currentUserId: UserId,
|
||||
onRequestFocus: () -> Unit,
|
||||
onSendMessage: (Message) -> Unit,
|
||||
onResetComposerMode: () -> Unit,
|
||||
onAddAttachment: () -> Unit,
|
||||
onDismissTextFormatting: () -> Unit,
|
||||
onVoiceRecorderEvent: (VoiceMessageRecorderEvent) -> Unit,
|
||||
onVoicePlayerEvent: (VoiceMessagePlayerEvent) -> Unit,
|
||||
onSendVoiceMessage: () -> Unit,
|
||||
onDeleteVoiceMessage: () -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onSuggestionReceived: (Suggestion?) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
showTextFormatting: Boolean = false,
|
||||
subcomposing: Boolean = false,
|
||||
onRequestFocus: () -> Unit = {},
|
||||
onSendMessage: (Message) -> Unit = {},
|
||||
onResetComposerMode: () -> Unit = {},
|
||||
onAddAttachment: () -> Unit = {},
|
||||
onDismissTextFormatting: () -> Unit = {},
|
||||
onVoiceRecorderEvent: (VoiceMessageRecorderEvent) -> Unit = {},
|
||||
onVoicePlayerEvent: (VoiceMessagePlayerEvent) -> Unit = {},
|
||||
onSendVoiceMessage: () -> Unit = {},
|
||||
onDeleteVoiceMessage: () -> Unit = {},
|
||||
onError: (Throwable) -> Unit = {},
|
||||
onSuggestionReceived: (Suggestion?) -> Unit = {},
|
||||
) {
|
||||
val onSendClicked = {
|
||||
val html = if (enableTextFormatting) state.messageHtml else null
|
||||
|
|
@ -591,48 +591,40 @@ private fun ReplyToModeView(
|
|||
internal fun TextComposerSimplePreview() = ElementPreview {
|
||||
PreviewColumn(items = persistentListOf(
|
||||
{
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("", initialFocus = true),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Normal,
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost"),
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message", initialFocus = true),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Normal,
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState(
|
||||
"A message\nWith several lines\nTo preview larger textfields and long lines with overflow",
|
||||
initialFocus = true
|
||||
),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Normal,
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message without focus", initialFocus = false),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Normal,
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
|
|
@ -645,7 +637,7 @@ internal fun TextComposerSimplePreview() = ElementPreview {
|
|||
@Composable
|
||||
internal fun TextComposerFormattingPreview() = ElementPreview {
|
||||
PreviewColumn(items = persistentListOf({
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("", initialFocus = false),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
showTextFormatting = true,
|
||||
|
|
@ -655,7 +647,7 @@ internal fun TextComposerFormattingPreview() = ElementPreview {
|
|||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message", initialFocus = false),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
showTextFormatting = true,
|
||||
|
|
@ -665,7 +657,7 @@ internal fun TextComposerFormattingPreview() = ElementPreview {
|
|||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message\nWith several lines\nTo preview larger textfields and long lines with overflow", initialFocus = false),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
showTextFormatting = true,
|
||||
|
|
@ -681,12 +673,10 @@ internal fun TextComposerFormattingPreview() = ElementPreview {
|
|||
@Composable
|
||||
internal fun TextComposerEditPreview() = ElementPreview {
|
||||
PreviewColumn(items = persistentListOf({
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message", initialFocus = true),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Edit(EventId("$1234"), "Some text", TransactionId("1234")),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
|
|
@ -698,10 +688,9 @@ internal fun TextComposerEditPreview() = ElementPreview {
|
|||
@Composable
|
||||
internal fun TextComposerReplyPreview() = ElementPreview {
|
||||
PreviewColumn(items = persistentListOf({
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState(""),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Reply(
|
||||
isThreaded = false,
|
||||
senderName = "Alice",
|
||||
|
|
@ -711,17 +700,15 @@ internal fun TextComposerReplyPreview() = ElementPreview {
|
|||
"With several lines\n" +
|
||||
"To preview larger textfields and long lines with overflow"
|
||||
),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
},
|
||||
{
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState(""),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Reply(
|
||||
isThreaded = true,
|
||||
senderName = "Alice",
|
||||
|
|
@ -731,16 +718,14 @@ internal fun TextComposerReplyPreview() = ElementPreview {
|
|||
"With several lines\n" +
|
||||
"To preview larger textfields and long lines with overflow"
|
||||
),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message"),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Reply(
|
||||
isThreaded = true,
|
||||
senderName = "Alice",
|
||||
|
|
@ -753,16 +738,14 @@ internal fun TextComposerReplyPreview() = ElementPreview {
|
|||
),
|
||||
defaultContent = "image.jpg"
|
||||
),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message"),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Reply(
|
||||
isThreaded = false,
|
||||
senderName = "Alice",
|
||||
|
|
@ -775,16 +758,14 @@ internal fun TextComposerReplyPreview() = ElementPreview {
|
|||
),
|
||||
defaultContent = "video.mp4"
|
||||
),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message"),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Reply(
|
||||
isThreaded = false,
|
||||
senderName = "Alice",
|
||||
|
|
@ -797,16 +778,14 @@ internal fun TextComposerReplyPreview() = ElementPreview {
|
|||
),
|
||||
defaultContent = "logs.txt"
|
||||
),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
)
|
||||
}, {
|
||||
TextComposer(
|
||||
ATextComposer(
|
||||
RichTextEditorState("A message", initialFocus = true),
|
||||
voiceMessageState = VoiceMessageState.Idle,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Reply(
|
||||
isThreaded = false,
|
||||
senderName = "Alice",
|
||||
|
|
@ -819,7 +798,6 @@ internal fun TextComposerReplyPreview() = ElementPreview {
|
|||
),
|
||||
defaultContent = "Shared location"
|
||||
),
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
|
|
@ -834,12 +812,10 @@ internal fun TextComposerVoicePreview() = ElementPreview {
|
|||
@Composable
|
||||
fun VoicePreview(
|
||||
voiceMessageState: VoiceMessageState
|
||||
) = TextComposer(
|
||||
) = ATextComposer(
|
||||
RichTextEditorState("", initialFocus = true),
|
||||
voiceMessageState = voiceMessageState,
|
||||
onSendMessage = {},
|
||||
composerMode = MessageComposerMode.Normal,
|
||||
onResetComposerMode = {},
|
||||
enableTextFormatting = true,
|
||||
enableVoiceMessages = true,
|
||||
currentUserId = UserId("@alice:localhost")
|
||||
|
|
@ -899,3 +875,35 @@ private fun PreviewColumn(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ATextComposer(
|
||||
richTextEditorState: RichTextEditorState,
|
||||
voiceMessageState: VoiceMessageState,
|
||||
composerMode: MessageComposerMode,
|
||||
enableTextFormatting: Boolean,
|
||||
enableVoiceMessages: Boolean,
|
||||
currentUserId: UserId,
|
||||
showTextFormatting: Boolean = false,
|
||||
) {
|
||||
TextComposer(
|
||||
state = richTextEditorState,
|
||||
showTextFormatting = showTextFormatting,
|
||||
voiceMessageState = voiceMessageState,
|
||||
composerMode = composerMode,
|
||||
enableTextFormatting = enableTextFormatting,
|
||||
enableVoiceMessages = enableVoiceMessages,
|
||||
currentUserId = currentUserId,
|
||||
onRequestFocus = {},
|
||||
onSendMessage = {},
|
||||
onResetComposerMode = {},
|
||||
onAddAttachment = {},
|
||||
onDismissTextFormatting = {},
|
||||
onVoiceRecorderEvent = {},
|
||||
onVoicePlayerEvent = {},
|
||||
onSendVoiceMessage = {},
|
||||
onDeleteVoiceMessage = {},
|
||||
onError = {},
|
||||
onSuggestionReceived = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
|||
@Composable
|
||||
fun VoiceMessageDeleteButton(
|
||||
enabled: Boolean,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit = {},
|
||||
) {
|
||||
IconButton(
|
||||
modifier = modifier
|
||||
|
|
@ -59,7 +59,13 @@ fun VoiceMessageDeleteButton(
|
|||
@Composable
|
||||
internal fun VoiceMessageDeleteButtonPreview() = ElementPreview {
|
||||
Row {
|
||||
VoiceMessageDeleteButton(enabled = true)
|
||||
VoiceMessageDeleteButton(enabled = false)
|
||||
VoiceMessageDeleteButton(
|
||||
enabled = true,
|
||||
onClick = {},
|
||||
)
|
||||
VoiceMessageDeleteButton(
|
||||
enabled = false,
|
||||
onClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ internal fun VoiceMessagePreview(
|
|||
showCursor: Boolean,
|
||||
waveform: ImmutableList<Float>,
|
||||
time: Duration,
|
||||
onPlayClick: () -> Unit,
|
||||
onPauseClick: () -> Unit,
|
||||
onSeek: (Float) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
playbackProgress: Float = 0f,
|
||||
onPlayClick: () -> Unit = {},
|
||||
onPauseClick: () -> Unit = {},
|
||||
onSeek: (Float) -> Unit = {},
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
|
|
@ -163,7 +163,7 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
|||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
VoiceMessagePreview(
|
||||
AVoiceMessagePreview(
|
||||
isInteractive = true,
|
||||
isPlaying = true,
|
||||
time = 2.seconds,
|
||||
|
|
@ -171,7 +171,7 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
|||
showCursor = true,
|
||||
waveform = createFakeWaveform()
|
||||
)
|
||||
VoiceMessagePreview(
|
||||
AVoiceMessagePreview(
|
||||
isInteractive = true,
|
||||
isPlaying = false,
|
||||
time = 0.seconds,
|
||||
|
|
@ -179,7 +179,7 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
|||
showCursor = true,
|
||||
waveform = createFakeWaveform()
|
||||
)
|
||||
VoiceMessagePreview(
|
||||
AVoiceMessagePreview(
|
||||
isInteractive = false,
|
||||
isPlaying = false,
|
||||
time = 789.seconds,
|
||||
|
|
@ -189,3 +189,25 @@ internal fun VoiceMessagePreviewPreview() = ElementPreview {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AVoiceMessagePreview(
|
||||
isInteractive: Boolean,
|
||||
isPlaying: Boolean,
|
||||
time: Duration,
|
||||
playbackProgress: Float,
|
||||
showCursor: Boolean,
|
||||
waveform: ImmutableList<Float>,
|
||||
) {
|
||||
VoiceMessagePreview(
|
||||
isInteractive = isInteractive,
|
||||
isPlaying = isPlaying,
|
||||
time = time,
|
||||
playbackProgress = playbackProgress,
|
||||
showCursor = showCursor,
|
||||
waveform = waveform,
|
||||
onPlayClick = {},
|
||||
onPauseClick = {},
|
||||
onSeek = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
|||
@Composable
|
||||
internal fun VoiceMessageRecorderButton(
|
||||
isRecording: Boolean,
|
||||
onEvent: (VoiceMessageRecorderEvent) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onEvent: (VoiceMessageRecorderEvent) -> Unit = {},
|
||||
) {
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
|
||||
|
|
@ -113,7 +113,13 @@ private fun StopButton(
|
|||
@Composable
|
||||
internal fun VoiceMessageRecorderButtonPreview() = ElementPreview {
|
||||
Row {
|
||||
VoiceMessageRecorderButton(isRecording = false)
|
||||
VoiceMessageRecorderButton(isRecording = true)
|
||||
VoiceMessageRecorderButton(
|
||||
isRecording = false,
|
||||
onEvent = {},
|
||||
)
|
||||
VoiceMessageRecorderButton(
|
||||
isRecording = true,
|
||||
onEvent = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue