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