Skip to content

Commit 076b787

Browse files
alex-signalmtang-signal
authored andcommitted
Fix reaction and state bar placement on new call screen.
1 parent a79a059 commit 076b787

File tree

3 files changed

+72
-36
lines changed

3 files changed

+72
-36
lines changed

app/src/main/java/org/thoughtcrime/securesms/components/webrtc/controls/RaiseHandSnackbar.kt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import androidx.compose.material3.TextButton
2727
import androidx.compose.runtime.Composable
2828
import androidx.compose.runtime.LaunchedEffect
2929
import androidx.compose.runtime.collectAsState
30-
import androidx.compose.runtime.derivedStateOf
3130
import androidx.compose.runtime.getValue
3231
import androidx.compose.runtime.mutableStateOf
3332
import androidx.compose.runtime.remember
@@ -54,6 +53,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
5453
import org.thoughtcrime.securesms.events.CallParticipant
5554
import org.thoughtcrime.securesms.events.GroupCallRaiseHandEvent
5655
import org.thoughtcrime.securesms.events.GroupCallSpeechEvent
56+
import org.thoughtcrime.securesms.recipients.Recipient
5757
import java.util.concurrent.TimeUnit
5858
import kotlin.math.max
5959
import kotlin.time.Duration
@@ -69,9 +69,7 @@ object RaiseHandSnackbar {
6969

7070
@Composable
7171
fun View(webRtcCallViewModel: WebRtcCallViewModel, showCallInfoListener: () -> Unit, modifier: Modifier = Modifier) {
72-
var expansionState by remember { mutableStateOf(ExpansionState(shouldExpand = false, forced = false, collapseTimestamp = Duration.ZERO)) }
73-
74-
val raisedHandsState by remember {
72+
val raisedHandsState: List<GroupCallRaiseHandEvent> by remember {
7573
webRtcCallViewModel.callParticipantsState
7674
.map { state ->
7775
val raisedHands = state.raisedHands.sortedBy {
@@ -90,12 +88,17 @@ object RaiseHandSnackbar {
9088
}
9189
}.collectAsState(initial = emptyList())
9290

93-
val speechEvent by webRtcCallViewModel.groupCallSpeechEvents.collectAsStateWithLifecycle()
91+
val speechEvent: GroupCallSpeechEvent? by webRtcCallViewModel.groupCallSpeechEvents.collectAsStateWithLifecycle()
9492

95-
val state by remember {
96-
derivedStateOf {
97-
RaiseHandState(raisedHands = raisedHandsState, expansionState = expansionState, speechEvent = speechEvent)
98-
}
93+
View(raisedHandsState, speechEvent, showCallInfoListener, modifier)
94+
}
95+
96+
@Composable
97+
fun View(raisedHandsState: List<GroupCallRaiseHandEvent>, speechEvent: GroupCallSpeechEvent?, showCallInfoListener: () -> Unit, modifier: Modifier = Modifier) {
98+
var expansionState by remember { mutableStateOf(ExpansionState(shouldExpand = false, forced = false, collapseTimestamp = Duration.ZERO)) }
99+
100+
val state = remember(raisedHandsState, speechEvent, expansionState) {
101+
RaiseHandState(raisedHands = raisedHandsState, expansionState = expansionState, speechEvent = speechEvent)
99102
}
100103

101104
LaunchedEffect(raisedHandsState, speechEvent) {
@@ -119,7 +122,7 @@ object RaiseHandSnackbar {
119122
@Composable
120123
private fun RaiseHandSnackbarPreview() {
121124
RaiseHand(
122-
state = RaiseHandState(listOf(GroupCallRaiseHandEvent(CallParticipant.EMPTY, System.currentTimeMillis())))
125+
state = RaiseHandState(listOf(GroupCallRaiseHandEvent(CallParticipant(recipient = Recipient(isResolving = false, systemContactName = "Miles Morales")), System.currentTimeMillis())))
123126
)
124127
}
125128

@@ -133,19 +136,20 @@ private fun RaiseHand(
133136
AnimatedVisibility(
134137
visible = state.raisedHands.isNotEmpty(),
135138
enter = fadeIn() + expandIn(expandFrom = Alignment.CenterEnd),
136-
exit = shrinkOut(shrinkTowards = Alignment.CenterEnd) + fadeOut()
139+
exit = shrinkOut(shrinkTowards = Alignment.CenterEnd) + fadeOut(),
140+
modifier = modifier
137141
) {
138142
SignalTheme(
139143
isDarkMode = true
140144
) {
141145
Surface(
142-
modifier = modifier
146+
modifier = Modifier
143147
.padding(horizontal = 16.dp)
144148
.clip(shape = RoundedCornerShape(16.dp, 16.dp, 16.dp, 16.dp))
145149
.background(SignalTheme.colors.colorSurface1)
146150
.animateContentSize()
147151
) {
148-
val boxModifier = modifier
152+
val boxModifier = Modifier
149153
.padding(horizontal = 16.dp)
150154
.clickable(
151155
!state.isExpanded,

app/src/main/java/org/thoughtcrime/securesms/components/webrtc/v2/CallScreen.kt

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ import org.signal.core.util.DimensionUnit
7575
import org.thoughtcrime.securesms.R
7676
import org.thoughtcrime.securesms.components.webrtc.CallParticipantView
7777
import org.thoughtcrime.securesms.components.webrtc.WebRtcLocalRenderState
78+
import org.thoughtcrime.securesms.components.webrtc.controls.RaiseHandSnackbar
7879
import org.thoughtcrime.securesms.conversation.colors.ChatColorsPalette
7980
import org.thoughtcrime.securesms.events.CallParticipant
81+
import org.thoughtcrime.securesms.events.GroupCallRaiseHandEvent
8082
import org.thoughtcrime.securesms.events.GroupCallReactionEvent
8183
import org.thoughtcrime.securesms.events.WebRtcViewModel
8284
import org.thoughtcrime.securesms.recipients.Recipient
@@ -249,11 +251,6 @@ fun CallScreen(
249251
} else Modifier
250252
)
251253

252-
CallScreenReactionsContainer(
253-
reactions = reactions,
254-
modifier = Modifier.padding(bottom = padding)
255-
)
256-
257254
val onCallInfoClick: () -> Unit = {
258255
scope.launch {
259256
if (scaffoldState.bottomSheetState.currentValue == SheetValue.Expanded) {
@@ -291,25 +288,44 @@ fun CallScreen(
291288
)
292289
}
293290

294-
raiseHandSnackbar(Modifier.fillMaxWidth())
295-
296-
AnimatedCallStateUpdate(
297-
callControlsChange = callScreenState.callControlsChange,
291+
// This content lives "above" the controls sheet and includes raised hands, status updates, etc.
292+
Box(
298293
modifier = Modifier
299-
.align(Alignment.BottomCenter)
294+
.fillMaxSize()
300295
.padding(bottom = padding)
301-
.padding(bottom = 20.dp)
302-
)
296+
) {
297+
Column(
298+
modifier = Modifier
299+
.fillMaxSize()
300+
.padding(bottom = 20.dp)
301+
) {
302+
CallScreenReactionsContainer(
303+
reactions = reactions,
304+
modifier = Modifier.weight(1f)
305+
)
303306

304-
val state = remember(callScreenState.pendingParticipantsState) {
305-
callScreenState.pendingParticipantsState
306-
}
307+
raiseHandSnackbar(
308+
Modifier
309+
)
310+
}
307311

308-
if (state != null) {
309-
PendingParticipants(
310-
pendingParticipantsState = state,
311-
pendingParticipantsListener = pendingParticipantsListener
312+
AnimatedCallStateUpdate(
313+
callControlsChange = callScreenState.callControlsChange,
314+
modifier = Modifier
315+
.align(Alignment.BottomCenter)
316+
.padding(bottom = 20.dp)
312317
)
318+
319+
val state = remember(callScreenState.pendingParticipantsState) {
320+
callScreenState.pendingParticipantsState
321+
}
322+
323+
if (state != null) {
324+
PendingParticipants(
325+
pendingParticipantsState = state,
326+
pendingParticipantsListener = pendingParticipantsListener
327+
)
328+
}
313329
}
314330
}
315331
}
@@ -649,7 +665,7 @@ private fun CallScreenPreview() {
649665
Previews.Preview {
650666
CallScreen(
651667
callRecipient = Recipient(systemContactName = "Test User"),
652-
webRtcCallState = WebRtcViewModel.State.CALL_PRE_JOIN,
668+
webRtcCallState = WebRtcViewModel.State.CALL_CONNECTED,
653669
isRemoteVideoOffer = false,
654670
isInPipMode = false,
655671
callScreenState = CallScreenState(
@@ -682,7 +698,24 @@ private fun CallScreenPreview() {
682698
callInfoView = {
683699
Text(text = "Call Info View Preview", modifier = Modifier.alpha(it))
684700
},
685-
raiseHandSnackbar = {},
701+
raiseHandSnackbar = {
702+
RaiseHandSnackbar.View(
703+
raisedHandsState = listOf(
704+
GroupCallRaiseHandEvent(
705+
sender = CallParticipant(
706+
recipient = Recipient(
707+
isResolving = false,
708+
systemContactName = "Miles Morales"
709+
)
710+
),
711+
timestampMillis = System.currentTimeMillis()
712+
)
713+
),
714+
speechEvent = null,
715+
showCallInfoListener = {},
716+
modifier = it
717+
)
718+
},
686719
onNavigationClick = {},
687720
onLocalPictureInPictureClicked = {},
688721
overflowParticipants = participants,

app/src/main/java/org/thoughtcrime/securesms/components/webrtc/v2/CallScreenReactionsContainer.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package org.thoughtcrime.securesms.components.webrtc.v2
77

8-
import androidx.compose.foundation.layout.fillMaxSize
98
import androidx.compose.foundation.layout.padding
109
import androidx.compose.runtime.Composable
1110
import androidx.compose.runtime.remember
@@ -42,7 +41,7 @@ fun CallScreenReactionsContainer(
4241
view.isVerticalScrollBarEnabled = false
4342

4443
view
45-
}, modifier = modifier.fillMaxSize().padding(16.dp).padding(bottom = 16.dp)) {
44+
}, modifier = modifier.padding(16.dp)) {
4645
adapter.submitList(reactions.toMutableList())
4746
}
4847
}

0 commit comments

Comments
 (0)