mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-05-06 15:51:03 +00:00
Move to 0.2.0-build128
This commit is contained in:
@@ -3,10 +3,12 @@ import kotlinx.benchmark.gradle.*
|
||||
import org.jetbrains.kotlin.allopen.gradle.*
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4.0"
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("jvm") version "1.4.20"
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
id("org.jetbrains.compose") version "0.1.0-build113"
|
||||
kotlin("plugin.allopen") version "1.4.0"
|
||||
id("org.jetbrains.compose") version "0.2.0-build128"
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("plugin.allopen") version "1.4.20"
|
||||
id("kotlinx.benchmark") version "0.2.0-dev-20"
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:0.1.0-build113")
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:0.2.0-build128")
|
||||
classpath("com.android.tools.build:gradle:4.0.1")
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.0"))
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.20"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,5 @@ private fun getFilter(type: FilterType, context: Context): BitmapFilter {
|
||||
FilterType.GrayScale -> GrayScaleFilter()
|
||||
FilterType.Pixel -> PixelFilter()
|
||||
FilterType.Blur -> BlurFilter(context)
|
||||
else -> {
|
||||
EmptyFilter()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,38 @@
|
||||
package example.imageviewer.style
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.ImageAsset
|
||||
import androidx.compose.ui.res.imageResource
|
||||
import example.imageviewer.common.R
|
||||
|
||||
@Composable
|
||||
fun icEmpty(): ImageAsset = imageResource(R.raw.empty)
|
||||
fun icEmpty() = imageResource(R.raw.empty)
|
||||
|
||||
@Composable
|
||||
fun icBack(): ImageAsset = imageResource(R.raw.back)
|
||||
fun icBack() = imageResource(R.raw.back)
|
||||
|
||||
@Composable
|
||||
fun icRefresh(): ImageAsset = imageResource(R.raw.refresh)
|
||||
fun icRefresh() = imageResource(R.raw.refresh)
|
||||
|
||||
@Composable
|
||||
fun icDots(): ImageAsset = imageResource(R.raw.dots)
|
||||
fun icDots() = imageResource(R.raw.dots)
|
||||
|
||||
@Composable
|
||||
fun icFilterGrayscaleOn(): ImageAsset = imageResource(R.raw.grayscale_on)
|
||||
fun icFilterGrayscaleOn() = imageResource(R.raw.grayscale_on)
|
||||
|
||||
@Composable
|
||||
fun icFilterGrayscaleOff(): ImageAsset = imageResource(R.raw.grayscale_off)
|
||||
fun icFilterGrayscaleOff() = imageResource(R.raw.grayscale_off)
|
||||
|
||||
@Composable
|
||||
fun icFilterPixelOn(): ImageAsset = imageResource(R.raw.pixel_on)
|
||||
fun icFilterPixelOn() = imageResource(R.raw.pixel_on)
|
||||
|
||||
@Composable
|
||||
fun icFilterPixelOff(): ImageAsset = imageResource(R.raw.pixel_off)
|
||||
fun icFilterPixelOff() = imageResource(R.raw.pixel_off)
|
||||
|
||||
@Composable
|
||||
fun icFilterBlurOn(): ImageAsset = imageResource(R.raw.blur_on)
|
||||
fun icFilterBlurOn() = imageResource(R.raw.blur_on)
|
||||
|
||||
@Composable
|
||||
fun icFilterBlurOff(): ImageAsset = imageResource(R.raw.blur_off)
|
||||
fun icFilterBlurOff() = imageResource(R.raw.blur_off)
|
||||
|
||||
@Composable
|
||||
fun icFilterUnknown(): ImageAsset = imageResource(R.raw.filter_unknown)
|
||||
fun icFilterUnknown() = imageResource(R.raw.filter_unknown)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package example.imageviewer.view
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Rect
|
||||
import androidx.compose.foundation.background
|
||||
@@ -8,27 +7,25 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.ScrollableRow
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ImageAsset
|
||||
import androidx.compose.ui.graphics.asImageAsset
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.Stack
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.preferredHeight
|
||||
import androidx.compose.foundation.layout.preferredSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.unit.dp
|
||||
import example.imageviewer.core.FilterType
|
||||
import example.imageviewer.model.AppState
|
||||
@@ -161,15 +158,12 @@ fun FilterButton(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getFilterImage(type: FilterType, content: ContentState): ImageAsset {
|
||||
fun getFilterImage(type: FilterType, content: ContentState): ImageBitmap {
|
||||
|
||||
return when (type) {
|
||||
FilterType.GrayScale -> if (content.isFilterEnabled(type)) icFilterGrayscaleOn() else icFilterGrayscaleOff()
|
||||
FilterType.Pixel -> if (content.isFilterEnabled(type)) icFilterPixelOn() else icFilterPixelOff()
|
||||
FilterType.Blur -> if (content.isFilterEnabled(type)) icFilterBlurOn() else icFilterBlurOff()
|
||||
else -> {
|
||||
icFilterUnknown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +181,7 @@ fun setImage(content: ContentState) {
|
||||
Scalable(onScale = scale, modifier = Modifier.fillMaxSize()) {
|
||||
val bitmap = imageByGesture(content, scale, drag)
|
||||
Image(
|
||||
asset = bitmap.asImageAsset(),
|
||||
bitmap = bitmap.asImageBitmap(),
|
||||
contentScale = adjustImageScale(bitmap)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.res.Configuration
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.ScrollableColumn
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -17,17 +16,19 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TopAppBar
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.graphics.asImageAsset
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.unit.dp
|
||||
import example.imageviewer.common.R
|
||||
@@ -146,7 +147,7 @@ fun setPreviewImageUI(content: ContentState) {
|
||||
icEmpty()
|
||||
}
|
||||
else {
|
||||
content.getSelectedImage().asImageAsset()
|
||||
content.getSelectedImage().asImageBitmap()
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth().padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 5.dp),
|
||||
@@ -179,7 +180,7 @@ fun setMiniatureUI(
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
picture.image.asImageAsset(),
|
||||
picture.image.asImageBitmap(),
|
||||
modifier = Modifier.preferredHeight(70.dp)
|
||||
.preferredWidth(90.dp)
|
||||
.padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 1.dp),
|
||||
|
||||
@@ -49,8 +49,5 @@ private fun getFilter(type: FilterType): BitmapFilter {
|
||||
FilterType.GrayScale -> GrayScaleFilter()
|
||||
FilterType.Pixel -> PixelFilter()
|
||||
FilterType.Blur -> BlurFilter()
|
||||
else -> {
|
||||
EmptyFilter()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,42 @@
|
||||
package example.imageviewer.style
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.ImageAsset
|
||||
import androidx.compose.ui.res.imageResource
|
||||
import java.awt.image.BufferedImage
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
@Composable
|
||||
fun icEmpty(): ImageAsset = imageResource("images/empty.png")
|
||||
fun icEmpty() = imageResource("images/empty.png")
|
||||
|
||||
@Composable
|
||||
fun icBack(): ImageAsset = imageResource("images/back.png")
|
||||
fun icBack() = imageResource("images/back.png")
|
||||
|
||||
@Composable
|
||||
fun icRefresh(): ImageAsset = imageResource("images/refresh.png")
|
||||
fun icRefresh() = imageResource("images/refresh.png")
|
||||
|
||||
@Composable
|
||||
fun icDots(): ImageAsset = imageResource("images/dots.png")
|
||||
fun icDots() = imageResource("images/dots.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterGrayscaleOn(): ImageAsset = imageResource("images/grayscale_on.png")
|
||||
fun icFilterGrayscaleOn() = imageResource("images/grayscale_on.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterGrayscaleOff(): ImageAsset = imageResource("images/grayscale_off.png")
|
||||
fun icFilterGrayscaleOff() = imageResource("images/grayscale_off.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterPixelOn(): ImageAsset = imageResource("images/pixel_on.png")
|
||||
fun icFilterPixelOn() = imageResource("images/pixel_on.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterPixelOff(): ImageAsset = imageResource("images/pixel_off.png")
|
||||
fun icFilterPixelOff() = imageResource("images/pixel_off.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterBlurOn(): ImageAsset = imageResource("images/blur_on.png")
|
||||
fun icFilterBlurOn() = imageResource("images/blur_on.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterBlurOff(): ImageAsset = imageResource("images/blur_off.png")
|
||||
fun icFilterBlurOff() = imageResource("images/blur_off.png")
|
||||
|
||||
@Composable
|
||||
fun icFilterUnknown(): ImageAsset = imageResource("images/filter_unknown.png")
|
||||
fun icFilterUnknown() = imageResource("images/filter_unknown.png")
|
||||
|
||||
private var icon: BufferedImage? = null
|
||||
fun icAppRounded(): BufferedImage {
|
||||
|
||||
@@ -2,10 +2,8 @@ package example.imageviewer.view
|
||||
|
||||
import java.awt.image.BufferedImage
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.ScrollableRow
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.MaterialTheme
|
||||
@@ -19,14 +17,15 @@ import androidx.compose.foundation.layout.preferredHeight
|
||||
import androidx.compose.foundation.layout.preferredSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ImageAsset
|
||||
import androidx.compose.ui.graphics.asImageAsset
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -57,7 +56,6 @@ import example.imageviewer.utils.cropImage
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
import org.jetbrains.skija.Image
|
||||
import org.jetbrains.skija.IRect
|
||||
import java.awt.event.KeyEvent
|
||||
import java.awt.Rectangle
|
||||
@@ -193,15 +191,12 @@ fun FilterButton(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getFilterImage(type: FilterType, content: ContentState): ImageAsset {
|
||||
fun getFilterImage(type: FilterType, content: ContentState): ImageBitmap {
|
||||
|
||||
return when (type) {
|
||||
FilterType.GrayScale -> if (content.isFilterEnabled(type)) icFilterGrayscaleOn() else icFilterGrayscaleOff()
|
||||
FilterType.Pixel -> if (content.isFilterEnabled(type)) icFilterPixelOn() else icFilterPixelOff()
|
||||
FilterType.Blur -> if (content.isFilterEnabled(type)) icFilterBlurOn() else icFilterBlurOff()
|
||||
else -> {
|
||||
icFilterUnknown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +227,7 @@ fun setImage(content: ContentState) {
|
||||
) {
|
||||
val bitmap = imageByGesture(content, scale, drag)
|
||||
Image(
|
||||
asset = bitmap.asImageAsset(),
|
||||
bitmap = bitmap,
|
||||
contentScale = ContentScale.Fit
|
||||
)
|
||||
}
|
||||
@@ -245,9 +240,9 @@ fun imageByGesture(
|
||||
content: ContentState,
|
||||
scale: ScaleHandler,
|
||||
drag: DragHandler
|
||||
): Image {
|
||||
): ImageBitmap {
|
||||
val bitmap = cropBitmapByScale(content.getSelectedImage(), scale.factor.value, drag)
|
||||
return Image.makeFromEncoded(toByteArray(bitmap))
|
||||
return org.jetbrains.skija.Image.makeFromEncoded(toByteArray(bitmap)).asImageBitmap()
|
||||
}
|
||||
|
||||
private fun cropBitmapByScale(bitmap: BufferedImage, scale: Float, drag: DragHandler): BufferedImage {
|
||||
|
||||
@@ -2,7 +2,6 @@ package example.imageviewer.view
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.ScrollableColumn
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -26,13 +25,14 @@ import androidx.compose.foundation.VerticalScrollbar
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TopAppBar
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.graphics.asImageAsset
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
@@ -76,7 +76,6 @@ fun setMainScreen(content: ContentState) {
|
||||
|
||||
@Composable
|
||||
private fun setLoadingScreen(content: ContentState) {
|
||||
|
||||
Box {
|
||||
Column {
|
||||
setTopContent(content)
|
||||
@@ -170,9 +169,9 @@ fun setPreviewImageUI(content: ContentState) {
|
||||
Image(
|
||||
if (content.isMainImageEmpty())
|
||||
icEmpty()
|
||||
else Image.makeFromEncoded(
|
||||
else org.jetbrains.skija.Image.makeFromEncoded(
|
||||
toByteArray(content.getSelectedImage())
|
||||
).asImageAsset(),
|
||||
).asImageBitmap(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth().padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 5.dp),
|
||||
contentScale = ContentScale.Fit
|
||||
@@ -212,9 +211,9 @@ fun setMiniatureUI(
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
Image.makeFromEncoded(
|
||||
org.jetbrains.skija.Image.makeFromEncoded(
|
||||
toByteArray(picture.image)
|
||||
).asImageAsset(),
|
||||
).asImageBitmap(),
|
||||
modifier = Modifier.preferredHeight(70.dp)
|
||||
.preferredWidth(90.dp)
|
||||
.padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 1.dp),
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package example.imageviewer.view
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.preferredSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.onActive
|
||||
@@ -22,6 +20,7 @@ import kotlinx.coroutines.GlobalScope
|
||||
import example.imageviewer.style.ToastBackground
|
||||
import example.imageviewer.style.Foreground
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
|
||||
enum class ToastDuration(val value: Int) {
|
||||
Short(1000), Long(3000)
|
||||
@@ -43,14 +42,14 @@ fun Toast(
|
||||
isShown = true
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize().padding(bottom = 20.dp),
|
||||
alignment = Alignment.BottomCenter
|
||||
contentAlignment = Alignment.BottomCenter
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.preferredSize(300.dp, 70.dp),
|
||||
color = ToastBackground,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
) {
|
||||
Box(alignment = Alignment.Center) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Text(
|
||||
text = text,
|
||||
color = Foreground
|
||||
|
||||
@@ -8,9 +8,11 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:0.1.0-m1-build62")
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:0.2.0-build128")
|
||||
classpath("com.android.tools.build:gradle:4.0.1")
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.0"))
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.20"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ actual fun SelectionContainer(children: @Composable () -> Unit) {
|
||||
DesktopSelectionContainer(
|
||||
selection = selection.value,
|
||||
onSelectionChange = { selection.value = it },
|
||||
children = children
|
||||
content = children
|
||||
)
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class IssuesRepositoryImpl(
|
||||
}
|
||||
|
||||
override fun onResponse(response: Response<IssueQuery.Data>) {
|
||||
val issue = response.data()?.repository?.issue
|
||||
val issue = response.data?.repository?.issue
|
||||
if (issue == null) {
|
||||
callback(Result.Error(UnknownIssue()))
|
||||
} else {
|
||||
|
||||
@@ -14,19 +14,15 @@
|
||||
|
||||
package androidx.ui.examples.jetissues.view
|
||||
|
||||
import androidx.compose.foundation.Box
|
||||
import androidx.compose.foundation.ContentGravity
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.ScrollableColumn
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import androidx.compose.ui.layout.WithConstraints
|
||||
@@ -109,7 +105,7 @@ fun SingleColumnLayout(currentIssue: MutableState<IssuesQuery.Node?>) {
|
||||
@Composable
|
||||
fun TwoColumnsLayout(currentIssue: MutableState<IssuesQuery.Node?>) {
|
||||
Row(Modifier.fillMaxSize()) {
|
||||
Box(modifier = Modifier.fillMaxWidth(0.4f), alignment = Alignment.Center) {
|
||||
Box(modifier = Modifier.fillMaxWidth(0.4f), contentAlignment = Alignment.Center) {
|
||||
IssuesList(currentIssue)
|
||||
}
|
||||
CurrentIssue(currentIssue.value)
|
||||
@@ -138,7 +134,7 @@ fun CurrentIssue(
|
||||
|
||||
@Composable
|
||||
fun CurrentIssueStatus(content: @Composable () -> Unit) {
|
||||
Box(modifier = Modifier.fillMaxSize(), gravity = ContentGravity.Center) {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
@@ -218,6 +214,7 @@ fun OrderButton(order: MutableState<OrderDirection>, scroll: ScrollState) {
|
||||
}) {
|
||||
Text("DESC")
|
||||
}
|
||||
else -> Error("Unknown direction")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +254,7 @@ fun ListBody(
|
||||
for (iss in it.data.nodes) {
|
||||
Box(modifier = Modifier.clickable {
|
||||
currentIssue.value = iss
|
||||
}, alignment = Alignment.CenterStart) {
|
||||
}, contentAlignment = Alignment.CenterStart) {
|
||||
ListItem(iss)
|
||||
}
|
||||
}
|
||||
@@ -342,7 +339,7 @@ fun MoreButton(issues: MutableState<UiState<Issues>>) {
|
||||
|
||||
var loading by remember { mutableStateOf(false) }
|
||||
Box(
|
||||
gravity = ContentGravity.Center,
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.fillMaxWidth().padding(10.dp)
|
||||
) {
|
||||
if (loading) {
|
||||
@@ -373,9 +370,10 @@ fun Labels(labels: IssuesQuery.Labels?) {
|
||||
val color = parseColor(it.color)
|
||||
val textColor = if (color.luminance() > 0.5) Color.Black else Color.White
|
||||
Box(
|
||||
shape = RoundedCornerShape(3.dp),
|
||||
modifier = Modifier.padding(3.dp),
|
||||
backgroundColor = color
|
||||
modifier = Modifier
|
||||
.padding(3.dp)
|
||||
.background(color = color)
|
||||
.clip(shape = RoundedCornerShape(3.dp))
|
||||
) {
|
||||
Text(
|
||||
text = it.name,
|
||||
@@ -390,7 +388,7 @@ fun Labels(labels: IssuesQuery.Labels?) {
|
||||
@Composable
|
||||
fun Loader() {
|
||||
Box(
|
||||
gravity = ContentGravity.Center,
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.fillMaxWidth().padding(20.dp)
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
@@ -400,7 +398,7 @@ fun Loader() {
|
||||
@Composable
|
||||
fun Error(err: String) {
|
||||
Box(
|
||||
gravity = ContentGravity.Center,
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.fillMaxWidth().padding(20.dp)
|
||||
) {
|
||||
Text(text = err, style = TextStyle(color = MaterialTheme.colors.error, fontWeight = FontWeight.Bold))
|
||||
|
||||
@@ -2,7 +2,8 @@ object Deps {
|
||||
|
||||
object JetBrains {
|
||||
object Kotlin {
|
||||
private const val VERSION = "1.4.0"
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
private const val VERSION = "1.4.20"
|
||||
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$VERSION"
|
||||
const val testCommon = "org.jetbrains.kotlin:kotlin-test-common:$VERSION"
|
||||
const val testJunit = "org.jetbrains.kotlin:kotlin-test-junit:$VERSION"
|
||||
@@ -11,7 +12,7 @@ object Deps {
|
||||
|
||||
object Compose {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
private const val VERSION = "0.1.0-build113"
|
||||
private const val VERSION = "0.2.0-build128"
|
||||
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import com.gradle.publish.PluginBundleExtension
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4.0" apply false
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("jvm") version "1.4.20" apply false
|
||||
id("com.gradle.plugin-publish") version "0.10.1" apply false
|
||||
id("de.fuerstenau.buildconfig") version "1.1.8" apply false
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ kotlin.code.style=official
|
||||
# unless overridden by COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION env var.
|
||||
#
|
||||
# __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
compose.version=0.1.0-build113
|
||||
compose.version=0.2.0-build128
|
||||
|
||||
# A version of Gradle plugin, that will be published,
|
||||
# unless overridden by COMPOSE_GRADLE_PLUGIN_VERSION env var.
|
||||
deploy.version=0.1.0-SNAPSHOT
|
||||
deploy.version=0.1.0-SNAPSHOT
|
||||
|
||||
@@ -2,9 +2,10 @@ import org.jetbrains.compose.compose
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4.0"
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("jvm") version "1.4.20"
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.1.0-build113")
|
||||
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.2.0-build128")
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -19,9 +19,11 @@ function mavenDep {
|
||||
}
|
||||
|
||||
PLATFORM=macos
|
||||
SKIKO_VERSION=0.1.10
|
||||
KOTLIN_VERSION=1.4.0
|
||||
COMPOSE_VERSION=0.1.0-m1-build57
|
||||
SKIKO_VERSION=0.1.16
|
||||
# __KOTLIN_COMPOSE_VERSION__
|
||||
KOTLIN_VERSION=1.4.20
|
||||
# __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
COMPOSE_VERSION=0.2.0-build128
|
||||
COROUTINES_VERSION=1.3.6
|
||||
COLLECTIONS_VERSION=0.3
|
||||
SPACE_REPO="https://packages.jetbrains.team/maven/p/ui/dev"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
buildscript {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.1.0-build113"
|
||||
val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.2.0-build128"
|
||||
|
||||
repositories {
|
||||
// TODO: remove after new build is published
|
||||
@@ -13,7 +13,8 @@ buildscript {
|
||||
dependencies {
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion")
|
||||
classpath("com.android.tools.build:gradle:4.0.1")
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.0"))
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.20"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user