|
|
@ -57,7 +57,6 @@ import io.element.android.libraries.textcomposer.components.VoiceMessagePreview |
|
|
|
import io.element.android.libraries.textcomposer.components.VoiceMessageRecorderButton |
|
|
|
import io.element.android.libraries.textcomposer.components.VoiceMessageRecorderButton |
|
|
|
import io.element.android.libraries.textcomposer.components.VoiceMessageRecording |
|
|
|
import io.element.android.libraries.textcomposer.components.VoiceMessageRecording |
|
|
|
import io.element.android.libraries.textcomposer.components.markdown.MarkdownTextInput |
|
|
|
import io.element.android.libraries.textcomposer.components.markdown.MarkdownTextInput |
|
|
|
import io.element.android.libraries.textcomposer.components.markdown.aMarkdownTextEditorState |
|
|
|
|
|
|
|
import io.element.android.libraries.textcomposer.components.textInputRoundedCornerShape |
|
|
|
import io.element.android.libraries.textcomposer.components.textInputRoundedCornerShape |
|
|
|
import io.element.android.libraries.textcomposer.model.MessageComposerMode |
|
|
|
import io.element.android.libraries.textcomposer.model.MessageComposerMode |
|
|
|
import io.element.android.libraries.textcomposer.model.Suggestion |
|
|
|
import io.element.android.libraries.textcomposer.model.Suggestion |
|
|
@ -65,6 +64,8 @@ import io.element.android.libraries.textcomposer.model.TextEditorState |
|
|
|
import io.element.android.libraries.textcomposer.model.VoiceMessagePlayerEvent |
|
|
|
import io.element.android.libraries.textcomposer.model.VoiceMessagePlayerEvent |
|
|
|
import io.element.android.libraries.textcomposer.model.VoiceMessageRecorderEvent |
|
|
|
import io.element.android.libraries.textcomposer.model.VoiceMessageRecorderEvent |
|
|
|
import io.element.android.libraries.textcomposer.model.VoiceMessageState |
|
|
|
import io.element.android.libraries.textcomposer.model.VoiceMessageState |
|
|
|
|
|
|
|
import io.element.android.libraries.textcomposer.model.aTextEditorStateMarkdown |
|
|
|
|
|
|
|
import io.element.android.libraries.textcomposer.model.aTextEditorStateRich |
|
|
|
import io.element.android.libraries.ui.strings.CommonStrings |
|
|
|
import io.element.android.libraries.ui.strings.CommonStrings |
|
|
|
import io.element.android.wysiwyg.compose.RichTextEditor |
|
|
|
import io.element.android.wysiwyg.compose.RichTextEditor |
|
|
|
import io.element.android.wysiwyg.compose.RichTextEditorState |
|
|
|
import io.element.android.wysiwyg.compose.RichTextEditorState |
|
|
@ -500,7 +501,7 @@ internal fun TextComposerSimplePreview() = ElementPreview { |
|
|
|
items = persistentListOf( |
|
|
|
items = persistentListOf( |
|
|
|
{ |
|
|
|
{ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Markdown(aMarkdownTextEditorState(initialText = "", initialFocus = true)), |
|
|
|
state = aTextEditorStateMarkdown(initialText = "", initialFocus = true), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
enableVoiceMessages = true, |
|
|
|
enableVoiceMessages = true, |
|
|
@ -508,7 +509,7 @@ internal fun TextComposerSimplePreview() = ElementPreview { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Markdown(aMarkdownTextEditorState(initialText = "A message", initialFocus = true)), |
|
|
|
state = aTextEditorStateMarkdown(initialText = "A message", initialFocus = true), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
enableVoiceMessages = true, |
|
|
|
enableVoiceMessages = true, |
|
|
@ -516,11 +517,9 @@ internal fun TextComposerSimplePreview() = ElementPreview { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Markdown( |
|
|
|
state = aTextEditorStateMarkdown( |
|
|
|
aMarkdownTextEditorState( |
|
|
|
initialText = "A message\nWith several lines\nTo preview larger textfields and long lines with overflow", |
|
|
|
initialText = "A message\nWith several lines\nTo preview larger textfields and long lines with overflow", |
|
|
|
initialFocus = true, |
|
|
|
initialFocus = true |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
@ -529,7 +528,7 @@ internal fun TextComposerSimplePreview() = ElementPreview { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Markdown(aMarkdownTextEditorState(initialText = "A message without focus", initialFocus = false)), |
|
|
|
state = aTextEditorStateMarkdown(initialText = "A message without focus", initialFocus = false), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
enableVoiceMessages = true, |
|
|
|
enableVoiceMessages = true, |
|
|
@ -544,7 +543,7 @@ internal fun TextComposerSimplePreview() = ElementPreview { |
|
|
|
internal fun TextComposerFormattingPreview() = ElementPreview { |
|
|
|
internal fun TextComposerFormattingPreview() = ElementPreview { |
|
|
|
PreviewColumn(items = persistentListOf({ |
|
|
|
PreviewColumn(items = persistentListOf({ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Rich(aRichTextEditorState()), |
|
|
|
state = aTextEditorStateRich(), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
showTextFormatting = true, |
|
|
|
showTextFormatting = true, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
@ -552,7 +551,7 @@ internal fun TextComposerFormattingPreview() = ElementPreview { |
|
|
|
) |
|
|
|
) |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Rich(aRichTextEditorState(initialText = "A message")), |
|
|
|
state = aTextEditorStateRich(initialText = "A message"), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
showTextFormatting = true, |
|
|
|
showTextFormatting = true, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
@ -560,10 +559,8 @@ internal fun TextComposerFormattingPreview() = ElementPreview { |
|
|
|
) |
|
|
|
) |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Rich( |
|
|
|
state = aTextEditorStateRich( |
|
|
|
aRichTextEditorState( |
|
|
|
initialText = "A message\nWith several lines\nTo preview larger textfields and long lines with overflow", |
|
|
|
initialText = "A message\nWith several lines\nTo preview larger textfields and long lines with overflow", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
showTextFormatting = true, |
|
|
|
showTextFormatting = true, |
|
|
@ -578,7 +575,7 @@ internal fun TextComposerFormattingPreview() = ElementPreview { |
|
|
|
internal fun TextComposerEditPreview() = ElementPreview { |
|
|
|
internal fun TextComposerEditPreview() = ElementPreview { |
|
|
|
PreviewColumn(items = persistentListOf({ |
|
|
|
PreviewColumn(items = persistentListOf({ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Rich(aRichTextEditorState(initialText = "A message", initialFocus = true)), |
|
|
|
state = aTextEditorStateRich(initialText = "A message", initialFocus = true), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = aMessageComposerModeEdit(), |
|
|
|
composerMode = aMessageComposerModeEdit(), |
|
|
|
enableVoiceMessages = true, |
|
|
|
enableVoiceMessages = true, |
|
|
@ -591,7 +588,7 @@ internal fun TextComposerEditPreview() = ElementPreview { |
|
|
|
internal fun MarkdownTextComposerEditPreview() = ElementPreview { |
|
|
|
internal fun MarkdownTextComposerEditPreview() = ElementPreview { |
|
|
|
PreviewColumn(items = persistentListOf({ |
|
|
|
PreviewColumn(items = persistentListOf({ |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
TextEditorState.Markdown(aMarkdownTextEditorState(initialText = "A message", initialFocus = true)), |
|
|
|
state = aTextEditorStateMarkdown(initialText = "A message", initialFocus = true), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = aMessageComposerModeEdit(), |
|
|
|
composerMode = aMessageComposerModeEdit(), |
|
|
|
enableVoiceMessages = true, |
|
|
|
enableVoiceMessages = true, |
|
|
@ -603,7 +600,7 @@ internal fun MarkdownTextComposerEditPreview() = ElementPreview { |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
internal fun TextComposerReplyPreview(@PreviewParameter(InReplyToDetailsProvider::class) inReplyToDetails: InReplyToDetails) = ElementPreview { |
|
|
|
internal fun TextComposerReplyPreview(@PreviewParameter(InReplyToDetailsProvider::class) inReplyToDetails: InReplyToDetails) = ElementPreview { |
|
|
|
ATextComposer( |
|
|
|
ATextComposer( |
|
|
|
state = TextEditorState.Rich(aRichTextEditorState()), |
|
|
|
state = aTextEditorStateRich(), |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
voiceMessageState = VoiceMessageState.Idle, |
|
|
|
composerMode = aMessageComposerModeReply( |
|
|
|
composerMode = aMessageComposerModeReply( |
|
|
|
replyToDetails = inReplyToDetails, |
|
|
|
replyToDetails = inReplyToDetails, |
|
|
@ -619,7 +616,7 @@ internal fun TextComposerVoicePreview() = ElementPreview { |
|
|
|
fun VoicePreview( |
|
|
|
fun VoicePreview( |
|
|
|
voiceMessageState: VoiceMessageState |
|
|
|
voiceMessageState: VoiceMessageState |
|
|
|
) = ATextComposer( |
|
|
|
) = ATextComposer( |
|
|
|
TextEditorState.Rich(aRichTextEditorState(initialFocus = true)), |
|
|
|
state = aTextEditorStateRich(initialFocus = true), |
|
|
|
voiceMessageState = voiceMessageState, |
|
|
|
voiceMessageState = voiceMessageState, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
composerMode = MessageComposerMode.Normal, |
|
|
|
enableVoiceMessages = true, |
|
|
|
enableVoiceMessages = true, |
|
|
@ -708,17 +705,6 @@ private fun ATextComposer( |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun aRichTextEditorState( |
|
|
|
|
|
|
|
initialText: String = "", |
|
|
|
|
|
|
|
initialHtml: String = initialText, |
|
|
|
|
|
|
|
initialMarkdown: String = initialText, |
|
|
|
|
|
|
|
initialFocus: Boolean = false, |
|
|
|
|
|
|
|
) = RichTextEditorState( |
|
|
|
|
|
|
|
initialHtml = initialHtml, |
|
|
|
|
|
|
|
initialMarkdown = initialMarkdown, |
|
|
|
|
|
|
|
initialFocus = initialFocus, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun aMessageComposerModeEdit( |
|
|
|
fun aMessageComposerModeEdit( |
|
|
|
eventOrTransactionId: EventOrTransactionId = EventId("$1234").toEventOrTransactionId(), |
|
|
|
eventOrTransactionId: EventOrTransactionId = EventId("$1234").toEventOrTransactionId(), |
|
|
|
content: String = "Some text", |
|
|
|
content: String = "Some text", |
|
|
|