Merge branch 'mkirk/gallery-pager-fixups'

pull/1/head
Michael Kirk 7 years ago
commit 8b0e4f902e

@ -477,7 +477,7 @@ class MediaGallery: NSObject, MediaGalleryDataSource, MediaTileViewControllerDel
return return
} }
pageViewController.currentItem = mediaGalleryItem pageViewController.setCurrentItem(mediaGalleryItem, direction: .forward, animated: false)
pageViewController.willBePresentedAgain() pageViewController.willBePresentedAgain()
// TODO fancy zoom animation // TODO fancy zoom animation

@ -44,21 +44,17 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
} }
public var currentItem: MediaGalleryItem! { public var currentItem: MediaGalleryItem! {
get { return currentViewController.galleryItemBox.value
return currentViewController.galleryItemBox.value
}
set {
setCurrentItem(newValue, direction: .forward, animated: false)
}
} }
private func setCurrentItem(_ item: MediaGalleryItem, direction: UIPageViewControllerNavigationDirection, animated isAnimated: Bool) { public func setCurrentItem(_ item: MediaGalleryItem, direction: UIPageViewControllerNavigationDirection, animated isAnimated: Bool) {
guard let galleryPage = self.buildGalleryPage(galleryItem: item) else { guard let galleryPage = self.buildGalleryPage(galleryItem: item) else {
owsFailDebug("unexpetedly unable to build new gallery page") owsFailDebug("unexpetedly unable to build new gallery page")
return return
} }
self.updateTitle(item: item) self.updateTitle(item: item)
self.updateCaption(item: item)
self.setViewControllers([galleryPage], direction: direction, animated: isAnimated) self.setViewControllers([galleryPage], direction: direction, animated: isAnimated)
self.updateFooterBarButtonItems(isPlayingVideo: false) self.updateFooterBarButtonItems(isPlayingVideo: false)
} }
@ -224,13 +220,13 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
} }
func updatePagerTransition(ratioComplete: CGFloat) { func updatePagerTransition(ratioComplete: CGFloat) {
if currentCaptionView.text != nil { if let currentCaptionText = currentCaptionView.text, currentCaptionText.count > 0 {
currentCaptionView.alpha = 1 - ratioComplete currentCaptionView.alpha = 1 - ratioComplete
} else { } else {
currentCaptionView.alpha = 0 currentCaptionView.alpha = 0
} }
if pendingCaptionView.text != nil { if let pendingCaptionText = pendingCaptionView.text, pendingCaptionText.count > 0 {
pendingCaptionView.alpha = ratioComplete pendingCaptionView.alpha = ratioComplete
} else { } else {
pendingCaptionView.alpha = 0 pendingCaptionView.alpha = 0
@ -717,6 +713,10 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
updateTitle(item: currentItem) updateTitle(item: currentItem)
} }
private func updateCaption(item: MediaGalleryItem) {
self.currentCaptionView.text = item.captionForDisplay
}
private func updateTitle(item: MediaGalleryItem) { private func updateTitle(item: MediaGalleryItem) {
let name = senderName(message: item.message) let name = senderName(message: item.message)
portraitHeaderNameLabel.text = name portraitHeaderNameLabel.text = name
@ -764,6 +764,8 @@ class CaptionView: UIView {
textView.font = UIFont.ows_dynamicTypeBody textView.font = UIFont.ows_dynamicTypeBody
textView.textColor = .white textView.textColor = .white
textView.backgroundColor = .clear textView.backgroundColor = .clear
textView.isEditable = false
textView.isSelectable = false
return textView return textView
}() }()
@ -801,7 +803,7 @@ class CaptionView: UIView {
class CaptionTextView: UITextView { class CaptionTextView: UITextView {
var kMaxHeight: CGFloat = ScaleFromIPhone5(100) var kMaxHeight: CGFloat = ScaleFromIPhone5(200)
override var text: String! { override var text: String! {
didSet { didSet {

Loading…
Cancel
Save