This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +23
-12
lines changed
androidMain/kotlin/dev/icerock/moko/widgets
commonMain/kotlin/dev/icerock/moko/widgets
iosMain/kotlin/dev/icerock/moko/widgets/core Expand file tree Collapse file tree 7 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ This is a Kotlin MultiPlatform library that provides declarative UI and applicat
66 in common code. You can implement full application for Android and iOS only from common code with it.
77
88## Current status
9- Current version - ` 0.1.0-dev-17 ` . Dev version is not tested in production tasks yet, API can be changed and
9+ Current version - ` 0.1.0-dev-18 ` . Dev version is not tested in production tasks yet, API can be changed and
1010 bugs may be found. But dev version is chance to test limits of API and concepts to feedback and improve lib.
1111 We open for any feedback and ideas (go to issues or #moko at [ kotlinlang.slack.com] ( https://kotlinlang.slack.com ) )!
1212
@@ -226,6 +226,7 @@ val loginScreen = Theme(baseTheme) {
226226- kotlin 1.3.70
227227 - 0.1.0-dev-16
228228 - 0.1.0-dev-17
229+ - 0.1.0-dev-18
229230
230231## Installation
231232root build.gradle
@@ -240,7 +241,7 @@ allprojects {
240241project build.gradle
241242``` groovy
242243dependencies {
243- commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-17 ")
244+ commonMainApi("dev.icerock.moko:widgets:0.1.0-dev-18 ")
244245}
245246```
246247
@@ -253,7 +254,7 @@ buildscript {
253254 }
254255
255256 dependencies {
256- classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-17 "
257+ classpath "dev.icerock.moko.widgets:gradle-plugin:0.1.0-dev-18 "
257258 }
258259}
259260
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ object Versions {
1010 }
1111
1212 const val kotlin = " 1.3.70"
13- private const val mokoWidgets = " 0.1.0-dev-17 "
13+ private const val mokoWidgets = " 0.1.0-dev-18 "
1414 private const val mokoResources = " 0.9.0"
1515
1616 object Plugins {
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ actual abstract class Image {
1919 return ResourceImage (imageResource)
2020 }
2121
22- actual fun network (url : String ): Image {
23- return NetworkImage (url)
22+ actual fun network (url : String , placeholder : ImageResource ? ): Image {
23+ return NetworkImage (url, placeholder )
2424 }
2525
2626 actual fun bitmap (bitmap : Bitmap ): Image {
@@ -35,11 +35,18 @@ private class ResourceImage(val imageResource: ImageResource) : Image() {
3535 }
3636}
3737
38- private class NetworkImage (val url : String ) : Image() {
38+ private class NetworkImage (val url : String , val placeholder : ImageResource ? ) : Image() {
3939 override fun loadIn (imageView : ImageView ) {
40+
4041 Glide .with (imageView)
4142 .load(Uri .parse(url))
43+ .apply {
44+ if (placeholder != null ) {
45+ placeholder(placeholder.drawableResId)
46+ }
47+ }
4248 .into(imageView)
49+
4350 }
4451}
4552
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ actual class WebViewFactory actual constructor(
3838 val root = WebView (context).apply {
3939 applyBackgroundIfNeeded(this @WebViewFactory.background)
4040 settings.javaScriptEnabled = widget.isJavaScriptEnabled
41+ settings.domStorageEnabled = widget.androidIsDomStorageEnabled
4142
4243 webViewClient = CustomWebViewClient (
4344 successRedirectConfig = widget.successRedirectConfig,
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ class WebViewWidget<WS : WidgetSize>(
3030 override val id : Id ? ,
3131 val targetUrl : String ,
3232 val isJavaScriptEnabled : Boolean = true ,
33+ val androidIsDomStorageEnabled : Boolean = true ,
3334 val isWebPageLoading : MutableLiveData <Boolean >? = null ,
3435 val successRedirectConfig : WebViewWidget .RedirectConfig ? = null ,
3536 val failureRedirectConfig : WebViewWidget .RedirectConfig ? = null
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ expect abstract class Image {
1111
1212 companion object {
1313 fun resource (imageResource : ImageResource ): Image
14- fun network (url : String ): Image
14+ fun network (url : String , placeholder : ImageResource ? = null ): Image
1515 fun bitmap (bitmap : Bitmap ): Image
1616 }
1717}
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ actual abstract class Image {
2222 return ResourceImage (imageResource)
2323 }
2424
25- actual fun network (url : String ): Image {
26- return NetworkImage (url)
25+ actual fun network (url : String , placeholder : ImageResource ? ): Image {
26+ return NetworkImage (url, placeholder )
2727 }
2828
2929 actual fun bitmap (bitmap : Bitmap ): Image {
@@ -51,10 +51,11 @@ class BitmapImage(
5151
5252// TODO add https://github.com/SDWebImage/SDWebImage to cache images
5353class NetworkImage (
54- private val url : String
54+ private val url : String ,
55+ private val placeholder : ImageResource ?
5556) : Image() {
5657 override fun apply (view : UIView , block : (UIImage ? ) -> Unit ) {
57- block(null )
58+ block(placeholder?.toUIImage() )
5859
5960 try {
6061 val tag = url.hashCode().toLong()
You can’t perform that action at this time.
0 commit comments