Commit 12c0cf16 by Demid Merzlyakov

IOS-160: fix nudge prompt message doesn't disappear when the user moves to next card.

parent b9ee5bee
......@@ -175,6 +175,14 @@ class ShortsViewController: UIViewController {
}
}
private func setUnreadShortsView(hidden: Bool, animated: Bool, completion: ((Bool) -> ())? = nil) {
UIView.animate(withDuration: animated ? 0.3 : 0.0) {
self.unreadShortsView.alpha = hidden ? 0.0 : 1.0
} completion: { success in
completion?(success)
}
}
private func showUnreadShortsView(willShowRowIndex index:Int) {
analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_SHORTS_NUDGE_VIEW_TYPE: "left_below"])
......@@ -183,16 +191,12 @@ class ShortsViewController: UIViewController {
guard unreadCount > 0 else { return }
unreadShortsView.configure(withCount: unreadCount)
UIView.animate(withDuration: 0.3) {
self.unreadShortsView.alpha = 1
} completion: { _ in
setUnreadShortsView(hidden: false, animated: true) { _ in
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
UIView.animate(withDuration: 0.3) {
self.unreadShortsView.alpha = 0
}
self.setUnreadShortsView(hidden: true, animated: true)
}
}
}
private func logShortsAnalytics(source: Source, forRowAtIndex index: Int) {
......@@ -358,6 +362,9 @@ extension ShortsViewController: UITableViewDelegate {
let nextRowRect = tableView.rectForRow(at: nextRowIndexPath)
viewModel.markAsViewed(atIndex: nextRowIndexPath.row)
if unreadShortsView.alpha > 0 {
self.setUnreadShortsView(hidden: true, animated: true)
}
updateView(basedOnDirection: direction, willShowRowAt: nextRowIndexPath.row)
self.scrollTo(newOffset: nextRowRect.origin, velocity: velocity)
self.logShortsAnalytics(source: source, forRowAtIndex: nextRowIndexPath.row - 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment