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 {
return { (activityType, _, _, _) in
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 UIContextMenuConfiguration(identifier: nil) {
return SFSafariViewController(url: url)
let vc = SFSafariViewController(url: url)
vc.preferredControlTintColor = Preferences.shared.accentColor.color
return vc
} actionProvider: { _ in
return UIMenu(children: self.actionsForTrendingLink(card: item.card))
}

View File

@ -10,19 +10,25 @@ import UIKit
class FastSwitchingAccountView: UIView {
private static let selectedColor = UIColor { (traits) in
if traits.userInterfaceStyle == .dark {
return UIColor(hue: 211 / 360, saturation: 85 / 100, brightness: 100 / 100, alpha: 1)
} else {
return UIColor(hue: 211 / 360, saturation: 70 / 100, brightness: 100 / 100, alpha: 1)
}
private lazy var selectedColor = UIColor { [unowned self] (traits) in
var hue: CGFloat = 0
var saturation: CGFloat = 0
var brightness: CGFloat = 0
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
if traits.userInterfaceStyle == .dark {
return UIColor(hue: 211 / 360, saturation: 85 / 100, brightness: 85 / 100, alpha: 1)
} else {
return UIColor(hue: 211 / 360, saturation: 50 / 100, brightness: 100 / 100, alpha: 1)
}
private lazy var currentColor = UIColor { [unowned self] (traits) in
var hue: CGFloat = 0
var saturation: CGFloat = 0
var brightness: CGFloat = 0
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 {
didSet {
@ -139,9 +145,9 @@ class FastSwitchingAccountView: UIView {
private func updateLabelColors() {
let color: UIColor
if isSelected {
color = FastSwitchingAccountView.selectedColor
color = selectedColor
} else if isCurrent {
color = FastSwitchingAccountView.currentColor
color = currentColor
} else {
color = .white
}

View File

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

View File

@ -50,7 +50,9 @@ extension TuskerNavigationDelegate {
url.scheme == "https" || url.scheme == "http" {
let config = SFSafariViewController.Configuration()
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) {
UIApplication.shared.open(url, options: [:])
} else {

View File

@ -185,7 +185,9 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
} else if let tag = getHashtag(for: url, text: text) {
return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!)
} 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 {
return nil
}

View File

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

View File

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

View File

@ -229,7 +229,9 @@ extension StatusCardView: UIContextMenuInteractionDelegate {
guard let card = card else { return 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
let actions = self.actionProvider?.actionsForURL(URL(card.url)!, source: .view(self)) ?? []
return UIMenu(title: "", image: nil, identifier: nil, options: [], children: actions)