diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NetworkAndServers.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NetworkAndServers.kt index 518a670615..b7529ece15 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NetworkAndServers.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/NetworkAndServers.kt @@ -1,6 +1,7 @@ package chat.simplex.common.views.usersettings.networkAndServers import SectionBottomSpacer +import SectionCustomFooter import SectionDividerSpaced import SectionItemView import SectionItemWithValue @@ -235,6 +236,12 @@ fun ModalData.NetworkAndServersView(close: () -> Unit) { ) { Text(stringResource(MR.strings.smp_servers_save), color = if (!saveDisabled) MaterialTheme.colors.onBackground else MaterialTheme.colors.secondary) } + val serversErr = globalServersError(serverErrors.value) + if (serversErr != null) { + SectionCustomFooter { + ServersErrorFooter(serversErr) + } + } SectionDividerSpaced() @@ -679,8 +686,11 @@ private fun ConditionsButton(conditionsAction: UsageConditionsAction) { } @Composable -fun ServerErrorsView(errStr: String) { - Row { +fun ServersErrorFooter(errStr: String) { + Row( + Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically + ) { Icon( painterResource(MR.images.ic_error), contentDescription = stringResource(MR.strings.server_error), @@ -690,7 +700,12 @@ fun ServerErrorsView(errStr: String) { .offset(x = 2.sp.toDp()) ) TextIconSpaced() - Text(errStr, color = MaterialTheme.colors.secondary) + Text( + errStr, + color = MaterialTheme.colors.secondary, + lineHeight = 18.sp, + fontSize = 14.sp + ) } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/OperatorView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/OperatorView.kt index 2574604356..5976819b2d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/OperatorView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/OperatorView.kt @@ -150,12 +150,19 @@ fun OperatorViewLayout( TextIconSpaced() Text(operator.tradeName, color = MaterialTheme.colors.onBackground) } - UseOperatorToggle(currUserServers = currUserServers, userServers = userServers, serverErrors = serverErrors, operatorIndex = operatorIndex, rhId = rhId) + UseOperatorToggle( + scope = scope, + currUserServers = currUserServers, + userServers = userServers, + serverErrors = serverErrors, + operatorIndex = operatorIndex, + rhId = rhId + ) } val serversErr = globalServersError(serverErrors.value) if (serversErr != null) { SectionCustomFooter { - ServerErrorsView(serversErr) + ServersErrorFooter(serversErr) } } else { val footerText = when (val c = operator.conditionsAcceptance) { @@ -226,7 +233,7 @@ fun OperatorViewLayout( val smpErr = globalSMPServersError(serverErrors.value) if (smpErr != null) { SectionCustomFooter { - ServerErrorsView(smpErr) + ServersErrorFooter(smpErr) } } } @@ -249,7 +256,7 @@ fun OperatorViewLayout( val smpErr = globalSMPServersError(serverErrors.value) if (smpErr != null) { SectionCustomFooter { - ServerErrorsView(smpErr) + ServersErrorFooter(smpErr) } } else { SectionTextFooter( @@ -312,7 +319,7 @@ fun OperatorViewLayout( val xftpErr = globalXFTPServersError(serverErrors.value) if (xftpErr != null) { SectionCustomFooter { - ServerErrorsView(xftpErr) + ServersErrorFooter(xftpErr) } } } @@ -335,7 +342,7 @@ fun OperatorViewLayout( val xftpErr = globalXFTPServersError(serverErrors.value) if (xftpErr != null) { SectionCustomFooter { - ServerErrorsView(xftpErr) + ServersErrorFooter(xftpErr) } } else { SectionTextFooter( @@ -419,6 +426,7 @@ private fun OperatorInfoView(serverOperator: ServerOperator) { @Composable private fun UseOperatorToggle( + scope: CoroutineScope, currUserServers: MutableState>, userServers: MutableState>, serverErrors: MutableState>, @@ -440,6 +448,7 @@ private fun UseOperatorToggle( when (val conditionsAcceptance = operator?.conditionsAcceptance) { is ConditionsAcceptance.Accepted -> { changeOperatorEnabled(userServers, operatorIndex, true) + scope.launch { validateServers(rhId, userServers, serverErrors) } } is ConditionsAcceptance.Required -> { @@ -456,6 +465,7 @@ private fun UseOperatorToggle( } } else { changeOperatorEnabled(userServers, operatorIndex, true) + scope.launch { validateServers(rhId, userServers, serverErrors) } } } @@ -463,6 +473,7 @@ private fun UseOperatorToggle( } } else { changeOperatorEnabled(userServers, operatorIndex, false) + scope.launch { validateServers(rhId, userServers, serverErrors) } } }, ) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt index facbd89eab..c035954169 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/networkAndServers/ProtocolServersView.kt @@ -90,7 +90,7 @@ fun YourServersViewLayout( val smpErr = globalSMPServersError(serverErrors.value) if (smpErr != null) { SectionCustomFooter { - ServerErrorsView(smpErr) + ServersErrorFooter(smpErr) } } else { SectionTextFooter( @@ -124,7 +124,7 @@ fun YourServersViewLayout( val xftpErr = globalXFTPServersError(serverErrors.value) if (xftpErr != null) { SectionCustomFooter { - ServerErrorsView(xftpErr) + ServersErrorFooter(xftpErr) } } else { SectionTextFooter( @@ -161,7 +161,7 @@ fun YourServersViewLayout( val serversErr = globalServersError(serverErrors.value) if (serversErr != null) { SectionCustomFooter { - ServerErrorsView(serversErr) + ServersErrorFooter(serversErr) } } SectionDividerSpaced(maxTopPadding = false, maxBottomPadding = false)