Browse Source

Fix and refactor jetissues example

pull/43/head
Igor Demin 4 years ago
parent
commit
3e53062e89
  1. 11
      examples/issues/common/src/androidMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt
  2. 5
      examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt
  3. 5
      examples/issues/common/src/commonMain/kotlin/androidx/ui/examples/jetissues/view/common/Platform.kt
  4. 13
      examples/issues/common/src/desktopMain/kotlin/androidx/ui/examples/jetissues/common/Platform.kt

11
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<Selection?>(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
)
}

5
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()
}
}

5
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)
expect fun SelectionContainer(children: @Composable () -> Unit)

13
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
)
}
}
Loading…
Cancel
Save