diff --git a/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/Platform.android.kt b/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/Platform.android.kt index 963d71c..efcbed6 100644 --- a/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/Platform.android.kt +++ b/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/Platform.android.kt @@ -7,3 +7,20 @@ class AndroidPlatform : Platform { } actual fun getPlatform(): Platform = AndroidPlatform() + +@androidx.compose.runtime.Composable +actual fun appVersionLabel(): String { + val context = androidx.compose.ui.platform.LocalContext.current + val info = rememberPackageInfo(context) + + @Suppress("DEPRECATION") + val code = if (android.os.Build.VERSION.SDK_INT >= 28) info.longVersionCode else info.versionCode.toLong() + return "${info.versionName ?: "?"} ($code)" +} + +@androidx.compose.runtime.Composable +private fun rememberPackageInfo(context: android.content.Context): android.content.pm.PackageInfo = + androidx.compose.runtime.remember(context.packageName) { + @Suppress("DEPRECATION") + context.packageManager.getPackageInfo(context.packageName, 0) + } diff --git a/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/theme/PlatformSystemBars.android.kt b/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/theme/PlatformSystemBars.android.kt index efdcf29..2743528 100644 --- a/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/theme/PlatformSystemBars.android.kt +++ b/composeApp/src/androidMain/kotlin/hu/petrik/filcapp/theme/PlatformSystemBars.android.kt @@ -34,9 +34,9 @@ actual fun ApplyPlatformSystemBars(darkTheme: Boolean) { @Suppress("DEPRECATION") activity.window.navigationBarColor = if (darkTheme) { - Color.rgb(11, 17, 32) + Color.rgb(24, 24, 27) } else { - Color.rgb(246, 247, 251) + Color.WHITE } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { diff --git a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/App.kt b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/App.kt index 63906a5..75ac07f 100644 --- a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/App.kt +++ b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/App.kt @@ -210,10 +210,7 @@ private fun FigmaBottomNavigation( onMore: () -> Unit, ) { Surface( - modifier = - Modifier - .fillMaxWidth() - .windowInsetsPadding(WindowInsets.navigationBars), + modifier = Modifier.fillMaxWidth(), color = MaterialTheme.colorScheme.surface, shadowElevation = 12.dp, ) { @@ -221,6 +218,7 @@ private fun FigmaBottomNavigation( modifier = Modifier .fillMaxWidth() + .windowInsetsPadding(WindowInsets.navigationBars) .height(64.dp) .padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically, diff --git a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/Platform.kt b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/Platform.kt index a39ad18..c6f4d57 100644 --- a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/Platform.kt +++ b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/Platform.kt @@ -5,3 +5,6 @@ interface Platform { } expect fun getPlatform(): Platform + +@androidx.compose.runtime.Composable +expect fun appVersionLabel(): String diff --git a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/components/TopBar.kt b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/components/TopBar.kt index f320fdc..fae34b7 100644 --- a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/components/TopBar.kt +++ b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/components/TopBar.kt @@ -14,9 +14,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.KeyboardArrowDown import androidx.compose.material.icons.filled.NotificationsNone import androidx.compose.material.icons.filled.School import androidx.compose.material3.HorizontalDivider @@ -29,25 +27,17 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import hu.petrik.filcapp.auth.AuthState @Composable fun TopBar(onProfileClick: () -> Unit = {}) { val user = AuthState.user - val profile = AuthState.profile - val displayName = user?.nickname?.takeIf { it.isNotBlank() } ?: user?.preferredName ?: "Petrik" - val profileLabel = - profile?.teacher?.short?.takeIf { it.isNotBlank() } - ?: profile?.cohort?.short?.takeIf { it.isNotBlank() } - ?: profile?.cohort?.name.orEmpty() - Surface( modifier = Modifier @@ -66,76 +56,19 @@ fun TopBar(onProfileClick: () -> Unit = {}) { horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.CenterVertically, ) { - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically, + Surface( + modifier = Modifier.size(34.dp), + shape = CircleShape, + color = MaterialTheme.colorScheme.tertiary.copy(alpha = 0.14f), ) { - Surface( - modifier = Modifier.size(34.dp), - shape = CircleShape, - color = MaterialTheme.colorScheme.tertiary.copy(alpha = 0.14f), - ) { - Box(contentAlignment = Alignment.Center) { - Icon( - imageVector = Icons.Default.School, - contentDescription = null, - modifier = Modifier.size(19.dp), - tint = MaterialTheme.colorScheme.tertiary, - ) - } - } - - Surface( - shape = RoundedCornerShape(999.dp), - color = MaterialTheme.colorScheme.primary.copy(alpha = 0.14f), - ) { - Text( - text = "V3", - modifier = Modifier.padding(horizontal = 10.dp, vertical = 6.dp), - style = MaterialTheme.typography.labelMedium, - color = MaterialTheme.colorScheme.primary, - fontWeight = FontWeight.Bold, + Box(contentAlignment = Alignment.Center) { + Icon( + imageVector = Icons.Default.School, + contentDescription = null, + modifier = Modifier.size(19.dp), + tint = MaterialTheme.colorScheme.tertiary, ) } - - Surface( - shape = RoundedCornerShape(14.dp), - color = MaterialTheme.colorScheme.surface, - tonalElevation = 1.dp, - shadowElevation = 0.dp, - ) { - Row( - modifier = Modifier.padding(start = 12.dp, end = 8.dp, top = 8.dp, bottom = 8.dp), - horizontalArrangement = Arrangement.spacedBy(4.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = displayName, - style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.onSurface, - fontWeight = FontWeight.Bold, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - - if (profileLabel.isNotBlank()) { - Text( - text = "· $profileLabel", - style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.colorScheme.onSurfaceVariant, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - } - - Icon( - imageVector = Icons.Default.KeyboardArrowDown, - contentDescription = null, - modifier = Modifier.size(15.dp), - tint = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } } Spacer(Modifier.weight(1f)) diff --git a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/screens/SettingsScreen.kt b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/screens/SettingsScreen.kt index 45a1fb7..7815a83 100644 --- a/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/screens/SettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/hu/petrik/filcapp/screens/SettingsScreen.kt @@ -63,10 +63,12 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import cafe.adriel.voyager.navigator.tab.Tab import cafe.adriel.voyager.navigator.tab.TabOptions +import hu.petrik.filcapp.appVersionLabel import hu.petrik.filcapp.auth.AuthManager import hu.petrik.filcapp.auth.AuthState import hu.petrik.filcapp.components.SearchableSelection @@ -298,6 +300,13 @@ fun SettingsScreen() { ) Spacer(Modifier.height(8.dp)) + Text( + text = "Mergen · " + tr("Build verzió", "Build version") + " " + appVersionLabel(), + modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp), + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + textAlign = TextAlign.Center, + ) } } } diff --git a/composeApp/src/iosMain/kotlin/hu/petrik/filcapp/Platform.ios.kt b/composeApp/src/iosMain/kotlin/hu/petrik/filcapp/Platform.ios.kt index 358fb47..b8bf9b0 100644 --- a/composeApp/src/iosMain/kotlin/hu/petrik/filcapp/Platform.ios.kt +++ b/composeApp/src/iosMain/kotlin/hu/petrik/filcapp/Platform.ios.kt @@ -7,3 +7,11 @@ class IOSPlatform : Platform { } actual fun getPlatform(): Platform = IOSPlatform() + +@androidx.compose.runtime.Composable +actual fun appVersionLabel(): String { + val bundle = platform.Foundation.NSBundle.mainBundle + val version = bundle.objectForInfoDictionaryKey("CFBundleShortVersionString") as? String ?: "?" + val build = bundle.objectForInfoDictionaryKey("CFBundleVersion") as? String ?: "?" + return "$version ($build)" +}