Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Singleton Only Presenter. Allow multiple presenters. #299

Closed
wants to merge 7 commits into from

Conversation

Errortype520
Copy link

@Errortype520 Errortype520 commented Mar 4, 2020

NVActivityIndicatorViewable worked differently than I had assumed, and felt ineffective.

I assumed it would automatically just block the View Controllers View, instead of just using the singleton blocker.

Opening up NVActivityIndicatorPresenter will allow more flexibility. Allowing anything to have a presenter, and allowing that presenter to specify the view it should attach to will give a lot more approaches to using this library.

In My case, I want to block the View for a view controller while loading, but do not want to prevent actions on the tab bar and the navigation controller.

There are times I want to block a specific view, while keeping the rest of the view operable (such as blocking a CollectionView while keeping other UI components functional.

class SomeViewController: UIViewController, NVActivityIndicatorViewable {
    // Activity Indicator
    
    lazy var activityIndicatorPresenter: NVActivityIndicatorPresenter = {
        
        return NVActivityIndicatorPresenter(presentingView: self.view)
    }()
}

…at wants to be Viewable,

Removed ActivityIndicatorPresenter singleton only Presenter. Allowed Block UI to be attached to any view.
}

/**
Remove UI blocker.

- parameter fadeOutAnimation: fade out animation.
*/
func stopAnimating(_ fadeOutAnimation: FadeOutAnimation? = NVActivityIndicatorView.DEFAULT_FADE_OUT_ANIMATION) {
NVActivityIndicatorPresenter.sharedInstance.stopAnimating(fadeOutAnimation)
func hideActivityIndicator(_ fadeOutAnimation: FadeOutAnimation? = NVActivityIndicatorView.DEFAULT_FADE_OUT_ANIMATION) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 124 characters (line_length)

- parameter size: Information used to display UIBlocker
- parameter fadeInAnimation: fade in animation.
*/
func showActivityIndicator(activityData: ActivityData, fadeInAnimation: FadeInAnimation? = NVActivityIndicatorView.DEFAULT_FADE_IN_ANIMATION) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 147 characters (line_length)

let leadingConstraint = NSLayoutConstraint(item: presentingView, attribute: .leading, relatedBy: .equal, toItem: containerView, attribute: .leading, multiplier: 1, constant: 0)
let trailingConstraint = NSLayoutConstraint(item: presentingView, attribute: .trailing, relatedBy: .equal, toItem: containerView, attribute: .trailing, multiplier: 1, constant: 0)
let topConstraint = NSLayoutConstraint(item: presentingView, attribute: .top, relatedBy: .equal, toItem: containerView, attribute: .top, multiplier: 1, constant: 0)
let bottomConstraint = NSLayoutConstraint(item: presentingView, attribute: .bottom, relatedBy: .equal, toItem: containerView, attribute: .bottom, multiplier: 1, constant: 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 185 characters (line_length)

}())
let leadingConstraint = NSLayoutConstraint(item: presentingView, attribute: .leading, relatedBy: .equal, toItem: containerView, attribute: .leading, multiplier: 1, constant: 0)
let trailingConstraint = NSLayoutConstraint(item: presentingView, attribute: .trailing, relatedBy: .equal, toItem: containerView, attribute: .trailing, multiplier: 1, constant: 0)
let topConstraint = NSLayoutConstraint(item: presentingView, attribute: .top, relatedBy: .equal, toItem: containerView, attribute: .top, multiplier: 1, constant: 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 176 characters (line_length)

keyWindow.addConstraints([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])
}())
let leadingConstraint = NSLayoutConstraint(item: presentingView, attribute: .leading, relatedBy: .equal, toItem: containerView, attribute: .leading, multiplier: 1, constant: 0)
let trailingConstraint = NSLayoutConstraint(item: presentingView, attribute: .trailing, relatedBy: .equal, toItem: containerView, attribute: .trailing, multiplier: 1, constant: 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 191 characters (line_length)


keyWindow.addConstraints([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])
}())
let leadingConstraint = NSLayoutConstraint(item: presentingView, attribute: .leading, relatedBy: .equal, toItem: containerView, attribute: .leading, multiplier: 1, constant: 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 188 characters (line_length)

guard let presentingView = self.presentingView ?? UIApplication.shared.keyWindow else { return }
let containerViewFrame = self.presentingView?.bounds ?? UIScreen.main.bounds
let containerView = UIView(frame: containerViewFrame)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

}


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

} else {
item.removeFromSuperview()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

…atorView

# Conflicts:
#	Sources/Extended/NVActivityIndicatorViewable.swift
guard let presentingView = self.presentingView ?? UIApplication.shared.keyWindow else { return }
let containerViewFrame = self.presentingView?.bounds ?? UIScreen.main.bounds
let containerView = UIView(frame: containerViewFrame)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines should not have trailing whitespace.

} else {
item.removeFromSuperview()
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines should not have trailing whitespace.

}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines should not have trailing whitespace.

}


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines should not have trailing whitespace.

}


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limit vertical whitespace to a single empty line. Currently 2.

@codeclimate
Copy link

codeclimate bot commented Jan 28, 2021

Code Climate has analyzed commit 43fa684 and detected 5 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 5

View more on Code Climate.

@ninjaprox
Copy link
Owner

Thanks for your PR. NVActivityIndicatorViewable is marked deprecated so no change should be made. The reason is explained here #315 (comment)

@ninjaprox ninjaprox closed this Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants