From 40429e0cb94a7ae74dcdaca7299791218228529f Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Wed, 3 Feb 2021 12:36:04 +0300 Subject: [PATCH] Notarization sample. --- .../src/main/assets/data/EditorView.kt | 22 ++++++------------- examples/codeviewer/build.gradle.kts | 2 +- .../org/jetbrains/codeviewer/ui/MainView.kt | 2 +- .../codeviewer/ui/editor/EditorView.kt | 12 +++++----- .../codeviewer/platform/Selection.kt | 12 ++-------- examples/codeviewer/desktop/build.gradle.kts | 10 +++++---- .../imageviewer/.idea/codeStyles/Project.xml | 16 -------------- 7 files changed, 22 insertions(+), 54 deletions(-) diff --git a/examples/codeviewer/android/src/main/assets/data/EditorView.kt b/examples/codeviewer/android/src/main/assets/data/EditorView.kt index 97f0d80acf..ea878feace 100644 --- a/examples/codeviewer/android/src/main/assets/data/EditorView.kt +++ b/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, ":") diff --git a/examples/codeviewer/build.gradle.kts b/examples/codeviewer/build.gradle.kts index ddbfe48e71..10a5097a0b 100644 --- a/examples/codeviewer/build.gradle.kts +++ b/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")) diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt index 77dc829194..f7000f4db4 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt +++ b/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 diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt index 71e6fee7f2..0b6c7151f0 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt +++ b/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) ) diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt index 8e925a6cfc..cc8c8406b0 100644 --- a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt +++ b/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(null) } - DesktopSelectionContainer( - selection = selection.value, - onSelectionChange = { selection.value = it }, - content = children - ) + DesktopSelectionContainer(content = children) } diff --git a/examples/codeviewer/desktop/build.gradle.kts b/examples/codeviewer/desktop/build.gradle.kts index 62e6c79bef..f23db7d853 100644 --- a/examples/codeviewer/desktop/build.gradle.kts +++ b/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" + } } } } diff --git a/examples/imageviewer/.idea/codeStyles/Project.xml b/examples/imageviewer/.idea/codeStyles/Project.xml index 3cc336b934..88ea3aa1e5 100755 --- a/examples/imageviewer/.idea/codeStyles/Project.xml +++ b/examples/imageviewer/.idea/codeStyles/Project.xml @@ -1,22 +1,6 @@ - -