refactored back in the obj-c interface to interact with swift extension

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-01-03 15:13:39 -06:00
parent c03e04069a
commit eb8ea989ec
5 changed files with 44 additions and 15 deletions

View File

@ -117,7 +117,7 @@
spinnerHeight = constraint.constant spinnerHeight = constraint.constant
loadingSpinnerHeightConstraint?.constant = 0 loadingSpinnerHeightConstraint?.constant = 0
loadingSpinnerHeightConstraint?.isActive = true loadingSpinnerHeightConstraint?.isActive = true
loadingSpinner.pauseSpinner() loadingSpinner.pause()
} }
} }
@ -326,7 +326,7 @@
guard let self = self, guard let self = self,
let loadingImageName = self.currentImageName, loadingImageName == imageName else { return } let loadingImageName = self.currentImageName, loadingImageName == imageName else { return }
self.isFallbackImage = isFallbackImage self.isFallbackImage = isFallbackImage
self.loadingSpinner.pauseSpinner() self.loadingSpinner.pause()
let layoutWillChange = self.shouldNotifyDelegateOnUpdate ? self.layoutWillChange(width: self.currentImageWidth, height: self.currentImageHeight, size: image?.size) : false let layoutWillChange = self.shouldNotifyDelegateOnUpdate ? self.layoutWillChange(width: self.currentImageWidth, height: self.currentImageHeight, size: image?.size) : false
self.addConstraints(width: width, height: height, size: image?.size) self.addConstraints(width: width, height: height, size: image?.size)
self.loadingSpinnerHeightConstraint?.constant = 0 self.loadingSpinnerHeightConstraint?.constant = 0
@ -359,7 +359,7 @@
return return
} }
self?.loadingSpinnerHeightConstraint?.constant = 0 self?.loadingSpinnerHeightConstraint?.constant = 0
self?.loadingSpinner.pauseSpinner() self?.loadingSpinner.pause()
if flipImage, let cgImage = image.cgImage { if flipImage, let cgImage = image.cgImage {
self?.imageView.image = UIImage(cgImage: cgImage, scale: image.scale, orientation: UIImage.Orientation.upMirrored) self?.imageView.image = UIImage(cgImage: cgImage, scale: image.scale, orientation: UIImage.Orientation.upMirrored)
} else { } else {

View File

@ -122,7 +122,7 @@ extension WebView : WKUIDelegate {
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
// hide loading // hide loading
overLayer.isHidden = true overLayer.isHidden = true
loadingSpinner.pauseSpinner() loadingSpinner.pause()
//update webview's heigth when webview is ready //update webview's heigth when webview is ready
if !dynamicHeight { if !dynamicHeight {
@ -159,7 +159,7 @@ extension WebView : WKUIDelegate {
//actually no error handle page show in webview. We can handle the error display view by our self. //actually no error handle page show in webview. We can handle the error display view by our self.
//or stop loading by default //or stop loading by default
overLayer.isHidden = true overLayer.isHidden = true
loadingSpinner.pauseSpinner() loadingSpinner.pause()
} }
} }

View File

@ -14,28 +14,27 @@ extension MFLoadingSpinner {
subviews.first as? Loader subviews.first as? Loader
} }
@objc(setUpCircle:) @objc open func setSurface(_ strokeColor: UIColor?) {
open func setUpCircle(strokeColor: UIColor?) {
if let strokeColor { if let strokeColor {
loader?.surface = strokeColor.isDark() ? .light : .dark loader?.surface = strokeColor.isDark() ? .light : .dark
} }
} }
@objc open func pauseSpinner() { @objc open func pause() {
loader?.isActive = false loader?.isActive = false
} }
@objc open func resumeSpinner() { @objc open func resume() {
loader?.isActive = true loader?.isActive = true
} }
@objc open func resumeSpinnerAfterDelay() { @objc open func resumeAfterDelay() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
self?.loader?.isActive = true self?.loader?.isActive = true
} }
} }
@objc open func pinWidthAndHeight() -> NSDictionary? { @objc open func pin() -> NSDictionary? {
guard let size = loader?.size else { return nil } guard let size = loader?.size else { return nil }
return NSLayoutConstraint.constraintPinView(self, heightConstraint: true, heightConstant: CGFloat(size), widthConstraint: true, widthConstant: CGFloat(size)) as NSDictionary? return NSLayoutConstraint.constraintPinView(self, heightConstraint: true, heightConstant: CGFloat(size), widthConstraint: true, widthConstant: CGFloat(size)) as NSDictionary?
} }

View File

@ -12,6 +12,17 @@
-(void)setUpCircle; -(void)setUpCircle;
-(void)setUpCircle:(nullable UIColor *)strokeColor;
-(void)changeColor:(nullable UIColor *)strokeColor; -(void)changeColor:(nullable UIColor *)strokeColor;
- (void)pauseSpinner;
- (void)resumeSpinner;
// Starts the spinner after a slight delay.
- (void)resumeSpinnerAfterDelay;
- (nullable NSDictionary *)pinWidthAndHeight;
@end @end

View File

@ -7,7 +7,6 @@
// //
#import "MFLoadingSpinner.h" #import "MFLoadingSpinner.h"
#import "NSLayoutConstraint+MFConvenience.h"
#import <VDS/VDS.h> #import <VDS/VDS.h>
#import <MVMCoreUI/MVMCoreUI-Swift.h> #import <MVMCoreUI/MVMCoreUI-Swift.h>
@ -29,11 +28,31 @@
} }
-(void)setUpCircle { -(void)setUpCircle {
[self setUpCircle:[UIColor blackColor]]; [self setSurface: UIColor.blackColor];
} }
-(void)changeColor:(UIColor *)strokeColor { -(void)setUpCircle:(nullable UIColor *)strokeColor {
[self setUpCircle: strokeColor]; [self setSurface: strokeColor];
} }
-(void)changeColor:(nullable UIColor *)strokeColor {
[self setSurface: strokeColor];
}
- (void)pauseSpinner {
[self pause];
}
- (void)resumeSpinner {
[self resume];
}
// Starts the spinner after a slight delay.
- (void)resumeSpinnerAfterDelay {
[self resumeAfterDelay];
}
- (nullable NSDictionary *)pinWidthAndHeight {
return [self pin];
}
@end @end