Skip to content

Commit 0570dbb

Browse files
author
Isaac
committed
Update
1 parent 8c3bfe9 commit 0570dbb

File tree

4 files changed

+62
-28
lines changed

4 files changed

+62
-28
lines changed

submodules/TelegramUI/Components/GlassBackgroundComponent/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ swift_library(
1414
"//submodules/ComponentFlow",
1515
"//submodules/Components/ComponentDisplayAdapters",
1616
"//submodules/UIKitRuntimeUtils",
17+
"//submodules/AppBundle",
1718
],
1819
visibility = [
1920
"//visibility:public",

submodules/TelegramUI/Components/GlassBackgroundComponent/Sources/GlassBackgroundComponent.swift

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ComponentFlow
55
import ComponentDisplayAdapters
66
import UIKitRuntimeUtils
77
import CoreImage
8+
import AppBundle
89

910
private final class ContentContainer: UIView {
1011
private let maskContentView: UIView
@@ -689,39 +690,59 @@ public extension GlassBackgroundView {
689690
addShadow(context, true, CGPoint(), 10.0, 0.0, UIColor(white: 0.0, alpha: 0.06), .normal)
690691
addShadow(context, true, CGPoint(), 20.0, 0.0, UIColor(white: 0.0, alpha: 0.06), .normal)
691692

692-
let innerImage = UIGraphicsImageRenderer(size: size).image { ctx in
693-
let context = ctx.cgContext
694-
695-
context.setFillColor(fillColor.cgColor)
696-
context.fill(CGRect(origin: CGPoint(), size: size).insetBy(dx: inset, dy: inset).insetBy(dx: 0.1, dy: 0.1))
697-
698-
var a: CGFloat = 0.0
699-
var b: CGFloat = 0.0
700-
var s: CGFloat = 0.0
701-
fillColor.getHue(nil, saturation: &s, brightness: &b, alpha: &a)
702-
703-
addShadow(context, true, CGPoint(x: 0.0, y: 0.0), 20.0, 0.0, UIColor(white: 0.0, alpha: 0.04), .normal)
704-
addShadow(context, true, CGPoint(x: 0.0, y: 0.0), 5.0, 0.0, UIColor(white: 0.0, alpha: 0.04), .normal)
705-
706-
if s <= 0.3 && !isDark {
707-
addShadow(context, false, CGPoint(x: 0.0, y: 0.0), 8.0, 0.0, UIColor(white: 0.0, alpha: 0.4), .overlay)
693+
var a: CGFloat = 0.0
694+
var b: CGFloat = 0.0
695+
var s: CGFloat = 0.0
696+
fillColor.getHue(nil, saturation: &s, brightness: &b, alpha: &a)
697+
698+
let innerImage: UIImage
699+
if size == CGSize(width: 40.0 + inset * 2.0, height: 40.0 + inset * 2.0) {
700+
innerImage = UIGraphicsImageRenderer(size: size).image { ctx in
701+
let context = ctx.cgContext
708702

709-
let edgeAlpha: CGFloat = max(0.8, min(1.0, a))
703+
context.setFillColor(fillColor.cgColor)
704+
context.fill(CGRect(origin: CGPoint(), size: size).insetBy(dx: inset, dy: inset).insetBy(dx: 0.1, dy: 0.1))
710705

711-
for _ in 0 ..< 2 {
712-
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 0.8, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
713-
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 0.8, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
706+
if let image = UIImage(bundleImageName: "Item List/GlassEdge40x40") {
707+
if s <= 0.3 && !isDark {
708+
image.draw(in: CGRect(origin: CGPoint(), size: size).insetBy(dx: inset, dy: inset), blendMode: .normal, alpha: 0.7)
709+
} else if b >= 0.2 {
710+
image.draw(in: CGRect(origin: CGPoint(), size: size).insetBy(dx: inset, dy: inset), blendMode: .plusLighter, alpha: 0.7)
711+
} else {
712+
image.draw(in: CGRect(origin: CGPoint(), size: size).insetBy(dx: inset, dy: inset), blendMode: .normal, alpha: 0.5)
713+
}
714714
}
715-
} else if b >= 0.2 {
716-
let edgeAlpha: CGFloat = max(0.2, min(isDark ? 0.7 : 0.7, a * a * a))
715+
}
716+
} else {
717+
innerImage = UIGraphicsImageRenderer(size: size).image { ctx in
718+
let context = ctx.cgContext
717719

718-
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 0.5, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .plusLighter)
719-
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 0.5, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .plusLighter)
720-
} else {
721-
let edgeAlpha: CGFloat = max(0.4, min(1.0, a * a * a))
720+
context.setFillColor(fillColor.cgColor)
721+
context.fill(CGRect(origin: CGPoint(), size: size).insetBy(dx: inset, dy: inset).insetBy(dx: 0.1, dy: 0.1))
722+
723+
addShadow(context, true, CGPoint(x: 0.0, y: 0.0), 20.0, 0.0, UIColor(white: 0.0, alpha: 0.04), .normal)
724+
addShadow(context, true, CGPoint(x: 0.0, y: 0.0), 5.0, 0.0, UIColor(white: 0.0, alpha: 0.04), .normal)
722725

723-
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 1.2, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
724-
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 1.2, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
726+
if s <= 0.3 && !isDark {
727+
addShadow(context, false, CGPoint(x: 0.0, y: 0.0), 8.0, 0.0, UIColor(white: 0.0, alpha: 0.4), .overlay)
728+
729+
let edgeAlpha: CGFloat = max(0.8, min(1.0, a))
730+
731+
for _ in 0 ..< 2 {
732+
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 0.8, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
733+
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 0.8, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
734+
}
735+
} else if b >= 0.2 {
736+
let edgeAlpha: CGFloat = max(0.2, min(isDark ? 0.7 : 0.7, a * a * a))
737+
738+
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 0.5, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .plusLighter)
739+
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 0.5, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .plusLighter)
740+
} else {
741+
let edgeAlpha: CGFloat = max(0.4, min(1.0, a * a * a))
742+
743+
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 1.2, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
744+
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 1.2, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
745+
}
725746
}
726747
}
727748

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "iOS 28.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Binary file not shown.

0 commit comments

Comments
 (0)