kotlin is here #3

Merged
saddydead1 merged 9 commits from develop into main 2025-07-21 22:13:29 +03:00
27 changed files with 770 additions and 190 deletions
Showing only changes of commit 363a82d0c5 - Show all commits

View File

@ -1,5 +1,6 @@
package su.sonoma.sclient package su.sonoma.sclient
import androidx.compose.material3.ColorScheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.navigation.NavController import androidx.navigation.NavController
@ -10,9 +11,11 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
fun App( fun App(
onNavHostReady: suspend (NavController) -> Unit = {} onNavHostReady: suspend (NavController) -> Unit = {}
) { ) {
CustomTheme {
val navController = Navigation().getNavController() val navController = Navigation().getNavController()
LaunchedEffect(navController) { LaunchedEffect(navController) {
onNavHostReady(navController) onNavHostReady(navController)
} }
}
} }

View File

@ -0,0 +1,66 @@
package su.sonoma.sclient
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import org.jetbrains.compose.resources.Font
import sclient.composeapp.generated.resources.Res
import sclient.composeapp.generated.resources.consolas
import sclient.composeapp.generated.resources.consolasbold
@Composable
fun CustomTheme(
content: @Composable () -> Unit
) {
val darkTheme = isSystemInDarkTheme()
val colors = if (darkTheme) {
darkColorScheme()
} else {
lightColorScheme()
}
val fontFamily = FontFamily(Font(Res.font.consolas, FontWeight.Normal))
val typography = InterTypography()
MaterialTheme(
colorScheme = colors,
content = content,
typography = typography
)
}
@Composable
private fun InterTypography(): Typography {
val interFont = FontFamily(
Font(Res.font.consolas, FontWeight.Normal),
Font(Res.font.consolasbold, FontWeight.Bold),
)
return with(MaterialTheme.typography) {
copy(
displayLarge = displayLarge.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
displayMedium = displayMedium.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
displaySmall = displaySmall.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
headlineLarge = headlineLarge.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
headlineMedium = headlineMedium.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
headlineSmall = headlineSmall.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
titleLarge = titleLarge.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
titleMedium = titleMedium.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
titleSmall = titleSmall.copy(fontFamily = interFont, fontWeight = FontWeight.Bold),
labelLarge = labelLarge.copy(fontFamily = interFont, fontWeight = FontWeight.Normal),
labelMedium = labelMedium.copy(fontFamily = interFont, fontWeight = FontWeight.Normal),
labelSmall = labelSmall.copy(fontFamily = interFont, fontWeight = FontWeight.Normal),
bodyLarge = bodyLarge.copy(fontFamily = interFont, fontWeight = FontWeight.Normal),
bodyMedium = bodyMedium.copy(fontFamily = interFont, fontWeight = FontWeight.Normal),
bodySmall = bodySmall.copy(fontFamily = interFont, fontWeight = FontWeight.Normal),
)
}
}

View File

@ -4,7 +4,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.safeContentPadding import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold
import su.sonoma.sclient.CustomTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -14,11 +15,13 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import org.jetbrains.compose.ui.tooling.preview.Preview
@Composable @Composable
@Preview
fun LoginScreen() { fun LoginScreen() {
MaterialTheme { Scaffold {
Column( Column(
modifier = Modifier modifier = Modifier
.safeContentPadding() .safeContentPadding()
@ -30,7 +33,7 @@ fun LoginScreen() {
TextField( TextField(
value = login, value = login,
onValueChange = { login = it}, onValueChange = { login = it },
label = { Text("Login") } label = { Text("Login") }
) )