Merge branch 'claude/add-webrtc-calls-4kBSR' of https://github.com/vitorpamplona/amethyst into claude/add-webrtc-calls-4kBSR
This commit is contained in:
@@ -55,6 +55,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.vitorpamplona.amethyst.commons.call.CallManager
|
import com.vitorpamplona.amethyst.commons.call.CallManager
|
||||||
import com.vitorpamplona.amethyst.commons.call.CallState
|
import com.vitorpamplona.amethyst.commons.call.CallState
|
||||||
|
import com.vitorpamplona.amethyst.service.call.CallController
|
||||||
import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture
|
import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture
|
||||||
import com.vitorpamplona.amethyst.ui.note.UsernameDisplay
|
import com.vitorpamplona.amethyst.ui.note.UsernameDisplay
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
@@ -66,6 +67,7 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun CallScreen(
|
fun CallScreen(
|
||||||
callManager: CallManager,
|
callManager: CallManager,
|
||||||
|
callController: CallController?,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
onCallEnded: () -> Unit,
|
onCallEnded: () -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -91,7 +93,7 @@ fun CallScreen(
|
|||||||
callerPubKey = state.callerPubKey,
|
callerPubKey = state.callerPubKey,
|
||||||
callType = state.callType,
|
callType = state.callType,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onAccept = { /* handled by caller */ },
|
onAccept = { callController?.acceptIncomingCall(state.sdpOffer) },
|
||||||
onReject = { scope.launch { callManager.rejectCall() } },
|
onReject = { scope.launch { callManager.rejectCall() } },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import androidx.compose.animation.fadeOut
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@@ -39,6 +40,7 @@ import androidx.core.util.Consumer
|
|||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.commons.call.CallState
|
||||||
import com.vitorpamplona.amethyst.service.crashreports.DisplayCrashMessages
|
import com.vitorpamplona.amethyst.service.crashreports.DisplayCrashMessages
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.notifyCommand.compose.DisplayNotifyMessages
|
import com.vitorpamplona.amethyst.service.relayClient.notifyCommand.compose.DisplayNotifyMessages
|
||||||
import com.vitorpamplona.amethyst.ui.actions.NewUserMetadataScreen
|
import com.vitorpamplona.amethyst.ui.actions.NewUserMetadataScreen
|
||||||
@@ -48,6 +50,7 @@ import com.vitorpamplona.amethyst.ui.call.CallScreen
|
|||||||
import com.vitorpamplona.amethyst.ui.components.getActivity
|
import com.vitorpamplona.amethyst.ui.components.getActivity
|
||||||
import com.vitorpamplona.amethyst.ui.components.toasts.DisplayErrorMessages
|
import com.vitorpamplona.amethyst.ui.components.toasts.DisplayErrorMessages
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.composableFromEnd
|
import com.vitorpamplona.amethyst.ui.navigation.composableFromEnd
|
||||||
|
import com.vitorpamplona.amethyst.ui.navigation.navs.INav
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.Nav
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberNav
|
import com.vitorpamplona.amethyst.ui.navigation.navs.rememberNav
|
||||||
import com.vitorpamplona.amethyst.ui.navigation.routes.Route
|
import com.vitorpamplona.amethyst.ui.navigation.routes.Route
|
||||||
@@ -162,6 +165,23 @@ fun AppNavigation(
|
|||||||
DisplayNotifyMessages(accountViewModel, nav)
|
DisplayNotifyMessages(accountViewModel, nav)
|
||||||
DisplayCrashMessages(accountViewModel, nav)
|
DisplayCrashMessages(accountViewModel, nav)
|
||||||
DisplayBroadcastProgress(accountViewModel)
|
DisplayBroadcastProgress(accountViewModel)
|
||||||
|
|
||||||
|
ObserveIncomingCalls(accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ObserveIncomingCalls(
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: INav,
|
||||||
|
) {
|
||||||
|
val callState by accountViewModel.callManager.state.collectAsState()
|
||||||
|
|
||||||
|
LaunchedEffect(callState) {
|
||||||
|
val state = callState
|
||||||
|
if (state is CallState.IncomingCall) {
|
||||||
|
nav.nav(Route.ActiveCall(state.callId, state.callerPubKey))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -263,6 +283,7 @@ fun BuildNavigation(
|
|||||||
composableFromEndArgs<Route.ActiveCall> {
|
composableFromEndArgs<Route.ActiveCall> {
|
||||||
CallScreen(
|
CallScreen(
|
||||||
callManager = accountViewModel.callManager,
|
callManager = accountViewModel.callManager,
|
||||||
|
callController = accountViewModel.callController,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
onCallEnded = { nav.popBack() },
|
onCallEnded = { nav.popBack() },
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user