diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index 735b9801..c7431915 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -81,10 +81,6 @@ class YepConfig { return 100 } - struct Conversation { - static let menuDirectionUpThreshold: CGFloat = 64 + 60 - } - struct AudioRecord { static let shortestDuration: NSTimeInterval = 0.5 static let longestDuration: NSTimeInterval = 60 diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index ba9c8939..808151ce 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -83,6 +83,9 @@ class ConversationViewController: BaseViewController { @IBOutlet weak var swipeUpView: UIView! + lazy var menuDirectionUpThreshold: CGFloat = { + return self.topBarsHeight + 60 + }() var currentMenu: BubbleMenuView? func removeOldMenu() { @@ -1766,7 +1769,7 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi let bubbleFrame = cell.convertRect(cell.bubbleBodyImageView.frame, toView: strongSelf.view) - let arrowDirection: BubbleMenuView.ArrowDirection = CGRectGetMidY(bubbleFrame) < YepConfig.Conversation.menuDirectionUpThreshold ? .Up : .Down + let arrowDirection: BubbleMenuView.ArrowDirection = CGRectGetMidY(bubbleFrame) < strongSelf.menuDirectionUpThreshold ? .Up : .Down let menu = BubbleMenuView(arrowDirection: arrowDirection, items: [copyItem]) @@ -2044,7 +2047,7 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi let bubbleFrame = cell.convertRect(cell.bubbleBodyImageView.frame, toView: strongSelf.view) - let arrowDirection: BubbleMenuView.ArrowDirection = CGRectGetMidY(bubbleFrame) < YepConfig.Conversation.menuDirectionUpThreshold ? .Up : .Down + let arrowDirection: BubbleMenuView.ArrowDirection = CGRectGetMidY(bubbleFrame) < strongSelf.menuDirectionUpThreshold ? .Up : .Down let menu = BubbleMenuView(arrowDirection: arrowDirection, items: [copyItem, deleteItem]) diff --git a/Yep/ViewControllers/Profile/ProfileLayout.swift b/Yep/ViewControllers/Profile/ProfileLayout.swift index 7501eff8..3d7139e7 100644 --- a/Yep/ViewControllers/Profile/ProfileLayout.swift +++ b/Yep/ViewControllers/Profile/ProfileLayout.swift @@ -12,10 +12,12 @@ class ProfileLayout: UICollectionViewFlowLayout { var scrollUpAction: ((progress: CGFloat) -> Void)? + let topBarsHeight: CGFloat = 64 let leftEdgeInset: CGFloat = YepConfig.Profile.leftEdgeInset override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? { + let layoutAttributes = super.layoutAttributesForElementsInRect(rect) as! [UICollectionViewLayoutAttributes] let contentInset = collectionView!.contentInset let contentOffset = collectionView!.contentOffset diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index 59c9371d..a3c3feca 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -316,7 +316,7 @@ class ProfileViewController: UIViewController { if let coverCell = self.profileCollectionView.cellForItemAtIndexPath(indexPath) as? ProfileHeaderCell { - let beginChangePercentage: CGFloat = 1 - topBarsHeight / self.collectionViewWidth * profileAvatarAspectRatio + let beginChangePercentage: CGFloat = 1 - self.topBarsHeight / self.collectionViewWidth * profileAvatarAspectRatio let normalizedProgressForChange: CGFloat = (progress - beginChangePercentage) / (1 - beginChangePercentage) coverCell.avatarBlurImageView.alpha = progress < beginChangePercentage ? 0 : normalizedProgressForChange