Browse Source

Update Android Examples

updateAndroidExamples
Igor Demin 2 years ago
parent
commit
ae1f72d7d5
  1. 8
      examples/codeviewer/android/build.gradle.kts
  2. 2
      examples/codeviewer/android/src/main/AndroidManifest.xml
  3. 8
      examples/codeviewer/build.gradle.kts
  4. 17
      examples/codeviewer/common/build.gradle.kts
  5. 6
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt
  6. 4
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  7. 1
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt
  8. 7
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt
  9. 2
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  10. 18
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt
  11. 21
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt
  12. 11
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt
  13. 2
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  14. 2
      examples/codeviewer/gradle.properties
  15. 8
      examples/imageviewer/android/build.gradle.kts
  16. 2
      examples/imageviewer/android/src/main/AndroidManifest.xml
  17. 10
      examples/imageviewer/common/build.gradle.kts
  18. 10
      examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AndroidHover.kt
  19. 10
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/PointerMoveFilter.kt
  20. 74
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt
  21. 61
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt
  22. 13
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MouseHover.kt
  23. 2
      examples/imageviewer/gradle.properties
  24. 6
      examples/issues/android/build.gradle.kts
  25. 2
      examples/issues/android/src/main/AndroidManifest.xml
  26. 8
      examples/issues/common/build.gradle.kts
  27. 13
      examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt
  28. 2
      examples/issues/gradle.properties
  29. 10
      examples/todoapp-lite/android/build.gradle.kts
  30. 2
      examples/todoapp-lite/android/src/main/AndroidManifest.xml
  31. 6
      examples/todoapp-lite/common/build.gradle.kts
  32. 2
      examples/todoapp-lite/gradle.properties
  33. 15
      examples/visual-effects/.gitignore
  34. 6
      examples/widgets-gallery/android/build.gradle.kts
  35. 3
      examples/widgets-gallery/android/src/main/AndroidManifest.xml
  36. 10
      examples/widgets-gallery/common/build.gradle.kts
  37. 6
      examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt
  38. 6
      examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt
  39. 6
      examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt
  40. 18
      examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt
  41. 8
      examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt
  42. 2
      examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt
  43. 8
      examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt
  44. 2
      examples/widgets-gallery/gradle.properties

8
examples/codeviewer/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdkVersion(31) compileSdk = 32
defaultConfig { defaultConfig {
minSdkVersion(26) minSdk = 26
targetSdkVersion(31) targetSdk = 32
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.4.0") implementation("androidx.activity:activity-compose:1.5.0")
} }

2
examples/codeviewer/android/src/main/AndroidManifest.xml

@ -12,7 +12,7 @@
<activity <activity
android:exported="true" android:exported="true"
android:name="MainActivity" android:name="MainActivity"
android:label="@string/app_name"> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

8
examples/codeviewer/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
// this is necessary to avoid the plugins to be loaded multiple times // this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader // in each subproject's classloader
@ -17,10 +15,4 @@ subprojects {
mavenCentral() mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
} }
plugins.withId("org.jetbrains.kotlin.multiplatform") {
tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}
} }

17
examples/codeviewer/common/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins { plugins {
id("com.android.library") id("com.android.library")
kotlin("multiplatform") kotlin("multiplatform")
@ -22,8 +20,8 @@ kotlin {
named("androidMain") { named("androidMain") {
kotlin.srcDirs("src/jvmMain/kotlin") kotlin.srcDirs("src/jvmMain/kotlin")
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.4.1") api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.7.0") api("androidx.core:core-ktx:1.8.0")
} }
} }
named("desktopMain") { named("desktopMain") {
@ -36,16 +34,11 @@ kotlin {
} }
android { android {
compileSdkVersion(31) compileSdk = 32
defaultConfig { defaultConfig {
minSdkVersion(21) minSdk = 26
targetSdkVersion(31) targetSdk = 32
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
} }
sourceSets { sourceSets {

6
examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -3,10 +3,4 @@ package org.jetbrains.codeviewer.platform
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this
actual fun Modifier.cursorForHorizontalResize() = this actual fun Modifier.cursorForHorizontalResize() = this

4
examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -1,13 +1,15 @@
package org.jetbrains.codeviewer.platform package org.jetbrains.codeviewer.platform
import android.annotation.SuppressLint
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
@SuppressLint("DiscouragedApi")
@Composable @Composable
actual fun Font(name: String, res: String, weight: FontWeight, style: FontStyle): Font { actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font {
val context = LocalContext.current val context = LocalContext.current
val id = context.resources.getIdentifier(res, "font", context.packageName) val id = context.resources.getIdentifier(res, "font", context.packageName)
return Font(id, weight, style) return Font(id, weight, style)

1
examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt

@ -4,7 +4,6 @@ import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
@Composable @Composable
actual fun VerticalScrollbar( actual fun VerticalScrollbar(

7
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -1,12 +1,5 @@
package org.jetbrains.codeviewer.platform package org.jetbrains.codeviewer.platform
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
expect fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean = { true },
onExit: () -> Boolean = { true },
onMove: (Offset) -> Boolean = { true }
): Modifier
expect fun Modifier.cursorForHorizontalResize(): Modifier expect fun Modifier.cursorForHorizontalResize(): Modifier

2
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -6,4 +6,4 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
@Composable @Composable
expect fun Font(name: String, res: String, weight: FontWeight, style: FontStyle): Font expect fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font

18
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt

@ -4,57 +4,57 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import org.jetbrains.codeviewer.platform.Font import org.jetbrains.codeviewer.platform.font
object Fonts { object Fonts {
@Composable @Composable
fun jetbrainsMono() = FontFamily( fun jetbrainsMono() = FontFamily(
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_regular", "jetbrainsmono_regular",
FontWeight.Normal, FontWeight.Normal,
FontStyle.Normal FontStyle.Normal
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_italic", "jetbrainsmono_italic",
FontWeight.Normal, FontWeight.Normal,
FontStyle.Italic FontStyle.Italic
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_bold", "jetbrainsmono_bold",
FontWeight.Bold, FontWeight.Bold,
FontStyle.Normal FontStyle.Normal
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_bold_italic", "jetbrainsmono_bold_italic",
FontWeight.Bold, FontWeight.Bold,
FontStyle.Italic FontStyle.Italic
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_extrabold", "jetbrainsmono_extrabold",
FontWeight.ExtraBold, FontWeight.ExtraBold,
FontStyle.Normal FontStyle.Normal
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_extrabold_italic", "jetbrainsmono_extrabold_italic",
FontWeight.ExtraBold, FontWeight.ExtraBold,
FontStyle.Italic FontStyle.Italic
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_medium", "jetbrainsmono_medium",
FontWeight.Medium, FontWeight.Medium,
FontStyle.Normal FontStyle.Normal
), ),
Font( font(
"JetBrains Mono", "JetBrains Mono",
"jetbrainsmono_medium_italic", "jetbrainsmono_medium_italic",
FontWeight.Medium, FontWeight.Medium,

21
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt

@ -1,6 +1,9 @@
package org.jetbrains.codeviewer.ui.filetree package org.jetbrains.codeviewer.ui.filetree
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
@ -11,6 +14,7 @@ import androidx.compose.material.Text
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.* import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -24,7 +28,6 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import org.jetbrains.codeviewer.platform.VerticalScrollbar import org.jetbrains.codeviewer.platform.VerticalScrollbar
import org.jetbrains.codeviewer.platform.pointerMoveFilter
import org.jetbrains.codeviewer.util.withoutWidthConstraints import org.jetbrains.codeviewer.util.withoutWidthConstraints
@Composable @Composable
@ -76,25 +79,17 @@ private fun FileTreeItemView(fontSize: TextUnit, height: Dp, model: FileTree.Ite
.height(height) .height(height)
.fillMaxWidth() .fillMaxWidth()
) { ) {
val active = remember { mutableStateOf(false) } val interactionSource = remember { MutableInteractionSource() }
val active by interactionSource.collectIsHoveredAsState()
FileItemIcon(Modifier.align(Alignment.CenterVertically), model) FileItemIcon(Modifier.align(Alignment.CenterVertically), model)
Text( Text(
text = model.name, text = model.name,
color = if (active.value) LocalContentColor.current.copy(alpha = 0.60f) else LocalContentColor.current, color = if (active) LocalContentColor.current.copy(alpha = 0.60f) else LocalContentColor.current,
modifier = Modifier modifier = Modifier
.align(Alignment.CenterVertically) .align(Alignment.CenterVertically)
.clipToBounds() .clipToBounds()
.pointerMoveFilter( .hoverable(interactionSource),
onEnter = {
active.value = true
true
},
onExit = {
active.value = false
true
}
),
softWrap = true, softWrap = true,
fontSize = fontSize, fontSize = fontSize,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,

11
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -2,20 +2,9 @@ package org.jetbrains.codeviewer.platform
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.PointerIcon import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.input.pointer.pointerMoveFilter
import java.awt.Cursor import java.awt.Cursor
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove)
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.cursorForHorizontalResize(): Modifier = actual fun Modifier.cursorForHorizontalResize(): Modifier =
this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR))) this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))

2
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -6,5 +6,5 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
@Composable @Composable
actual fun Font(name: String, res: String, weight: FontWeight, style: FontStyle): Font = actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font =
androidx.compose.ui.text.platform.Font("font/$res.ttf", weight, style) androidx.compose.ui.text.platform.Font("font/$res.ttf", weight, style)

2
examples/codeviewer/gradle.properties

@ -20,5 +20,5 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete": # Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official kotlin.code.style=official
kotlin.version=1.7.10 kotlin.version=1.7.10
agp.version=7.0.4 agp.version=7.1.3
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02

8
examples/imageviewer/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 26
targetSdk = 31 targetSdk = 32
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.1") implementation("androidx.activity:activity-compose:1.5.0")
} }

2
examples/imageviewer/android/src/main/AndroidManifest.xml

@ -17,7 +17,7 @@
<activity <activity
android:exported="true" android:exported="true"
android:name="example.imageviewer.MainActivity" android:name="example.imageviewer.MainActivity"
android:label="@string/app_name"> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />

10
examples/imageviewer/common/build.gradle.kts

@ -20,8 +20,8 @@ kotlin {
} }
named("androidMain") { named("androidMain") {
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.3.1") api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.3.1") api("androidx.core:core-ktx:1.8.0")
implementation("io.ktor:ktor-client-cio:1.4.1") implementation("io.ktor:ktor-client-cio:1.4.1")
} }
} }
@ -35,11 +35,11 @@ kotlin {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 26
targetSdk = 31 targetSdk = 32
} }
compileOptions { compileOptions {

10
examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AndroidHover.kt

@ -1,10 +0,0 @@
package example.imageviewer.view
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
actual fun Modifier.hover(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this

10
examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/PointerMoveFilter.kt

@ -1,10 +0,0 @@
package example.imageviewer.view
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
expect fun Modifier.hover(
onEnter: () -> Boolean = { true },
onExit: () -> Boolean = { true },
onMove: (Offset) -> Boolean = { true }
): Modifier

74
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt

@ -1,8 +1,6 @@
package example.imageviewer.view package example.imageviewer.view
import androidx.compose.foundation.Image import androidx.compose.foundation.*
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@ -12,22 +10,20 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.ScrollState import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface import androidx.compose.material.Surface
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.key
@ -36,14 +32,12 @@ import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowSize
import example.imageviewer.core.FilterType import example.imageviewer.core.FilterType
import example.imageviewer.model.AppState import example.imageviewer.model.AppState
import example.imageviewer.model.ContentState import example.imageviewer.model.ContentState
import example.imageviewer.model.ScreenType import example.imageviewer.model.ScreenType
import example.imageviewer.ResString import example.imageviewer.ResString
import example.imageviewer.style.DarkGray import example.imageviewer.style.DarkGray
import example.imageviewer.style.DarkGreen
import example.imageviewer.style.Foreground import example.imageviewer.style.Foreground
import example.imageviewer.style.MiniatureColor import example.imageviewer.style.MiniatureColor
import example.imageviewer.style.TranslucentBlack import example.imageviewer.style.TranslucentBlack
@ -74,7 +68,8 @@ fun ToolBar(
text: String, text: String,
content: ContentState content: ContentState
) { ) {
val backButtonHover = remember { mutableStateOf(false) } val backButtonInteractionSource = remember { MutableInteractionSource() }
val backButtonHover by backButtonInteractionSource.collectIsHoveredAsState()
Surface( Surface(
color = MiniatureColor, color = MiniatureColor,
modifier = Modifier.height(44.dp) modifier = Modifier.height(44.dp)
@ -87,16 +82,9 @@ fun ToolBar(
) { ) {
Tooltip(ResString.back) { Tooltip(ResString.back) {
Clickable( Clickable(
modifier = Modifier.hover( modifier = Modifier
onEnter = { .hoverable(backButtonInteractionSource)
backButtonHover.value = true .background(color = if (backButtonHover) TranslucentBlack else Transparent),
false
},
onExit = {
backButtonHover.value = false
false
})
.background(color = if (backButtonHover.value) TranslucentBlack else Transparent),
onClick = { onClick = {
if (content.isContentReady()) { if (content.isContentReady()) {
content.restoreMainImage() content.restoreMainImage()
@ -145,33 +133,27 @@ fun FilterButton(
type: FilterType, type: FilterType,
modifier: Modifier = Modifier.size(38.dp) modifier: Modifier = Modifier.size(38.dp)
) { ) {
val filterButtonHover = remember { mutableStateOf(false) } val interactionSource = remember { MutableInteractionSource() }
Box( val filterButtonHover by interactionSource.collectIsHoveredAsState()
modifier = Modifier.background(color = Transparent).clip(CircleShape) Box(
) { modifier = Modifier.background(color = Transparent).clip(CircleShape)
Tooltip("$type") { ) {
Clickable( Tooltip("$type") {
modifier = Modifier.hover( Clickable(
onEnter = { modifier = Modifier
filterButtonHover.value = true .hoverable(interactionSource)
false .background(color = if (filterButtonHover) TranslucentBlack else Transparent),
}, onClick = { content.toggleFilter(type)}
onExit = { ) {
filterButtonHover.value = false Image(
false getFilterImage(type = type, content = content),
}) contentDescription = null,
.background(color = if (filterButtonHover.value) TranslucentBlack else Transparent), modifier
onClick = { content.toggleFilter(type)} )
) {
Image(
getFilterImage(type = type, content = content),
contentDescription = null,
modifier
)
}
} }
} }
Spacer(Modifier.width(20.dp)) }
Spacer(Modifier.width(20.dp))
} }
@Composable @Composable

61
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt

@ -1,9 +1,6 @@
package example.imageviewer.view package example.imageviewer.view
import androidx.compose.foundation.Image import androidx.compose.foundation.*
import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@ -12,17 +9,12 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.rememberScrollbarAdapter import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card import androidx.compose.material.Card
import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Divider import androidx.compose.material.Divider
@ -31,6 +23,7 @@ import androidx.compose.material.Surface
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.TopAppBar import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -81,7 +74,8 @@ fun TopContent(content: ContentState) {
@Composable @Composable
fun TitleBar(text: String, content: ContentState) { fun TitleBar(text: String, content: ContentState) {
val refreshButtonHover = remember { mutableStateOf(false) } val interactionSource = remember { MutableInteractionSource() }
val refreshButtonHover by interactionSource.collectIsHoveredAsState()
TopAppBar( TopAppBar(
backgroundColor = DarkGreen, backgroundColor = DarkGreen,
title = { title = {
@ -98,17 +92,9 @@ fun TitleBar(text: String, content: ContentState) {
) { ) {
Tooltip(ResString.refresh) { Tooltip(ResString.refresh) {
Clickable( Clickable(
modifier = Modifier.hover( modifier = Modifier
onEnter = { .hoverable(interactionSource)
refreshButtonHover.value = true .background(color = if (refreshButtonHover) TranslucentBlack else Transparent),
false
},
onExit = {
refreshButtonHover.value = false
false
}
)
.background(color = if (refreshButtonHover.value) TranslucentBlack else Transparent),
onClick = { onClick = {
if (content.isContentReady()) { if (content.isContentReady()) {
content.refresh() content.refresh()
@ -160,20 +146,15 @@ fun Miniature(
picture: Picture, picture: Picture,
content: ContentState content: ContentState
) { ) {
val cardHover = remember { mutableStateOf(false) } val cardHoverInteractionSource = remember { MutableInteractionSource() }
val infoButtonHover = remember { mutableStateOf(false) } val cardHover by cardHoverInteractionSource.collectIsHoveredAsState()
val infoButtonInteractionSource = remember { MutableInteractionSource() }
val infoButtonHover by infoButtonInteractionSource.collectIsHoveredAsState()
Card( Card(
backgroundColor = if (cardHover.value) MiniatureHoverColor else MiniatureColor, backgroundColor = if (cardHover) MiniatureHoverColor else MiniatureColor,
modifier = Modifier.padding(start = 10.dp, end = 18.dp).height(70.dp) modifier = Modifier.padding(start = 10.dp, end = 18.dp).height(70.dp)
.fillMaxWidth() .fillMaxWidth()
.hover(onEnter = { .hoverable(cardHoverInteractionSource)
cardHover.value = true
false
},
onExit = {
cardHover.value = false
false
})
.clickable { .clickable {
content.setMainImage(picture) content.setMainImage(picture)
}, },
@ -209,16 +190,8 @@ fun Miniature(
Clickable( Clickable(
modifier = Modifier.height(70.dp) modifier = Modifier.height(70.dp)
.width(30.dp) .width(30.dp)
.hover( .hoverable(infoButtonInteractionSource)
onEnter = { .background(color = if (infoButtonHover) TranslucentWhite else Transparent),
infoButtonHover.value = true
false
},
onExit = {
infoButtonHover.value = false
false
})
.background(color = if (infoButtonHover.value) TranslucentWhite else Transparent),
onClick = { onClick = {
showPopUpMessage( showPopUpMessage(
"${ResString.picture} " + "${ResString.picture} " +

13
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MouseHover.kt

@ -1,13 +0,0 @@
package example.imageviewer.view
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerMoveFilter
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.hover(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove)

2
examples/imageviewer/gradle.properties

@ -20,5 +20,5 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete": # Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official kotlin.code.style=official
kotlin.version=1.7.10 kotlin.version=1.7.10
agp.version=7.0.4 agp.version=7.1.3
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02

6
examples/issues/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 26 minSdk = 26
targetSdk = 31 targetSdk = 32
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.1") implementation("androidx.activity:activity-compose:1.5.0")
} }

2
examples/issues/android/src/main/AndroidManifest.xml

@ -12,7 +12,7 @@
<activity <activity
android:exported="true" android:exported="true"
android:name="androidx.ui.examples.jetissues.MainActivity" android:name="androidx.ui.examples.jetissues.MainActivity"
android:label="@string/app_name"> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

8
examples/issues/common/build.gradle.kts

@ -24,8 +24,8 @@ kotlin {
named("androidMain") { named("androidMain") {
kotlin.srcDirs("src/jvmAndAndroidMain/kotlin") kotlin.srcDirs("src/jvmAndAndroidMain/kotlin")
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.3.1") api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.3.1") api("androidx.core:core-ktx:1.8.0")
} }
} }
named("desktopMain") { named("desktopMain") {
@ -40,11 +40,11 @@ apollo {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 26 minSdk = 26
targetSdk = 31 targetSdk = 32
} }
compileOptions { compileOptions {

13
examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt

@ -19,6 +19,8 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.* import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -31,6 +33,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.ui.examples.jetissues.data.* import androidx.ui.examples.jetissues.data.*
import androidx.ui.examples.jetissues.query.IssueQuery import androidx.ui.examples.jetissues.query.IssueQuery
import androidx.ui.examples.jetissues.query.IssuesQuery import androidx.ui.examples.jetissues.query.IssuesQuery
@ -83,10 +86,12 @@ fun SingleColumnLayout(currentIssue: MutableState<IssuesQuery.Node?>) {
) )
}, },
navigationIcon = { navigationIcon = {
Button(onClick = { IconButton(
currentIssue.value = null onClick = {
}) { currentIssue.value = null
Text(text = "Back") }
) {
Icon(Icons.Default.ArrowBack, contentDescription = "Back")
} }
} }
) )

2
examples/issues/gradle.properties

@ -20,5 +20,5 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true android.enableJetifier=true
kotlin.version=1.7.10 kotlin.version=1.7.10
agp.version=7.0.4 agp.version=7.1.3
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02

10
examples/todoapp-lite/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 26
targetSdk = 31 targetSdk = 32
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -23,7 +23,7 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation(compose.material) implementation(compose.material)
implementation("androidx.appcompat:appcompat:1.3.0") implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.activity:activity-compose:1.3.0") implementation("androidx.activity:activity-compose:1.5.0")
} }

2
examples/todoapp-lite/android/src/main/AndroidManifest.xml

@ -13,7 +13,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:label="@string/app_name"> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>

6
examples/todoapp-lite/common/build.gradle.kts

@ -22,11 +22,11 @@ kotlin {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 26
targetSdk = 31 targetSdk = 32
} }
compileOptions { compileOptions {

2
examples/todoapp-lite/gradle.properties

@ -20,5 +20,5 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete": # Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official kotlin.code.style=official
kotlin.version=1.7.10 kotlin.version=1.7.10
agp.version=7.0.4 agp.version=7.1.3
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02

15
examples/visual-effects/.gitignore vendored

@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
build/
/captures
.externalNativeBuild
.cxx

6
examples/widgets-gallery/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdk = 31 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 26 minSdk = 26
targetSdk = 30 targetSdk = 32
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.0") implementation("androidx.activity:activity-compose:1.5.0")
} }

3
examples/widgets-gallery/android/src/main/AndroidManifest.xml

@ -10,8 +10,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"> android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity <activity
android:exported="true"
android:name="MainActivity" android:name="MainActivity"
android:label="@string/app_name"> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

10
examples/widgets-gallery/common/build.gradle.kts

@ -21,8 +21,8 @@ kotlin {
} }
named("androidMain") { named("androidMain") {
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.3.1") api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.3.1") api("androidx.core:core-ktx:1.8.0")
} }
} }
named("desktopMain") { named("desktopMain") {
@ -34,11 +34,11 @@ kotlin {
} }
android { android {
compileSdk = 30 compileSdk = 32
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 26
targetSdk = 30 targetSdk = 32
} }
compileOptions { compileOptions {

6
examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt

@ -3,10 +3,4 @@ package org.jetbrains.compose.demo.widgets.platform
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this
actual fun Modifier.cursorForHorizontalResize() = this actual fun Modifier.cursorForHorizontalResize() = this

6
examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt

@ -1,10 +1,7 @@
package org.jetbrains.compose.demo.widgets.platform package org.jetbrains.compose.demo.widgets.platform
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import org.jetbrains.compose.demo.widgets.platform.R
@Composable @Composable
actual fun painterResource(res: String): Painter { actual fun painterResource(res: String): Painter {
@ -17,6 +14,5 @@ private fun drawableId(res: String): Int {
val imageName = res.substringAfterLast("/").substringBeforeLast(".") val imageName = res.substringAfterLast("/").substringBeforeLast(".")
val drawableClass = R.drawable::class.java val drawableClass = R.drawable::class.java
val field = drawableClass.getDeclaredField(imageName) val field = drawableClass.getDeclaredField(imageName)
val idValue = field.get(drawableClass) as Integer return field.get(drawableClass) as Int
return idValue.toInt()
} }

6
examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt

@ -3,10 +3,4 @@ package org.jetbrains.compose.demo.widgets.platform
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
expect fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean = { true },
onExit: () -> Boolean = { true },
onMove: (Offset) -> Boolean = { true }
): Modifier
expect fun Modifier.cursorForHorizontalResize(): Modifier expect fun Modifier.cursorForHorizontalResize(): Modifier

18
examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt

@ -4,6 +4,9 @@ import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.SpringSpec import androidx.compose.animation.core.SpringSpec
import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
@ -26,7 +29,6 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import org.jetbrains.compose.demo.widgets.platform.VerticalScrollbar import org.jetbrains.compose.demo.widgets.platform.VerticalScrollbar
import org.jetbrains.compose.demo.widgets.platform.pointerMoveFilter
import org.jetbrains.compose.demo.widgets.theme.WidgetGalleryTheme import org.jetbrains.compose.demo.widgets.theme.WidgetGalleryTheme
import org.jetbrains.compose.demo.widgets.ui.utils.PanelState import org.jetbrains.compose.demo.widgets.ui.utils.PanelState
import org.jetbrains.compose.demo.widgets.ui.utils.ResizablePanel import org.jetbrains.compose.demo.widgets.ui.utils.ResizablePanel
@ -132,7 +134,8 @@ private fun WidgetsListItemViewImpl(
.height(height) .height(height)
.padding(start = 16.dp) .padding(start = 16.dp)
) { ) {
var inFocus by remember { mutableStateOf(false) } val inFocusInteractionSource = remember { MutableInteractionSource() }
val inFocus by inFocusInteractionSource.collectIsHoveredAsState()
val textColor = LocalContentColor.current.let { val textColor = LocalContentColor.current.let {
when { when {
isCurrent -> it isCurrent -> it
@ -147,16 +150,7 @@ private fun WidgetsListItemViewImpl(
modifier = Modifier modifier = Modifier
.align(Alignment.CenterVertically) .align(Alignment.CenterVertically)
.clipToBounds() .clipToBounds()
.pointerMoveFilter( .hoverable(inFocusInteractionSource),
onEnter = {
inFocus = true
true
},
onExit = {
inFocus = false
true
}
),
softWrap = true, softWrap = true,
fontSize = fontSize, fontSize = fontSize,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,

8
examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt

@ -1,5 +1,7 @@
package org.jetbrains.compose.demo.widgets.ui package org.jetbrains.compose.demo.widgets.ui
import java.util.Locale
enum class WidgetsType(private val customTitle: String? = null) { enum class WidgetsType(private val customTitle: String? = null) {
APP_BARS, APP_BARS,
BUTTONS, BUTTONS,
@ -13,9 +15,11 @@ enum class WidgetsType(private val customTitle: String? = null) {
val readableName: String by lazy { val readableName: String by lazy {
name.split("_") name.split("_")
.map { it.toLowerCase() } .map { it.lowercase(Locale.getDefault()) }
.mapIndexed { i, it -> .mapIndexed { i, it ->
if (i == 0) it.capitalize() else it if (i == 0) it.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
} else it
}.joinToString(" ") }.joinToString(" ")
} }

2
examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt

@ -14,7 +14,7 @@ fun SubtitleText(subtitle: String, modifier: Modifier = Modifier) {
} }
@Composable @Composable
fun TitleText(title: String, modifier: Modifier = Modifier) { fun TitleText(title: String) {
Text( Text(
text = title, text = title,
style = typography.h6.copy(fontSize = 14.sp), style = typography.h6.copy(fontSize = 14.sp),

8
examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt

@ -8,13 +8,5 @@ import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.input.pointer.pointerMoveFilter import androidx.compose.ui.input.pointer.pointerMoveFilter
import java.awt.Cursor import java.awt.Cursor
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove)
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.cursorForHorizontalResize(): Modifier = actual fun Modifier.cursorForHorizontalResize(): Modifier =
this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR))) this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))

2
examples/widgets-gallery/gradle.properties

@ -21,4 +21,4 @@ android.enableJetifier=true
kotlin.code.style=official kotlin.code.style=official
kotlin.version=1.7.10 kotlin.version=1.7.10
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02
agp.version=7.0.4 agp.version=7.1.3

Loading…
Cancel
Save