android: close Use from desktop when disconnecting

This commit is contained in:
Evgeny Poberezkin 2023-11-22 22:34:30 +00:00
parent 01f351e65a
commit d0419df396

View File

@ -53,6 +53,7 @@ fun ConnectDesktopView(close: () -> Unit) {
ModalView(close = closeWithAlert) { ModalView(close = closeWithAlert) {
ConnectDesktopLayout( ConnectDesktopLayout(
deviceName = deviceName.value!!, deviceName = deviceName.value!!,
close
) )
} }
val ntfModeService = remember { chatModel.controller.appPrefs.notificationsMode.get() == NotificationsMode.SERVICE } val ntfModeService = remember { chatModel.controller.appPrefs.notificationsMode.get() == NotificationsMode.SERVICE }
@ -67,7 +68,7 @@ fun ConnectDesktopView(close: () -> Unit) {
} }
@Composable @Composable
private fun ConnectDesktopLayout(deviceName: String) { private fun ConnectDesktopLayout(deviceName: String, close: () -> Unit) {
val sessionAddress = remember { mutableStateOf("") } val sessionAddress = remember { mutableStateOf("") }
val remoteCtrls = remember { mutableStateListOf<RemoteCtrlInfo>() } val remoteCtrls = remember { mutableStateListOf<RemoteCtrlInfo>() }
val session = remember { chatModel.remoteCtrlSession }.value val session = remember { chatModel.remoteCtrlSession }.value
@ -89,7 +90,7 @@ private fun ConnectDesktopLayout(deviceName: String) {
} }
} }
is UIRemoteCtrlSessionState.Connected -> ActiveSession(session, session.sessionState.remoteCtrl) is UIRemoteCtrlSessionState.Connected -> ActiveSession(session, session.sessionState.remoteCtrl, close)
} }
} else { } else {
ConnectDesktop(deviceName, remoteCtrls, sessionAddress) ConnectDesktop(deviceName, remoteCtrls, sessionAddress)
@ -205,7 +206,7 @@ private fun CtrlDeviceVersionText(session: RemoteCtrlSession) {
} }
@Composable @Composable
private fun ActiveSession(session: RemoteCtrlSession, rc: RemoteCtrlInfo) { private fun ActiveSession(session: RemoteCtrlSession, rc: RemoteCtrlInfo, close: () -> Unit) {
AppBarTitle(stringResource(MR.strings.connected_to_desktop)) AppBarTitle(stringResource(MR.strings.connected_to_desktop))
SectionView(stringResource(MR.strings.connected_desktop).uppercase(), padding = PaddingValues(horizontal = DEFAULT_PADDING)) { SectionView(stringResource(MR.strings.connected_desktop).uppercase(), padding = PaddingValues(horizontal = DEFAULT_PADDING)) {
Text(rc.deviceViewName) Text(rc.deviceViewName)
@ -223,7 +224,7 @@ private fun ActiveSession(session: RemoteCtrlSession, rc: RemoteCtrlInfo) {
SectionSpacer() SectionSpacer()
SectionView { SectionView {
DisconnectButton(::disconnectDesktop) DisconnectButton { disconnectDesktop(close) }
} }
} }