From 59af5f7850a82976bb75727927a30504fb9c0daf Mon Sep 17 00:00:00 2001 From: komodgn Date: Mon, 11 May 2026 23:21:27 +0900 Subject: [PATCH 1/4] feat(compose): Add line number display option to CodeView --- .../komodgn/codeview/compose/CodeView.kt | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/codeview/compose/src/commonMain/kotlin/io/github/komodgn/codeview/compose/CodeView.kt b/codeview/compose/src/commonMain/kotlin/io/github/komodgn/codeview/compose/CodeView.kt index dd95cbb..9b60728 100644 --- a/codeview/compose/src/commonMain/kotlin/io/github/komodgn/codeview/compose/CodeView.kt +++ b/codeview/compose/src/commonMain/kotlin/io/github/komodgn/codeview/compose/CodeView.kt @@ -16,15 +16,20 @@ package io.github.komodgn.codeview.compose import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontFamily @@ -38,9 +43,13 @@ import io.github.komodgn.codeview.core.extension.toDefinition fun CodeView( code: String, language: CodeLanguage, + showLineNumbers: Boolean = true, modifier: Modifier = Modifier, fontFamily: FontFamily? = null, ) { + val lines = code.lines() + val lineCount = lines.size + val tokens = SyntaxParser.parse(code, language.toDefinition()) val annotatedString = tokens.toAnnotatedString(code) @@ -49,6 +58,11 @@ fun CodeView( modifier = modifier .fillMaxWidth() .background(Color(0xFF0D1117), RoundedCornerShape(8.dp)) + .border( + width = 1.dp, + color = Color(0xFF30363D), + shape = RoundedCornerShape(8.dp), + ) .padding(12.dp), ) { Text( @@ -58,14 +72,34 @@ fun CodeView( modifier = Modifier.padding(bottom = 8.dp), ) - Box(modifier = Modifier.horizontalScroll(rememberScrollState())) { - Text( - text = annotatedString, - color = Color.White, - fontSize = 14.sp, - fontFamily = fontFamily ?: FontFamily.Monospace, - lineHeight = 20.sp, - ) + Row { + if (showLineNumbers) { + Spacer(modifier = Modifier.width(16.dp)) + Column( + modifier = Modifier.padding(end = 12.dp), + horizontalAlignment = Alignment.End, + ) { + for (i in 1..lineCount) { + Text( + text = i.toString(), + color = Color(0xFF8B949E), + fontSize = 14.sp, + fontFamily = fontFamily ?: FontFamily.Monospace, + lineHeight = 20.sp, + ) + } + } + } + + Box(modifier = Modifier.horizontalScroll(rememberScrollState())) { + Text( + text = annotatedString, + color = Color.White, + fontSize = 14.sp, + fontFamily = fontFamily ?: FontFamily.Monospace, + lineHeight = 20.sp, + ) + } } } } From 73176141232991bceb14cecf02bb748d7bdc1c5f Mon Sep 17 00:00:00 2001 From: komodgn Date: Mon, 11 May 2026 23:38:47 +0900 Subject: [PATCH 2/4] feat(demo): Update sample app - Define centralized color palettes in Color.kt for consistent styling. - Integrate CodeViewTheme with support for dynamic dark/light mode switching. --- .../komodgn/example/Platform.android.kt | 20 ++++++++ .../io/github/komodgn/example/Application.kt | 50 ++++++++++++++++--- .../io/github/komodgn/example/Platform.kt | 5 ++ .../example/component/LanguageDropDown.kt | 5 +- .../komodgn/example/section/EditorSection.kt | 7 ++- .../komodgn/example/theme/CodeViewTheme.kt | 39 ++++++++++++++- .../io/github/komodgn/example/theme/Color.kt | 35 +++++++++++++ .../io/github/komodgn/example/Platform.ios.kt | 5 ++ .../io/github/komodgn/example/Platform.js.kt | 6 +++ .../github/komodgn/example/Platform.wasmJs.kt | 5 ++ 10 files changed, 165 insertions(+), 12 deletions(-) create mode 100644 example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt diff --git a/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt b/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt index 938e383..4e83136 100644 --- a/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt +++ b/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt @@ -15,4 +15,24 @@ */ package io.github.komodgn.example +import android.app.Activity +import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + actual fun platform() = "Android" + +@Composable +actual fun PlatformColors(isDarkTheme: Boolean) { + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + val insetsController = WindowCompat.getInsetsController(window, view) + + insetsController.isAppearanceLightStatusBars = !isDarkTheme + insetsController.isAppearanceLightNavigationBars = !isDarkTheme + } + } +} \ No newline at end of file diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt index cc66738..bbfc4de 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt @@ -21,23 +21,33 @@ import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.displayCutoutPadding import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.statusBarsPadding +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.DarkMode +import androidx.compose.material.icons.filled.LightMode +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import io.github.komodgn.AppConfig import io.github.komodgn.codeview.core.CodeLanguage @@ -48,24 +58,48 @@ import io.github.komodgn.example.util.getInitialCode @Composable fun App() { + var isDark by rememberSaveable { mutableStateOf(true) } var currentLang by remember { mutableStateOf(CodeLanguage.KOTLIN) } var userInput by remember { mutableStateOf(getInitialCode(currentLang, AppConfig.LIBRARY_VERSION)) } val scrollState = rememberScrollState() - CodeViewTheme { + CodeViewTheme(isDarkTheme = isDark) { Scaffold( modifier = Modifier .fillMaxSize(), contentWindowInsets = WindowInsets(0, 0, 0, 0), + topBar = { + Row( + modifier = Modifier + .fillMaxWidth() + .statusBarsPadding() + .navigationBarsPadding() + .background(MaterialTheme.colorScheme.primary) + .padding(horizontal = 16.dp, vertical = 8.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = "Compose CodeView Demo", + fontWeight = FontWeight.Bold, + color = MaterialTheme.colorScheme.background, + modifier = Modifier.padding(8.dp), + ) + IconButton(onClick = { isDark = !isDark }) { + Icon( + imageVector = if (isDark) Icons.Default.LightMode else Icons.Default.DarkMode, + contentDescription = "Toggle Theme", + tint = MaterialTheme.colorScheme.background, + ) + } + } + }, ) { innerPadding -> BoxWithConstraints( modifier = Modifier - .padding(innerPadding) .fillMaxSize() - .background(Color.White) - .statusBarsPadding() - .displayCutoutPadding() - .navigationBarsPadding() + .padding(innerPadding) + .background(MaterialTheme.colorScheme.background) + .windowInsetsPadding(WindowInsets.safeDrawing) .imePadding(), ) { val isCompact = maxWidth < 600.dp diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/Platform.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/Platform.kt index fea356f..f969edb 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/Platform.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/Platform.kt @@ -15,4 +15,9 @@ */ package io.github.komodgn.example +import androidx.compose.runtime.Composable + expect fun platform(): String + +@Composable +expect fun PlatformColors(isDarkTheme: Boolean) diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/component/LanguageDropDown.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/component/LanguageDropDown.kt index 6fa5526..4c92b84 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/component/LanguageDropDown.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/component/LanguageDropDown.kt @@ -62,7 +62,8 @@ fun LanguageDropDown( Text( text = selectedLanguage.name, style = MaterialTheme.typography.labelLarge, - color = MaterialTheme.colorScheme.onSurface, + color = MaterialTheme.colorScheme.primary, + fontWeight = FontWeight.Bold, ) Icon( imageVector = Icons.Default.ArrowDropDown, @@ -83,6 +84,8 @@ fun LanguageDropDown( Text( text = language.name, style = MaterialTheme.typography.bodyMedium, + fontWeight = if (language == selectedLanguage) FontWeight.Bold else FontWeight.Normal, + color = if (language == selectedLanguage) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant, ) }, onClick = { diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/section/EditorSection.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/section/EditorSection.kt index aab4e2a..f66a6e9 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/section/EditorSection.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/section/EditorSection.kt @@ -50,6 +50,7 @@ fun EditorSection( horizontalArrangement = Arrangement.SpaceBetween, ) { Text( + modifier = Modifier.padding(4.dp), text = "Edit Code", style = MaterialTheme.typography.titleMedium, ) @@ -67,8 +68,10 @@ fun EditorSection( fontFamily = LocalAppFontFamily.current, ), colors = TextFieldDefaults.colors( - unfocusedContainerColor = Color.Blue.copy(0.3f), - focusedContainerColor = Color.Blue.copy(0.3f), + focusedTextColor = MaterialTheme.colorScheme.onPrimary, + unfocusedTextColor = MaterialTheme.colorScheme.onPrimary, + unfocusedContainerColor = MaterialTheme.colorScheme.onBackground, + focusedContainerColor = MaterialTheme.colorScheme.onBackground, focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent, diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt index 5dd7f30..205a7e2 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt @@ -15,19 +15,55 @@ */ package io.github.komodgn.example.theme +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.runtime.CompositionLocalProvider +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import compose_codeview.example.generated.resources.NotoColorEmoji import compose_codeview.example.generated.resources.NotoSansKR_Regular import compose_codeview.example.generated.resources.Res +import io.github.komodgn.example.PlatformColors import org.jetbrains.compose.resources.Font +private val DarkColors = darkColorScheme( + primary = CodeAccent, + onPrimary = Color.Black, + background = CodeBackground, + onBackground = CodeTextPrimary, + surface = CodeSurface, + onSurface = CodeTextPrimary, + surfaceVariant = Grey700, + error = ErrorRed, + onError = Color.White, +) + +private val LightColors = lightColorScheme( + primary = CodeAccentRed, + onPrimary = Color.White, + background = CodeBackgroundLight, + onBackground = CodeTextPrimaryLight, + surface = CodeSurfaceLight, + onSurface = CodeTextPrimaryLight, + surfaceVariant = LightGrey200, + error = LightError, + onError = Color.White, +) + @Composable -fun CodeViewTheme(content: @Composable () -> Unit) { +fun CodeViewTheme( + isDarkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit, +) { + val colors = if (isDarkTheme) DarkColors else LightColors + + PlatformColors(isDarkTheme) + val codeFont = FontFamily( Font(Res.font.NotoSansKR_Regular), Font(Res.font.NotoColorEmoji), @@ -45,6 +81,7 @@ fun CodeViewTheme(content: @Composable () -> Unit) { CompositionLocalProvider(LocalAppFontFamily provides codeFont) { MaterialTheme( typography = typography, + colorScheme = colors, content = content, ) } diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt new file mode 100644 index 0000000..f787997 --- /dev/null +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt @@ -0,0 +1,35 @@ +package io.github.komodgn.example.theme + +import androidx.compose.ui.graphics.Color + +// --- Dark Mode Colors --- +val Grey900 = Color(0xFF0D1117) +val Grey800 = Color(0xFF161B22) +val Grey700 = Color(0xFF30363D) +val Grey300 = Color(0xFF8B949E) +val Grey100 = Color(0xFFC9D1D9) + +val SkyBlue = Color(0xFF58A6FF) +val BrightRed = Color(0xFFFA7970) +val ErrorRed = Color(0xFFF85149) + +val CodeBackground = Grey900 +val CodeSurface = Grey800 +val CodeTextPrimary = Grey100 +val CodeTextSecondary = Grey300 +val CodeAccent = SkyBlue +val CodeAccentRed = BrightRed + +// --- Light Mode Colors --- +val LightGrey100 = Color(0xFFF6F8FA) +val LightGrey200 = Color(0xFFEAEEF2) +val LightGrey900 = Color(0xFF24292F) +val DeepRed = Color(0xFFCF222E) +val LightBlue = Color(0xFF0969DA) +val LightError = Color(0xFFCF222E) + +val CodeBackgroundLight = Color.White +val CodeSurfaceLight = LightGrey100 +val CodeTextPrimaryLight = LightGrey900 +val CodeAccentLight = LightBlue +val CodeAccentRedLight = DeepRed diff --git a/example/src/iosMain/kotlin/io/github/komodgn/example/Platform.ios.kt b/example/src/iosMain/kotlin/io/github/komodgn/example/Platform.ios.kt index 1d59f0d..704b428 100644 --- a/example/src/iosMain/kotlin/io/github/komodgn/example/Platform.ios.kt +++ b/example/src/iosMain/kotlin/io/github/komodgn/example/Platform.ios.kt @@ -15,4 +15,9 @@ */ package io.github.komodgn.example +import androidx.compose.runtime.Composable + actual fun platform() = "iOS" + +@Composable +actual fun PlatformColors(isDarkTheme: Boolean) {} diff --git a/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt b/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt index 8a8ed9d..7d00b20 100644 --- a/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt +++ b/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt @@ -15,4 +15,10 @@ */ package io.github.komodgn.example +import androidx.compose.runtime.Composable + actual fun platform() = "Web with JS" + +@Composable +actual fun PlatformColors(isDarkTheme: Boolean) {} + diff --git a/example/src/wasmJsMain/kotlin/io/github/komodgn/example/Platform.wasmJs.kt b/example/src/wasmJsMain/kotlin/io/github/komodgn/example/Platform.wasmJs.kt index 41bab72..c8353eb 100644 --- a/example/src/wasmJsMain/kotlin/io/github/komodgn/example/Platform.wasmJs.kt +++ b/example/src/wasmJsMain/kotlin/io/github/komodgn/example/Platform.wasmJs.kt @@ -15,4 +15,9 @@ */ package io.github.komodgn.example +import androidx.compose.runtime.Composable + actual fun platform() = "Web with Kotlin/Wasm" + +@Composable +actual fun PlatformColors(isDarkTheme: Boolean) {} From d734c16bd7bc58ba43f2e4c42144bc0a90d439ed Mon Sep 17 00:00:00 2001 From: komodgn Date: Mon, 11 May 2026 23:49:25 +0900 Subject: [PATCH 3/4] docs: Update README.md --- README.md | 13 +++++++------ docs/codeview/overview.md | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c6dc7ed..65a21c6 100644 --- a/README.md +++ b/README.md @@ -90,12 +90,13 @@ fun CodeViewerExample() { #### Parameters -| PARAMETER | TYPE | DESCRIPTION | DEFAULT | -|--------------|----------------|----------------------------------------------------------------------------------|------------| -| `code` | `String` | The source code string to be highlighted. | (Required) | -| `language` | `CodeLanguage` | The programming language to use for syntax analysis (e.g., `KOTLIN`, `JAVA`). | (Required) | -| `modifier` | `Modifier` | The modifier to be applied to the CodeView container. | `Modifier` | -| `fontFamily` | `FontFamily?` | The font family for the code text. If null, it defaults to FontFamily.Monospace. | `null` | +| PARAMETER | TYPE | DESCRIPTION | DEFAULT | +|-------------------|----------------|----------------------------------------------------------------------------------|------------| +| `code` | `String` | The source code string to be highlighted. | (Required) | +| `language` | `CodeLanguage` | The programming language to use for syntax analysis (e.g., `KOTLIN`, `JAVA`). | (Required) | +| `showLineNumbers` | `Boolean` | Whether to display line numbers on the left side of the code. | `true` | +| `modifier` | `Modifier` | The modifier to be applied to the CodeView container. | `Modifier` | +| `fontFamily` | `FontFamily?` | The font family for the code text. If null, it defaults to FontFamily.Monospace. | `null` | ## ⭐ Contributing You can see the 👉 [Contributing Guide](https://github.com/komodgn/compose-codeview?tab=contributing-ov-file). diff --git a/docs/codeview/overview.md b/docs/codeview/overview.md index 5dd01ff..5b1cbfd 100644 --- a/docs/codeview/overview.md +++ b/docs/codeview/overview.md @@ -28,9 +28,10 @@ fun CodeViewerExample() { ### Parameters -| PARAMETER | TYPE | DESCRIPTION | DEFAULT | -|--------------|----------------|----------------------------------------------------------------------------------|------------| -| `code` | `String` | The source code string to be highlighted. | (Required) | -| `language` | `CodeLanguage` | The programming language to use for syntax analysis (e.g., `KOTLIN`, `JAVA`). | (Required) | -| `modifier` | `Modifier` | The modifier to be applied to the CodeView container. | `Modifier` | -| `fontFamily` | `FontFamily?` | The font family for the code text. If null, it defaults to FontFamily.Monospace. | `null` | \ No newline at end of file +| PARAMETER | TYPE | DESCRIPTION | DEFAULT | +|-------------------|----------------|----------------------------------------------------------------------------------|------------| +| `code` | `String` | The source code string to be highlighted. | (Required) | +| `language` | `CodeLanguage` | The programming language to use for syntax analysis (e.g., `KOTLIN`, `JAVA`). | (Required) | +| `showLineNumbers` | `Boolean` | Whether to display line numbers on the left side of the code. | `true` | +| `modifier` | `Modifier` | The modifier to be applied to the CodeView container. | `Modifier` | +| `fontFamily` | `FontFamily?` | The font family for the code text. If null, it defaults to FontFamily.Monospace. | `null` | \ No newline at end of file From b3e5ffa2e895e07a193a895abf91140396676c9f Mon Sep 17 00:00:00 2001 From: komodgn Date: Mon, 11 May 2026 23:58:42 +0900 Subject: [PATCH 4/4] style: Apply spotless --- .../komodgn/example/Platform.android.kt | 2 +- .../io/github/komodgn/example/theme/Color.kt | 15 +++++++++++ .../github/komodgn/example/util/SampleCode.kt | 26 +++++++++---------- .../io/github/komodgn/example/Platform.js.kt | 1 - 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt b/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt index 4e83136..9759b1d 100644 --- a/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt +++ b/example/src/androidMain/kotlin/io/github/komodgn/example/Platform.android.kt @@ -35,4 +35,4 @@ actual fun PlatformColors(isDarkTheme: Boolean) { insetsController.isAppearanceLightNavigationBars = !isDarkTheme } } -} \ No newline at end of file +} diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt index f787997..20bd2bd 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/theme/Color.kt @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2026 komodgn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package io.github.komodgn.example.theme import androidx.compose.ui.graphics.Color diff --git a/example/src/commonMain/kotlin/io/github/komodgn/example/util/SampleCode.kt b/example/src/commonMain/kotlin/io/github/komodgn/example/util/SampleCode.kt index 643215e..f05e170 100644 --- a/example/src/commonMain/kotlin/io/github/komodgn/example/util/SampleCode.kt +++ b/example/src/commonMain/kotlin/io/github/komodgn/example/util/SampleCode.kt @@ -20,17 +20,16 @@ import io.github.komodgn.codeview.core.CodeLanguage /** * Provides the initial code snippet for the demo application. */ -fun getInitialCode(language: CodeLanguage, version: String): String { - return when (language) { - CodeLanguage.KOTLIN -> """ +fun getInitialCode(language: CodeLanguage, version: String): String = when (language) { + CodeLanguage.KOTLIN -> """ package io.github.komodgn.example - + /** * Welcome to Compose CodeView v$version Demo! * * This library provides syntax highlighting for Compose Multiplatform. * Feel free to edit the code on the left to see real-time updates. - */ + */ @Composable fun CodeDisplay() { val greeting = getWelcomeMessage() @@ -41,11 +40,11 @@ fun getInitialCode(language: CodeLanguage, version: String): String { language = CodeLanguage.KOTLIN, ) } - + private fun getWelcomeMessage() = "Hello, CodeView!" - """.trimIndent() + """.trimIndent() - CodeLanguage.JAVA -> """ + CodeLanguage.JAVA -> """ package io.github.komodgn.example; /** @@ -57,17 +56,16 @@ fun getInitialCode(language: CodeLanguage, version: String): String { System.out.println(message); } } - """.trimIndent() + """.trimIndent() - CodeLanguage.PYTHON -> """ + CodeLanguage.PYTHON -> """ # Welcome to Compose CodeView v$version! - + def welcome_codeview(): message = "Hello, Python!" print(message) if __name__ == "__main__": welcome_codeview() - """.trimIndent() - } -} \ No newline at end of file + """.trimIndent() +} diff --git a/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt b/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt index 7d00b20..db167a1 100644 --- a/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt +++ b/example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt @@ -21,4 +21,3 @@ actual fun platform() = "Web with JS" @Composable actual fun PlatformColors(isDarkTheme: Boolean) {} -