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

Ability to set custom views for every state #954

Closed
wants to merge 0 commits into from

Conversation

ManueGE
Copy link

@ManueGE ManueGE commented Apr 12, 2019

Hello!

NOTE: I know that usually you are not on favor of merging PRs that enlarge the HUD customization. In any case, I am submitting this PR to see if you are willing to merge it. If you are, I will update the sample app, docs, etc.

With this PR you can set any view as the progress hud for any of its states.

It includes basically a few more methods:

/// Sets a custom view for the indefinite spinner
+ (void)setCustomIndefinitedAnimationView:(UIView*)view;

/// Sets a custom view for the progress view. 
+ (void)setCustomProgressAnimationView:(UIView*)view;

/// Sets a custom view for each one of the three typical stage
+ (void)setCustomInfoView:(UIView*)view;
+ (void)setCustomSuccessView:(UIView*)view;
+ (void)setCustomErrorView:(UIView*)view;

/// Shows a custom view with the given status
+ (void)showCustomView:(nonnull UIView*)view status:(nullable NSString*)status;

You can add any UIView as custom view, but you can go a step further and make that view implements the new SVCustomHUDView protocol, which includes three optional methods:

/// Called when the view is about to be displayed inside a HUD
- (void) startHUDAnimationWithDuration:(NSTimeInterval) duration;

/// Called when the view is removed from the HUD
- (void) stopHUDAnimation;

/// Called when a progress value is set to the view
- (void) setHUDProgress:(float) progress;

As I said, I know that you want to keep the library simple and usually you don't merge any customization PRs. So, why I am submitting this anyway? I think that some of the PRs provided for customization are useful just for a few use cases, but I also believe that this one is flexible enough to satisfy a lot of cases. For instance, if you want to add a set of UIImage instances to perform an animation, you just need to create a UIImageView then assign those images and set this UIImageView as the custom view for the required state. It also works if you need to perform an animation with a UIBezierPath or CAShapeLayer; you just need to prepare your view, set it and you are done.

Also, I believe that this goes just a little further from the current customization. Whereas now you can add a UIImage for any state, with this PR you will be able to set a whole view, but the concept is quite similar.

If you think that you could want to merge this into the main project, please submit an answer and I'll complete it.

In any case, thanks for your project. It's awesome :)

@ManueGE ManueGE force-pushed the master branch 2 times, most recently from ddabee4 to c5618ee Compare April 20, 2019 08:35
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.

None yet

3 participants