Skip to content

Commit 030f2b4

Browse files
authored
Remove track null check from FloatingParticipantVideo (#1424)
1 parent 4ee2194 commit 030f2b4

File tree

1 file changed

+45
-50
lines changed
  • stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer

1 file changed

+45
-50
lines changed

stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/call/renderer/FloatingParticipantVideo.kt

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import androidx.compose.ui.unit.IntOffset
5454
import androidx.compose.ui.unit.IntSize
5555
import androidx.compose.ui.unit.LayoutDirection
5656
import androidx.compose.ui.unit.dp
57-
import androidx.lifecycle.compose.collectAsStateWithLifecycle
5857
import io.getstream.video.android.compose.theme.VideoTheme
5958
import io.getstream.video.android.compose.ui.components.avatar.LocalAvatarPreviewProvider
6059
import io.getstream.video.android.core.Call
@@ -109,8 +108,6 @@ public fun BoxScope.FloatingParticipantVideo(
109108

110109
val paddingOffset = density.run { VideoTheme.dimens.spacingS.toPx() }
111110

112-
val track by participant.videoTrack.collectAsStateWithLifecycle()
113-
114111
if (LocalInspectionMode.current) {
115112
val width = VideoTheme.dimens.genericMax * 2
116113
val height = width * 1.2f
@@ -142,57 +139,55 @@ public fun BoxScope.FloatingParticipantVideo(
142139
return
143140
}
144141

145-
if (track != null) {
146-
Card(
147-
elevation = 8.dp,
148-
modifier = Modifier
149-
.align(alignment)
150-
.size(
151-
height = VideoTheme.dimens.genericMax * 2.2f,
152-
width = VideoTheme.dimens.genericMax * 1.5f,
153-
)
154-
.offset { IntOffset(offset.x.toInt(), offset.y.toInt()) }
155-
.pointerInput(parentBounds) {
156-
detectDragGestures { change, dragAmount ->
157-
change.consume()
142+
Card(
143+
elevation = 8.dp,
144+
modifier = Modifier
145+
.align(alignment)
146+
.size(
147+
height = VideoTheme.dimens.genericMax * 2.2f,
148+
width = VideoTheme.dimens.genericMax * 1.5f,
149+
)
150+
.offset { IntOffset(offset.x.toInt(), offset.y.toInt()) }
151+
.pointerInput(parentBounds) {
152+
detectDragGestures { change, dragAmount ->
153+
change.consume()
158154

159-
val newOffsetX = (offsetX + dragAmount.x)
160-
.coerceAtLeast(
161-
-calculateHorizontalOffsetBounds(
162-
parentBounds = parentBounds,
163-
paddingValues = PaddingValues(0.dp),
164-
floatingVideoSize = videoSize,
165-
density = density,
166-
offset = paddingOffset * 2,
167-
),
168-
)
169-
.coerceAtMost(
170-
0f,
171-
)
155+
val newOffsetX = (offsetX + dragAmount.x)
156+
.coerceAtLeast(
157+
-calculateHorizontalOffsetBounds(
158+
parentBounds = parentBounds,
159+
paddingValues = PaddingValues(0.dp),
160+
floatingVideoSize = videoSize,
161+
density = density,
162+
offset = paddingOffset * 2,
163+
),
164+
)
165+
.coerceAtMost(
166+
0f,
167+
)
172168

173-
val newOffsetY = (offsetY + dragAmount.y)
174-
.coerceAtLeast(0f)
175-
.coerceAtMost(
176-
calculateVerticalOffsetBounds(
177-
parentBounds = parentBounds,
178-
paddingValues = PaddingValues(0.dp),
179-
floatingVideoSize = videoSize,
180-
density = density,
181-
offset = paddingOffset * 2,
182-
),
183-
)
169+
val newOffsetY = (offsetY + dragAmount.y)
170+
.coerceAtLeast(0f)
171+
.coerceAtMost(
172+
calculateVerticalOffsetBounds(
173+
parentBounds = parentBounds,
174+
paddingValues = PaddingValues(0.dp),
175+
floatingVideoSize = videoSize,
176+
density = density,
177+
offset = paddingOffset * 2,
178+
),
179+
)
184180

185-
offsetX = newOffsetX
186-
offsetY = newOffsetY
187-
}
181+
offsetX = newOffsetX
182+
offsetY = newOffsetY
188183
}
189-
.then(modifier)
190-
.padding(VideoTheme.dimens.spacingS)
191-
.onGloballyPositioned { videoSize = it.size },
192-
shape = VideoTheme.shapes.dialog,
193-
) {
194-
videoRenderer.invoke(participant)
195-
}
184+
}
185+
.then(modifier)
186+
.padding(VideoTheme.dimens.spacingS)
187+
.onGloballyPositioned { videoSize = it.size },
188+
shape = VideoTheme.shapes.dialog,
189+
) {
190+
videoRenderer.invoke(participant)
196191
}
197192
}
198193

0 commit comments

Comments
 (0)