@@ -174,4 +174,158 @@ void ImageProps::setProp(
174174 }
175175}
176176
177+ #ifdef ANDROID
178+
179+ static folly::dynamic convertImageSource (const ImageSource& imageSource) {
180+ folly::dynamic imageSourceResult = folly::dynamic::object ();
181+ switch (imageSource.type ) {
182+ case ImageSource::Type::Invalid:
183+ imageSourceResult[" type" ] = " invalid" ;
184+ break ;
185+ case ImageSource::Type::Remote:
186+ imageSourceResult[" type" ] = " remote" ;
187+ break ;
188+ case ImageSource::Type::Local:
189+ imageSourceResult[" type" ] = " local" ;
190+ break ;
191+ }
192+
193+ imageSourceResult[" uri" ] = imageSource.uri ;
194+ imageSourceResult[" bundle" ] = imageSource.bundle ;
195+ imageSourceResult[" scale" ] = imageSource.scale ;
196+
197+ folly::dynamic size = folly::dynamic::object ();
198+ size[" width" ] = imageSource.size .width ;
199+ size[" height" ] = imageSource.size .height ;
200+ imageSourceResult[" size" ] = size;
201+
202+ imageSourceResult[" body" ] = imageSource.body ;
203+ imageSourceResult[" method" ] = imageSource.method ;
204+
205+ switch (imageSource.cache ) {
206+ case ImageSource::CacheStategy::Default:
207+ imageSourceResult[" cache" ] = " default" ;
208+ break ;
209+ case ImageSource::CacheStategy::Reload:
210+ imageSourceResult[" cache" ] = " reload" ;
211+ break ;
212+ case ImageSource::CacheStategy::ForceCache:
213+ imageSourceResult[" cache" ] = " force-cache" ;
214+ break ;
215+ case ImageSource::CacheStategy::OnlyIfCached:
216+ imageSourceResult[" cache" ] = " only-if-cached" ;
217+ break ;
218+ }
219+
220+ folly::dynamic headersObject = folly::dynamic::object ();
221+ for (const auto & header : imageSource.headers ) {
222+ headersObject[header.first ] = header.second ;
223+ }
224+ imageSourceResult[" headers" ] = headersObject;
225+ return imageSourceResult;
226+ }
227+
228+ static folly::dynamic convertEdgeInsets (const EdgeInsets& edgeInsets) {
229+ folly::dynamic edgeInsetsResult = folly::dynamic::object ();
230+ edgeInsetsResult[" left" ] = edgeInsets.left ;
231+ edgeInsetsResult[" top" ] = edgeInsets.top ;
232+ edgeInsetsResult[" right" ] = edgeInsets.right ;
233+ edgeInsetsResult[" bottom" ] = edgeInsets.bottom ;
234+ return edgeInsetsResult;
235+ }
236+
237+ folly::dynamic ImageProps::getDiffProps (const Props* prevProps) const {
238+ static const auto defaultProps = ImageProps ();
239+
240+ const ImageProps* oldProps = prevProps == nullptr
241+ ? &defaultProps
242+ : static_cast <const ImageProps*>(prevProps);
243+
244+ folly::dynamic result = ViewProps::getDiffProps (oldProps);
245+
246+ if (sources != oldProps->sources ) {
247+ auto sourcesArray = folly::dynamic::array ();
248+ for (const auto & source : sources) {
249+ sourcesArray.push_back (convertImageSource (source));
250+ }
251+ result[" source" ] = sourcesArray;
252+ }
253+
254+ if (defaultSource != oldProps->defaultSource ) {
255+ result[" defaultSource" ] = convertImageSource (defaultSource);
256+ }
257+
258+ if (loadingIndicatorSource != oldProps->loadingIndicatorSource ) {
259+ result[" loadingIndicatorSource" ] =
260+ convertImageSource (loadingIndicatorSource);
261+ }
262+
263+ if (resizeMode != oldProps->resizeMode ) {
264+ switch (resizeMode) {
265+ case ImageResizeMode::Cover:
266+ result[" resizeMode" ] = " cover" ;
267+ break ;
268+ case ImageResizeMode::Contain:
269+ result[" resizeMode" ] = " contain" ;
270+ break ;
271+ case ImageResizeMode::Stretch:
272+ result[" resizeMode" ] = " stretch" ;
273+ break ;
274+ case ImageResizeMode::Center:
275+ result[" resizeMode" ] = " center" ;
276+ break ;
277+ case ImageResizeMode::Repeat:
278+ result[" resizeMode" ] = " repeat" ;
279+ break ;
280+ case ImageResizeMode::None:
281+ result[" resizeMode" ] = " none" ;
282+ break ;
283+ }
284+ }
285+
286+ if (blurRadius != oldProps->blurRadius ) {
287+ result[" blurRadius" ] = blurRadius;
288+ }
289+
290+ if (capInsets != oldProps->capInsets ) {
291+ result[" capInsets" ] = convertEdgeInsets (capInsets);
292+ }
293+
294+ if (tintColor != oldProps->tintColor ) {
295+ result[" tintColor" ] = *tintColor;
296+ }
297+
298+ if (internal_analyticTag != oldProps->internal_analyticTag ) {
299+ result[" internal_analyticTag" ] = internal_analyticTag;
300+ }
301+
302+ if (resizeMethod != oldProps->resizeMethod ) {
303+ result[" resizeMethod" ] = resizeMethod;
304+ }
305+
306+ if (resizeMultiplier != oldProps->resizeMultiplier ) {
307+ result[" resizeMultiplier" ] = resizeMultiplier;
308+ }
309+
310+ if (shouldNotifyLoadEvents != oldProps->shouldNotifyLoadEvents ) {
311+ result[" shouldNotifyLoadEvents" ] = shouldNotifyLoadEvents;
312+ }
313+
314+ if (overlayColor != oldProps->overlayColor ) {
315+ result[" overlayColor" ] = *overlayColor;
316+ }
317+
318+ if (fadeDuration != oldProps->fadeDuration ) {
319+ result[" fadeDuration" ] = fadeDuration;
320+ }
321+
322+ if (progressiveRenderingEnabled != oldProps->progressiveRenderingEnabled ) {
323+ result[" progressiveRenderingEnabled" ] = progressiveRenderingEnabled;
324+ }
325+
326+ return result;
327+ }
328+
329+ #endif
330+
177331} // namespace facebook::react
0 commit comments