Fix various things not adjusting to accent color preference

Closes #325
This commit is contained in:
Shadowfacts 2023-01-16 11:24:42 -05:00
parent 4811747790
commit 0653d695d9
9 changed files with 41 additions and 23 deletions

View File

@ -39,7 +39,9 @@ class OpenInSafariActivity: UIActivity {
static func completionHandler(navigator: TuskerNavigationDelegate, url: URL) -> UIActivityViewController.CompletionWithItemsHandler { static func completionHandler(navigator: TuskerNavigationDelegate, url: URL) -> UIActivityViewController.CompletionWithItemsHandler {
return { (activityType, _, _, _) in return { (activityType, _, _, _) in
if activityType == .openInSafari { if activityType == .openInSafari {
navigator.show(SFSafariViewController(url: url)) let vc = SFSafariViewController(url: url)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
navigator.show(vc)
} }
} }
} }

View File

@ -75,7 +75,9 @@ class TrendingLinksViewController: EnhancedTableViewController {
return nil return nil
} }
return UIContextMenuConfiguration(identifier: nil) { return UIContextMenuConfiguration(identifier: nil) {
return SFSafariViewController(url: url) let vc = SFSafariViewController(url: url)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
return vc
} actionProvider: { _ in } actionProvider: { _ in
return UIMenu(children: self.actionsForTrendingLink(card: item.card)) return UIMenu(children: self.actionsForTrendingLink(card: item.card))
} }

View File

@ -10,19 +10,25 @@ import UIKit
class FastSwitchingAccountView: UIView { class FastSwitchingAccountView: UIView {
private static let selectedColor = UIColor { (traits) in private lazy var selectedColor = UIColor { [unowned self] (traits) in
if traits.userInterfaceStyle == .dark { var hue: CGFloat = 0
return UIColor(hue: 211 / 360, saturation: 85 / 100, brightness: 100 / 100, alpha: 1) var saturation: CGFloat = 0
} else { var brightness: CGFloat = 0
return UIColor(hue: 211 / 360, saturation: 70 / 100, brightness: 100 / 100, alpha: 1) var alpha: CGFloat = 0
} self.tintColor.resolvedColor(with: traits).getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha)
brightness = min(1, brightness + 0.4)
saturation = max(0, saturation - 0.3)
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: alpha)
} }
private static let currentColor = UIColor { (traits) in private lazy var currentColor = UIColor { [unowned self] (traits) in
if traits.userInterfaceStyle == .dark { var hue: CGFloat = 0
return UIColor(hue: 211 / 360, saturation: 85 / 100, brightness: 85 / 100, alpha: 1) var saturation: CGFloat = 0
} else { var brightness: CGFloat = 0
return UIColor(hue: 211 / 360, saturation: 50 / 100, brightness: 100 / 100, alpha: 1) var alpha: CGFloat = 0
} self.tintColor.resolvedColor(with: traits).getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha)
brightness = min(1, brightness + 0.3)
saturation = max(0, saturation - 0.2)
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: alpha)
} }
var isSelected = false { var isSelected = false {
didSet { didSet {
@ -139,9 +145,9 @@ class FastSwitchingAccountView: UIView {
private func updateLabelColors() { private func updateLabelColors() {
let color: UIColor let color: UIColor
if isSelected { if isSelected {
color = FastSwitchingAccountView.selectedColor color = selectedColor
} else if isCurrent { } else if isCurrent {
color = FastSwitchingAccountView.currentColor color = currentColor
} else { } else {
color = .white color = .white
} }

View File

@ -278,7 +278,9 @@ extension SearchViewController: UICollectionViewDelegate {
return nil return nil
} }
return UIContextMenuConfiguration { return UIContextMenuConfiguration {
SFSafariViewController(url: url) let vc = SFSafariViewController(url: url)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
return vc
} actionProvider: { _ in } actionProvider: { _ in
UIMenu(children: self.actionsForTrendingLink(card: card)) UIMenu(children: self.actionsForTrendingLink(card: card))
} }

View File

@ -50,7 +50,9 @@ extension TuskerNavigationDelegate {
url.scheme == "https" || url.scheme == "http" { url.scheme == "https" || url.scheme == "http" {
let config = SFSafariViewController.Configuration() let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = Preferences.shared.inAppSafariAutomaticReaderMode config.entersReaderIfAvailable = Preferences.shared.inAppSafariAutomaticReaderMode
present(SFSafariViewController(url: url, configuration: config), animated: true) let vc = SFSafariViewController(url: url, configuration: config)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
present(vc, animated: true)
} else if UIApplication.shared.canOpenURL(url) { } else if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:]) UIApplication.shared.open(url, options: [:])
} else { } else {

View File

@ -185,7 +185,9 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
} else if let tag = getHashtag(for: url, text: text) { } else if let tag = getHashtag(for: url, text: text) {
return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!) return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!)
} else if url.scheme == "https" || url.scheme == "http" { } else if url.scheme == "https" || url.scheme == "http" {
return SFSafariViewController(url: url) let vc = SFSafariViewController(url: url)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
return vc
} else { } else {
return nil return nil
} }

View File

@ -56,7 +56,7 @@ class PollOptionView: UIView {
let fillView = UIView() let fillView = UIView()
fillView.translatesAutoresizingMaskIntoConstraints = false fillView.translatesAutoresizingMaskIntoConstraints = false
fillView.backgroundColor = tintColor.withAlphaComponent(0.6) fillView.backgroundColor = .tintColor.withAlphaComponent(0.6)
fillView.layer.zPosition = -1 fillView.layer.zPosition = -1
fillView.layer.cornerRadius = layer.cornerRadius fillView.layer.cornerRadius = layer.cornerRadius
addSubview(fillView) addSubview(fillView)

View File

@ -294,7 +294,7 @@ class BaseStatusTableViewCell: UITableViewCell {
} else { } else {
let view = UIView() let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = tintColor.withAlphaComponent(0.5) view.backgroundColor = .tintColor.withAlphaComponent(0.5)
view.layer.cornerRadius = 2.5 view.layer.cornerRadius = 2.5
view.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner] view.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
prevThreadLinkView = view prevThreadLinkView = view
@ -316,7 +316,7 @@ class BaseStatusTableViewCell: UITableViewCell {
} else { } else {
let view = UIView() let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = tintColor.withAlphaComponent(0.5) view.backgroundColor = .tintColor.withAlphaComponent(0.5)
view.layer.cornerRadius = 2.5 view.layer.cornerRadius = 2.5
view.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] view.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
nextThreadLinkView = view nextThreadLinkView = view

View File

@ -229,7 +229,9 @@ extension StatusCardView: UIContextMenuInteractionDelegate {
guard let card = card else { return nil } guard let card = card else { return nil }
return UIContextMenuConfiguration(identifier: nil) { return UIContextMenuConfiguration(identifier: nil) {
return SFSafariViewController(url: URL(card.url)!) let vc = SFSafariViewController(url: URL(card.url)!)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
return vc
} actionProvider: { (_) in } actionProvider: { (_) in
let actions = self.actionProvider?.actionsForURL(URL(card.url)!, source: .view(self)) ?? [] let actions = self.actionProvider?.actionsForURL(URL(card.url)!, source: .view(self)) ?? []
return UIMenu(title: "", image: nil, identifier: nil, options: [], children: actions) return UIMenu(title: "", image: nil, identifier: nil, options: [], children: actions)