Remove patch on ActionListView and ensure all the test are passing.
This commit is contained in:
parent
7077b8e1bd
commit
c53bf4cab9
2 changed files with 11 additions and 42 deletions
|
|
@ -45,7 +45,6 @@ import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalInspectionMode
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
|
@ -87,7 +86,6 @@ import io.element.android.libraries.designsystem.theme.components.hide
|
||||||
import io.element.android.libraries.designsystem.utils.CommonDrawables
|
import io.element.android.libraries.designsystem.utils.CommonDrawables
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -103,52 +101,28 @@ fun ActionListView(
|
||||||
val targetItem = (state.target as? ActionListState.Target.Success)?.event
|
val targetItem = (state.target as? ActionListState.Target.Success)?.event
|
||||||
|
|
||||||
fun onItemActionClicked(
|
fun onItemActionClicked(
|
||||||
itemAction: TimelineItemAction,
|
itemAction: TimelineItemAction
|
||||||
immediate: Boolean,
|
|
||||||
) {
|
) {
|
||||||
if (targetItem == null) return
|
if (targetItem == null) return
|
||||||
if (immediate) {
|
sheetState.hide(coroutineScope) {
|
||||||
coroutineScope.launch { sheetState.hide() }
|
|
||||||
state.eventSink(ActionListEvents.Clear)
|
state.eventSink(ActionListEvents.Clear)
|
||||||
onActionSelected(itemAction, targetItem)
|
onActionSelected(itemAction, targetItem)
|
||||||
} else {
|
|
||||||
sheetState.hide(coroutineScope) {
|
|
||||||
state.eventSink(ActionListEvents.Clear)
|
|
||||||
onActionSelected(itemAction, targetItem)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEmojiReactionClicked(
|
fun onEmojiReactionClicked(emoji: String) {
|
||||||
emoji: String,
|
|
||||||
immediate: Boolean,
|
|
||||||
) {
|
|
||||||
if (targetItem == null) return
|
if (targetItem == null) return
|
||||||
if (immediate) {
|
sheetState.hide(coroutineScope) {
|
||||||
coroutineScope.launch { sheetState.hide() }
|
|
||||||
state.eventSink(ActionListEvents.Clear)
|
state.eventSink(ActionListEvents.Clear)
|
||||||
onEmojiReactionClicked(emoji, targetItem)
|
onEmojiReactionClicked(emoji, targetItem)
|
||||||
} else {
|
|
||||||
sheetState.hide(coroutineScope) {
|
|
||||||
state.eventSink(ActionListEvents.Clear)
|
|
||||||
onEmojiReactionClicked(emoji, targetItem)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onCustomReactionClicked(
|
fun onCustomReactionClicked() {
|
||||||
immediate: Boolean,
|
|
||||||
) {
|
|
||||||
if (targetItem == null) return
|
if (targetItem == null) return
|
||||||
if (immediate) {
|
sheetState.hide(coroutineScope) {
|
||||||
coroutineScope.launch { sheetState.hide() }
|
|
||||||
state.eventSink(ActionListEvents.Clear)
|
state.eventSink(ActionListEvents.Clear)
|
||||||
onCustomReactionClicked(targetItem)
|
onCustomReactionClicked(targetItem)
|
||||||
} else {
|
|
||||||
sheetState.hide(coroutineScope) {
|
|
||||||
state.eventSink(ActionListEvents.Clear)
|
|
||||||
onCustomReactionClicked(targetItem)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,18 +136,11 @@ fun ActionListView(
|
||||||
onDismissRequest = ::onDismiss,
|
onDismissRequest = ::onDismiss,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
val immediate = LocalInspectionMode.current
|
|
||||||
SheetContent(
|
SheetContent(
|
||||||
state = state,
|
state = state,
|
||||||
onActionClicked = {
|
onActionClicked = ::onItemActionClicked,
|
||||||
onItemActionClicked(it, immediate)
|
onEmojiReactionClicked = ::onEmojiReactionClicked,
|
||||||
},
|
onCustomReactionClicked = ::onCustomReactionClicked,
|
||||||
onEmojiReactionClicked = {
|
|
||||||
onEmojiReactionClicked(it, immediate)
|
|
||||||
},
|
|
||||||
onCustomReactionClicked = {
|
|
||||||
onCustomReactionClicked(immediate)
|
|
||||||
},
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.navigationBarsPadding()
|
.navigationBarsPadding()
|
||||||
.imePadding()
|
.imePadding()
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,8 @@ class MessagesViewTest {
|
||||||
state = stateWithMessageAction,
|
state = stateWithMessageAction,
|
||||||
)
|
)
|
||||||
rule.clickOn(CommonStrings.action_edit)
|
rule.clickOn(CommonStrings.action_edit)
|
||||||
|
// Give time for the close animation to complete
|
||||||
|
rule.mainClock.advanceTimeBy(milliseconds = 1_000)
|
||||||
eventsRecorder.assertSingle(MessagesEvents.HandleAction(TimelineItemAction.Edit, timelineItem))
|
eventsRecorder.assertSingle(MessagesEvents.HandleAction(TimelineItemAction.Edit, timelineItem))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue