From 9368d1033d1c110b3d8aae7d412e21a26a771ee1 Mon Sep 17 00:00:00 2001 From: Mihael Cholakov Date: Sun, 12 Jan 2020 23:53:08 +0200 Subject: [PATCH] Implement VibrantBasicTableViewCell --- iOS/Inspector/Inspector.storyboard | 13 ++++++-- .../WebFeedInspectorViewController.swift | 5 +-- iOS/Settings/Settings.storyboard | 8 ++--- .../VibrantTableViewCell.swift | 32 +++++++++++++++++++ 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/iOS/Inspector/Inspector.storyboard b/iOS/Inspector/Inspector.storyboard index 18209dfdb..52533c98f 100644 --- a/iOS/Inspector/Inspector.storyboard +++ b/iOS/Inspector/Inspector.storyboard @@ -252,14 +252,14 @@ - + - + + + + + + + + @@ -372,6 +380,7 @@ + diff --git a/iOS/Inspector/WebFeedInspectorViewController.swift b/iOS/Inspector/WebFeedInspectorViewController.swift index ddc9fd2d6..a632dbe6c 100644 --- a/iOS/Inspector/WebFeedInspectorViewController.swift +++ b/iOS/Inspector/WebFeedInspectorViewController.swift @@ -101,8 +101,9 @@ extension WebFeedInspectorViewController { let safari = SFSafariViewController(url: homePageUrl) safari.modalPresentationStyle = .pageSheet - present(safari, animated: true) - + present(safari, animated: true) { + tableView.deselectRow(at: indexPath, animated: true) + } } } diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index 09a0ad8bc..c67fc73f2 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -1,8 +1,8 @@ - + - + @@ -296,7 +296,7 @@ - + @@ -313,7 +313,7 @@ - + diff --git a/iOS/UIKit Extensions/VibrantTableViewCell.swift b/iOS/UIKit Extensions/VibrantTableViewCell.swift index 4c3a7c27d..012ad631e 100644 --- a/iOS/UIKit Extensions/VibrantTableViewCell.swift +++ b/iOS/UIKit Extensions/VibrantTableViewCell.swift @@ -67,3 +67,35 @@ class VibrantTableViewCell: UITableViewCell { } } + +class VibrantBasicTableViewCell: VibrantTableViewCell { + + @IBOutlet private var label: UILabel! + @IBOutlet private var icon: UIImageView! + + @IBInspectable var imageNormal: UIImage? + @IBInspectable var imageSelected: UIImage? + + var iconTint: UIColor { + return isHighlighted || isSelected ? .systemBackground : AppAssets.primaryAccentColor + } + + var iconImage: UIImage? { + return isHighlighted || isSelected ? imageSelected : imageNormal + } + + override func updateVibrancy(animated: Bool) { + super.updateVibrancy(animated: animated) + updateIconVibrancy(icon, color: iconTint, image: iconImage, animated: animated) + updateLabelVibrancy(label, color: labelColor, animated: animated) + } + + private func updateIconVibrancy(_ icon: UIImageView?, color: UIColor, image: UIImage?, animated: Bool) { + guard let icon = icon else { return } + UIView.transition(with: label, duration: duration(animated: animated), options: .transitionCrossDissolve, animations: { + icon.tintColor = color + icon.image = image + }, completion: nil) + } + +}