From a22457d4b5cbf06029418b0926702fc0dcaf1420 Mon Sep 17 00:00:00 2001 From: Martin Felber <45291671+FelberMartin@users.noreply.github.com> Date: Fri, 3 Jan 2025 19:29:21 +0100 Subject: [PATCH] `Chore`: Set tum artemis server as default (#257) --- .../commonConfiguration/KotlinAndroid.kt | 6 +- .../TestServerConfigurationProvider.kt | 2 - .../ServerConfigurationServiceStub.kt | 4 +- .../datastore/ServerConfigurationService.kt | 5 - .../impl/ServerConfigurationServiceImpl.kt | 22 --- .../native_app/feature/login/AccountUi.kt | 149 ++++++++---------- .../InstanceSelectionScreen.kt | 59 +++++++ .../native_app/feature/login/login/LoginUi.kt | 3 +- .../feature/settings/SettingsScreen.kt | 32 +--- 9 files changed, 137 insertions(+), 145 deletions(-) diff --git a/build-logic/convention/src/main/kotlin/commonConfiguration/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/commonConfiguration/KotlinAndroid.kt index eafc2d203..40f40ba46 100644 --- a/build-logic/convention/src/main/kotlin/commonConfiguration/KotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/commonConfiguration/KotlinAndroid.kt @@ -134,6 +134,8 @@ internal fun Project.configureReleaseTypeFlavors( } } +private const val TUM_ARTEMIS_SERVER_URL = "https://artemis.cit.tum.de" + internal fun Project.configureInstanceSelectionFlavors( commonExtension: CommonExtension<*, *, *, *, *, *>, ) { @@ -153,7 +155,7 @@ internal fun Project.configureInstanceSelectionFlavors( buildConfigField( "String", ProductFlavors.BuildConfigFields.DefaultServerUrl, - "\"\"" + "\"$TUM_ARTEMIS_SERVER_URL\"" ) } @@ -169,7 +171,7 @@ internal fun Project.configureInstanceSelectionFlavors( buildConfigField( "String", ProductFlavors.BuildConfigFields.DefaultServerUrl, - "\"https://artemis.cit.tum.de\"" + "\"$TUM_ARTEMIS_SERVER_URL\"" ) } } diff --git a/core/core-test/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/test/test_setup/TestServerConfigurationProvider.kt b/core/core-test/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/test/test_setup/TestServerConfigurationProvider.kt index 7be927f5b..999eb67e8 100644 --- a/core/core-test/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/test/test_setup/TestServerConfigurationProvider.kt +++ b/core/core-test/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/test/test_setup/TestServerConfigurationProvider.kt @@ -8,7 +8,5 @@ import kotlinx.coroutines.flow.flowOf class TestServerConfigurationProvider : ServerConfigurationService { override val serverUrl: Flow = flowOf(testServerUrl) - override val hasUserSelectedInstance: Flow = flowOf(true) - override suspend fun updateServerUrl(serverUrl: String) = Unit } diff --git a/core/datastore/src/debug/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationServiceStub.kt b/core/datastore/src/debug/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationServiceStub.kt index b3ee1415a..41ea73d56 100644 --- a/core/datastore/src/debug/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationServiceStub.kt +++ b/core/datastore/src/debug/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationServiceStub.kt @@ -1,12 +1,10 @@ package de.tum.informatics.www1.artemis.native_app.core.datastore -import de.tum.informatics.www1.artemis.native_app.core.datastore.ServerConfigurationService import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf class ServerConfigurationServiceStub( - override val serverUrl: Flow = flowOf("https://example.com"), - override val hasUserSelectedInstance: Flow = flowOf(true) + override val serverUrl: Flow = flowOf("https://example.com") ) : ServerConfigurationService { override suspend fun updateServerUrl(serverUrl: String) = Unit } diff --git a/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationService.kt b/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationService.kt index 46aeb6bb2..4b01fafde 100644 --- a/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationService.kt +++ b/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/ServerConfigurationService.kt @@ -17,10 +17,5 @@ interface ServerConfigurationService { val host: Flow get() = serverUrl.map { Url(it).host } - /** - * If [updateServerUrl] has ever been called. - */ - val hasUserSelectedInstance: Flow - suspend fun updateServerUrl(serverUrl: String) } \ No newline at end of file diff --git a/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/impl/ServerConfigurationServiceImpl.kt b/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/impl/ServerConfigurationServiceImpl.kt index a9a334f28..9bbcc8f64 100644 --- a/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/impl/ServerConfigurationServiceImpl.kt +++ b/core/datastore/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/datastore/impl/ServerConfigurationServiceImpl.kt @@ -1,13 +1,11 @@ package de.tum.informatics.www1.artemis.native_app.core.datastore.impl import android.content.Context -import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import de.tum.informatics.www1.artemis.native_app.core.datastore.BuildConfig import de.tum.informatics.www1.artemis.native_app.core.datastore.ServerConfigurationService -import io.ktor.http.Url import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.Flow @@ -28,7 +26,6 @@ internal class ServerConfigurationServiceImpl( private val Context.serverCommunicationPreferences by preferencesDataStore("server_communication") private val SERVER_URL_KEY = stringPreferencesKey("server_url") - private val HAS_SELECTED_INSTANCE_KEY = booleanPreferencesKey("has_selected_instance") } /** @@ -47,28 +44,9 @@ internal class ServerConfigurationServiceImpl( .shareIn(GlobalScope, SharingStarted.Eagerly, replay = 1) } - override val host: Flow = - serverUrl - .map { Url(it).host } - - /** - * Use to decide if we want to show an instance selection UI to the user. - * If [BuildConfig.hasInstanceRestriction] is set to true, we never want to show such a UI. - */ - override val hasUserSelectedInstance: Flow = - if (BuildConfig.hasInstanceRestriction) flowOf(true) - else { - context - .serverCommunicationPreferences - .data - .map { it[HAS_SELECTED_INSTANCE_KEY] ?: false } - } - - override suspend fun updateServerUrl(serverUrl: String) { context.serverCommunicationPreferences.edit { data -> data[SERVER_URL_KEY] = serverUrl - data[HAS_SELECTED_INSTANCE_KEY] = true } } } \ No newline at end of file diff --git a/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/AccountUi.kt b/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/AccountUi.kt index 278bdca04..cb887b4ed 100644 --- a/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/AccountUi.kt +++ b/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/AccountUi.kt @@ -7,17 +7,17 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close @@ -27,11 +27,10 @@ import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.Scaffold import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.material3.TopAppBar -import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -44,7 +43,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -67,14 +65,13 @@ import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.linkTe import de.tum.informatics.www1.artemis.native_app.core.ui.navigation.DefaultTransition import de.tum.informatics.www1.artemis.native_app.core.ui.navigation.animatedComposable import de.tum.informatics.www1.artemis.native_app.feature.login.custom_instance_selection.CustomInstanceSelectionScreen -import de.tum.informatics.www1.artemis.native_app.feature.login.instance_selection.InstanceSelectionScreen +import de.tum.informatics.www1.artemis.native_app.feature.login.instance_selection.InstanceSelectionBottomSheet import de.tum.informatics.www1.artemis.native_app.feature.login.login.LoginScreen import de.tum.informatics.www1.artemis.native_app.feature.login.login.LoginUi import de.tum.informatics.www1.artemis.native_app.feature.login.register.RegisterUi import de.tum.informatics.www1.artemis.native_app.feature.login.saml2_login.Saml2LoginScreen import de.tum.informatics.www1.artemis.native_app.feature.login.saml2_login.Saml2LoginViewModel import de.tum.informatics.www1.artemis.native_app.feature.login.service.ServerNotificationStorageService -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import kotlinx.serialization.Serializable @@ -87,8 +84,6 @@ private const val ARG_REMEMBER_ME = "rememberMe" @Serializable private sealed interface NestedDestination { - @Serializable - data object InstanceSelection : NestedDestination @Serializable data object CustomInstanceSelection : NestedDestination @Serializable @@ -212,12 +207,6 @@ private fun LoginUiScreen( val nestedNavController = rememberNavController() val serverConfigurationService: ServerConfigurationService = koinInject() - val hasSelectedInstance = serverConfigurationService - .hasUserSelectedInstance - .collectAsState(initial = null) - .value - ?: return // Display nothing to avoid switching between destinations - // Force recomposition val currentBackStack by nestedNavController.currentBackStackEntryAsState() nestedNavController.currentBackStackEntryAsState().value @@ -260,18 +249,17 @@ private fun LoginUiScreen( ) } ) { paddingValues -> - val sheetState = rememberModalBottomSheetState() - val scope = rememberCoroutineScope() - var showBottomSheet by remember { mutableStateOf(false) } + var showInstanceSelectionBottomSheet by remember { mutableStateOf(false) } NavHost( modifier = Modifier .fillMaxSize() .imePadding() .consumeWindowInsets(WindowInsets.systemBars) - .padding(top = paddingValues.calculateTopPadding()), + .padding(top = paddingValues.calculateTopPadding()) + .padding(horizontal = Spacings.ScreenHorizontalSpacing), navController = nestedNavController, - startDestination = if (hasSelectedInstance) NestedDestination.Home else NestedDestination.InstanceSelection + startDestination = NestedDestination.Home ) { animatedComposable { AccountScreen( @@ -285,7 +273,7 @@ private fun LoginUiScreen( }, onNavigateToInstanceSelection = { onNavigatedToInstanceSelection() - showBottomSheet = true + showInstanceSelectionBottomSheet = true }, onLoggedIn = onLoggedIn, onClickSaml2Login = onClickSaml2Login @@ -298,11 +286,7 @@ private fun LoginUiScreen( .fillMaxSize() .padding(horizontal = 16.dp) ) { - nestedNavController.navigate(NestedDestination.Home) { - popUpTo { - inclusive = true - } - } + nestedNavController.navigate(NestedDestination.Home) } } @@ -344,45 +328,20 @@ private fun LoginUiScreen( } } - val hideBottomSheet: (action: (suspend CoroutineScope.() -> Unit)?) -> Unit = { action -> - scope.launch { - if (action != null) { - action() - } - sheetState.hide() - }.invokeOnCompletion { - if (!sheetState.isVisible) { - showBottomSheet = false - } - } - } - - if (showBottomSheet) { - ModalBottomSheet( - onDismissRequest = { - showBottomSheet = false + if (showInstanceSelectionBottomSheet) { + InstanceSelectionBottomSheet( + onDismiss = { + showInstanceSelectionBottomSheet = false }, - sheetState = sheetState - ) { - InstanceSelectionScreen( - modifier = Modifier - .fillMaxSize() - .padding(horizontal = Spacings.ScreenHorizontalSpacing), - availableInstances = ArtemisInstances.instances, - onSelectArtemisInstance = { serverUrl -> - hideBottomSheet { - serverConfigurationService.updateServerUrl(serverUrl) - } - }, - onRequestOpenCustomInstanceSelection = { - hideBottomSheet { - nestedNavController.navigate( - NestedDestination.CustomInstanceSelection - ) - } - } - ) - } + onSelectArtemisInstance = { + serverConfigurationService.updateServerUrl(it) + }, + onRequestOpenCustomInstanceSelection = { + nestedNavController.navigate( + NestedDestination.CustomInstanceSelection + ) + } + ) } } } @@ -402,10 +361,12 @@ private fun AccountScreen( onClickSaml2Login: (rememberMe: Boolean) -> Unit ) { val serverProfileInfo by viewModel.serverProfileInfo.collectAsState() + val selectedInstance by viewModel.selectedArtemisInstance.collectAsState() AccountUi( modifier = modifier, serverProfileInfo = serverProfileInfo, + selectedInstance = selectedInstance, canSwitchInstance = canSwitchInstance, retryLoadServerProfileInfo = viewModel::requestReloadServerProfileInfo, onNavigateToLoginScreen = onNavigateToLoginScreen, @@ -420,6 +381,7 @@ private fun AccountScreen( private fun AccountUi( modifier: Modifier, serverProfileInfo: DataState, + selectedInstance: ArtemisInstances.ArtemisInstance, canSwitchInstance: Boolean, retryLoadServerProfileInfo: () -> Unit, onNavigateToLoginScreen: () -> Unit, @@ -437,7 +399,10 @@ private fun AccountUi( .fillMaxHeight(0.05f) ) - ArtemisHeader(modifier = Modifier.fillMaxWidth()) + ArtemisHeader( + modifier = Modifier.fillMaxWidth(), + selectedInstance = selectedInstance + ) Box( modifier = Modifier @@ -458,19 +423,17 @@ private fun AccountUi( ) if (canSwitchInstance) { - ClickableText( + TextButton( modifier = Modifier - .align(Alignment.CenterHorizontally) - .padding( - bottom = WindowInsets.systemBars - .asPaddingValues() - .calculateBottomPadding() - + 8.dp - ), - text = AnnotatedString(stringResource(id = R.string.account_change_artemis_instance_label)), - style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.linkTextColor), - onClick = { onNavigateToInstanceSelection() } - ) + .padding(vertical = 8.dp) + .align(Alignment.CenterHorizontally), + onClick = onNavigateToInstanceSelection + ) { + Text( + text = stringResource(id = R.string.account_change_artemis_instance_label), + style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.linkTextColor) + ) + } } } } @@ -521,7 +484,7 @@ private fun RegisterLoginAccount( //Just for the preview. LoginUi( modifier = loginUiModifier, - accountName = "TUm", + accountName = "TUM", needsToAcceptTerms = true, hasUserAcceptedTerms = true, saml2Config = null, @@ -608,10 +571,16 @@ private fun LoginOrRegister( } @Composable -internal fun ArtemisHeader(modifier: Modifier) { - Column(modifier = modifier) { +internal fun ArtemisHeader( + modifier: Modifier, + selectedInstance: ArtemisInstances.ArtemisInstance, +) { + Column( + modifier = modifier, + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { Text( - modifier = Modifier.fillMaxWidth(), text = stringResource(id = R.string.account_screen_title), fontSize = 32.sp, fontWeight = FontWeight.Bold, @@ -619,14 +588,22 @@ internal fun ArtemisHeader(modifier: Modifier) { ) Text( - modifier = Modifier - .fillMaxWidth() - .padding(top = 4.dp), text = stringResource(id = R.string.account_screen_subtitle), fontSize = 20.sp, fontWeight = FontWeight.Normal, textAlign = TextAlign.Center ) + + + if (BuildConfig.DEBUG || selectedInstance.type == ArtemisInstances.ArtemisInstance.Type.CUSTOM) { + Spacer(Modifier.height(8.dp)) + + Text( + text = selectedInstance.host, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.secondary + ) + } } } @@ -637,6 +614,7 @@ fun AccountUiPreviewLoadingProfileInfo() { modifier = Modifier.fillMaxSize(), canSwitchInstance = true, serverProfileInfo = DataState.Loading(), + selectedInstance = ArtemisInstances.TumArtemis, retryLoadServerProfileInfo = {}, onNavigateToLoginScreen = {}, onNavigateToRegisterScreen = {}, @@ -653,6 +631,7 @@ fun AccountUiPreviewFailedLoadingProfileInfo() { modifier = Modifier.fillMaxSize(), canSwitchInstance = true, serverProfileInfo = DataState.Failure(IOException()), + selectedInstance = ArtemisInstances.TumArtemis, retryLoadServerProfileInfo = {}, onNavigateToLoginScreen = {}, onNavigateToRegisterScreen = {}, @@ -673,6 +652,7 @@ fun AccountUiPreviewWithRegister() { registrationEnabled = true ) ), + selectedInstance = ArtemisInstances.TumArtemis, retryLoadServerProfileInfo = {}, onNavigateToLoginScreen = {}, onNavigateToRegisterScreen = {}, @@ -693,6 +673,7 @@ fun AccountUiPreviewWithoutRegister() { registrationEnabled = false ) ), + selectedInstance = ArtemisInstances.TumArtemis, retryLoadServerProfileInfo = {}, onNavigateToLoginScreen = {}, onNavigateToRegisterScreen = {}, diff --git a/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/instance_selection/InstanceSelectionScreen.kt b/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/instance_selection/InstanceSelectionScreen.kt index f7dc4e843..dcb81a09f 100644 --- a/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/instance_selection/InstanceSelectionScreen.kt +++ b/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/instance_selection/InstanceSelectionScreen.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -17,9 +18,12 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material3.Card import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.Text +import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -30,7 +34,62 @@ import androidx.compose.ui.unit.dp import coil3.compose.AsyncImage import coil3.request.ImageRequest import de.tum.informatics.www1.artemis.native_app.core.datastore.defaults.ArtemisInstances +import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings import de.tum.informatics.www1.artemis.native_app.feature.login.R +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch + + +@Composable +fun InstanceSelectionBottomSheet( + modifier: Modifier = Modifier, + onDismiss: () -> Unit, + onSelectArtemisInstance: suspend (String) -> Unit, + onRequestOpenCustomInstanceSelection: suspend () -> Unit +) { + val scope = rememberCoroutineScope() + val sheetState = rememberModalBottomSheetState( + skipPartiallyExpanded = true + ) + + val hideBottomSheet: (action: (suspend CoroutineScope.() -> Unit)?) -> Unit = { action -> + scope.launch { + if (action != null) { + action() + } + sheetState.hide() + }.invokeOnCompletion { + if (!sheetState.isVisible) { + onDismiss() + } + } + } + + ModalBottomSheet( + modifier = modifier.padding( + top = WindowInsets.systemBars.asPaddingValues().calculateTopPadding(), + ), + onDismissRequest = onDismiss, + sheetState = sheetState + ) { + InstanceSelectionScreen( + modifier = Modifier + .fillMaxSize() + .padding(horizontal = Spacings.ScreenHorizontalSpacing), + availableInstances = ArtemisInstances.instances, + onSelectArtemisInstance = { serverUrl -> + hideBottomSheet { + onSelectArtemisInstance(serverUrl) + } + }, + onRequestOpenCustomInstanceSelection = { + hideBottomSheet { + onRequestOpenCustomInstanceSelection() + } + } + ) + } +} @Composable internal fun InstanceSelectionScreen( diff --git a/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/login/LoginUi.kt b/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/login/LoginUi.kt index f38f78582..228b90772 100644 --- a/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/login/LoginUi.kt +++ b/feature/login/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/login/login/LoginUi.kt @@ -3,7 +3,6 @@ package de.tum.informatics.www1.artemis.native_app.feature.login.login import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.rememberScrollState @@ -193,7 +192,7 @@ internal fun LoginUi( ) val loginModifier = Modifier - .padding(16.dp) + .padding(vertical = 16.dp) .widthIn(max = 600.dp) .fillMaxWidth(0.8f) .align(Alignment.CenterHorizontally) diff --git a/feature/settings/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/settings/SettingsScreen.kt b/feature/settings/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/settings/SettingsScreen.kt index fb97d1cc6..7c209f462 100644 --- a/feature/settings/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/settings/SettingsScreen.kt +++ b/feature/settings/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/settings/SettingsScreen.kt @@ -20,7 +20,6 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.AlternateEmail import androidx.compose.material.icons.filled.ChevronRight import androidx.compose.material.icons.filled.Mail -import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -147,10 +146,6 @@ private fun SettingsScreen( val scope = rememberCoroutineScope() - val hasUserSelectedInstance by serverConfigurationService.hasUserSelectedInstance.collectAsState( - initial = false - ) - val accountDataService: AccountDataService = koinInject() val networkStatusProvider: NetworkStatusProvider = koinInject() @@ -230,7 +225,6 @@ private fun SettingsScreen( AboutSection( modifier = Modifier.fillMaxWidth(), - hasUserSelectedInstance = hasUserSelectedInstance, serverUrl = serverUrl, onOpenPrivacyPolicy = { val link = URLBuilder(serverUrl).appendPathSegments("privacy").buildString() @@ -242,9 +236,6 @@ private fun SettingsScreen( linkOpener.openLink(link) }, onOpenThirdPartyLicenses = onDisplayThirdPartyLicenses, - // it can only be unselected, if the user has navigated to the settings from the instance selection screen. - // Therefore, a simple navigate up will let the user select the server instance. - onRequestSelectServerInstance = onNavigateUp ) BuildInformationSection( @@ -341,9 +332,7 @@ private fun NotificationSection(modifier: Modifier, onOpenNotificationSettings: @Composable private fun AboutSection( modifier: Modifier, - hasUserSelectedInstance: Boolean, serverUrl: String, - onRequestSelectServerInstance: () -> Unit, onOpenPrivacyPolicy: () -> Unit, onOpenImprint: () -> Unit, onOpenThirdPartyLicenses: () -> Unit @@ -362,7 +351,7 @@ private fun AboutSection( ) } - if (hasUserSelectedInstance) { + if (serverUrl.isNotEmpty()) { ServerURLEntry( modifier = Modifier.fillMaxWidth(), text = stringResource(R.string.settings_server_url), @@ -385,19 +374,12 @@ private fun AboutSection( onClick = onOpenImprint ) } else { - Column(modifier = Modifier.padding(horizontal = 16.dp)) { - Text( - text = stringResource(id = R.string.settings_server_specifics_unavailable), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.error - ) - - Button( - onClick = onRequestSelectServerInstance - ) { - Text(text = stringResource(id = R.string.settings_server_specifics_unavailable_select_instance_button)) - } - } + Text( + modifier = Modifier.padding(horizontal = 16.dp), + text = stringResource(id = R.string.settings_server_specifics_unavailable), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.error + ) } ButtonEntry(