|
@@ -112,38 +112,6 @@ class NCUtility: NSObject {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- @objc func resizeImage(_ image: UIImage, size: CGSize) -> UIImage? {
|
|
|
-
|
|
|
- let cgImage = image.cgImage!
|
|
|
- var format = vImage_CGImageFormat(bitsPerComponent: 8, bitsPerPixel: 32, colorSpace: nil, bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.first.rawValue), version: 0, decode: nil, renderingIntent: CGColorRenderingIntent.defaultIntent)
|
|
|
- var sourceBuffer = vImage_Buffer()
|
|
|
- defer {
|
|
|
- free(sourceBuffer.data)
|
|
|
- }
|
|
|
- var error = vImageBuffer_InitWithCGImage(&sourceBuffer, &format, nil, cgImage, numericCast(kvImageNoFlags))
|
|
|
- guard error == kvImageNoError else { return nil }
|
|
|
- // create a destination buffer
|
|
|
- let destWidth = Int(size.width)
|
|
|
- let destHeight = Int(size.height)
|
|
|
- let bytesPerPixel = image.cgImage!.bitsPerPixel/8
|
|
|
- let destBytesPerRow = destWidth * bytesPerPixel
|
|
|
- let destData = UnsafeMutablePointer<UInt8>.allocate(capacity: destHeight * destBytesPerRow)
|
|
|
- defer {
|
|
|
- destData.deallocate()
|
|
|
- }
|
|
|
- var destBuffer = vImage_Buffer(data: destData, height: vImagePixelCount(destHeight), width: vImagePixelCount(destWidth), rowBytes: destBytesPerRow)
|
|
|
- // scale the image
|
|
|
- error = vImageScale_ARGB8888(&sourceBuffer, &destBuffer, nil, numericCast(kvImageHighQualityResampling))
|
|
|
- guard error == kvImageNoError else { return nil }
|
|
|
- // create a CGImage from vImage_Buffer
|
|
|
- var destCGImage = vImageCreateCGImageFromBuffer(&destBuffer, &format, nil, nil, numericCast(kvImageNoFlags), &error)?.takeRetainedValue()
|
|
|
- guard error == kvImageNoError else { return nil }
|
|
|
- // create a UIImage
|
|
|
- let resizedImage = destCGImage.flatMap { UIImage(cgImage: $0, scale: 0.0, orientation: image.imageOrientation) }
|
|
|
- destCGImage = nil
|
|
|
- return resizedImage
|
|
|
- }
|
|
|
-
|
|
|
func cellBlurEffect(with frame: CGRect) -> UIView {
|
|
|
|
|
|
let blurEffect = UIBlurEffect(style: .extraLight)
|
|
@@ -615,7 +583,7 @@ class NCUtility: NSObject {
|
|
|
messageUserDefined = NSLocalizedString("_away_", comment: "")
|
|
|
}
|
|
|
if userStatus?.lowercased() == "dnd" {
|
|
|
- onlineStatus = UIImage.init(named: "userStatusDnd")?.resizeImageUsingVImage(size: CGSize(width: 100, height: 100))
|
|
|
+ onlineStatus = UIImage.init(named: "userStatusDnd")?.resizeImage(size: CGSize(width: 100, height: 100))
|
|
|
messageUserDefined = NSLocalizedString("_dnd_", comment: "")
|
|
|
}
|
|
|
if userStatus?.lowercased() == "offline" || userStatus?.lowercased() == "invisible" {
|
|
@@ -643,6 +611,8 @@ class NCUtility: NSObject {
|
|
|
if themingColor?.first == "#" {
|
|
|
if let color = UIColor(hex: themingColor!) {
|
|
|
NCBrandColor.shared.brand = color
|
|
|
+ } else {
|
|
|
+ NCBrandColor.shared.brand = NCBrandColor.shared.customer
|
|
|
}
|
|
|
} else {
|
|
|
NCBrandColor.shared.brand = NCBrandColor.shared.customer
|
|
@@ -652,6 +622,8 @@ class NCUtility: NSObject {
|
|
|
if themingColorText?.first == "#" {
|
|
|
if let color = UIColor(hex: themingColorText!) {
|
|
|
NCBrandColor.shared.brandText = color
|
|
|
+ } else {
|
|
|
+ NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
|
|
|
}
|
|
|
} else {
|
|
|
NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
|
|
@@ -661,13 +633,11 @@ class NCUtility: NSObject {
|
|
|
if themingColorElement?.first == "#" {
|
|
|
if let color = UIColor(hex: themingColorElement!) {
|
|
|
NCBrandColor.shared.brandElement = color
|
|
|
- }
|
|
|
- } else {
|
|
|
- if themingColorText == "#000000" {
|
|
|
- NCBrandColor.shared.brandElement = .black
|
|
|
} else {
|
|
|
NCBrandColor.shared.brandElement = NCBrandColor.shared.brand
|
|
|
}
|
|
|
+ } else {
|
|
|
+ NCBrandColor.shared.brandElement = NCBrandColor.shared.brand
|
|
|
}
|
|
|
}
|
|
|
}
|