Skip to content

Commit

Permalink
Merge pull request #4 from maribelmai/update_dev17
Browse files Browse the repository at this point in the history
Update to be compatible with Compose dev17
  • Loading branch information
mvarnagiris authored Aug 20, 2020
2 parents 5f74d9a + 5193ed9 commit b129595
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = "1.3.72"
ext.kotlin_version = "1.4.0"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0-alpha10'
classpath 'com.android.tools.build:gradle:4.2.0-alpha07'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
23 changes: 14 additions & 9 deletions compose-glide-image/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
compileSdkVersion 30

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -36,19 +36,24 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion "0.1.0-dev12"
kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
kotlinCompilerExtensionVersion "0.1.0-dev17"
kotlinCompilerVersion "1.4.0"
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
}
}

dependencies {
def compose_version = '0.1.0-dev12'
def coroutines_version = "1.3.6"
def compose_version = '0.1.0-dev17'
def coroutines_version = "1.3.9"

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.compose:compose-runtime:$compose_version"
implementation "androidx.ui:ui-core:$compose_version"
implementation "androidx.ui:ui-foundation:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
api 'com.github.bumptech.glide:glide:4.11.0'

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ package com.koduok.compose.glideimage

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import androidx.compose.Composable
import androidx.compose.FrameManager
import androidx.compose.onPreCommit
import androidx.compose.state
import androidx.ui.core.ContextAmbient
import androidx.ui.core.Modifier
import androidx.ui.core.WithConstraints
import androidx.ui.foundation.Canvas
import androidx.ui.foundation.Image
import androidx.ui.graphics.ImageAsset
import androidx.ui.graphics.asImageAsset
import androidx.ui.graphics.drawscope.drawCanvas
import androidx.ui.layout.fillMaxSize
import androidx.ui.unit.IntPx
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.WithConstraints
import androidx.compose.ui.graphics.ImageAsset
import androidx.compose.ui.graphics.asImageAsset
import androidx.compose.ui.graphics.drawscope.drawCanvas
import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.platform.ContextAmbient
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.request.target.CustomTarget
Expand All @@ -32,8 +29,8 @@ fun GlideImage(
customize: RequestBuilder<Bitmap>.() -> RequestBuilder<Bitmap> = { this }
) {
WithConstraints {
val image = state<ImageAsset?> { null }
val drawable = state<Drawable?> { null }
val image = stateFor <ImageAsset?> (null) { null }
val drawable = stateFor<Drawable?> (null) { null }
val context = ContextAmbient.current

onPreCommit(model) {
Expand All @@ -47,23 +44,22 @@ fun GlideImage(
}

override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
FrameManager.framed {
image.value = resource.asImageAsset()
onImageReady?.invoke()
}
FrameManager.ensureStarted()
image.value = resource.asImageAsset()
onImageReady?.invoke()
}
}

val width =
if (constraints.maxWidth > IntPx.Zero && constraints.maxWidth < IntPx.Infinity) {
constraints.maxWidth.value
if (constraints.maxWidth > 0 && constraints.maxWidth < Int.MAX_VALUE) {
constraints.maxWidth
} else {
SIZE_ORIGINAL
}

val height =
if (constraints.maxHeight > IntPx.Zero && constraints.maxHeight < IntPx.Infinity) {
constraints.maxHeight.value
if (constraints.maxHeight > 0 && constraints.maxHeight < Int.MAX_VALUE) {
constraints.maxHeight
} else {
SIZE_ORIGINAL
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-milestone-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

0 comments on commit b129595

Please sign in to comment.