mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Move custom status emoji/text into CustomInput state (MVI)
This commit is contained in:
-19
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2026 Element Creations Ltd.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
||||||
* Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.features.preferences.impl.userstatus
|
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import io.element.android.features.preferences.impl.R
|
|
||||||
|
|
||||||
enum class PredefinedUserStatus(val emoji: String, @StringRes val labelRes: Int) {
|
|
||||||
IN_A_MEETING("💬", R.string.common_user_status_in_a_meeting),
|
|
||||||
FOCUS_TIME("💡", R.string.common_user_status_focus_time),
|
|
||||||
ON_THE_ROAD("🚙", R.string.common_user_status_on_the_road),
|
|
||||||
BE_RIGHT_BACK("☕", R.string.common_user_status_be_right_back),
|
|
||||||
AWAY("🌴", R.string.common_user_status_away),
|
|
||||||
}
|
|
||||||
+4
@@ -20,6 +20,10 @@ sealed interface UserStatusEvent {
|
|||||||
data object OpenCustomInput : UserStatusEvent
|
data object OpenCustomInput : UserStatusEvent
|
||||||
/** User tapped Cancel in the inline custom input row. */
|
/** User tapped Cancel in the inline custom input row. */
|
||||||
data object CancelCustomInput : UserStatusEvent
|
data object CancelCustomInput : UserStatusEvent
|
||||||
|
/** User changed the emoji in the custom input row. */
|
||||||
|
data class UpdateCustomEmoji(val emoji: String) : UserStatusEvent
|
||||||
|
/** User changed the text in the custom input row. */
|
||||||
|
data class UpdateCustomText(val text: String) : UserStatusEvent
|
||||||
/** User tapped the clear action on an existing status. */
|
/** User tapped the clear action on an existing status. */
|
||||||
data object Clear : UserStatusEvent
|
data object Clear : UserStatusEvent
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-3
@@ -14,13 +14,15 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import dev.zacsweers.metro.ContributesBinding
|
||||||
import dev.zacsweers.metro.Inject
|
import dev.zacsweers.metro.Inject
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
|
import io.element.android.libraries.di.SessionScope
|
||||||
import io.element.android.libraries.matrix.api.MatrixClient
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
import io.element.android.libraries.matrix.api.user.UserStatus
|
import io.element.android.libraries.matrix.api.user.UserStatus
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Inject
|
@ContributesBinding(SessionScope::class)
|
||||||
class UserStatusPresenter(
|
class UserStatusPresenter(
|
||||||
private val matrixClient: MatrixClient,
|
private val matrixClient: MatrixClient,
|
||||||
) : Presenter<UserStatusState> {
|
) : Presenter<UserStatusState> {
|
||||||
@@ -38,8 +40,8 @@ class UserStatusPresenter(
|
|||||||
UserStatusEvent.OpenCustomInput -> {
|
UserStatusEvent.OpenCustomInput -> {
|
||||||
val raw = userProfile.rawStatus
|
val raw = userProfile.rawStatus
|
||||||
pickerState = UserStatusPickerState.CustomInput(
|
pickerState = UserStatusPickerState.CustomInput(
|
||||||
initialEmoji = raw?.emoji ?: "😀",
|
emoji = raw?.emoji ?: "😀",
|
||||||
initialText = raw?.text ?: "",
|
text = raw?.text ?: "",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is UserStatusEvent.Set -> {
|
is UserStatusEvent.Set -> {
|
||||||
@@ -51,6 +53,14 @@ class UserStatusPresenter(
|
|||||||
coroutineScope.launch { matrixClient.clearUserStatus() }
|
coroutineScope.launch { matrixClient.clearUserStatus() }
|
||||||
}
|
}
|
||||||
UserStatusEvent.CancelCustomInput -> pickerState = UserStatusPickerState.Hidden
|
UserStatusEvent.CancelCustomInput -> pickerState = UserStatusPickerState.Hidden
|
||||||
|
is UserStatusEvent.UpdateCustomEmoji -> {
|
||||||
|
val current = pickerState as? UserStatusPickerState.CustomInput ?: return
|
||||||
|
pickerState = current.copy(emoji = event.emoji)
|
||||||
|
}
|
||||||
|
is UserStatusEvent.UpdateCustomText -> {
|
||||||
|
val current = pickerState as? UserStatusPickerState.CustomInput ?: return
|
||||||
|
pickerState = current.copy(text = event.text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
package io.element.android.features.preferences.impl.userstatus
|
package io.element.android.features.preferences.impl.userstatus
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import io.element.android.features.preferences.impl.R
|
||||||
import io.element.android.libraries.matrix.api.user.DisplayedStatus
|
import io.element.android.libraries.matrix.api.user.DisplayedStatus
|
||||||
|
|
||||||
data class UserStatusState(
|
data class UserStatusState(
|
||||||
@@ -19,7 +21,15 @@ sealed interface UserStatusPickerState {
|
|||||||
data object Hidden : UserStatusPickerState
|
data object Hidden : UserStatusPickerState
|
||||||
data object ShowingPicker : UserStatusPickerState
|
data object ShowingPicker : UserStatusPickerState
|
||||||
data class CustomInput(
|
data class CustomInput(
|
||||||
val initialEmoji: String = "😀",
|
val emoji: String = "😀",
|
||||||
val initialText: String = "",
|
val text: String = "",
|
||||||
) : UserStatusPickerState
|
) : UserStatusPickerState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class PredefinedUserStatus(val emoji: String, @param:StringRes val labelRes: Int) {
|
||||||
|
IN_A_MEETING("💬", R.string.common_user_status_in_a_meeting),
|
||||||
|
FOCUS_TIME("💡", R.string.common_user_status_focus_time),
|
||||||
|
ON_THE_ROAD("🚙", R.string.common_user_status_on_the_road),
|
||||||
|
BE_RIGHT_BACK("☕", R.string.common_user_status_be_right_back),
|
||||||
|
AWAY("🌴", R.string.common_user_status_away),
|
||||||
|
}
|
||||||
|
|||||||
+76
-54
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package io.element.android.features.preferences.impl.userstatus
|
package io.element.android.features.preferences.impl.userstatus
|
||||||
|
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -17,26 +18,29 @@ import androidx.compose.foundation.shape.CircleShape
|
|||||||
import androidx.compose.foundation.text.KeyboardActions
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.ListItem
|
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
|
||||||
import androidx.compose.material3.OutlinedTextField
|
|
||||||
import androidx.compose.material3.Surface
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.TextButton
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
|
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||||
import io.element.android.features.preferences.impl.R
|
import io.element.android.features.preferences.impl.R
|
||||||
|
import io.element.android.libraries.designsystem.components.list.ListItemContent
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.Button
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.IconSource
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.ListItem
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.ModalBottomSheet
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.Surface
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.TextButton
|
||||||
|
import io.element.android.libraries.designsystem.theme.components.TextField
|
||||||
import io.element.android.libraries.matrix.api.user.DisplayedStatus
|
import io.element.android.libraries.matrix.api.user.DisplayedStatus
|
||||||
import io.element.android.libraries.matrix.api.user.UserStatus
|
import io.element.android.libraries.matrix.api.user.UserStatus
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
@@ -72,11 +76,11 @@ fun UserStatusRow(
|
|||||||
}
|
}
|
||||||
is UserStatusPickerState.CustomInput -> {
|
is UserStatusPickerState.CustomInput -> {
|
||||||
CustomStatusInputRow(
|
CustomStatusInputRow(
|
||||||
initialEmoji = pickerState.initialEmoji,
|
emoji = pickerState.emoji,
|
||||||
initialText = pickerState.initialText,
|
text = pickerState.text,
|
||||||
onConfirm = { emoji, text ->
|
onEmojiChange = { state.eventSink(UserStatusEvent.UpdateCustomEmoji(it)) },
|
||||||
state.eventSink(UserStatusEvent.Set(UserStatus(emoji, text)))
|
onTextChange = { state.eventSink(UserStatusEvent.UpdateCustomText(it)) },
|
||||||
},
|
onConfirm = { state.eventSink(UserStatusEvent.Set(UserStatus(pickerState.emoji, pickerState.text))) },
|
||||||
onCancel = { state.eventSink(UserStatusEvent.CancelCustomInput) },
|
onCancel = { state.eventSink(UserStatusEvent.CancelCustomInput) },
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
@@ -91,14 +95,9 @@ private fun EmptyStatusRow(
|
|||||||
) {
|
) {
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(text = stringResource(R.string.screen_preferences_user_status_placeholder))
|
||||||
text = stringResource(R.string.screen_preferences_user_status_placeholder),
|
|
||||||
color = ElementTheme.colors.textSecondary,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = {
|
|
||||||
Text(text = "🙂", style = ElementTheme.typography.fontBodyLgRegular)
|
|
||||||
},
|
},
|
||||||
|
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Reaction())),
|
||||||
modifier = modifier.clickable(onClick = onClick),
|
modifier = modifier.clickable(onClick = onClick),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -116,15 +115,14 @@ private fun CurrentStatusRow(
|
|||||||
}
|
}
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(text = text) },
|
headlineContent = { Text(text = text) },
|
||||||
leadingContent = {
|
leadingContent = ListItemContent.Text(emoji),
|
||||||
Text(text = emoji, style = ElementTheme.typography.fontBodyLgRegular)
|
trailingContent = ListItemContent.Custom({
|
||||||
},
|
IconButton(onClick = onClear) {
|
||||||
trailingContent = {
|
Icon(imageVector = CompoundIcons.Close(), contentDescription = null)
|
||||||
TextButton(onClick = onClear) {
|
|
||||||
Text(text = stringResource(CommonStrings.action_clear))
|
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
modifier = modifier.clickable(onClick = onClick),
|
onClick = onClick,
|
||||||
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,16 +132,15 @@ private fun UserStatusPickerBottomSheet(
|
|||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onSelectPredefined: (UserStatus) -> Unit,
|
onSelectPredefined: (UserStatus) -> Unit,
|
||||||
onSelectCustom: () -> Unit,
|
onSelectCustom: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
ModalBottomSheet(onDismissRequest = onDismiss) {
|
ModalBottomSheet(onDismissRequest = onDismiss, scrollable = true, modifier = modifier) {
|
||||||
PredefinedUserStatus.entries.forEach { predefined ->
|
PredefinedUserStatus.entries.forEach { predefined ->
|
||||||
val label = stringResource(predefined.labelRes)
|
val label = stringResource(predefined.labelRes)
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(text = label) },
|
headlineContent = { Text(text = label) },
|
||||||
leadingContent = {
|
leadingContent = ListItemContent.Text(text = predefined.emoji),
|
||||||
Text(text = predefined.emoji, style = ElementTheme.typography.fontBodyLgRegular)
|
onClick = {
|
||||||
},
|
|
||||||
modifier = Modifier.clickable {
|
|
||||||
onSelectPredefined(UserStatus(emoji = predefined.emoji, text = label))
|
onSelectPredefined(UserStatus(emoji = predefined.emoji, text = label))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -152,25 +149,54 @@ private fun UserStatusPickerBottomSheet(
|
|||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(text = stringResource(R.string.common_user_status_custom))
|
Text(text = stringResource(R.string.common_user_status_custom))
|
||||||
},
|
},
|
||||||
leadingContent = {
|
leadingContent = ListItemContent.Text(text = "✏️"),
|
||||||
Text(text = "✏️", style = ElementTheme.typography.fontBodyLgRegular)
|
onClick = onSelectCustom,
|
||||||
},
|
|
||||||
modifier = Modifier.clickable(onClick = onSelectCustom),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CustomStatusInputRow(
|
private fun CustomStatusInputRow(
|
||||||
initialEmoji: String,
|
emoji: String,
|
||||||
initialText: String,
|
text: String,
|
||||||
onConfirm: (emoji: String, text: String) -> Unit,
|
onEmojiChange: (String) -> Unit,
|
||||||
|
onTextChange: (String) -> Unit,
|
||||||
|
onConfirm: () -> Unit,
|
||||||
onCancel: () -> Unit,
|
onCancel: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
var emoji by remember { mutableStateOf(initialEmoji) }
|
ListItem(
|
||||||
var text by remember { mutableStateOf(initialText) }
|
headlineContent = {
|
||||||
|
TextField(
|
||||||
|
value = text,
|
||||||
|
onValueChange = { if (it.length <= 30) onTextChange(it) },
|
||||||
|
placeholder = stringResource(R.string.screen_preferences_user_status_custom_hint),
|
||||||
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onDone = { if (text.isNotBlank()) onConfirm() }
|
||||||
|
),
|
||||||
|
singleLine = true,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
trailingContent = ListItemContent.Custom({
|
||||||
|
TextButton(onClick = onCancel, text = stringResource(CommonStrings.action_cancel))
|
||||||
|
}),
|
||||||
|
leadingContent = ListItemContent.Custom( {
|
||||||
|
Surface(
|
||||||
|
shape = CircleShape,
|
||||||
|
border = BorderStroke(1.dp, ElementTheme.colors.bgSubtleSecondary),
|
||||||
|
modifier = Modifier
|
||||||
|
.size(50.dp)
|
||||||
|
.clickable { },
|
||||||
|
) {
|
||||||
|
Box(contentAlignment = Alignment.Center) {
|
||||||
|
Text(text = emoji, style = ElementTheme.typography.fontBodyLgRegular)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -188,25 +214,21 @@ private fun CustomStatusInputRow(
|
|||||||
Text(text = emoji, style = ElementTheme.typography.fontBodyLgRegular)
|
Text(text = emoji, style = ElementTheme.typography.fontBodyLgRegular)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OutlinedTextField(
|
TextField(
|
||||||
value = text,
|
value = text,
|
||||||
onValueChange = { if (it.length <= 30) text = it },
|
onValueChange = { if (it.length <= 30) text = it },
|
||||||
placeholder = {
|
placeholder = stringResource(R.string.screen_preferences_user_status_custom_hint),
|
||||||
Text(text = stringResource(R.string.screen_preferences_user_status_custom_hint))
|
|
||||||
},
|
|
||||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
||||||
keyboardActions = KeyboardActions(
|
keyboardActions = KeyboardActions(
|
||||||
onDone = { if (text.isNotBlank()) onConfirm(emoji, text) }
|
onDone = { if (text.isNotBlank()) onConfirm(emoji, text) }
|
||||||
),
|
),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
modifier = Modifier
|
modifier = Modifier.weight(1f).padding(horizontal = 8.dp),
|
||||||
.weight(1f)
|
|
||||||
.padding(horizontal = 8.dp),
|
|
||||||
)
|
)
|
||||||
TextButton(onClick = onCancel) {
|
TextButton(onClick = onCancel, text = stringResource(CommonStrings.action_cancel))
|
||||||
Text(text = stringResource(CommonStrings.action_cancel))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@@ -239,7 +261,7 @@ internal fun UserStatusRowCustomInputPreview() = ElementPreview {
|
|||||||
UserStatusRow(
|
UserStatusRow(
|
||||||
state = UserStatusState(
|
state = UserStatusState(
|
||||||
displayedStatus = null,
|
displayedStatus = null,
|
||||||
pickerState = UserStatusPickerState.CustomInput(initialEmoji = "😀", initialText = ""),
|
pickerState = UserStatusPickerState.CustomInput(emoji = "😀", text = ""),
|
||||||
eventSink = {},
|
eventSink = {},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2026 Element Creations Ltd.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
||||||
* Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.features.preferences.impl.userstatus.di
|
|
||||||
|
|
||||||
import dev.zacsweers.metro.BindingContainer
|
|
||||||
import dev.zacsweers.metro.Binds
|
|
||||||
import dev.zacsweers.metro.ContributesTo
|
|
||||||
import io.element.android.features.preferences.impl.userstatus.UserStatusPresenter
|
|
||||||
import io.element.android.features.preferences.impl.userstatus.UserStatusState
|
|
||||||
import io.element.android.libraries.architecture.Presenter
|
|
||||||
import io.element.android.libraries.di.SessionScope
|
|
||||||
|
|
||||||
@ContributesTo(SessionScope::class)
|
|
||||||
@BindingContainer
|
|
||||||
interface UserStatusModule {
|
|
||||||
@Binds
|
|
||||||
fun bindUserStatusPresenter(presenter: UserStatusPresenter): Presenter<UserStatusState>
|
|
||||||
}
|
|
||||||
+28
-4
@@ -80,8 +80,8 @@ class UserStatusPresenterTest {
|
|||||||
awaitItem().eventSink(UserStatusEvent.OpenCustomInput)
|
awaitItem().eventSink(UserStatusEvent.OpenCustomInput)
|
||||||
val state = awaitItem()
|
val state = awaitItem()
|
||||||
val pickerState = state.pickerState as UserStatusPickerState.CustomInput
|
val pickerState = state.pickerState as UserStatusPickerState.CustomInput
|
||||||
assertThat(pickerState.initialEmoji).isEqualTo("😀")
|
assertThat(pickerState.emoji).isEqualTo("😀")
|
||||||
assertThat(pickerState.initialText).isEqualTo("")
|
assertThat(pickerState.text).isEqualTo("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +97,32 @@ class UserStatusPresenterTest {
|
|||||||
awaitItem().eventSink(UserStatusEvent.OpenCustomInput)
|
awaitItem().eventSink(UserStatusEvent.OpenCustomInput)
|
||||||
val state = awaitItem()
|
val state = awaitItem()
|
||||||
val pickerState = state.pickerState as UserStatusPickerState.CustomInput
|
val pickerState = state.pickerState as UserStatusPickerState.CustomInput
|
||||||
assertThat(pickerState.initialEmoji).isEqualTo("🌴")
|
assertThat(pickerState.emoji).isEqualTo("🌴")
|
||||||
assertThat(pickerState.initialText).isEqualTo("Away")
|
assertThat(pickerState.text).isEqualTo("Away")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `UpdateCustomText updates text in CustomInput state`() = runTest {
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
createPresenter().present()
|
||||||
|
}.test {
|
||||||
|
awaitItem().eventSink(UserStatusEvent.OpenCustomInput)
|
||||||
|
awaitItem().eventSink(UserStatusEvent.UpdateCustomText("Focusing"))
|
||||||
|
val state = awaitItem()
|
||||||
|
assertThat((state.pickerState as UserStatusPickerState.CustomInput).text).isEqualTo("Focusing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `UpdateCustomEmoji updates emoji in CustomInput state`() = runTest {
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
createPresenter().present()
|
||||||
|
}.test {
|
||||||
|
awaitItem().eventSink(UserStatusEvent.OpenCustomInput)
|
||||||
|
awaitItem().eventSink(UserStatusEvent.UpdateCustomEmoji("🚀"))
|
||||||
|
val state = awaitItem()
|
||||||
|
assertThat((state.pickerState as UserStatusPickerState.CustomInput).emoji).isEqualTo("🚀")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user