Support dark mode for small avatars on iOS

This commit is contained in:
Maurice Parker 2019-06-20 11:58:26 -05:00
parent 6c55fdd8ec
commit 2ee72125ba
6 changed files with 55 additions and 48 deletions

View File

@ -51,7 +51,7 @@ private extension RSImage {
let rect = CGRect(x: 0, y: 0, width: avatarSize, height: avatarSize)
UIGraphicsBeginImageContext(rect.size)
if let context = UIGraphicsGetCurrentContext() {
context.setFillColor(AppAssets.avatarLightBackgroundColor.cgColor)
context.setFillColor(AppAssets.avatarBackgroundColor.cgColor)
context.fill(rect)
context.translateBy(x: 0.0, y: CGFloat(integerLiteral: avatarSize));
context.scaleBy(x: 1.0, y: -1.0)

View File

@ -10,14 +10,10 @@ import RSCore
struct AppAssets {
static var avatarDarkBackgroundColor: UIColor {
return UIColor(named: "avatarDarkBackgroundColor")!
}
static var avatarBackgroundColor: UIColor = {
return UIColor(named: "avatarBackgroundColor")!
}()
static var avatarLightBackgroundColor: UIColor {
return UIColor(named: "avatarLightBackgroundColor")!
}
static var circleClosedImage: RSImage = {
return RSImage(named: "circleClosedImage")!
}()

View File

@ -73,6 +73,19 @@ class MasterTimelineViewController: ProgressTableViewController, UndoableCommand
}
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle {
appDelegate.authorAvatarDownloader.resetCache()
appDelegate.feedIconDownloader.resetCache()
appDelegate.faviconDownloader.resetCache()
performBlockAndRestoreSelection {
tableView.reloadData()
}
}
}
// MARK Actions
@IBAction func markAllAsRead(_ sender: Any) {

View File

@ -0,0 +1,38 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "242",
"alpha" : "1.000",
"blue" : "242",
"green" : "242"
}
}
},
{
"idiom" : "universal",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "56",
"alpha" : "1.000",
"blue" : "56",
"green" : "56"
}
}
}
]
}

View File

@ -1,20 +0,0 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "56",
"alpha" : "1.000",
"blue" : "56",
"green" : "56"
}
}
}
]
}

View File

@ -1,20 +0,0 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "242",
"alpha" : "1.000",
"blue" : "242",
"green" : "242"
}
}
}
]
}