From d805246cb7d0dd915840bd92847c668f6b3121f2 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 9 Nov 2018 16:26:12 -0600 Subject: [PATCH] update caption after deleting item --- .../MediaGalleryViewController.swift | 2 +- .../ViewControllers/MediaPageViewController.swift | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/MediaGalleryViewController.swift b/Signal/src/ViewControllers/MediaGalleryViewController.swift index 8a8855dfc..ec0fe67c5 100644 --- a/Signal/src/ViewControllers/MediaGalleryViewController.swift +++ b/Signal/src/ViewControllers/MediaGalleryViewController.swift @@ -477,7 +477,7 @@ class MediaGallery: NSObject, MediaGalleryDataSource, MediaTileViewControllerDel return } - pageViewController.currentItem = mediaGalleryItem + pageViewController.setCurrentItem(mediaGalleryItem, direction: .forward, animated: false) pageViewController.willBePresentedAgain() // TODO fancy zoom animation diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index 62c62f71a..d33c11e59 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -44,21 +44,17 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou } public var currentItem: MediaGalleryItem! { - get { - return currentViewController.galleryItemBox.value - } - set { - setCurrentItem(newValue, direction: .forward, animated: false) - } + return currentViewController.galleryItemBox.value } - 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 { owsFailDebug("unexpetedly unable to build new gallery page") return } self.updateTitle(item: item) + self.updateCaption(item: item) self.setViewControllers([galleryPage], direction: direction, animated: isAnimated) self.updateFooterBarButtonItems(isPlayingVideo: false) } @@ -717,6 +713,10 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou updateTitle(item: currentItem) } + private func updateCaption(item: MediaGalleryItem) { + self.currentCaptionView.text = item.captionForDisplay + } + private func updateTitle(item: MediaGalleryItem) { let name = senderName(message: item.message) portraitHeaderNameLabel.text = name