Share login-required content; use shared composable in Android dialog

This commit is contained in:
2025-09-18 23:29:19 +02:00
parent 9da472fd2d
commit 793419893a
2 changed files with 43 additions and 5 deletions

View File

@@ -144,6 +144,7 @@ import app.klottr.ui.FoundContent // Delat innehåll för “Hittat”
import app.klottr.ui.FoundDetailContent // Delad detalj-UI (CMP) import app.klottr.ui.FoundDetailContent // Delad detalj-UI (CMP)
import app.klottr.ui.KlottrAboutContent import app.klottr.ui.KlottrAboutContent
import app.klottr.ui.KlottrHomeContent // Ny: delat mittinnehåll import app.klottr.ui.KlottrHomeContent // Ny: delat mittinnehåll
import app.klottr.ui.LoginRequiredContent
import app.klottr.ui.NearbyContent // Delat material-fritt innehåll för Närliggande import app.klottr.ui.NearbyContent // Delat material-fritt innehåll för Närliggande
import app.klottr.ui.MapPanelShell import app.klottr.ui.MapPanelShell
import app.klottr.ui.SettingsContent // Delad material-fri UI för inställningar import app.klottr.ui.SettingsContent // Delad material-fri UI för inställningar
@@ -351,7 +352,7 @@ fun AboutDialog(onDismiss: () -> Unit) {
"Version ${BuildConfig.VERSION_NAME} (${BuildConfig.BUILD_TYPE}) • build $versionCode", "Version ${BuildConfig.VERSION_NAME} (${BuildConfig.BUILD_TYPE}) • build $versionCode",
"Byggd ${BuildConfig.BUILD_TIME_UTC}", "Byggd ${BuildConfig.BUILD_TIME_UTC}",
"Utvecklad av Fabian Norlin.", "Utvecklad av Fabian Norlin.",
"IOS-ansvarig: Olov Hedman." "IOS-ansvarig: Olof Hedman.",
"Mejlkontakt: utv@ointressant.se" "Mejlkontakt: utv@ointressant.se"
), ),
lineStyle = MaterialTheme.typography.bodyMedium.copy( lineStyle = MaterialTheme.typography.bodyMedium.copy(
@@ -364,8 +365,6 @@ fun AboutDialog(onDismiss: () -> Unit) {
) )
} }
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
private fun KlottrApp( private fun KlottrApp(
@@ -1232,7 +1231,14 @@ private fun KlottrApp(
AlertDialog( AlertDialog(
onDismissRequest = { showLoginRequired = false }, onDismissRequest = { showLoginRequired = false },
title = { Text("Inloggning krävs") }, title = { Text("Inloggning krävs") },
text = { Text("Du måste logga in för att kunna klottra.") }, text = {
LoginRequiredContent(
message = "Du måste logga in för att kunna klottra.",
textStyle = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onSurface // Följer dag/natt
)
)
},
confirmButton = { confirmButton = {
Button(onClick = { Button(onClick = {
showLoginRequired = false showLoginRequired = false
@@ -2581,4 +2587,4 @@ private fun fetchBitmapFromUrl(url: String): Bitmap? {
conn.instanceFollowRedirects = true conn.instanceFollowRedirects = true
conn.inputStream.use { stream -> BitmapFactory.decodeStream(stream) } conn.inputStream.use { stream -> BitmapFactory.decodeStream(stream) }
} catch (_: Exception) { null } } catch (_: Exception) { null }
} }

View File

@@ -0,0 +1,32 @@
package app.klottr.ui
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
/**
* Material-fri textkropp för "inloggning krävs".
* Android/iOS sätter färg/typografi via textStyle.
*/
@Composable
fun LoginRequiredContent(
message: String,
textStyle: TextStyle,
noteLines: List<String> = emptyList()
) {
Column {
BasicText(message, style = textStyle)
if (noteLines.isNotEmpty()) {
Spacer(Modifier.height(8.dp))
noteLines.forEachIndexed { i, s ->
if (i > 0) Spacer(Modifier.height(4.dp))
BasicText(s, style = textStyle)
}
}
}
}