Browse Source

Notarization sample.

pull/350/head
Nikolay Igotti 4 years ago
parent
commit
40429e0cb9
  1. 22
      examples/codeviewer/android/src/main/assets/data/EditorView.kt
  2. 2
      examples/codeviewer/build.gradle.kts
  3. 2
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt
  4. 12
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt
  5. 12
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt
  6. 10
      examples/codeviewer/desktop/build.gradle.kts
  7. 16
      examples/imageviewer/.idea/codeStyles/Project.xml

22
examples/codeviewer/android/src/main/assets/data/EditorView.kt

@ -6,7 +6,7 @@ package org.jetbrains.codeviewer.ui.editor
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.material.AmbientContentColor
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Surface
@ -14,31 +14,23 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawOpacity
import androidx.compose.ui.platform.DensityAmbient
import androidx.compose.ui.selection.DisableSelection
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.annotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.*
import androidx.compose.ui.unit.dp
import org.jetbrains.codeviewer.platform.SelectionContainer
import org.jetbrains.codeviewer.platform.VerticalScrollbar
import org.jetbrains.codeviewer.ui.common.AppTheme
import org.jetbrains.codeviewer.ui.common.Fonts
import org.jetbrains.codeviewer.ui.common.Settings
import org.jetbrains.codeviewer.util.LazyColumnFor
import org.jetbrains.codeviewer.util.loadable
import org.jetbrains.codeviewer.util.loadableScoped
import org.jetbrains.codeviewer.util.withoutWidthConstraints
import kotlin.text.Regex.Companion.fromLiteral
@Composable
fun EditorView(model: Editor, settings: Settings) = key(model) {
with (DensityAmbient.current) {
with (LocalDensity.current) {
SelectionContainer {
Surface(
Modifier.fillMaxSize(),
@ -112,7 +104,7 @@ private fun Line(modifier: Modifier, maxNumber: String, line: Editor.Line, setti
Row(modifier = modifier) {
DisableSelection {
Box {
LineNumber(maxNumber, Modifier.drawOpacity(0f), settings)
LineNumber(maxNumber, Modifier.alpha(0f), settings)
LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings)
}
}
@ -149,7 +141,7 @@ private fun LineContent(content: Editor.Content, modifier: Modifier, settings: S
softWrap = false
)
private fun codeString(str: String) = annotatedString {
private fun codeString(str: String) = buildAnnotatedString {
withStyle(AppTheme.code.simple) {
append(str.replace("\t", " "))
addStyle(AppTheme.code.punctuation, ":")

2
examples/codeviewer/build.gradle.kts

@ -9,7 +9,7 @@ buildscript {
dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build146")
classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build148")
classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.4.21-2"))

2
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt

@ -1,10 +1,10 @@
package org.jetbrains.codeviewer.ui
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.selection.DisableSelection
import org.jetbrains.codeviewer.platform.HomeFolder
import org.jetbrains.codeviewer.platform.PlatformTheme
import org.jetbrains.codeviewer.ui.common.AppTheme

12
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt

@ -3,10 +3,8 @@ package org.jetbrains.codeviewer.ui.editor
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.AmbientContentColor
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
@ -15,7 +13,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.selection.DisableSelection
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
@ -33,7 +31,7 @@ import kotlin.text.Regex.Companion.fromLiteral
@Composable
fun EditorView(model: Editor, settings: Settings) = key(model) {
with (AmbientDensity.current) {
with (LocalDensity.current) {
SelectionContainer {
Surface(
Modifier.fillMaxSize(),
@ -124,7 +122,7 @@ private fun LineNumber(number: String, modifier: Modifier, settings: Settings) =
text = number,
fontSize = settings.fontSize,
fontFamily = Fonts.jetbrainsMono(),
color = AmbientContentColor.current.copy(alpha = 0.30f),
color = LocalContentColor.current.copy(alpha = 0.30f),
modifier = modifier.padding(start = 12.dp)
)

12
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt

@ -1,17 +1,9 @@
package org.jetbrains.codeviewer.platform
import androidx.compose.foundation.text.selection.DesktopSelectionContainer
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.DesktopSelectionContainer
import androidx.compose.ui.selection.Selection
@Composable
actual fun SelectionContainer(children: @Composable () -> Unit) {
val selection = remember { mutableStateOf<Selection?>(null) }
DesktopSelectionContainer(
selection = selection.value,
onSelectionChange = { selection.value = it },
content = children
)
DesktopSelectionContainer(content = children)
}

10
examples/codeviewer/desktop/build.gradle.kts

@ -7,10 +7,7 @@ plugins {
}
kotlin {
jvm {
withJava()
}
jvm {}
sourceSets {
named("jvmMain") {
dependencies {
@ -34,6 +31,11 @@ compose.desktop {
// see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html
upgradeUuid = "AF792DA6-2EA3-495A-95E5-C3C6CBCB9948"
}
macOS {
// Use -Pcompose.desktop.mac.sign=true to sign and notarize.
bundleID = "com.jetbrains.compose.codeviewer"
}
}
}
}

16
examples/imageviewer/.idea/codeStyles/Project.xml

@ -1,22 +1,6 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">

Loading…
Cancel
Save