mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Codeviewer. 1.0.0-beta1
This commit is contained in:
@@ -5,11 +5,11 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion(30)
|
||||
compileSdkVersion(31)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(26)
|
||||
targetSdkVersion(30)
|
||||
targetSdkVersion(31)
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
@@ -22,5 +22,5 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation(project(":common"))
|
||||
implementation("androidx.activity:activity-compose:1.3.0-alpha02")
|
||||
implementation("androidx.activity:activity-compose:1.3.1")
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<activity
|
||||
android:exported="true"
|
||||
android:name="MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
|
||||
@@ -8,8 +8,8 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:0.0.0-master-build423")
|
||||
classpath("com.android.tools.build:gradle:4.0.1")
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-beta1")
|
||||
classpath("com.android.tools.build:gradle:4.2.2")
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.31"))
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ kotlin {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion(30)
|
||||
compileSdkVersion(31)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(21)
|
||||
targetSdkVersion(30)
|
||||
targetSdkVersion(31)
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
|
||||
@@ -15,7 +15,5 @@ actual fun VerticalScrollbar(
|
||||
@Composable
|
||||
actual fun VerticalScrollbar(
|
||||
modifier: Modifier,
|
||||
scrollState: LazyListState,
|
||||
itemCount: Int,
|
||||
averageItemSize: Dp
|
||||
scrollState: LazyListState
|
||||
) = Unit
|
||||
@@ -1,6 +0,0 @@
|
||||
package org.jetbrains.codeviewer.platform
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformTheme(content: @Composable () -> Unit) = content()
|
||||
@@ -15,7 +15,5 @@ expect fun VerticalScrollbar(
|
||||
@Composable
|
||||
expect fun VerticalScrollbar(
|
||||
modifier: Modifier,
|
||||
scrollState: LazyListState,
|
||||
itemCount: Int,
|
||||
averageItemSize: Dp
|
||||
scrollState: LazyListState
|
||||
)
|
||||
@@ -1,6 +0,0 @@
|
||||
package org.jetbrains.codeviewer.platform
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
expect fun PlatformTheme(content: @Composable () -> Unit)
|
||||
@@ -6,7 +6,6 @@ import androidx.compose.material.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import org.jetbrains.codeviewer.platform.HomeFolder
|
||||
import org.jetbrains.codeviewer.platform.PlatformTheme
|
||||
import org.jetbrains.codeviewer.ui.common.AppTheme
|
||||
import org.jetbrains.codeviewer.ui.common.Settings
|
||||
import org.jetbrains.codeviewer.ui.editor.Editors
|
||||
@@ -28,10 +27,8 @@ fun MainView() {
|
||||
MaterialTheme(
|
||||
colors = AppTheme.colors.material
|
||||
) {
|
||||
PlatformTheme {
|
||||
Surface {
|
||||
CodeViewerView(codeViewer)
|
||||
}
|
||||
Surface {
|
||||
CodeViewerView(codeViewer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,14 +74,13 @@ private fun Lines(lines: Editor.Lines, settings: Settings) = with(LocalDensity.c
|
||||
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
val scrollState = rememberLazyListState()
|
||||
val lineHeight = settings.fontSize.toDp() * 1.6f
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
state = scrollState
|
||||
) {
|
||||
items(lines.size) { index ->
|
||||
Box(Modifier.height(lineHeight)) {
|
||||
Box(Modifier.height(settings.fontSize.toDp() * 1.6f)) {
|
||||
Line(Modifier.align(Alignment.CenterStart), maxNum, lines[index], settings)
|
||||
}
|
||||
}
|
||||
@@ -89,9 +88,7 @@ private fun Lines(lines: Editor.Lines, settings: Settings) = with(LocalDensity.c
|
||||
|
||||
VerticalScrollbar(
|
||||
Modifier.align(Alignment.CenterEnd),
|
||||
scrollState,
|
||||
lines.size,
|
||||
lineHeight
|
||||
scrollState
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,23 +49,19 @@ fun FileTreeView(model: FileTree) = Surface(
|
||||
with(LocalDensity.current) {
|
||||
Box {
|
||||
val scrollState = rememberLazyListState()
|
||||
val fontSize = 14.sp
|
||||
val lineHeight = fontSize.toDp() * 1.5f
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize().withoutWidthConstraints(),
|
||||
state = scrollState
|
||||
) {
|
||||
items(model.items.size) {
|
||||
FileTreeItemView(fontSize, lineHeight, model.items[it])
|
||||
FileTreeItemView(14.sp, 14.sp.toDp() * 1.5f, model.items[it])
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollbar(
|
||||
Modifier.align(Alignment.CenterEnd),
|
||||
scrollState,
|
||||
model.items.size,
|
||||
lineHeight
|
||||
scrollState
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package org.jetbrains.codeviewer.platform
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.rememberScrollbarAdapter
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.Dp
|
||||
|
||||
@Composable
|
||||
actual fun VerticalScrollbar(
|
||||
@@ -17,13 +15,10 @@ actual fun VerticalScrollbar(
|
||||
modifier
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
actual fun VerticalScrollbar(
|
||||
modifier: Modifier,
|
||||
scrollState: LazyListState,
|
||||
itemCount: Int,
|
||||
averageItemSize: Dp
|
||||
scrollState: LazyListState
|
||||
) = androidx.compose.foundation.VerticalScrollbar(
|
||||
rememberScrollbarAdapter(scrollState),
|
||||
modifier
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.jetbrains.codeviewer.platform
|
||||
|
||||
import androidx.compose.desktop.DesktopMaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformTheme(content: @Composable () -> Unit) = DesktopMaterialTheme(content = content)
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.jetbrains.codeviewer
|
||||
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.graphics.painter.BitmapPainter
|
||||
import androidx.compose.ui.res.loadImageBitmap
|
||||
import androidx.compose.ui.res.useResource
|
||||
@@ -9,7 +8,6 @@ import androidx.compose.ui.window.WindowState
|
||||
import androidx.compose.ui.window.singleWindowApplication
|
||||
import org.jetbrains.codeviewer.ui.MainView
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
fun main() = singleWindowApplication(
|
||||
title = "Code Viewer",
|
||||
state = WindowState(width = 1280.dp, height = 768.dp),
|
||||
|
||||
Reference in New Issue
Block a user