customtheme
This commit is contained in:
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
|
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 = {}
|
||||||
) {
|
) {
|
||||||
val navController = Navigation().getNavController()
|
CustomTheme {
|
||||||
|
val navController = Navigation().getNavController()
|
||||||
|
|
||||||
LaunchedEffect(navController) {
|
LaunchedEffect(navController) {
|
||||||
onNavHostReady(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.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") }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user