kotlin is here #3
BIN
client/composeApp/src/commonMain/composeResources/font/consolas.ttf
Executable file
BIN
client/composeApp/src/commonMain/composeResources/font/consolas.ttf
Executable file
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
package su.sonoma.sclient
|
||||
|
||||
import androidx.compose.material3.ColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.navigation.NavController
|
||||
@ -10,9 +11,11 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
fun App(
|
||||
onNavHostReady: suspend (NavController) -> Unit = {}
|
||||
) {
|
||||
CustomTheme {
|
||||
val navController = Navigation().getNavController()
|
||||
|
||||
LaunchedEffect(navController) {
|
||||
onNavHostReady(navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,8 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.safeContentPadding
|
||||
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.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -14,11 +15,13 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun LoginScreen() {
|
||||
MaterialTheme {
|
||||
Scaffold {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.safeContentPadding()
|
||||
@ -30,7 +33,7 @@ fun LoginScreen() {
|
||||
|
||||
TextField(
|
||||
value = login,
|
||||
onValueChange = { login = it},
|
||||
onValueChange = { login = it },
|
||||
label = { Text("Login") }
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user