From 3e53062e8953e7beac77244952ca7f067a1a572b Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Fri, 30 Oct 2020 21:23:00 +0300 Subject: [PATCH] Fix and refactor jetissues example --- .../ui/examples/jetissues/view/common/Platform.kt | 11 ++--------- .../ui/examples/jetissues/view/JetIssuesView.kt | 5 ++--- .../ui/examples/jetissues/view/common/Platform.kt | 5 +---- .../ui/examples/jetissues/common/Platform.kt | 13 +------------ 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/examples/issues/common/src/androidMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt b/examples/issues/common/src/androidMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt index 8a53d7748d..fefe99b054 100644 --- a/examples/issues/common/src/androidMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt +++ b/examples/issues/common/src/androidMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt @@ -4,7 +4,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.selection.Selection +import androidx.compose.ui.text.InternalTextApi +@OptIn(InternalTextApi::class) @Composable actual fun SelectionContainer(children: @Composable () -> Unit) { val selection = remember { mutableStateOf(null) } @@ -13,13 +15,4 @@ actual fun SelectionContainer(children: @Composable () -> Unit) { onSelectionChange = { selection.value = it }, children = children ) -} - -@Composable -actual fun WithoutSelection(children: @Composable () -> Unit) { - androidx.compose.ui.selection.SelectionContainer( - selection = null, - onSelectionChange = {}, - children = children - ) } \ No newline at end of file diff --git a/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt b/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt index 99fccaf8bf..b41224a011 100644 --- a/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt +++ b/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt @@ -1,7 +1,6 @@ package androidx.ui.examples.jetissues.view import androidx.compose.foundation.* -import androidx.ui.examples.jetissues.view.common.WithoutSelection import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.* @@ -11,7 +10,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance import androidx.compose.ui.layout.WithConstraints -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.TextStyle @@ -34,7 +33,7 @@ fun JetIssuesView() { MaterialTheme( colors = lightThemeColors ) { - WithoutSelection { + DisableSelection { Main() } } diff --git a/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt b/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt index 8e9348a681..530d954349 100644 --- a/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt +++ b/examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt @@ -3,7 +3,4 @@ package androidx.ui.examples.jetissues.view.common import androidx.compose.runtime.Composable @Composable -expect fun SelectionContainer(children: @Composable () -> Unit) - -@Composable -expect fun WithoutSelection(children: @Composable () -> Unit) \ No newline at end of file +expect fun SelectionContainer(children: @Composable () -> Unit) \ No newline at end of file diff --git a/examples/issues/common/src/desktopMain/kotlin/androidx/ui/examples/jetissues/common/Platform.kt b/examples/issues/common/src/desktopMain/kotlin/androidx/ui/examples/jetissues/common/Platform.kt index 854c113a96..9ba9c4efc1 100644 --- a/examples/issues/common/src/desktopMain/kotlin/androidx/ui/examples/jetissues/common/Platform.kt +++ b/examples/issues/common/src/desktopMain/kotlin/androidx/ui/examples/jetissues/common/Platform.kt @@ -5,7 +5,6 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.platform.DesktopSelectionContainer import androidx.compose.ui.selection.Selection -import androidx.compose.ui.text.InternalTextApi @Composable actual fun SelectionContainer(children: @Composable () -> Unit) { @@ -15,14 +14,4 @@ actual fun SelectionContainer(children: @Composable () -> Unit) { onSelectionChange = { selection.value = it }, children = children ) -} - -@Composable -@OptIn(InternalTextApi::class) -actual fun WithoutSelection(children: @Composable () -> Unit) { - androidx.compose.ui.selection.SelectionContainer( - selection = null, - onSelectionChange = {}, - children = children - ) -} +} \ No newline at end of file