Lambda parameters in a composable function should be in present tense, not past tense.

https://mrmans0n.github.io/compose-rules/rules/#naming-parameters-properly
This commit is contained in:
Benoit Marty 2024-05-29 10:48:29 +02:00
parent 0ba5537082
commit 37d9a9f5a9
250 changed files with 1698 additions and 1698 deletions

View file

@ -106,8 +106,8 @@ fun TextComposer(
onDeleteVoiceMessage: () -> Unit,
onError: (Throwable) -> Unit,
onTyping: (Boolean) -> Unit,
onSuggestionReceived: (Suggestion?) -> Unit,
onRichContentSelected: ((Uri) -> Unit)?,
onReceiveSuggestion: (Suggestion?) -> Unit,
onSelectRichContent: ((Uri) -> Unit)?,
modifier: Modifier = Modifier,
showTextFormatting: Boolean = false,
subcomposing: Boolean = false,
@ -116,15 +116,15 @@ fun TextComposer(
is TextEditorState.Markdown -> state.state.text.value()
is TextEditorState.Rich -> state.richTextEditorState.messageMarkdown
}
val onSendClicked = {
val onSendClick = {
onSendMessage()
}
val onPlayVoiceMessageClicked = {
val onPlayVoiceMessageClick = {
onVoicePlayerEvent(VoiceMessagePlayerEvent.Play)
}
val onPauseVoiceMessageClicked = {
val onPauseVoiceMessageClick = {
onVoicePlayerEvent(VoiceMessagePlayerEvent.Pause)
}
@ -169,7 +169,7 @@ fun TextComposer(
resolveRoomMentionDisplay = { TextDisplay.Custom(mentionSpanProvider.getMentionSpanFor("@room", "#")) },
onError = onError,
onTyping = onTyping,
onRichContentSelected = onRichContentSelected,
onSelectRichContent = onSelectRichContent,
)
}
}
@ -188,9 +188,9 @@ fun TextComposer(
state = state.state,
subcomposing = subcomposing,
onTyping = onTyping,
onSuggestionReceived = onSuggestionReceived,
onReceiveSuggestion = onReceiveSuggestion,
richTextEditorStyle = style,
onRichContentSelected = onRichContentSelected,
onSelectRichContent = onSelectRichContent,
)
}
}
@ -201,7 +201,7 @@ fun TextComposer(
val sendButton = @Composable {
SendButton(
canSendMessage = canSendMessage,
onClick = onSendClicked,
onClick = onSendClick,
composerMode = composerMode,
)
}
@ -251,8 +251,8 @@ fun TextComposer(
waveform = voiceMessageState.waveform,
playbackProgress = voiceMessageState.playbackProgress,
time = voiceMessageState.time,
onPlayClick = onPlayVoiceMessageClicked,
onPauseClick = onPauseVoiceMessageClicked,
onPlayClick = onPlayVoiceMessageClick,
onPauseClick = onPauseVoiceMessageClick,
onSeek = onSeekVoiceMessage,
)
is VoiceMessageState.Recording ->
@ -302,15 +302,15 @@ fun TextComposer(
SoftKeyboardEffect(showTextFormatting, onRequestFocus) { it }
}
val latestOnSuggestionReceived by rememberUpdatedState(onSuggestionReceived)
val latestOnReceiveSuggestion by rememberUpdatedState(onReceiveSuggestion)
if (state is TextEditorState.Rich) {
val menuAction = state.richTextEditorState.menuAction
LaunchedEffect(menuAction) {
if (menuAction is MenuAction.Suggestion) {
val suggestion = Suggestion(menuAction.suggestionPattern)
latestOnSuggestionReceived(suggestion)
latestOnReceiveSuggestion(suggestion)
} else {
latestOnSuggestionReceived(null)
latestOnReceiveSuggestion(null)
}
}
}
@ -481,7 +481,7 @@ private fun TextInput(
resolveMentionDisplay: (text: String, url: String) -> TextDisplay,
onError: (Throwable) -> Unit,
onTyping: (Boolean) -> Unit,
onRichContentSelected: ((Uri) -> Unit)?,
onSelectRichContent: ((Uri) -> Unit)?,
) {
TextInputBox(
composerMode = composerMode,
@ -502,7 +502,7 @@ private fun TextInput(
resolveMentionDisplay = resolveMentionDisplay,
resolveRoomMentionDisplay = resolveRoomMentionDisplay,
onError = onError,
onRichContentSelected = onRichContentSelected,
onRichContentSelected = onSelectRichContent,
onTyping = onTyping,
)
}
@ -842,8 +842,8 @@ private fun ATextComposer(
onDeleteVoiceMessage = {},
onError = {},
onTyping = {},
onSuggestionReceived = {},
onRichContentSelected = null,
onReceiveSuggestion = {},
onSelectRichContent = null,
)
}

View file

@ -104,14 +104,14 @@ private fun CreateLinkWithTextDialog(
TextFieldListItem(
placeholder = stringResource(id = CommonStrings.common_text),
text = linkText,
onTextChanged = { linkText = it },
onTextChange = { linkText = it },
)
}
item {
TextFieldListItem(
placeholder = stringResource(id = R.string.rich_text_editor_url_placeholder),
text = linkUrl,
onTextChanged = { linkUrl = it },
onTextChange = { linkUrl = it },
)
}
}
@ -142,7 +142,7 @@ private fun CreateLinkWithoutTextDialog(
TextFieldListItem(
placeholder = stringResource(id = R.string.rich_text_editor_url_placeholder),
text = linkUrl,
onTextChanged = { linkUrl = it },
onTextChange = { linkUrl = it },
)
}
}
@ -167,7 +167,7 @@ private fun EditLinkDialog(
onDismissRequest()
}
fun onRemoveClicked() {
fun onRemoveClick() {
onRemoveLinkRequest()
onDismissRequest()
}
@ -182,7 +182,7 @@ private fun EditLinkDialog(
TextFieldListItem(
placeholder = stringResource(id = R.string.rich_text_editor_url_placeholder),
text = linkUrl,
onTextChanged = { linkUrl = it },
onTextChange = { linkUrl = it },
)
}
item {
@ -193,7 +193,7 @@ private fun EditLinkDialog(
color = ElementTheme.colors.textCriticalPrimary
)
},
onClick = ::onRemoveClicked,
onClick = ::onRemoveClick,
)
}
}

View file

@ -52,9 +52,9 @@ fun MarkdownTextInput(
state: MarkdownTextEditorState,
subcomposing: Boolean,
onTyping: (Boolean) -> Unit,
onSuggestionReceived: (Suggestion?) -> Unit,
onReceiveSuggestion: (Suggestion?) -> Unit,
richTextEditorStyle: RichTextEditorStyle,
onRichContentSelected: ((Uri) -> Unit)?,
onSelectRichContent: ((Uri) -> Unit)?,
) {
val canUpdateState = !subcomposing
@ -106,18 +106,18 @@ fun MarkdownTextInput(
state.lineCount = lineCount
state.currentMentionSuggestion = editable?.checkSuggestionNeeded()
onSuggestionReceived(state.currentMentionSuggestion)
onReceiveSuggestion(state.currentMentionSuggestion)
}
onSelectionChangeListener = { selStart, selEnd ->
state.selection = selStart..selEnd
state.currentMentionSuggestion = editableText.checkSuggestionNeeded()
onSuggestionReceived(state.currentMentionSuggestion)
onReceiveSuggestion(state.currentMentionSuggestion)
}
if (onRichContentSelected != null) {
if (onSelectRichContent != null) {
ViewCompat.setOnReceiveContentListener(
this,
arrayOf("image/*"),
ReceiveUriContentListener { onRichContentSelected(it) }
ReceiveUriContentListener { onSelectRichContent(it) }
)
}
state.requestFocusAction = { this.requestFocus() }
@ -188,9 +188,9 @@ internal fun MarkdownTextInputPreview() {
state = aMarkdownTextEditorState(),
subcomposing = false,
onTyping = {},
onSuggestionReceived = {},
onReceiveSuggestion = {},
richTextEditorStyle = style,
onRichContentSelected = {},
onSelectRichContent = {},
)
}
}

View file

@ -189,9 +189,9 @@ class MarkdownTextInputTest {
state = state,
subcomposing = subcomposing,
onTyping = onTyping,
onSuggestionReceived = onSuggestionReceived,
onReceiveSuggestion = onSuggestionReceived,
richTextEditorStyle = style,
onRichContentSelected = null,
onSelectRichContent = null,
)
}
}