Skip to content

Commit

Permalink
Merge pull request #195 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.1.0-dev-18
  • Loading branch information
Alex009 authored Mar 19, 2020
2 parents 1304bf1 + 5365036 commit 897a299
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a Kotlin MultiPlatform library that provides declarative UI and applicat
in common code. You can implement full application for Android and iOS only from common code with it.

## Current status
Current version - `0.1.0-dev-17`. Dev version is not tested in production tasks yet, API can be changed and
Current version - `0.1.0-dev-18`. Dev version is not tested in production tasks yet, API can be changed and
bugs may be found. But dev version is chance to test limits of API and concepts to feedback and improve lib.
We open for any feedback and ideas (go to issues or #moko at [kotlinlang.slack.com](https://kotlinlang.slack.com))!

Expand Down Expand Up @@ -226,6 +226,7 @@ val loginScreen = Theme(baseTheme) {
- kotlin 1.3.70
- 0.1.0-dev-16
- 0.1.0-dev-17
- 0.1.0-dev-18

## Installation
root build.gradle
Expand All @@ -240,7 +241,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-17")
commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-18")
}
```

Expand All @@ -253,7 +254,7 @@ buildscript {
}
dependencies {
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-17"
classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-18"
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Versions {
}

const val kotlin = "1.3.70"
private const val mokoWidgets = "0.1.0-dev-17"
private const val mokoWidgets = "0.1.0-dev-18"
private const val mokoResources = "0.9.0"

object Plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ actual abstract class Image {
return ResourceImage(imageResource)
}

actual fun network(url: String): Image {
return NetworkImage(url)
actual fun network(url: String, placeholder: ImageResource?): Image {
return NetworkImage(url, placeholder)
}

actual fun bitmap(bitmap: Bitmap): Image {
Expand All @@ -35,11 +35,18 @@ private class ResourceImage(val imageResource: ImageResource) : Image() {
}
}

private class NetworkImage(val url: String) : Image() {
private class NetworkImage(val url: String, val placeholder: ImageResource?) : Image() {
override fun loadIn(imageView: ImageView) {

Glide.with(imageView)
.load(Uri.parse(url))
.apply {
if(placeholder != null) {
placeholder(placeholder.drawableResId)
}
}
.into(imageView)

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ actual class WebViewFactory actual constructor(
val root = WebView(context).apply {
applyBackgroundIfNeeded(this@WebViewFactory.background)
settings.javaScriptEnabled = widget.isJavaScriptEnabled
settings.domStorageEnabled = widget.androidIsDomStorageEnabled

webViewClient = CustomWebViewClient(
successRedirectConfig = widget.successRedirectConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WebViewWidget<WS : WidgetSize>(
override val id: Id?,
val targetUrl: String,
val isJavaScriptEnabled: Boolean = true,
val androidIsDomStorageEnabled: Boolean = true,
val isWebPageLoading: MutableLiveData<Boolean>? = null,
val successRedirectConfig: WebViewWidget.RedirectConfig? = null,
val failureRedirectConfig: WebViewWidget.RedirectConfig? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ expect abstract class Image {

companion object {
fun resource(imageResource: ImageResource): Image
fun network(url: String): Image
fun network(url: String, placeholder: ImageResource? = null): Image
fun bitmap(bitmap: Bitmap): Image
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ actual abstract class Image {
return ResourceImage(imageResource)
}

actual fun network(url: String): Image {
return NetworkImage(url)
actual fun network(url: String, placeholder: ImageResource?): Image {
return NetworkImage(url, placeholder)
}

actual fun bitmap(bitmap: Bitmap): Image {
Expand Down Expand Up @@ -51,10 +51,11 @@ class BitmapImage(

// TODO add https://github.com/SDWebImage/SDWebImage to cache images
class NetworkImage(
private val url: String
private val url: String,
private val placeholder: ImageResource?
) : Image() {
override fun apply(view: UIView, block: (UIImage?) -> Unit) {
block(null)
block(placeholder?.toUIImage())

try {
val tag = url.hashCode().toLong()
Expand Down

0 comments on commit 897a299

Please sign in to comment.