chore: migrate to new version + fixed several critical bugs

- Migrated project to latest Telegram iOS base (v12.3.2+)
- Fixed circular dependency between GhostModeManager and MiscSettingsManager
- Fixed multiple Bazel build configuration errors (select() default conditions)
- Fixed duplicate type definitions in PeerInfoScreen
- Fixed swiftmodule directory resolution in build scripts
- Added Ghostgram Settings tab in main Settings menu with all 5 features
- Cleared sensitive credentials from config.json (template-only now)
- Excluded bazel-cache from version control
This commit is contained in:
ichmagmaus 812
2026-02-23 23:04:32 +01:00
parent 703e291bcb
commit db53826061
1017 changed files with 62337 additions and 40559 deletions
@@ -410,7 +410,7 @@ public final class CombinedComponentContext<ComponentType: Component> {
public let component: ComponentType
public let availableSize: CGSize
public let transition: ComponentTransition
private let addImpl: (_ updatedComponent: _UpdatedChildComponent) -> Void
private let addImpl: (_ updatedComponent: _UpdatedChildComponent, _ container: UIView?) -> Void
public var environment: Environment<ComponentType.EnvironmentType> {
return self.context.environment
@@ -425,7 +425,7 @@ public final class CombinedComponentContext<ComponentType: Component> {
component: ComponentType,
availableSize: CGSize,
transition: ComponentTransition,
add: @escaping (_ updatedComponent: _UpdatedChildComponent) -> Void
add: @escaping (_ updatedComponent: _UpdatedChildComponent, _ container: UIView?) -> Void
) {
self.context = context
self.view = view
@@ -436,7 +436,11 @@ public final class CombinedComponentContext<ComponentType: Component> {
}
public func add(_ updatedComponent: _UpdatedChildComponent) {
self.addImpl(updatedComponent)
self.addImpl(updatedComponent, nil)
}
public func addWithExternalContainer(_ updatedComponent: _UpdatedChildComponent, container: UIView) {
self.addImpl(updatedComponent, container)
}
}
@@ -671,7 +675,7 @@ public extension CombinedComponent {
component: self,
availableSize: availableSize,
transition: transition,
add: { updatedChild in
add: { updatedChild, optionalContainer in
if !addedChildIds.insert(updatedChild.id).inserted {
preconditionFailure("Child component can only be added once")
}
@@ -692,7 +696,11 @@ public extension CombinedComponent {
context.childViewIndices.remove(at: previousView.index)
context.childViewIndices.insert(updatedChild.id, at: index)
previousView.index = index
view.insertSubview(previousView.view, at: index)
if let optionalContainer {
optionalContainer.addSubview(previousView.view)
} else {
view.insertSubview(previousView.view, at: index)
}
}
previousView.updateGestures(updatedChild.gestures)
@@ -715,7 +723,11 @@ public extension CombinedComponent {
childView.transition = updatedChild.transitionDisappear
childView.transitionWithGuide = updatedChild.transitionDisappearWithGuide
view.insertSubview(updatedChild.view, at: index)
if let optionalContainer {
optionalContainer.addSubview(updatedChild.view)
} else {
view.insertSubview(updatedChild.view, at: index)
}
updatedChild.view.layer.anchorPoint = updatedChild._anchorPoint ?? CGPoint(x: 0.5, y: 0.5)
@@ -489,7 +489,25 @@ public struct ComponentTransition {
}
public func setAlpha(view: UIView, alpha: CGFloat, delay: Double = 0.0, completion: ((Bool) -> Void)? = nil) {
self.setAlpha(layer: view.layer, alpha: alpha, delay: delay, completion: completion)
if view.alpha == alpha {
completion?(true)
return
}
switch self.animation {
case .none:
view.alpha = alpha
view.layer.removeAnimation(forKey: "opacity")
completion?(true)
case .curve:
let previousAlpha: Float
if view.layer.animation(forKey: "opacity") != nil {
previousAlpha = view.layer.presentation()?.opacity ?? Float(view.alpha)
} else {
previousAlpha = Float(view.alpha)
}
view.alpha = alpha
self.animateAlpha(layer: view.layer, from: CGFloat(previousAlpha), to: alpha, delay: delay, completion: completion)
}
}
public func setAlpha(layer: CALayer, alpha: CGFloat, delay: Double = 0.0, completion: ((Bool) -> Void)? = nil) {
@@ -1335,6 +1353,41 @@ public struct ComponentTransition {
completion: completion
)
}
public func setBlur(layer: CALayer, radius: CGFloat, completion: ((Bool) -> Void)? = nil) {
var currentRadius: CGFloat = 0.0
if let currentFilters = layer.filters {
for filter in currentFilters {
if let filter = filter as? NSObject, filter.description.contains("gaussianBlur") {
currentRadius = filter.value(forKey: "inputRadius") as? CGFloat ?? 0.0
}
}
}
if currentRadius == radius {
completion?(true)
return
}
if let blurFilter = CALayer.blur() {
blurFilter.setValue(radius as NSNumber, forKey: "inputRadius")
layer.filters = [blurFilter]
switch self.animation {
case .none:
completion?(true)
case let .curve(duration, curve):
layer.animate(from: currentRadius as NSNumber, to: radius as NSNumber, keyPath: "filters.gaussianBlur.inputRadius", duration: duration, delay: 0.0, curve: curve, removeOnCompletion: true, additive: false,completion: { [weak layer] flag in
if let layer {
if radius <= 0.0 {
layer.filters = nil
}
}
completion?(flag)
})
}
}
}
public func animateBlur(layer: CALayer, fromRadius: CGFloat, toRadius: CGFloat, delay: Double = 0.0, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
let duration: Double
@@ -1359,4 +1412,23 @@ public struct ComponentTransition {
})
}
}
public func animateMeshTransform(layer: CALayer, from fromValue: NSObject, to toValue: NSObject, delay: Double = 0.0, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
switch self.animation {
case .none:
completion?(true)
case let .curve(duration, curve):
layer.animate(
from: fromValue,
to: toValue,
keyPath: "meshTransform",
duration: duration,
delay: delay,
curve: curve,
removeOnCompletion: removeOnCompletion,
additive: false,
completion: completion
)
}
}
}
@@ -3,6 +3,7 @@ import UIKit
public final class Button: Component {
public let content: AnyComponent<Empty>
public let contentInsets: UIEdgeInsets
public let minSize: CGSize?
public let hitTestEdgeInsets: UIEdgeInsets?
public let tag: AnyObject?
@@ -15,6 +16,7 @@ public final class Button: Component {
convenience public init(
content: AnyComponent<Empty>,
contentInsets: UIEdgeInsets = UIEdgeInsets(),
isEnabled: Bool = true,
automaticHighlight: Bool = true,
action: @escaping () -> Void,
@@ -22,6 +24,7 @@ public final class Button: Component {
) {
self.init(
content: content,
contentInsets: contentInsets,
minSize: nil,
hitTestEdgeInsets: nil,
tag: nil,
@@ -35,6 +38,7 @@ public final class Button: Component {
private init(
content: AnyComponent<Empty>,
contentInsets: UIEdgeInsets = UIEdgeInsets(),
minSize: CGSize? = nil,
hitTestEdgeInsets: UIEdgeInsets? = nil,
tag: AnyObject? = nil,
@@ -46,6 +50,7 @@ public final class Button: Component {
highlightedAction: ActionSlot<Bool>?
) {
self.content = content
self.contentInsets = contentInsets
self.minSize = minSize
self.hitTestEdgeInsets = hitTestEdgeInsets
self.tag = tag
@@ -60,6 +65,7 @@ public final class Button: Component {
public func minSize(_ minSize: CGSize?) -> Button {
return Button(
content: self.content,
contentInsets: self.contentInsets,
minSize: minSize,
hitTestEdgeInsets: self.hitTestEdgeInsets,
tag: self.tag,
@@ -75,6 +81,7 @@ public final class Button: Component {
public func withHitTestEdgeInsets(_ hitTestEdgeInsets: UIEdgeInsets?) -> Button {
return Button(
content: self.content,
contentInsets: self.contentInsets,
minSize: self.minSize,
hitTestEdgeInsets: hitTestEdgeInsets,
tag: self.tag,
@@ -90,6 +97,7 @@ public final class Button: Component {
public func withIsExclusive(_ isExclusive: Bool) -> Button {
return Button(
content: self.content,
contentInsets: self.contentInsets,
minSize: self.minSize,
hitTestEdgeInsets: self.hitTestEdgeInsets,
tag: self.tag,
@@ -106,6 +114,7 @@ public final class Button: Component {
public func withHoldAction(_ holdAction: ((UIView) -> Void)?) -> Button {
return Button(
content: self.content,
contentInsets: self.contentInsets,
minSize: self.minSize,
hitTestEdgeInsets: self.hitTestEdgeInsets,
tag: self.tag,
@@ -121,6 +130,7 @@ public final class Button: Component {
public func tagged(_ tag: AnyObject) -> Button {
return Button(
content: self.content,
contentInsets: self.contentInsets,
minSize: self.minSize,
hitTestEdgeInsets: self.hitTestEdgeInsets,
tag: tag,
@@ -137,6 +147,9 @@ public final class Button: Component {
if lhs.content != rhs.content {
return false
}
if lhs.contentInsets != rhs.contentInsets {
return false
}
if lhs.minSize != rhs.minSize {
return false
}
@@ -318,6 +331,8 @@ public final class Button: Component {
size.width = max(size.width, minSize.width)
size.height = max(size.height, minSize.height)
}
size.width += component.contentInsets.left + component.contentInsets.right
size.height += component.contentInsets.top + component.contentInsets.bottom
self.component = component
@@ -6,17 +6,20 @@ public final class Image: Component {
public let tintColor: UIColor?
public let size: CGSize?
public let contentMode: UIImageView.ContentMode
public let cornerRadius: CGFloat
public init(
image: UIImage?,
tintColor: UIColor? = nil,
size: CGSize? = nil,
contentMode: UIImageView.ContentMode = .scaleToFill
contentMode: UIImageView.ContentMode = .scaleToFill,
cornerRadius: CGFloat = 0.0
) {
self.image = image
self.tintColor = tintColor
self.size = size
self.contentMode = contentMode
self.cornerRadius = cornerRadius
}
public static func ==(lhs: Image, rhs: Image) -> Bool {
@@ -32,6 +35,9 @@ public final class Image: Component {
if lhs.contentMode != rhs.contentMode {
return false
}
if lhs.cornerRadius != rhs.cornerRadius {
return false
}
return true
}
@@ -47,7 +53,9 @@ public final class Image: Component {
func update(component: Image, availableSize: CGSize, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
self.image = component.image
self.contentMode = component.contentMode
self.clipsToBounds = component.cornerRadius > 0.0
transition.setCornerRadius(layer: self.layer, cornerRadius: component.cornerRadius)
transition.setTintColor(view: self, color: component.tintColor ?? .white)
switch component.contentMode {