Skip to content

Commit

Permalink
feat(iOS): fade duration
Browse files Browse the repository at this point in the history
  • Loading branch information
duguyihou committed Nov 16, 2023
1 parent 50d18f4 commit 1720d05
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -18,7 +18,7 @@ export default function App() {
style={styles.box}
resizeMode="contain"
showActivityIndicator
base64Placeholder={base64Placeholder}
fadeDuration={5}
/>
))}
</ScrollView>
Expand Down
4 changes: 3 additions & 1 deletion ios/TurboImage/TurboImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions ios/TurboImage/TurboImageViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ @interface RCT_EXTERN_MODULE(TurboImageViewManager, RCTViewManager)

RCT_EXPORT_VIEW_PROPERTY(base64Placeholder, NSString)

RCT_EXPORT_VIEW_PROPERTY(fadeDuration, NSNumber)

@end

1 change: 1 addition & 0 deletions src/TurboImage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 1720d05

Please sign in to comment.