From 1720d05c73962cb3d17d8e25b49980436a8ffc64 Mon Sep 17 00:00:00 2001
From: duguyihou <duguyihou@gmail.com>
Date: Thu, 16 Nov 2023 19:04:02 +1100
Subject: [PATCH] feat(iOS): fade duration

---
 example/src/App.tsx                    | 4 ++--
 ios/TurboImage/TurboImageView.swift    | 4 +++-
 ios/TurboImage/TurboImageViewManager.m | 2 ++
 src/TurboImage.d.ts                    | 1 +
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/example/src/App.tsx b/example/src/App.tsx
index 8fbf8ee..42b80f5 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import { SafeAreaView, ScrollView, StyleSheet, Text } from 'react-native';
 import TurboImage from 'react-native-turbo-image';
-import { images, base64Placeholder } from './mockData';
+import { images } from './mockData';
 
 export default function App() {
   return (
@@ -18,7 +18,7 @@ export default function App() {
             style={styles.box}
             resizeMode="contain"
             showActivityIndicator
-            base64Placeholder={base64Placeholder}
+            fadeDuration={5}
           />
         ))}
       </ScrollView>
diff --git a/ios/TurboImage/TurboImageView.swift b/ios/TurboImage/TurboImageView.swift
index 2ab82ec..a375dce 100644
--- a/ios/TurboImage/TurboImageView.swift
+++ b/ios/TurboImage/TurboImageView.swift
@@ -32,6 +32,8 @@ class TurboImageView : UIView {
   
   @objc var base64Placeholder: String?
   
+  @objc var fadeDuration: NSNumber = 0.5
+  
   override init(frame: CGRect) {
     super.init(frame: frame)
     addSubview(lazyImageView)
@@ -60,7 +62,7 @@ fileprivate extension TurboImageView {
     else { return }
     
     KF.url(url)
-      .fade(duration: 5)
+      .fade(duration: TimeInterval(truncating: fadeDuration))
       .placeholder(UIImage(base64Placeholder: base64Placeholder))
       .onSuccess({ result in
         self.onSuccess?(["result": result])
diff --git a/ios/TurboImage/TurboImageViewManager.m b/ios/TurboImage/TurboImageViewManager.m
index da8c16d..8603a12 100644
--- a/ios/TurboImage/TurboImageViewManager.m
+++ b/ios/TurboImage/TurboImageViewManager.m
@@ -14,5 +14,7 @@ @interface RCT_EXTERN_MODULE(TurboImageViewManager, RCTViewManager)
 
 RCT_EXPORT_VIEW_PROPERTY(base64Placeholder, NSString)
 
+RCT_EXPORT_VIEW_PROPERTY(fadeDuration, NSNumber)
+
 @end
 
diff --git a/src/TurboImage.d.ts b/src/TurboImage.d.ts
index 97840b9..d30f85f 100644
--- a/src/TurboImage.d.ts
+++ b/src/TurboImage.d.ts
@@ -4,6 +4,7 @@ export interface TurboImageProps extends AccessibilityProps, ViewProps {
   resizeMode?: ResizeMode;
   showActivityIndicator?: boolean;
   base64Placeholder?: string;
+  fadeDuration?: number;
   onError?: (result: { nativeEvent: { error: string } }) => void;
   onSuccess?: (result: {
     nativeEvent: {