Clean
This commit is contained in:
parent
c61fb8533d
commit
1c4f0700a1
|
@ -951,16 +951,16 @@ static CGRect oldframe;
|
|||
|
||||
-(void)showProfilePicture:(UITapGestureRecognizer *)tapGesture
|
||||
{
|
||||
LKProfilePictureView *avatarImageView = (LKProfilePictureView *)tapGesture.view;
|
||||
UIImage * _Nullable image = [avatarImageView getProfilePicture];
|
||||
LKProfilePictureView *profilePictureView = (LKProfilePictureView *)tapGesture.view;
|
||||
UIImage *image = [profilePictureView getProfilePicture];
|
||||
if (image == nil) { return; }
|
||||
|
||||
UIWindow *window = [UIApplication sharedApplication].keyWindow;
|
||||
UIView *backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
|
||||
oldframe = [avatarImageView convertRect:avatarImageView.bounds toView:window];
|
||||
oldframe = [profilePictureView convertRect:profilePictureView.bounds toView:window];
|
||||
backgroundView.backgroundColor = [UIColor blackColor];
|
||||
backgroundView.alpha = 0;
|
||||
UIImageView *imageView = [[UIImageView alloc]initWithFrame:oldframe];
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithFrame:oldframe];
|
||||
imageView.image = image;
|
||||
imageView.tag = 1;
|
||||
imageView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width / 2;
|
||||
|
@ -971,7 +971,7 @@ static CGRect oldframe;
|
|||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideImage:)];
|
||||
[backgroundView addGestureRecognizer: tap];
|
||||
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
imageView.frame = CGRectMake(0,([UIScreen mainScreen].bounds.size.height - oldframe.size.height * [UIScreen mainScreen].bounds.size.width / oldframe.size.width) / 2, [UIScreen mainScreen].bounds.size.width, oldframe.size.height * [UIScreen mainScreen].bounds.size.width / oldframe.size.width);
|
||||
backgroundView.alpha = 1;
|
||||
} completion:nil];
|
||||
|
@ -979,8 +979,8 @@ static CGRect oldframe;
|
|||
|
||||
-(void)hideImage:(UITapGestureRecognizer *)tap{
|
||||
UIView *backgroundView = tap.view;
|
||||
UIImageView *imageView=(UIImageView *)[tap.view viewWithTag:1];
|
||||
[UIView animateWithDuration:0.2 animations:^{
|
||||
UIImageView *imageView = (UIImageView *)[tap.view viewWithTag:1];
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
imageView.frame = oldframe;
|
||||
backgroundView.alpha = 0;
|
||||
} completion:^(BOOL finished) {
|
||||
|
|
|
@ -5,12 +5,12 @@ public final class ProfilePictureView : UIView {
|
|||
private var imageViewHeightConstraint: NSLayoutConstraint!
|
||||
private var additionalImageViewWidthConstraint: NSLayoutConstraint!
|
||||
private var additionalImageViewHeightConstraint: NSLayoutConstraint!
|
||||
private var isUsingPlaceholder: Bool = true
|
||||
@objc public var size: CGFloat = 0 // Not an implicitly unwrapped optional due to Obj-C limitations
|
||||
@objc public var isRSSFeed = false
|
||||
@objc public var hexEncodedPublicKey: String!
|
||||
@objc public var additionalHexEncodedPublicKey: String?
|
||||
@objc public var openGroupProfilePicture: UIImage?
|
||||
private var isUsingDefualtPicture: Bool = true
|
||||
|
||||
// MARK: Components
|
||||
private lazy var imageView = getImageView()
|
||||
|
@ -66,7 +66,7 @@ public final class ProfilePictureView : UIView {
|
|||
} else if let openGroupProfilePicture = thread.groupModel.groupImage { // An open group with a profile picture
|
||||
self.openGroupProfilePicture = openGroupProfilePicture
|
||||
isRSSFeed = false
|
||||
isUsingDefualtPicture = false
|
||||
isUsingPlaceholder = false
|
||||
} else if thread.groupModel.groupType == .openGroup
|
||||
|| thread.groupModel.groupType == .rssFeed { // An open group without a profile picture or an RSS feed
|
||||
hexEncodedPublicKey = ""
|
||||
|
@ -93,7 +93,7 @@ public final class ProfilePictureView : UIView {
|
|||
func getProfilePicture(of size: CGFloat, for publicKey: String) -> UIImage? {
|
||||
guard !publicKey.isEmpty else { return nil }
|
||||
if let profilePicture = OWSProfileManager.shared().profileAvatar(forRecipientId: publicKey) {
|
||||
isUsingDefualtPicture = false
|
||||
isUsingPlaceholder = false
|
||||
return profilePicture
|
||||
} else {
|
||||
let displayName = OWSProfileManager.shared().profileNameForRecipient(withID: publicKey) ?? publicKey
|
||||
|
@ -149,7 +149,6 @@ public final class ProfilePictureView : UIView {
|
|||
}
|
||||
|
||||
@objc public func getProfilePicture() -> UIImage? {
|
||||
if isUsingDefualtPicture { return nil }
|
||||
return self.imageView.image
|
||||
return isUsingPlaceholder ? nil : imageView.image
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue