Skip to content

Commit 0510267

Browse files
oprisnikfacebook-github-bot
authored andcommitted
Added basic Vito Compose image component
Reviewed By: kartavya-ramnani Differential Revision: D64615504 fbshipit-source-id: e02fd80235299f14a32e5fd923a53b3a7750b91a
1 parent 5a56467 commit 0510267

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ include ':vito:core'
4848
include ':vito:core-common-impl'
4949
include ':vito:core-impl'
5050
include ':vito:core-java-impl'
51+
include ':vito:compose'
5152
include ':vito:drawee-support'
5253
include ':vito:init'
5354
include ':vito:ktx'

vito/compose/build.gradle

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import com.facebook.fresco.buildsrc.Deps
9+
import com.facebook.fresco.buildsrc.GradleDeps
10+
11+
plugins {
12+
id 'com.android.library'
13+
id 'kotlin-android'
14+
id 'org.jetbrains.kotlin.plugin.compose' version "2.0.0" // Must match GradleDeps.Kotlin.version
15+
}
16+
17+
kotlin {
18+
jvmToolchain(11)
19+
}
20+
21+
android {
22+
ndkVersion GradleDeps.Native.version
23+
24+
buildToolsVersion FrescoConfig.buildToolsVersion
25+
compileSdkVersion FrescoConfig.compileSdkVersion
26+
27+
namespace "com.facebook.fresco.vito.compose"
28+
29+
defaultConfig {
30+
minSdkVersion FrescoConfig.minSdkVersion
31+
targetSdkVersion FrescoConfig.targetSdkVersion
32+
}
33+
34+
lintOptions {
35+
abortOnError false
36+
}
37+
38+
buildFeatures {
39+
compose true
40+
}
41+
}
42+
43+
dependencies {
44+
compileOnly Deps.inferAnnotation
45+
46+
implementation Deps.AndroidX.core
47+
48+
implementation project(':vito:core')
49+
implementation project(':vito:options')
50+
implementation project(':vito:provider')
51+
implementation project(':vito:source')
52+
implementation project(':vito:view')
53+
implementation project(':ui-common')
54+
55+
// Specify the Compose BOM with a version definition
56+
Dependency composeBom = platform('androidx.compose:compose-bom:2024.10.01')
57+
implementation composeBom
58+
testImplementation composeBom
59+
androidTestImplementation composeBom
60+
61+
// Specify Compose library dependencies without a version definition
62+
implementation 'androidx.compose.foundation:foundation'
63+
}
64+
65+
apply plugin: "com.vanniktech.maven.publish"

vito/compose/gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
POM_NAME=VitoCompose
2+
POM_DESCRIPTION=Fresco Vito Compose components
3+
POM_ARTIFACT_ID=vito-compose
4+
POM_PACKAGING=aar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.facebook.fresco.vito.compose" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.fresco.vito.compose
9+
10+
import android.widget.ImageView
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.viewinterop.AndroidView
14+
import com.facebook.fresco.vito.options.ImageOptions
15+
import com.facebook.fresco.vito.source.ImageSource
16+
import com.facebook.fresco.vito.view.VitoView
17+
18+
/** Fresco Image Composables */
19+
@Composable
20+
fun VitoImage(
21+
modifier: Modifier = Modifier,
22+
source: ImageSource,
23+
options: ImageOptions = ImageOptions.defaults(),
24+
callerContext: Any,
25+
) {
26+
AndroidView(
27+
modifier = modifier,
28+
factory = { ImageView(it) },
29+
update = {
30+
VitoView.show(
31+
imageSource = source,
32+
target = it,
33+
imageOptions = options,
34+
callerContext = callerContext,
35+
)
36+
},
37+
onRelease = { VitoView.release(it) },
38+
)
39+
}

0 commit comments

Comments
 (0)