2019-09-22 00:59:58 +02:00
|
|
|
//
|
|
|
|
// MasterFeedTitleView.swift
|
|
|
|
// NetNewsWire-iOS
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 9/21/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class MasterTimelineTitleView: UIView {
|
|
|
|
|
2019-11-06 01:05:57 +01:00
|
|
|
@IBOutlet weak var iconView: IconView!
|
2019-09-22 00:59:58 +02:00
|
|
|
@IBOutlet weak var label: UILabel!
|
2019-10-01 03:01:02 +02:00
|
|
|
@IBOutlet weak var unreadCountView: MasterTimelineUnreadCountView!
|
2020-03-24 22:42:46 +01:00
|
|
|
|
|
|
|
private lazy var pointerInteraction: UIPointerInteraction = {
|
|
|
|
UIPointerInteraction(delegate: self)
|
|
|
|
}()
|
2020-07-29 08:07:27 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-24 22:42:46 +01:00
|
|
|
func buttonize() {
|
|
|
|
heightAnchor.constraint(equalToConstant: 40.0).isActive = true
|
|
|
|
accessibilityTraits = .button
|
2024-11-12 07:03:32 +01:00
|
|
|
addInteraction(pointerInteraction)
|
2020-03-24 22:42:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func debuttonize() {
|
2020-07-29 08:07:27 +02:00
|
|
|
heightAnchor.constraint(equalToConstant: 40.0).isActive = true
|
2020-03-24 22:42:46 +01:00
|
|
|
accessibilityTraits.remove(.button)
|
2024-11-12 07:03:32 +01:00
|
|
|
removeInteraction(pointerInteraction)
|
2020-03-24 22:42:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension MasterTimelineTitleView: UIPointerInteractionDelegate {
|
|
|
|
|
|
|
|
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
2020-03-25 00:27:54 +01:00
|
|
|
var rect = self.frame
|
2020-03-24 22:42:46 +01:00
|
|
|
rect.origin.x = rect.origin.x - 10
|
|
|
|
rect.size.width = rect.width + 20
|
|
|
|
|
2020-03-25 00:27:54 +01:00
|
|
|
return UIPointerStyle(effect: .automatic(UITargetedPreview(view: self)), shape: .roundedRect(rect))
|
2020-03-24 22:42:46 +01:00
|
|
|
}
|
2019-09-22 00:59:58 +02:00
|
|
|
}
|