NewsBlur/clients/ios/Widget Extension/WidgetBarView.swift
David Sinclair 65c706d3a6 #1162 (widget)
- Added the feed color bars (sharing those colors required a bit of refactoring).
- The fonts etc now more closely match the app.
- Now uses elipsises for the feed name, title, and content text, if needed.
- Improved HTML tag cleanup.
2019-12-23 21:19:45 -08:00

48 lines
1.4 KiB
Swift

//
// WidgetBarView.swift
// Widget Extension
//
// Created by David Sinclair on 2019-12-23.
// Copyright © 2019 NewsBlur. All rights reserved.
//
import UIKit
/// Color bars at the left of the feed cell.
class BarView: UIView {
/// The left bar color.
var leftColor: UIColor?
/// The right bar color.
var rightColor: UIColor?
override func draw(_ rect: CGRect) {
guard let leftColor = leftColor, let rightColor = rightColor, let context = UIGraphicsGetCurrentContext() else {
return
}
let height = bounds.height
context.setStrokeColor(leftColor.cgColor)
context.setLineWidth(4)
context.beginPath()
context.move(to: CGPoint(x: 2, y: 0))
context.addLine(to: CGPoint(x: 2, y: height))
context.strokePath()
context.setStrokeColor(rightColor.cgColor)
context.beginPath()
context.move(to: CGPoint(x: 6, y: 0))
context.addLine(to: CGPoint(x: 6, y: height))
context.strokePath()
let isDark = traitCollection.userInterfaceStyle == .dark
context.setStrokeColor(isDark ? UIColor.black.cgColor : UIColor.white.cgColor)
context.setLineWidth(1)
context.beginPath()
context.move(to: CGPoint(x: 0, y: 0.5))
context.addLine(to: CGPoint(x: bounds.width, y: 0.5))
context.strokePath()
}
}