| | |
| | | var id: String { name } |
| | | let name: String |
| | | let colorIndex: Int |
| | | let customColor: TagCustomColor? |
| | | } |
| | | |
| | | struct TagNavigationView: NSViewRepresentable { |
| | |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | self.item = TagNavigationItem(name: "", colorIndex: 0) |
| | | self.item = TagNavigationItem(name: "", colorIndex: 0, customColor: nil) |
| | | self.orientation = .horizontal |
| | | super.init(coder: coder) |
| | | } |
| | |
| | | } |
| | | |
| | | private func updateAppearance() { |
| | | let background = TagColor.nsColor(for: item.colorIndex) |
| | | let background = TagColor.nsColor(for: item.colorIndex, customColor: item.customColor) |
| | | let dragScale: CGFloat = isDragging ? 1.04 : 1.0 |
| | | layer?.backgroundColor = background.cgColor |
| | | layer?.cornerRadius = orientation == .horizontal ? 7 : 6 |
| | |
| | | layer?.setAffineTransform(CGAffineTransform(scaleX: dragScale, y: dragScale)) |
| | | alphaValue = dragModeActive ? (isDragging ? 1.0 : 0.62) : 1.0 |
| | | |
| | | let textColor: NSColor = (item.colorIndex == 0 || item.colorIndex == 5) ? .labelColor : .white |
| | | let textColor: NSColor = TagColor.prefersDarkText(for: background) ? .labelColor : .white |
| | | let paragraph = NSMutableParagraphStyle() |
| | | paragraph.alignment = alignment |
| | | if orientation == .vertical { |