NetNewsWire/iOS/Timeline/TimelineTitleView.swift

57 lines
1.4 KiB
Swift
Raw Normal View History

2019-09-22 00:59:58 +02:00
//
2024-11-15 05:38:51 +01:00
// FeedTitleView.swift
2019-09-22 00:59:58 +02:00
// NetNewsWire-iOS
//
// Created by Maurice Parker on 9/21/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
2024-11-15 05:38:51 +01:00
class TimelineTitleView: UIView {
2019-09-22 00:59:58 +02:00
@IBOutlet weak var iconView: IconView!
2019-09-22 00:59:58 +02:00
@IBOutlet weak var label: UILabel!
2024-11-15 05:38:51 +01:00
@IBOutlet weak var unreadCountView: TimelineUnreadCountView!
private lazy var pointerInteraction: UIPointerInteraction = {
UIPointerInteraction(delegate: self)
}()
override var accessibilityLabel: String? {
set { }
get {
if let name = label.text {
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessiblity")
return "\(name) \(unreadCountView.unreadCount) \(unreadLabel)"
}
else {
return nil
}
}
}
func buttonize() {
heightAnchor.constraint(equalToConstant: 40.0).isActive = true
accessibilityTraits = .button
addInteraction(pointerInteraction)
}
func debuttonize() {
heightAnchor.constraint(equalToConstant: 40.0).isActive = true
accessibilityTraits.remove(.button)
removeInteraction(pointerInteraction)
}
}
2024-11-15 05:38:51 +01:00
extension TimelineTitleView: UIPointerInteractionDelegate {
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
var rect = self.frame
rect.origin.x = rect.origin.x - 10
rect.size.width = rect.width + 20
return UIPointerStyle(effect: .automatic(UITargetedPreview(view: self)), shape: .roundedRect(rect))
}
2019-09-22 00:59:58 +02:00
}