Skip to content

Commit

Permalink
feat(iOS): show activity indiactor (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
duguyihou authored Nov 15, 2023
1 parent 1c5d91c commit 6343e41
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function App() {
url={img.url}
style={styles.box}
resizeMode="contain"
showActivityIndicator
/>
))}
</ScrollView>
Expand Down
8 changes: 7 additions & 1 deletion ios/TurboImage/TurboImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class TurboImageView : UIView {
}
}

@objc var showActivityIndicator = false {
didSet {
lazyImageView.kf.indicatorType = .activity
}
}

override init(frame: CGRect) {
super.init(frame: frame)
addSubview(lazyImageView)
Expand Down Expand Up @@ -52,7 +58,7 @@ fileprivate extension TurboImageView {
else { return }

KF.url(url)
.fade(duration: 1)
.fade(duration: 0.75)
.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 @@ -10,5 +10,7 @@ @interface RCT_EXTERN_MODULE(TurboImageViewManager, RCTViewManager)

RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString)

RCT_EXPORT_VIEW_PROPERTY(showActivityIndicator, BOOL)

@end

1 change: 1 addition & 0 deletions src/TurboImage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ResizeMode } from './types';
export interface TurboImageProps extends AccessibilityProps, ViewProps {
url: string;
resizeMode?: ResizeMode;
showActivityIndicator?: boolean;
onError?: (result: { nativeEvent: { error: string } }) => void;
onSuccess?: (result: {
nativeEvent: {
Expand Down

0 comments on commit 6343e41

Please sign in to comment.