EmojiPickerEvents -> EmojiPickerEvent
This commit is contained in:
parent
cca2fa5ccc
commit
f327461358
6 changed files with 9 additions and 9 deletions
|
|
@ -60,7 +60,7 @@ fun EmojiPicker(
|
||||||
queryState = state.searchQuery,
|
queryState = state.searchQuery,
|
||||||
resultState = state.searchResults,
|
resultState = state.searchResults,
|
||||||
active = state.isSearchActive,
|
active = state.isSearchActive,
|
||||||
onActiveChange = { state.eventSink(EmojiPickerEvents.ToggleSearchActive(it)) },
|
onActiveChange = { state.eventSink(EmojiPickerEvent.ToggleSearchActive(it)) },
|
||||||
windowInsets = WindowInsets(0, 0, 0, 0),
|
windowInsets = WindowInsets(0, 0, 0, 0),
|
||||||
placeHolderTitle = stringResource(CommonStrings.emoji_picker_search_placeholder),
|
placeHolderTitle = stringResource(CommonStrings.emoji_picker_search_placeholder),
|
||||||
) { emojis ->
|
) { emojis ->
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
|
|
||||||
package io.element.android.features.messages.impl.timeline.components.customreaction.picker
|
package io.element.android.features.messages.impl.timeline.components.customreaction.picker
|
||||||
|
|
||||||
sealed interface EmojiPickerEvents {
|
sealed interface EmojiPickerEvent {
|
||||||
data class ToggleSearchActive(val isActive: Boolean) : EmojiPickerEvents
|
data class ToggleSearchActive(val isActive: Boolean) : EmojiPickerEvent
|
||||||
}
|
}
|
||||||
|
|
@ -93,10 +93,10 @@ class EmojiPickerPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
val isInPreview = LocalInspectionMode.current
|
val isInPreview = LocalInspectionMode.current
|
||||||
fun handleEvent(event: EmojiPickerEvents) {
|
fun handleEvent(event: EmojiPickerEvent) {
|
||||||
when (event) {
|
when (event) {
|
||||||
// For some reason, in preview mode the SearchBar emits this event with an `isActive = true` value automatically
|
// For some reason, in preview mode the SearchBar emits this event with an `isActive = true` value automatically
|
||||||
is EmojiPickerEvents.ToggleSearchActive -> if (!isInPreview) {
|
is EmojiPickerEvent.ToggleSearchActive -> if (!isInPreview) {
|
||||||
isSearchActive = event.isActive
|
isSearchActive = event.isActive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ data class EmojiPickerState(
|
||||||
val searchQuery: TextFieldState,
|
val searchQuery: TextFieldState,
|
||||||
val isSearchActive: Boolean,
|
val isSearchActive: Boolean,
|
||||||
val searchResults: SearchBarResultState<ImmutableList<Emoji>>,
|
val searchResults: SearchBarResultState<ImmutableList<Emoji>>,
|
||||||
val eventSink: (EmojiPickerEvents) -> Unit,
|
val eventSink: (EmojiPickerEvent) -> Unit,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ internal fun anEmojiPickerState(
|
||||||
searchQuery: String = "",
|
searchQuery: String = "",
|
||||||
isSearchActive: Boolean = false,
|
isSearchActive: Boolean = false,
|
||||||
searchResults: SearchBarResultState<ImmutableList<Emoji>> = SearchBarResultState.Initial(),
|
searchResults: SearchBarResultState<ImmutableList<Emoji>> = SearchBarResultState.Initial(),
|
||||||
eventSink: (EmojiPickerEvents) -> Unit = {},
|
eventSink: (EmojiPickerEvent) -> Unit = {},
|
||||||
) = EmojiPickerState(
|
) = EmojiPickerState(
|
||||||
categories = categories,
|
categories = categories,
|
||||||
allEmojis = allEmojis,
|
allEmojis = allEmojis,
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,10 @@ class EmojiPickerPresenterTest {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
assertThat(initialState.isSearchActive).isFalse()
|
assertThat(initialState.isSearchActive).isFalse()
|
||||||
|
|
||||||
initialState.eventSink(EmojiPickerEvents.ToggleSearchActive(true))
|
initialState.eventSink(EmojiPickerEvent.ToggleSearchActive(true))
|
||||||
assertThat(awaitItem().isSearchActive).isTrue()
|
assertThat(awaitItem().isSearchActive).isTrue()
|
||||||
|
|
||||||
initialState.eventSink(EmojiPickerEvents.ToggleSearchActive(false))
|
initialState.eventSink(EmojiPickerEvent.ToggleSearchActive(false))
|
||||||
assertThat(awaitItem().isSearchActive).isFalse()
|
assertThat(awaitItem().isSearchActive).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue