Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dark mode #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 54 additions & 29 deletions Demo/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,97 @@
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
12 changes: 6 additions & 6 deletions Demo/Images.xcassets/progress.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "progress.pdf"
"filename" : "progress.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
"template-rendering-intent" : "template"
}
}
}
4 changes: 4 additions & 0 deletions PKHUD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
12CE19FD1E2578680062D873 /* PKHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F996321E19514FD8001F73CA /* PKHUD.framework */; };
3097AF3A1C4843AE007DD42B /* PKHUDRotatingImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3097AF391C4843AE007DD42B /* PKHUDRotatingImageView.swift */; };
640011571C5B6C080013F32B /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 640011551C5B6C080013F32B /* HUD.swift */; };
AC028B24255C285F001B6ACD /* UIColor+.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC028B23255C285F001B6ACD /* UIColor+.swift */; };
F908BEC01BB849290015E5A8 /* PKHUDSuccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEBF1BB849290015E5A8 /* PKHUDSuccessView.swift */; };
F908BEC31BB84D0B0015E5A8 /* PKHUDAnimating.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEC21BB84D0B0015E5A8 /* PKHUDAnimating.swift */; };
F908BEC51BB852C60015E5A8 /* PKHUDErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEC41BB852C60015E5A8 /* PKHUDErrorView.swift */; };
Expand Down Expand Up @@ -88,6 +89,7 @@
12CE19F51E25784D0062D873 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3097AF391C4843AE007DD42B /* PKHUDRotatingImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDRotatingImageView.swift; sourceTree = "<group>"; };
640011551C5B6C080013F32B /* HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = "<group>"; };
AC028B23255C285F001B6ACD /* UIColor+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+.swift"; sourceTree = "<group>"; };
F908BEBF1BB849290015E5A8 /* PKHUDSuccessView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDSuccessView.swift; sourceTree = "<group>"; };
F908BEC21BB84D0B0015E5A8 /* PKHUDAnimating.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDAnimating.swift; sourceTree = "<group>"; };
F908BEC41BB852C60015E5A8 /* PKHUDErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDErrorView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -250,6 +252,7 @@
F996324919514FEF001F73CA /* FrameView.swift */,
F996324B19514FEF001F73CA /* Window.swift */,
F996324C19514FEF001F73CA /* WindowRootViewController.swift */,
AC028B23255C285F001B6ACD /* UIColor+.swift */,
);
name = Internal;
sourceTree = "<group>";
Expand Down Expand Up @@ -443,6 +446,7 @@
F996325019514FEF001F73CA /* FrameView.swift in Sources */,
640011571C5B6C080013F32B /* HUD.swift in Sources */,
3097AF3A1C4843AE007DD42B /* PKHUDRotatingImageView.swift in Sources */,
AC028B24255C285F001B6ACD /* UIColor+.swift in Sources */,
F935B1611B2B8C8E003C3734 /* PKHUDTextView.swift in Sources */,
F996325319514FEF001F73CA /* WindowRootViewController.swift in Sources */,
F908BEC31BB84D0B0015E5A8 /* PKHUDAnimating.swift in Sources */,
Expand Down
14 changes: 12 additions & 2 deletions PKHUD/FrameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import UIKit
internal class FrameView: UIVisualEffectView {

internal init() {
super.init(effect: UIBlurEffect(style: .light))
let blurEffectStyle: UIBlurEffect.Style
if #available(iOS 13.0, *) {
blurEffectStyle = .systemUltraThinMaterial
} else {
blurEffectStyle = .light
}
super.init(effect: UIBlurEffect(style: blurEffectStyle))
DispatchQueue.main.async {
self.commonInit()
}
Expand All @@ -27,7 +33,11 @@ internal class FrameView: UIVisualEffectView {
}

private func commonInit() {
backgroundColor = UIColor(white: 0.8, alpha: 0.36)
if #available(iOS 13.0, *) {
backgroundColor = .clear
} else {
backgroundColor = UIColor(white: 0.8, alpha: 0.36)
}
layer.cornerRadius = 9.0
layer.masksToBounds = true

Expand Down
13 changes: 8 additions & 5 deletions PKHUD/Images.xcassets/checkmark.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "checkmark.pdf"
"filename" : "checkmark.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
}
13 changes: 8 additions & 5 deletions PKHUD/Images.xcassets/cross.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "cross.pdf"
"filename" : "cross.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
}
13 changes: 8 additions & 5 deletions PKHUD/Images.xcassets/progress_activity.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "progress.pdf"
"filename" : "progress.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
}
12 changes: 6 additions & 6 deletions PKHUD/Images.xcassets/progress_circular.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "progress_circular.pdf"
"filename" : "progress_circular.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
"template-rendering-intent" : "template"
}
}
}
2 changes: 1 addition & 1 deletion PKHUD/PKHUDErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ open class PKHUDErrorView: PKHUDSquareBaseView, PKHUDAnimating {
#endif

dash.fillColor = nil
dash.strokeColor = UIColor(red: 0.15, green: 0.15, blue: 0.15, alpha: 1.0).cgColor
dash.strokeColor = UIColor.imageTintColor.cgColor
dash.lineWidth = 6
return dash
}
Expand Down
9 changes: 7 additions & 2 deletions PKHUD/PKHUDSquareBaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ open class PKHUDSquareBaseView: UIView {
public init(image: UIImage? = nil, title: String? = nil, subtitle: String? = nil) {
super.init(frame: PKHUDSquareBaseView.defaultSquareBaseViewFrame)
self.imageView.image = image
if #available(iOS 13.0, *) {
imageView.tintColor = .label
} else {
imageView.tintColor = .black
}
titleLabel.text = title
subtitleLabel.text = subtitle

Expand All @@ -45,7 +50,7 @@ open class PKHUDSquareBaseView: UIView {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 17.0)
label.textColor = UIColor.black.withAlphaComponent(0.85)
label.textColor = .textTintColor
label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.25
return label
Expand All @@ -55,7 +60,7 @@ open class PKHUDSquareBaseView: UIView {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.systemFont(ofSize: 14.0)
label.textColor = UIColor.black.withAlphaComponent(0.7)
label.textColor = .textTintColor
label.adjustsFontSizeToFitWidth = true
label.numberOfLines = 2
label.adjustsFontSizeToFitWidth = true
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDSuccessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class PKHUDSuccessView: PKHUDSquareBaseView, PKHUDAnimating {
#endif

layer.fillColor = nil
layer.strokeColor = UIColor(red: 0.15, green: 0.15, blue: 0.15, alpha: 1.0).cgColor
layer.strokeColor = UIColor.imageTintColor.cgColor
layer.lineWidth = 6.0
return layer
}()
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/PKHUDTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ open class PKHUDTextView: PKHUDWideBaseView {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 17.0)
label.textColor = UIColor.black.withAlphaComponent(0.85)
label.textColor = .textTintColor
label.adjustsFontSizeToFitWidth = true
label.numberOfLines = 3
return label
Expand Down
28 changes: 28 additions & 0 deletions PKHUD/UIColor+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// UIColor+.swift
// PKHUD
//
// Created by Mario Iannotta on 11/11/2020.
// Copyright © 2020 NSExceptional. All rights reserved.
//

import Foundation

extension UIColor {

static var textTintColor: UIColor {
if #available(iOS 13.0, *) {
return UIColor.label.withAlphaComponent(0.85)
} else {
return UIColor.black.withAlphaComponent(0.85)
}
}

static var imageTintColor: UIColor {
if #available(iOS 13.0, *) {
return UIColor.secondaryLabel
} else {
return UIColor(red: 0.15, green: 0.15, blue: 0.15, alpha: 1.0)
}
}
}