Created
January 4, 2018 22:58
-
-
Save frosty/a34e76cd9811b289f9411d279569fa30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/WordPress/Classes/ViewRelated/Blog/BlogDetailHeaderView.m b/WordPress/Classes/ViewRelated/Blog/BlogDetailHeaderView.m | |
index 87e745150..cb127b4bb 100644 | |
--- a/WordPress/Classes/ViewRelated/Blog/BlogDetailHeaderView.m | |
+++ b/WordPress/Classes/ViewRelated/Blog/BlogDetailHeaderView.m | |
@@ -11,7 +11,7 @@ @interface BlogDetailHeaderView () <UIDropInteractionDelegate> | |
@property (nonatomic, strong) UIStackView *stackView; | |
@property (nonatomic, strong) UIActivityIndicatorView *blavatarUpdateActivityIndicatorView; | |
@property (nonatomic, strong) UIStackView *labelsStackView; | |
-@property (nonatomic) BOOL isAnimating; | |
+@property (nonatomic, strong) UIView *blavatarDropTarget; | |
@end | |
@@ -37,6 +37,7 @@ - (void)performSetup | |
self.preservesSuperviewLayoutMargins = YES; | |
[self setupStackView]; | |
[self setupBlavatarImageView]; | |
+ [self setupBlavatarDropTarget]; | |
[self setupLabelsStackView]; | |
[self setupTitleLabel]; | |
[self setupSubtitleLabel]; | |
@@ -58,9 +59,8 @@ - (void)setBlog:(Blog *)blog | |
if (@available(iOS 11.0, *)) { | |
if ([self.delegate siteIconShouldAllowDroppedImages]) { | |
- self.isAnimating = NO; | |
UIDropInteraction *dropInteraction = [[UIDropInteraction alloc] initWithDelegate:self]; | |
- [self.blavatarImageView addInteraction:dropInteraction]; | |
+ [self.blavatarDropTarget addInteraction:dropInteraction]; | |
} | |
} | |
} | |
@@ -121,11 +121,6 @@ - (void)setupBlavatarImageView | |
imageView.translatesAutoresizingMaskIntoConstraints = NO; | |
imageView.layer.borderColor = [[UIColor whiteColor] CGColor]; | |
imageView.layer.borderWidth = 1.0; | |
- imageView.userInteractionEnabled = YES; | |
- UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self | |
- action:@selector(blavatarImageTapped)]; | |
- singleTap.numberOfTapsRequired = 1; | |
- [imageView addGestureRecognizer:singleTap]; | |
[_stackView addArrangedSubview:imageView]; | |
@@ -135,9 +130,25 @@ - (void)setupBlavatarImageView | |
[imageView.widthAnchor constraintEqualToConstant:BlogDetailHeaderViewBlavatarSize], | |
heightConstraint | |
]]; | |
+ | |
_blavatarImageView = imageView; | |
} | |
+- (void)setupBlavatarDropTarget | |
+{ | |
+ self.blavatarDropTarget = [UIView new]; | |
+ [self.blavatarDropTarget setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
+ self.blavatarDropTarget.backgroundColor = [UIColor clearColor]; | |
+ | |
+ UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self | |
+ action:@selector(blavatarImageTapped)]; | |
+ singleTap.numberOfTapsRequired = 1; | |
+ [self.blavatarDropTarget addGestureRecognizer:singleTap]; | |
+ | |
+ [self addSubview:self.blavatarDropTarget]; | |
+ [self.blavatarDropTarget pinSubviewToAllEdgeMargins:self.blavatarImageView]; | |
+} | |
+ | |
- (UIActivityIndicatorView *)blavatarUpdateActivityIndicatorView { | |
if (!_blavatarUpdateActivityIndicatorView) { | |
_blavatarUpdateActivityIndicatorView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; | |
@@ -221,10 +232,7 @@ - (void)setUpdatingIcon:(BOOL)updatingIcon | |
- (void)dropInteraction:(UIDropInteraction *)interaction | |
sessionDidEnter:(id<UIDropSession>)session API_AVAILABLE(ios(11.0)) | |
{ | |
- if (!self.isAnimating) { | |
- self.isAnimating = YES; | |
- [self.blavatarImageView depressSpringAnimation:nil]; | |
- } | |
+ [self.blavatarImageView depressSpringAnimation:nil]; | |
} | |
- (BOOL)dropInteraction:(UIDropInteraction *)interaction | |
@@ -238,10 +246,11 @@ - (BOOL)dropInteraction:(UIDropInteraction *)interaction | |
- (UIDropProposal *)dropInteraction:(UIDropInteraction *)interaction | |
sessionDidUpdate:(id<UIDropSession>)session API_AVAILABLE(ios(11.0)) | |
{ | |
- CGPoint dropLocation = [session locationInView:self]; | |
+ CGPoint dropLocation = [session locationInView:self.blavatarDropTarget]; | |
+ | |
UIDropOperation dropOperation = UIDropOperationCancel; | |
- if (CGRectContainsPoint(self.blavatarImageView.frame, dropLocation)) { | |
+ if (CGRectContainsPoint(self.blavatarDropTarget.bounds, dropLocation)) { | |
dropOperation = UIDropOperationCopy; | |
} | |
@@ -263,19 +272,18 @@ - (void)dropInteraction:(UIDropInteraction *)interaction | |
- (void)dropInteraction:(UIDropInteraction *)interaction | |
concludeDrop:(id<UIDropSession>)session API_AVAILABLE(ios(11.0)) | |
{ | |
- if (self.isAnimating) { | |
- self.isAnimating = NO; | |
- [self.blavatarImageView normalizeSpringAnimation:nil]; | |
- } | |
+ [self.blavatarImageView normalizeSpringAnimation:nil]; | |
+} | |
+ | |
+- (void)dropInteraction:(UIDropInteraction *)interaction sessionDidExit:(id<UIDropSession>)session API_AVAILABLE(ios(11.0)) | |
+{ | |
+ [self.blavatarImageView normalizeSpringAnimation:nil]; | |
} | |
- (void)dropInteraction:(UIDropInteraction *)interaction | |
sessionDidEnd:(id<UIDropSession>)session API_AVAILABLE(ios(11.0)) | |
{ | |
- if (self.isAnimating) { | |
- self.isAnimating = NO; | |
- [self.blavatarImageView normalizeSpringAnimation:nil]; | |
- } | |
+ [self.blavatarImageView normalizeSpringAnimation:nil]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment