Browse Source

Merge remote-tracking branch 'origin/master' into templates

# Conflicts:
#	.gitignore
#	ci/compose-uber-jar/gradle/wrapper/gradle-wrapper.jar
pull/3/head
Igor Demin 4 years ago
parent
commit
1ed7f9078a
  1. 3
      .gitignore
  2. 2
      ci/compose-uber-jar/README.md
  3. 9
      ci/compose-uber-jar/build.gradle.kts
  4. 2
      ci/compose-uber-jar/gradle.properties
  5. BIN
      ci/compose-uber-jar/gradle/wrapper/gradle-wrapper.jar
  6. 2
      ci/compose-uber-jar/settings.gradle
  7. 2
      examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/ContentState.kt
  8. 2
      examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AndroidHover.kt
  9. 4
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/style/Palette.kt
  10. 2
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/PointerMoveFilter.kt
  11. 23
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/ContentState.kt
  12. 2
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/AppUI.kt
  13. 33
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullImageScreen.kt
  14. 84
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt
  15. 2
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MouseHover.kt
  16. 4
      examples/imageviewer/desktop/src/main/kotlin/imageviewer/Main.kt

3
.gitignore vendored

@ -11,6 +11,9 @@
.mtj.tmp/ .mtj.tmp/
# Package Files # # Package Files #
*.jar
!gradle-wrapper.jar
*.war *.war
*.nar *.nar
*.ear *.ear

2
ci/compose-uber-jar/README.md

@ -22,5 +22,5 @@ The jar will be available at `build/libs/compose-full.jar`
``` ```
export COMPOSE_REPO_USERNAME=<COMPOSE_REPO_USERNAME> export COMPOSE_REPO_USERNAME=<COMPOSE_REPO_USERNAME>
export COMPOSE_REPO_KEY=<COMPOSE_REPO_KEY> export COMPOSE_REPO_KEY=<COMPOSE_REPO_KEY>
./gradlew publishToSpace ./gradlew publishToComposeRepo
``` ```

9
ci/compose-uber-jar/build.gradle.kts

@ -33,8 +33,8 @@ val shadowJar = tasks.named("shadowJar", ShadowJar::class) {
archiveFileName.set("compose-full.jar") archiveFileName.set("compose-full.jar")
} }
tasks.register("publishToSpace") { tasks.register("publishToComposeRepo") {
dependsOn(tasks.named("publishAllPublicationsToSpaceRepository")) dependsOn(tasks.named("publishAllPublicationsToComposeRepoRepository"))
} }
publishing { publishing {
@ -48,7 +48,7 @@ publishing {
} }
repositories { repositories {
maven(properties.composeRepoUrl) { maven(properties.composeRepoUrl) {
name = "Space" name = "ComposeRepo"
authentication { authentication {
credentials { credentials {
username = properties.composeRepoUserName username = properties.composeRepoUserName
@ -66,7 +66,8 @@ class ComposeUberJarProperties {
val composeVersionFile: String? val composeVersionFile: String?
get() = typedProperty<String>(COMPOSE_VERSION_FILE_PROPERTY) get() = typedProperty<String>(COMPOSE_VERSION_FILE_PROPERTY)
val composeRepoUrl: String = "https://packages.jetbrains.team/maven/p/ui/dev" val composeRepoUrl: String
get() = System.getenv("COMPOSE_REPO_URL") ?: "https://maven.pkg.jetbrains.space/public/p/compose/dev"
val composeRepoUserName: String? val composeRepoUserName: String?
get() = System.getenv("COMPOSE_REPO_USERNAME") get() = System.getenv("COMPOSE_REPO_USERNAME")

2
ci/compose-uber-jar/gradle.properties

@ -1,2 +1,2 @@
compose.version=0.1.0-build49 compose.version=0.1.0-build63
kotlin.code.style=official kotlin.code.style=official

BIN
ci/compose-uber-jar/gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

2
ci/compose-uber-jar/settings.gradle

@ -1,2 +1,2 @@
rootProject.name = 'untitled23' rootProject.name = 'compose-uber-jar'

2
examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/ContentState.kt

@ -159,7 +159,7 @@ object ContentState {
} }
// application content initialization // application content initialization
fun initData() { private fun initData() {
if (isAppUIReady.value) if (isAppUIReady.value)
return return

2
examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/ActualAndroid.kt → examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AndroidHover.kt

@ -3,7 +3,7 @@ package example.imageviewer.view
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.maybePointerMoveFilter( actual fun Modifier.hover(
onEnter: () -> Boolean, onEnter: () -> Boolean,
onExit: () -> Boolean, onExit: () -> Boolean,
onMove: (Offset) -> Boolean onMove: (Offset) -> Boolean

4
examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/style/Palette.kt

@ -21,7 +21,11 @@ val DarkGreen = Color(16, 139, 102)
val Gray = Color.DarkGray val Gray = Color.DarkGray
val LightGray = Color(100, 100, 100) val LightGray = Color(100, 100, 100)
val DarkGray = Color(32, 32, 32) val DarkGray = Color(32, 32, 32)
val PreviewImageAreaHoverColor = Color(45, 45, 45)
val ToastBackground = Color(23, 23, 23) val ToastBackground = Color(23, 23, 23)
val MiniatureColor = Color(50, 50, 50) val MiniatureColor = Color(50, 50, 50)
val MiniatureHoverColor = Color(60, 60, 60)
val Foreground = Color(210, 210, 210) val Foreground = Color(210, 210, 210)
val TranslucentBlack = Color(0, 0, 0, 60)
val TranslucentWhite = Color(255, 255, 255, 20)
val Transparent = Color.Transparent val Transparent = Color.Transparent

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

@ -3,7 +3,7 @@ package example.imageviewer.view
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.maybePointerMoveFilter( expect fun Modifier.hover(
onEnter: () -> Boolean = { true }, onEnter: () -> Boolean = { true },
onExit: () -> Boolean = { true }, onExit: () -> Boolean = { true },
onMove: (Offset) -> Boolean = { true } onMove: (Offset) -> Boolean = { true }

23
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/ContentState.kt

@ -32,9 +32,24 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
class ContentState( object ContentState {
private val repository: ImageRepository
) { private lateinit var repository: ImageRepository
private lateinit var uriRepository: String
fun applyContent(uriRepository: String): ContentState {
if (this::uriRepository.isInitialized && this.uriRepository == uriRepository) {
return this
}
this.uriRepository = uriRepository
repository = ImageRepository(uriRepository)
isAppUIReady.value = false
initData()
return this
}
private val executor: ExecutorService by lazy { Executors.newFixedThreadPool(2) } private val executor: ExecutorService by lazy { Executors.newFixedThreadPool(2) }
private val isAppUIReady = mutableStateOf(false) private val isAppUIReady = mutableStateOf(false)
@ -124,7 +139,7 @@ class ContentState(
} }
// application content initialization // application content initialization
fun initData() { private fun initData() {
if (isAppUIReady.value) if (isAppUIReady.value)
return return

2
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/AppUI.kt

@ -32,8 +32,6 @@ private val state: MutableState<Boolean> = mutableStateOf(false)
@Composable @Composable
fun BuildAppUI(content: ContentState) { fun BuildAppUI(content: ContentState) {
content.initData()
Surface( Surface(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
color = Gray color = Gray

33
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullImageScreen.kt

@ -19,6 +19,7 @@ import java.awt.image.BufferedImage
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.ScrollableRow import androidx.compose.foundation.ScrollableRow
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
@ -41,6 +42,8 @@ import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredSize import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.Surface import androidx.compose.material.Surface
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import example.imageviewer.core.FilterType import example.imageviewer.core.FilterType
import example.imageviewer.model.AppState import example.imageviewer.model.AppState
@ -51,6 +54,8 @@ 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.Transparent import example.imageviewer.style.Transparent
import example.imageviewer.style.TranslucentBlack
import example.imageviewer.style.TranslucentWhite
import example.imageviewer.style.icBack import example.imageviewer.style.icBack
import example.imageviewer.style.icFilterGrayscaleOn import example.imageviewer.style.icFilterGrayscaleOn
import example.imageviewer.style.icFilterGrayscaleOff import example.imageviewer.style.icFilterGrayscaleOff
@ -106,8 +111,11 @@ fun setToolBar(
text: String, text: String,
content: ContentState content: ContentState
) { ) {
val backButtonHover = remember { mutableStateOf(false) }
Surface(color = MiniatureColor, modifier = Modifier.preferredHeight(44.dp)) { Surface(
color = MiniatureColor,
modifier = Modifier.preferredHeight(44.dp)
) {
Row(modifier = Modifier.padding(end = 30.dp)) { Row(modifier = Modifier.padding(end = 30.dp)) {
Surface( Surface(
color = Transparent, color = Transparent,
@ -115,6 +123,16 @@ fun setToolBar(
shape = CircleShape shape = CircleShape
) { ) {
Clickable( Clickable(
modifier = Modifier.hover(
onEnter = {
backButtonHover.value = true
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()
@ -160,11 +178,22 @@ fun FilterButton(
type: FilterType, type: FilterType,
modifier: Modifier = Modifier.preferredSize(38.dp) modifier: Modifier = Modifier.preferredSize(38.dp)
) { ) {
val filterButtonHover = remember { mutableStateOf(false) }
Surface( Surface(
color = Transparent, color = Transparent,
shape = CircleShape shape = CircleShape
) { ) {
Clickable( Clickable(
modifier = Modifier.hover(
onEnter = {
filterButtonHover.value = true
false
},
onExit = {
filterButtonHover.value = false
false
})
.background(color = if (filterButtonHover.value) TranslucentBlack else Transparent),
onClick = { content.toggleFilter(type)} onClick = { content.toggleFilter(type)}
) { ) {
Image( Image(

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

@ -15,7 +15,12 @@
*/ */
package example.imageviewer.view package example.imageviewer.view
import androidx.compose.foundation.* import androidx.compose.foundation.clickable
import androidx.compose.foundation.background
import androidx.compose.foundation.Box
import androidx.compose.foundation.Text
import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollableColumn
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.RectangleShape
@ -53,6 +58,10 @@ import example.imageviewer.style.DarkGray
import example.imageviewer.style.DarkGreen import example.imageviewer.style.DarkGreen
import example.imageviewer.style.Foreground import example.imageviewer.style.Foreground
import example.imageviewer.style.Transparent import example.imageviewer.style.Transparent
import example.imageviewer.style.TranslucentBlack
import example.imageviewer.style.TranslucentWhite
import example.imageviewer.style.PreviewImageAreaHoverColor
import example.imageviewer.style.MiniatureHoverColor
import example.imageviewer.style.MiniatureColor import example.imageviewer.style.MiniatureColor
import example.imageviewer.style.LightGray import example.imageviewer.style.LightGray
import example.imageviewer.style.icRefresh import example.imageviewer.style.icRefresh
@ -112,7 +121,7 @@ fun setTopContent(content: ContentState) {
@Composable @Composable
fun setTitleBar(text: String, content: ContentState) { fun setTitleBar(text: String, content: ContentState) {
val refreshButtonHover = remember { mutableStateOf(false) }
TopAppBar( TopAppBar(
backgroundColor = DarkGreen, backgroundColor = DarkGreen,
title = { title = {
@ -128,6 +137,16 @@ fun setTitleBar(text: String, content: ContentState) {
shape = CircleShape shape = CircleShape
) { ) {
Clickable( Clickable(
modifier = Modifier.hover(
onEnter = {
refreshButtonHover.value = true
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()
@ -144,12 +163,23 @@ fun setTitleBar(text: String, content: ContentState) {
@Composable @Composable
fun setPreviewImageUI(content: ContentState) { fun setPreviewImageUI(content: ContentState) {
val previewImageHover = remember { mutableStateOf(false) }
Clickable(onClick = { Clickable(
modifier = Modifier.hover(
onEnter = {
previewImageHover.value = true
false
},
onExit = {
previewImageHover.value = false
false
})
.background(color = if (previewImageHover.value) PreviewImageAreaHoverColor else DarkGray),
onClick = {
AppState.screenState(ScreenType.FullscreenImage) AppState.screenState(ScreenType.FullscreenImage)
}) { }) {
Card( Card(
backgroundColor = DarkGray, backgroundColor = Transparent,
modifier = Modifier.preferredHeight(250.dp), modifier = Modifier.preferredHeight(250.dp),
shape = RectangleShape, shape = RectangleShape,
elevation = 1.dp elevation = 1.dp
@ -173,29 +203,28 @@ fun setMiniatureUI(
picture: Picture, picture: Picture,
content: ContentState content: ContentState
) { ) {
val active = remember { mutableStateOf(false) } val cardHover = remember { mutableStateOf(false) }
val infoButtonHover = remember { mutableStateOf(false) }
Card( Card(
backgroundColor = MiniatureColor, backgroundColor = if (cardHover.value) MiniatureHoverColor else MiniatureColor,
modifier = Modifier.padding(start = 10.dp, end = 10.dp).preferredHeight(70.dp) modifier = Modifier.padding(start = 10.dp, end = 10.dp).preferredHeight(70.dp)
.fillMaxWidth() .fillMaxWidth()
.hover(onEnter = {
cardHover.value = true
false
},
onExit = {
cardHover.value = false
false
})
.clickable { .clickable {
content.setMainImage(picture) content.setMainImage(picture)
}, },
shape = RectangleShape, shape = RectangleShape,
elevation = 2.dp elevation = 20.dp
) {
Row(modifier = Modifier.padding(end = 30.dp)
) { ) {
Row(modifier = Modifier
.padding(end = 30.dp)
.maybePointerMoveFilter(onEnter = {
active.value = true
false
},
onExit = {
active.value = false
false
}
)
.background(color = if (active.value) Color.LightGray else Color.Black)) {
Clickable( Clickable(
onClick = { onClick = {
content.fullscreen(picture) content.fullscreen(picture)
@ -213,18 +242,27 @@ fun setMiniatureUI(
} }
Text( Text(
text = picture.name, text = picture.name,
color = if (active.value) Color.Red else Foreground, color = Foreground,
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.align(Alignment.CenterVertically) .align(Alignment.CenterVertically)
.padding(start = 16.dp), .padding(start = 16.dp),
fontSize = TextUnit.Sp(if (active.value) 40 else 16),
style = MaterialTheme.typography.body1 style = MaterialTheme.typography.body1
) )
Clickable( Clickable(
modifier = Modifier.preferredHeight(70.dp) modifier = Modifier.preferredHeight(70.dp)
.preferredWidth(30.dp), .preferredWidth(30.dp)
.hover(
onEnter = {
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} " +

2
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/ActualDesktop.kt → examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MouseHover.kt

@ -4,7 +4,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerMoveFilter import androidx.compose.ui.input.pointer.pointerMoveFilter
actual fun Modifier.maybePointerMoveFilter( actual fun Modifier.hover(
onEnter: () -> Boolean, onEnter: () -> Boolean,
onExit: () -> Boolean, onExit: () -> Boolean,
onMove: (Offset) -> Boolean onMove: (Offset) -> Boolean

4
examples/imageviewer/desktop/src/main/kotlin/imageviewer/Main.kt

@ -23,8 +23,8 @@ import example.imageviewer.model.ImageRepository
fun main() { fun main() {
val content = ContentState( val content = ContentState.applyContent(
ImageRepository("https://spvessel.com/iv/images/fetching.list") "https://spvessel.com/iv/images/fetching.list"
) )
AppWindow("ImageViewer", getPreferredWindowSize(800, 1000)).show { AppWindow("ImageViewer", getPreferredWindowSize(800, 1000)).show {

Loading…
Cancel
Save