expo-image 0.2.2 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +13 -15
- package/android/build.gradle +8 -3
- package/android/proguard-rules.pro +6 -1
- package/android/src/main/java/expo/modules/image/Exceptions.kt +9 -0
- package/android/src/main/java/expo/modules/image/ExpoImageAppGlideModule.kt +9 -1
- package/android/src/main/java/expo/modules/image/ExpoImageModule.kt +157 -41
- package/android/src/main/java/expo/modules/image/ExpoImageView.kt +287 -104
- package/android/src/main/java/expo/modules/image/GlideModel.kt +58 -0
- package/android/src/main/java/expo/modules/image/ImageUtils.kt +37 -21
- package/android/src/main/java/expo/modules/image/ThumbnailRequestCoordinatorExtension.kt +18 -0
- package/android/src/main/java/expo/modules/image/ViewConnectedTarget.kt +170 -0
- package/android/src/main/java/expo/modules/image/YogaUtils.kt +0 -2
- package/android/src/main/java/expo/modules/image/blurhash/BlurHashFetcher.kt +32 -0
- package/android/src/main/java/expo/modules/image/blurhash/BlurhashDecoder.kt +189 -0
- package/android/src/main/java/expo/modules/image/blurhash/BlurhashModelLoader.kt +30 -0
- package/android/src/main/java/expo/modules/image/blurhash/BlurhashModelLoaderFactory.kt +14 -0
- package/android/src/main/java/expo/modules/image/blurhash/BlurhashModule.kt +17 -0
- package/android/src/main/java/expo/modules/image/dataurls/Base64DataFetcher.kt +27 -0
- package/android/src/main/java/expo/modules/image/dataurls/Base64ModelLoader.kt +24 -0
- package/android/src/main/java/expo/modules/image/dataurls/Base64ModelLoaderFactory.kt +12 -0
- package/android/src/main/java/expo/modules/image/{decoding/InputStreamBitmapOptionsDecoderGlideModule.kt → dataurls/Base64Module.kt} +5 -5
- package/android/src/main/java/expo/modules/image/drawing/OutlineProvider.kt +16 -14
- package/android/src/main/java/expo/modules/image/enums/ContentFit.kt +69 -0
- package/android/src/main/java/expo/modules/image/enums/ImageCacheType.kt +5 -11
- package/android/src/main/java/expo/modules/image/enums/ImageResizeMode.kt +13 -11
- package/android/src/main/java/expo/modules/image/enums/Priority.kt +15 -0
- package/android/src/main/java/expo/modules/image/events/GlideRequestListener.kt +64 -0
- package/android/src/main/java/expo/modules/image/events/OkHttpProgressListener.kt +26 -0
- package/android/src/main/java/expo/modules/image/okhttp/ExpoImageOkHttpClientGlideModule.kt +2 -1
- package/android/src/main/java/expo/modules/image/okhttp/OkHttpClientProgressInterceptor.kt +9 -7
- package/android/src/main/java/expo/modules/image/records/CachePolicy.kt +10 -0
- package/android/src/main/java/expo/modules/image/records/ContentPosition.kt +89 -0
- package/android/src/main/java/expo/modules/image/records/SourceMap.kt +143 -0
- package/android/src/main/java/expo/modules/image/records/events.kt +25 -0
- package/android/src/main/java/expo/modules/image/svg/SVGDecoder.kt +2 -2
- package/build/ExpoImage.d.ts +12 -2
- package/build/ExpoImage.d.ts.map +1 -1
- package/build/ExpoImage.js +71 -53
- package/build/ExpoImage.js.map +1 -1
- package/build/ExpoImage.web.d.ts +2 -2
- package/build/ExpoImage.web.d.ts.map +1 -1
- package/build/ExpoImage.web.js +139 -5
- package/build/ExpoImage.web.js.map +1 -1
- package/build/Image.d.ts +16 -37
- package/build/Image.d.ts.map +1 -1
- package/build/Image.js +33 -38
- package/build/Image.js.map +1 -1
- package/build/Image.types.d.ts +265 -31
- package/build/Image.types.d.ts.map +1 -1
- package/build/Image.types.js +99 -4
- package/build/Image.types.js.map +1 -1
- package/build/index.d.ts +1 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -2
- package/build/index.js.map +1 -1
- package/build/utils/resolveAssetSource.d.ts +3 -0
- package/build/utils/resolveAssetSource.d.ts.map +1 -0
- package/build/utils/resolveAssetSource.js +3 -0
- package/build/utils/resolveAssetSource.js.map +1 -0
- package/build/utils/resolveAssetSource.web.d.ts +2 -0
- package/build/utils/resolveAssetSource.web.d.ts.map +1 -0
- package/build/utils/resolveAssetSource.web.js +5 -0
- package/build/utils/resolveAssetSource.web.js.map +1 -0
- package/build/utils/resolveSources.d.ts +6 -0
- package/build/utils/resolveSources.d.ts.map +1 -0
- package/build/utils/resolveSources.js +45 -0
- package/build/utils/resolveSources.js.map +1 -0
- package/build/utils.d.ts +17 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +87 -0
- package/build/utils.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/Blurhash.swift +326 -0
- package/ios/BlurhashLoader.swift +57 -0
- package/ios/ContentFit.swift +55 -0
- package/ios/ContentPosition.swift +108 -0
- package/ios/ExpoImage.podspec +30 -0
- package/ios/ImageCachePolicy.swift +24 -0
- package/ios/ImageCacheType.swift +24 -0
- package/ios/ImageModule.swift +99 -0
- package/ios/ImagePriority.swift +22 -0
- package/ios/ImageSource.swift +28 -0
- package/ios/ImageTransition.swift +73 -0
- package/ios/ImageUtils.swift +175 -0
- package/ios/ImageView.swift +357 -0
- package/package.json +3 -3
- package/src/ExpoImage.tsx +104 -81
- package/src/ExpoImage.web.tsx +204 -6
- package/src/Image.tsx +51 -80
- package/src/Image.types.ts +307 -32
- package/src/index.ts +1 -2
- package/src/utils/resolveAssetSource.tsx +3 -0
- package/src/utils/resolveAssetSource.web.tsx +4 -0
- package/src/utils/resolveSources.tsx +50 -0
- package/src/utils.ts +111 -0
- package/tsconfig.json +1 -1
- package/EXImage.podspec +0 -43
- package/android/src/main/java/expo/modules/image/ExpoImagePackage.kt +0 -13
- package/android/src/main/java/expo/modules/image/ExpoImageViewManager.kt +0 -147
- package/android/src/main/java/expo/modules/image/decoding/InputStreamBitmapFactoryOptionsDecoder.kt +0 -20
- package/android/src/main/java/expo/modules/image/drawing/BorderDrawable.kt +0 -1072
- package/android/src/main/java/expo/modules/image/events/ImageErrorEvent.kt +0 -56
- package/android/src/main/java/expo/modules/image/events/ImageLoadEvent.kt +0 -34
- package/android/src/main/java/expo/modules/image/events/ImageLoadEventsManager.kt +0 -57
- package/android/src/main/java/expo/modules/image/events/ImageLoadStartEvent.kt +0 -17
- package/android/src/main/java/expo/modules/image/events/ImageProgressEvent.kt +0 -21
- package/ios/AutolinkingPlaceholder.xcodeproj +0 -0
- package/ios/EXImageBorders.h +0 -49
- package/ios/EXImageBorders.m +0 -368
- package/ios/EXImageCornerRadii.h +0 -32
- package/ios/EXImageCornerRadii.m +0 -159
- package/ios/EXImageCustomCoders.h +0 -12
- package/ios/EXImageCustomCoders.m +0 -57
- package/ios/EXImageTypes.h +0 -20
- package/ios/EXImageTypes.m +0 -68
- package/ios/EXImageView.h +0 -79
- package/ios/EXImageView.m +0 -368
- package/ios/EXImageViewManager.h +0 -7
- package/ios/EXImageViewManager.m +0 -37
- package/react-native.config.js +0 -1
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
# expo-image
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 🚨 This module is experimental, incomplete, and we advise against using it in production its current state.
|
|
4
|
+
|
|
5
|
+
A cross-platform, performant image component for React Native and Expo with Web support.
|
|
4
6
|
|
|
5
7
|
# API documentation
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/image/)
|
|
9
|
+
The documentation is not available yet, but most of the public APIs already have TSDoc comments.
|
|
9
10
|
|
|
10
11
|
# Installation in managed Expo projects
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
`expo-image` is not available for managed workflow yet.
|
|
13
14
|
|
|
14
15
|
# Installation in bare React Native projects
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
npm install expo-image
|
|
20
|
-
```
|
|
17
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
> 🚨 Expo Image is compatible only with Expo SDK47+
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
Add the package to your dependencies with the following commands:
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
```
|
|
24
|
+
expo install expo-camera
|
|
25
|
+
npx pod-install
|
|
26
|
+
```
|
|
29
27
|
|
|
30
28
|
# Contributing
|
|
31
29
|
|
|
32
|
-
Contributions are
|
|
30
|
+
Contributions are not encouraged at this time.
|
package/android/build.gradle
CHANGED
|
@@ -55,7 +55,7 @@ android {
|
|
|
55
55
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
56
56
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
57
57
|
versionCode 1
|
|
58
|
-
versionName "0.
|
|
58
|
+
versionName "1.0.0-alpha.1"
|
|
59
59
|
}
|
|
60
60
|
lintOptions {
|
|
61
61
|
abortOnError false
|
|
@@ -88,16 +88,21 @@ repositories {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
dependencies {
|
|
91
|
-
def GLIDE_VERSION = "4.
|
|
91
|
+
def GLIDE_VERSION = "4.13.2"
|
|
92
|
+
|
|
93
|
+
implementation project(':expo-modules-core')
|
|
92
94
|
|
|
93
95
|
//noinspection GradleDynamicVersion
|
|
94
96
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
95
97
|
|
|
96
|
-
implementation "com.github.zjupure:webpdecoder:2.
|
|
98
|
+
implementation "com.github.zjupure:webpdecoder:2.1.${GLIDE_VERSION}"
|
|
97
99
|
api "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
|
98
100
|
kapt "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
|
|
99
101
|
api 'com.caverock:androidsvg-aar:1.4'
|
|
100
102
|
|
|
103
|
+
implementation "com.github.penfeizhou.android.animation:glide-plugin:2.24.0"
|
|
104
|
+
implementation "com.github.bumptech.glide:avif-integration:${GLIDE_VERSION}"
|
|
105
|
+
|
|
101
106
|
api 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
|
|
102
107
|
api "com.squareup.okhttp3:okhttp:${safeExtGet("okHttpVersion", '4.9.2')}"
|
|
103
108
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# https://bumptech.github.io/glide/doc/download-setup.html#proguard
|
|
2
2
|
|
|
3
|
+
-keep public class * implements com.bumptech.glide.module.LibraryGlideModule
|
|
3
4
|
-keep public class * implements com.bumptech.glide.module.GlideModule
|
|
4
5
|
-keep public class * extends com.bumptech.glide.module.AppGlideModule
|
|
5
6
|
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
|
|
@@ -17,4 +18,8 @@
|
|
|
17
18
|
|
|
18
19
|
-keep public class com.bumptech.glide.integration.webp.WebpImage { *; }
|
|
19
20
|
-keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }
|
|
20
|
-
-keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }
|
|
21
|
+
-keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }
|
|
22
|
+
|
|
23
|
+
-keep public class com.bumptech.glide.requestThumbnailRequestCoordinator {
|
|
24
|
+
*;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package expo.modules.image
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.exception.CodedException
|
|
4
|
+
|
|
5
|
+
class ImagePrefetchFailure(message: String) :
|
|
6
|
+
CodedException(message = "Failed to prefetch the image: $message")
|
|
7
|
+
|
|
8
|
+
class MissingActivity :
|
|
9
|
+
CodedException(message = "The current activity is no longer available")
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
package expo.modules.image
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import com.bumptech.glide.GlideBuilder
|
|
3
6
|
import com.bumptech.glide.annotation.GlideModule
|
|
4
7
|
import com.bumptech.glide.module.AppGlideModule
|
|
5
8
|
|
|
@@ -8,4 +11,9 @@ import com.bumptech.glide.module.AppGlideModule
|
|
|
8
11
|
* to work.
|
|
9
12
|
*/
|
|
10
13
|
@GlideModule
|
|
11
|
-
class ExpoImageAppGlideModule : AppGlideModule()
|
|
14
|
+
class ExpoImageAppGlideModule : AppGlideModule() {
|
|
15
|
+
override fun applyOptions(context: Context, builder: GlideBuilder) {
|
|
16
|
+
super.applyOptions(context, builder)
|
|
17
|
+
builder.setLogLevel(Log.ERROR)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,52 +1,168 @@
|
|
|
1
1
|
package expo.modules.image
|
|
2
2
|
|
|
3
|
-
import android.
|
|
3
|
+
import android.view.View
|
|
4
4
|
import com.bumptech.glide.Glide
|
|
5
5
|
import com.bumptech.glide.load.model.GlideUrl
|
|
6
|
-
import com.facebook.react.
|
|
7
|
-
import com.facebook.react.
|
|
8
|
-
import com.facebook.react.
|
|
9
|
-
import com.facebook.
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (result != null) {
|
|
32
|
-
promise.resolve(null)
|
|
33
|
-
} else {
|
|
34
|
-
promise.reject("ERR_IMAGE_PREFETCH_FAILURE", "Failed to prefetch the image: ${url}.")
|
|
35
|
-
}
|
|
36
|
-
} catch (e: Exception) {
|
|
37
|
-
promise.reject("ERR_IMAGE_PREFETCH_FAILURE", "Failed to prefetch the image: ${e.message}", e)
|
|
6
|
+
import com.facebook.react.uimanager.PixelUtil
|
|
7
|
+
import com.facebook.react.uimanager.Spacing
|
|
8
|
+
import com.facebook.react.uimanager.ViewProps
|
|
9
|
+
import com.facebook.yoga.YogaConstants
|
|
10
|
+
import expo.modules.image.enums.ContentFit
|
|
11
|
+
import expo.modules.image.enums.Priority
|
|
12
|
+
import expo.modules.image.records.CachePolicy
|
|
13
|
+
import expo.modules.image.records.ContentPosition
|
|
14
|
+
import expo.modules.image.records.SourceMap
|
|
15
|
+
import expo.modules.kotlin.functions.Queues
|
|
16
|
+
import expo.modules.kotlin.modules.Module
|
|
17
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
18
|
+
import expo.modules.kotlin.views.ViewDefinitionBuilder
|
|
19
|
+
|
|
20
|
+
class ExpoImageModule : Module() {
|
|
21
|
+
override fun definition() = ModuleDefinition {
|
|
22
|
+
Name("ExpoImage")
|
|
23
|
+
|
|
24
|
+
Function("prefetch") { urls: List<String> ->
|
|
25
|
+
val context = appContext.reactContext ?: return@Function
|
|
26
|
+
urls.forEach {
|
|
27
|
+
Glide
|
|
28
|
+
.with(context)
|
|
29
|
+
.download(GlideUrl(it))
|
|
30
|
+
.submit()
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
}
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
34
|
+
AsyncFunction("clearMemoryCache") {
|
|
35
|
+
val activity = appContext.currentActivity ?: return@AsyncFunction false
|
|
36
|
+
Glide.get(activity).clearMemory()
|
|
37
|
+
return@AsyncFunction true
|
|
38
|
+
}.runOnQueue(Queues.MAIN)
|
|
39
|
+
|
|
40
|
+
AsyncFunction("clearDiskCache") {
|
|
41
|
+
val activity = appContext.currentActivity ?: return@AsyncFunction false
|
|
42
|
+
activity.let {
|
|
43
|
+
Glide.get(activity).clearDiskCache()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return@AsyncFunction true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
View(ExpoImageViewWrapper::class) {
|
|
50
|
+
Events(
|
|
51
|
+
"onLoadStart",
|
|
52
|
+
"onProgress",
|
|
53
|
+
"onError",
|
|
54
|
+
"onLoad"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
Prop("source") { view: ExpoImageViewWrapper, sources: List<SourceMap>? ->
|
|
58
|
+
view.imageView.sources = sources ?: emptyList()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Prop("contentFit") { view: ExpoImageViewWrapper, contentFit: ContentFit? ->
|
|
62
|
+
view.imageView.contentFit = contentFit ?: ContentFit.Cover
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Prop("contentPosition") { view: ExpoImageViewWrapper, contentPosition: ContentPosition? ->
|
|
66
|
+
view.imageView.contentPosition = contentPosition ?: ContentPosition.center
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Prop("blurRadius") { view: ExpoImageViewWrapper, blurRadius: Int ->
|
|
70
|
+
view.imageView.blurRadius = blurRadius
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Prop("fadeDuration") { view: ExpoImageViewWrapper, fadeDuration: Int ->
|
|
74
|
+
view.imageView.fadeDuration = fadeDuration
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
PropGroup(
|
|
78
|
+
ViewProps.BORDER_RADIUS to 0,
|
|
79
|
+
ViewProps.BORDER_TOP_LEFT_RADIUS to 1,
|
|
80
|
+
ViewProps.BORDER_TOP_RIGHT_RADIUS to 2,
|
|
81
|
+
ViewProps.BORDER_BOTTOM_RIGHT_RADIUS to 3,
|
|
82
|
+
ViewProps.BORDER_BOTTOM_LEFT_RADIUS to 4,
|
|
83
|
+
ViewProps.BORDER_TOP_START_RADIUS to 5,
|
|
84
|
+
ViewProps.BORDER_TOP_END_RADIUS to 6,
|
|
85
|
+
ViewProps.BORDER_BOTTOM_START_RADIUS to 7,
|
|
86
|
+
ViewProps.BORDER_BOTTOM_END_RADIUS to 8
|
|
87
|
+
) { view: ExpoImageViewWrapper, index: Int, borderRadius: Float? ->
|
|
88
|
+
val radius = makeYogaUndefinedIfNegative(borderRadius ?: YogaConstants.UNDEFINED)
|
|
89
|
+
view.imageView.setBorderRadius(index, radius)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
PropGroup(
|
|
93
|
+
ViewProps.BORDER_WIDTH to Spacing.ALL,
|
|
94
|
+
ViewProps.BORDER_LEFT_WIDTH to Spacing.LEFT,
|
|
95
|
+
ViewProps.BORDER_RIGHT_WIDTH to Spacing.RIGHT,
|
|
96
|
+
ViewProps.BORDER_TOP_WIDTH to Spacing.TOP,
|
|
97
|
+
ViewProps.BORDER_BOTTOM_WIDTH to Spacing.BOTTOM,
|
|
98
|
+
ViewProps.BORDER_START_WIDTH to Spacing.START,
|
|
99
|
+
ViewProps.BORDER_END_WIDTH to Spacing.END
|
|
100
|
+
) { view: ExpoImageViewWrapper, index: Int, width: Float? ->
|
|
101
|
+
val pixelWidth = makeYogaUndefinedIfNegative(width ?: YogaConstants.UNDEFINED)
|
|
102
|
+
.ifYogaDefinedUse(PixelUtil::toPixelFromDIP)
|
|
103
|
+
view.imageView.setBorderWidth(index, pixelWidth)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
PropGroup(
|
|
107
|
+
ViewProps.BORDER_COLOR to Spacing.ALL,
|
|
108
|
+
ViewProps.BORDER_LEFT_COLOR to Spacing.LEFT,
|
|
109
|
+
ViewProps.BORDER_RIGHT_COLOR to Spacing.RIGHT,
|
|
110
|
+
ViewProps.BORDER_TOP_COLOR to Spacing.TOP,
|
|
111
|
+
ViewProps.BORDER_BOTTOM_COLOR to Spacing.BOTTOM,
|
|
112
|
+
ViewProps.BORDER_START_COLOR to Spacing.START,
|
|
113
|
+
ViewProps.BORDER_END_COLOR to Spacing.END
|
|
114
|
+
) { view: ExpoImageViewWrapper, index: Int, color: Int? ->
|
|
115
|
+
val rgbComponent = if (color == null) YogaConstants.UNDEFINED else (color and 0x00FFFFFF).toFloat()
|
|
116
|
+
val alphaComponent = if (color == null) YogaConstants.UNDEFINED else (color ushr 24).toFloat()
|
|
117
|
+
view.imageView.setBorderColor(index, rgbComponent, alphaComponent)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Prop("borderStyle") { view: ExpoImageViewWrapper, borderStyle: String? ->
|
|
121
|
+
view.imageView.setBorderStyle(borderStyle)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Prop("backgroundColor") { view: ExpoImageViewWrapper, color: Int? ->
|
|
125
|
+
view.imageView.setBackgroundColor(color)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
Prop("tintColor") { view: ExpoImageViewWrapper, color: Int? ->
|
|
129
|
+
view.imageView.setTintColor(color)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
Prop("placeholder") { view: ExpoImageViewWrapper, placeholder: List<SourceMap>? ->
|
|
133
|
+
view.imageView.placeholders = placeholder ?: emptyList()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
Prop("accessible") { view: ExpoImageViewWrapper, accessible: Boolean ->
|
|
137
|
+
view.imageView.isFocusable = accessible
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
Prop("priority") { view: ExpoImageViewWrapper, priority: Priority? ->
|
|
141
|
+
view.imageView.priority = priority ?: Priority.NORMAL
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
Prop("cachePolicy") { view: ExpoImageViewWrapper, cachePolicy: CachePolicy? ->
|
|
145
|
+
view.imageView.cachePolicy = cachePolicy ?: CachePolicy.DISK
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
OnViewDidUpdateProps { view: ExpoImageViewWrapper ->
|
|
149
|
+
view.imageView.onAfterUpdateTransaction()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
OnViewDestroys { view: ExpoImageViewWrapper ->
|
|
153
|
+
view.imageView.onDrop()
|
|
154
|
+
}
|
|
48
155
|
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
49
158
|
|
|
50
|
-
|
|
159
|
+
// TODO(@lukmccall): Remove when the same functionality will be defined by the expo-modules-core in SDK 48
|
|
160
|
+
@Suppress("FunctionName")
|
|
161
|
+
private inline fun <reified T : View, reified PropType, reified CustomValueType> ViewDefinitionBuilder<T>.PropGroup(
|
|
162
|
+
vararg props: Pair<String, CustomValueType>,
|
|
163
|
+
noinline body: (view: T, value: CustomValueType, prop: PropType) -> Unit
|
|
164
|
+
) {
|
|
165
|
+
for ((name, value) in props) {
|
|
166
|
+
Prop<T, PropType>(name) { view, prop -> body(view, value, prop) }
|
|
51
167
|
}
|
|
52
168
|
}
|