mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Temp
This commit is contained in:
parent
7805b4ccc0
commit
c890c13fd4
@ -209,14 +209,14 @@ static void CollectAccessibilityElementsForView(UIView *view, NSMutableArray *el
|
||||
|
||||
ASDisplayNode *node = view.asyncdisplaykit_node;
|
||||
|
||||
static Class telegramListViewClass = nil;
|
||||
static Class displayListViewClass = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
telegramListViewClass = NSClassFromString(@"Display.ListView");
|
||||
displayListViewClass = NSClassFromString(@"Display.ListView");
|
||||
});
|
||||
BOOL anySubNodeIsCollection = (nil != ASDisplayNodeFindFirstNode(node,
|
||||
^BOOL(ASDisplayNode *nodeToCheck) {
|
||||
if (telegramListViewClass != nil && [nodeToCheck isKindOfClass:telegramListViewClass]) {
|
||||
if (displayListViewClass != nil && [nodeToCheck isKindOfClass:displayListViewClass]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -31,6 +31,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
|
||||
let navigationController: NavigationController? = nil
|
||||
|
||||
init(controller: ViewController, sourceNode: ASDisplayNode?) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
|
@ -34,8 +34,6 @@ public final class PresentationContext {
|
||||
}
|
||||
}
|
||||
|
||||
weak var volumeControlStatusBarNodeView: UIView?
|
||||
|
||||
var updateIsInteractionBlocked: ((Bool) -> Void)?
|
||||
var updateHasBlocked: ((Bool) -> Void)?
|
||||
|
||||
|
@ -141,46 +141,6 @@ public func doesViewTreeDisableInteractiveTransitionGestureRecognizer(_ view: UI
|
||||
return false
|
||||
}
|
||||
|
||||
private let transitionClass: AnyClass? = NSClassFromString(encodeText("VJUsbotjujpoWjfx", -1))
|
||||
private let previewingClass: AnyClass? = NSClassFromString("UIVisualEffectView")
|
||||
private let previewingActionGroupClass: AnyClass? = NSClassFromString("UIInterfaceActionGroupView")
|
||||
private func checkIsPreviewingView(_ view: UIView) -> Bool {
|
||||
if let transitionClass = transitionClass, view.isKind(of: transitionClass) {
|
||||
for subview in view.subviews {
|
||||
if let previewingClass = previewingClass, subview.isKind(of: previewingClass) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private func applyThemeToPreviewingView(_ view: UIView, accentColor: UIColor, darkBlur: Bool) {
|
||||
if let previewingActionGroupClass = previewingActionGroupClass, view.isKind(of: previewingActionGroupClass) {
|
||||
view.tintColor = accentColor
|
||||
if darkBlur {
|
||||
applyThemeToPreviewingEffectView(view)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for subview in view.subviews {
|
||||
applyThemeToPreviewingView(subview, accentColor: accentColor, darkBlur: darkBlur)
|
||||
}
|
||||
}
|
||||
|
||||
private func applyThemeToPreviewingEffectView(_ view: UIView) {
|
||||
if let previewingClass = previewingClass, view.isKind(of: previewingClass) {
|
||||
if let view = view as? UIVisualEffectView {
|
||||
view.effect = UIBlurEffect(style: .dark)
|
||||
}
|
||||
}
|
||||
|
||||
for subview in view.subviews {
|
||||
applyThemeToPreviewingEffectView(subview)
|
||||
}
|
||||
}
|
||||
|
||||
public func getFirstResponderAndAccessoryHeight(_ view: UIView, _ accessoryHeight: CGFloat? = nil) -> (UIView?, CGFloat?) {
|
||||
if view.isFirstResponder {
|
||||
return (view, accessoryHeight)
|
||||
@ -283,7 +243,6 @@ public class Window1 {
|
||||
private var deviceMetrics: DeviceMetrics
|
||||
|
||||
private let statusBarHost: StatusBarHost?
|
||||
//private let statusBarManager: StatusBarManager?
|
||||
private let keyboardManager: KeyboardManager?
|
||||
private let keyboardViewManager: KeyboardViewManager?
|
||||
private var statusBarChangeObserver: AnyObject?
|
||||
@ -301,6 +260,7 @@ public class Window1 {
|
||||
|
||||
private let presentationContext: PresentationContext
|
||||
private let overlayPresentationContext: GlobalOverlayPresentationContext
|
||||
private let topPresentationContext: PresentationContext
|
||||
|
||||
private var tracingStatusBarsInvalidated = false
|
||||
private var shouldUpdateDeferScreenEdgeGestures = false
|
||||
@ -315,7 +275,6 @@ public class Window1 {
|
||||
public private(set) var forceInCallStatusBarText: String? = nil
|
||||
public var inCallNavigate: (() -> Void)? {
|
||||
didSet {
|
||||
//self.statusBarManager?.inCallNavigate = self.inCallNavigate
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,9 +287,6 @@ public class Window1 {
|
||||
|
||||
private var keyboardTypeChangeTimer: SwiftSignalKit.Timer?
|
||||
|
||||
//private let volumeControlStatusBar: VolumeControlStatusBar
|
||||
//private let volumeControlStatusBarNode: VolumeControlStatusBarNode
|
||||
|
||||
private var isInteractionBlocked = false
|
||||
|
||||
public init(hostView: WindowHostView, statusBarHost: StatusBarHost?) {
|
||||
@ -360,6 +316,7 @@ public class Window1 {
|
||||
self.updatingLayout = UpdatingLayout(layout: self.windowLayout, transition: .immediate)
|
||||
self.presentationContext = PresentationContext()
|
||||
self.overlayPresentationContext = GlobalOverlayPresentationContext(statusBarHost: statusBarHost, parentView: self.hostView.containerView)
|
||||
self.topPresentationContext = PresentationContext()
|
||||
|
||||
self.presentationContext.updateIsInteractionBlocked = { [weak self] value in
|
||||
self?.isInteractionBlocked = value
|
||||
@ -424,13 +381,10 @@ public class Window1 {
|
||||
})
|
||||
}
|
||||
|
||||
/*self.hostView.getAccessibilityElements = { [weak self] in
|
||||
return self?.accessibilityElements
|
||||
}*/
|
||||
|
||||
self.presentationContext.view = self.hostView.containerView
|
||||
//self.presentationContext.volumeControlStatusBarNodeView = self.volumeControlStatusBarNode.view
|
||||
self.topPresentationContext.view = self.hostView.containerView
|
||||
self.presentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics), transition: .immediate)
|
||||
self.topPresentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics), transition: .immediate)
|
||||
self.overlayPresentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics), transition: .immediate)
|
||||
|
||||
self.statusBarChangeObserver = NotificationCenter.default.addObserver(forName: UIApplication.willChangeStatusBarFrameNotification, object: nil, queue: OperationQueue.main, using: { [weak self] notification in
|
||||
@ -615,9 +569,6 @@ public class Window1 {
|
||||
}
|
||||
self.windowPanRecognizer = recognizer
|
||||
self.hostView.containerView.addGestureRecognizer(recognizer)
|
||||
|
||||
//self.hostView.containerView.addSubview(self.volumeControlStatusBar)
|
||||
//self.hostView.containerView.addSubview(self.volumeControlStatusBarNode.view)
|
||||
}
|
||||
|
||||
public required init(coder aDecoder: NSCoder) {
|
||||
@ -642,10 +593,6 @@ public class Window1 {
|
||||
}
|
||||
}
|
||||
|
||||
public func setupVolumeControlStatusBarGraphics(_ graphics: (UIImage, UIImage, UIImage)) {
|
||||
//self.volumeControlStatusBarNode.graphics = graphics
|
||||
}
|
||||
|
||||
public func setForceInCallStatusBar(_ forceInCallStatusBarText: String?, transition: ContainedViewLayoutTransition = .animated(duration: 0.3, curve: .easeInOut)) {
|
||||
if self.forceInCallStatusBarText != forceInCallStatusBarText {
|
||||
self.forceInCallStatusBarText = forceInCallStatusBarText
|
||||
@ -695,6 +642,11 @@ public class Window1 {
|
||||
if self.isInteractionBlocked {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let result = self.topPresentationContext.hitTest(view: self.hostView.containerView, point: point, with: event) {
|
||||
return result
|
||||
}
|
||||
|
||||
if let coveringView = self.coveringView, !coveringView.isHidden, coveringView.superview != nil, coveringView.frame.contains(point) {
|
||||
return coveringView.hitTest(point, with: event)
|
||||
}
|
||||
@ -828,7 +780,11 @@ public class Window1 {
|
||||
coveringView.layer.removeAnimation(forKey: "opacity")
|
||||
coveringView.layer.allowsGroupOpacity = false
|
||||
coveringView.alpha = 1.0
|
||||
self.hostView.containerView.addSubview(coveringView)
|
||||
if let controller = self.topPresentationContext.controllers.first {
|
||||
self.hostView.containerView.insertSubview(coveringView, belowSubview: controller.0.displayNode.view)
|
||||
} else {
|
||||
self.hostView.containerView.addSubview(coveringView)
|
||||
}
|
||||
if !self.windowLayout.size.width.isZero {
|
||||
coveringView.frame = CGRect(origin: CGPoint(), size: self.windowLayout.size)
|
||||
coveringView.updateLayout(self.windowLayout.size)
|
||||
@ -839,58 +795,9 @@ public class Window1 {
|
||||
}
|
||||
|
||||
private func layoutSubviews(force: Bool) {
|
||||
var hasPreview = false
|
||||
var updatedHasPreview = false
|
||||
for subview in self.hostView.eventView.subviews {
|
||||
if checkIsPreviewingView(subview) {
|
||||
applyThemeToPreviewingView(subview, accentColor: self.previewThemeAccentColor, darkBlur: self.previewThemeDarkBlur)
|
||||
hasPreview = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if hasPreview != self.cachedHasPreview {
|
||||
self.cachedHasPreview = hasPreview
|
||||
updatedHasPreview = true
|
||||
}
|
||||
|
||||
if self.tracingStatusBarsInvalidated || updatedHasPreview, let keyboardManager = keyboardManager {
|
||||
if self.tracingStatusBarsInvalidated, let keyboardManager = keyboardManager {
|
||||
self.tracingStatusBarsInvalidated = false
|
||||
|
||||
/*if self.statusBarHidden {
|
||||
statusBarManager.updateState(surfaces: [], withSafeInsets: false, forceInCallStatusBarText: nil, forceHiddenBySystemWindows: false, animated: false)
|
||||
} else {
|
||||
var statusBarSurfaces: [StatusBarSurface] = []
|
||||
for layers in self.hostView.containerView.layer.traceableLayerSurfaces(withTag: WindowTracingTags.statusBar) {
|
||||
let surface = StatusBarSurface()
|
||||
for layer in layers {
|
||||
let traceableInfo = layer.traceableInfo()
|
||||
if let statusBar = traceableInfo?.userData as? StatusBar {
|
||||
surface.addStatusBar(statusBar)
|
||||
}
|
||||
}
|
||||
statusBarSurfaces.append(surface)
|
||||
}
|
||||
self.hostView.containerView.layer.adjustTraceableLayerTransforms(CGSize())
|
||||
var animatedUpdate = false
|
||||
if let updatingLayout = self.updatingLayout {
|
||||
if case .animated = updatingLayout.transition {
|
||||
animatedUpdate = true
|
||||
}
|
||||
}
|
||||
self.cachedWindowSubviewCount = self.hostView.containerView.window?.subviews.count ?? 0
|
||||
statusBarManager.updateState(surfaces: statusBarSurfaces, withSafeInsets: !self.windowLayout.safeInsets.top.isZero, forceInCallStatusBarText: self.forceInCallStatusBarText, forceHiddenBySystemWindows: hasPreview, animated: animatedUpdate)
|
||||
}
|
||||
|
||||
var keyboardSurfaces: [KeyboardSurface] = []
|
||||
for layers in self.hostView.containerView.layer.traceableLayerSurfaces(withTag: WindowTracingTags.keyboard) {
|
||||
for layer in layers {
|
||||
if let view = layer.delegate as? UITracingLayerView {
|
||||
keyboardSurfaces.append(KeyboardSurface(host: view))
|
||||
}
|
||||
}
|
||||
}
|
||||
//keyboardManager.surfaces = keyboardSurfaces*/
|
||||
|
||||
var supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .all)
|
||||
let orientationToLock: UIInterfaceOrientationMask
|
||||
if self.windowLayout.size.width < self.windowLayout.size.height {
|
||||
@ -1085,9 +992,6 @@ public class Window1 {
|
||||
})
|
||||
}
|
||||
|
||||
//self.volumeControlStatusBarNode.frame = CGRect(origin: CGPoint(), size: self.windowLayout.size)
|
||||
//self.volumeControlStatusBarNode.updateLayout(layout: childLayout, transition: updatingLayout.transition)
|
||||
|
||||
if let coveringView = self.coveringView {
|
||||
coveringView.frame = CGRect(origin: CGPoint(), size: self.windowLayout.size)
|
||||
coveringView.updateLayout(self.windowLayout.size)
|
||||
@ -1111,7 +1015,11 @@ public class Window1 {
|
||||
self.presentationContext.present(controller, on: level, blockInteraction: blockInteraction, completion: completion)
|
||||
}
|
||||
} else {
|
||||
self.presentationContext.present(controller, on: level, blockInteraction: blockInteraction, completion: completion)
|
||||
if let controller = controller as? ViewController, controller.presentedOverCoveringView {
|
||||
self.topPresentationContext.present(controller, on: level, completion: completion)
|
||||
} else {
|
||||
self.presentationContext.present(controller, on: level, blockInteraction: blockInteraction, completion: completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1270,5 +1178,10 @@ public class Window1 {
|
||||
break
|
||||
}
|
||||
}
|
||||
for (controller, _) in self.topPresentationContext.controllers {
|
||||
if !f(controller) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,5 @@ UIImage * _Nullable applyBlurWithRadius(UIImage *image, CGFloat blurRadius, UICo
|
||||
}
|
||||
|
||||
UIImage * _Nullable applyScreenshotEffectToImage(UIImage * _Nonnull image) {
|
||||
UIColor *tintColor = [UIColor colorWithWhite:1.0f alpha:0.3f];
|
||||
return applyBlurWithRadius(image, 10.0f, tintColor, 1.8f, nil);
|
||||
return applyBlurWithRadius(image, 10.0f, nil, 1.8f, nil);
|
||||
}
|
||||
|
@ -69,6 +69,25 @@ public class MapSnapshotMediaResource: TelegramMediaResource {
|
||||
}
|
||||
}
|
||||
|
||||
public final class MapSnapshotMediaResourceRepresentation: CachedMediaResourceRepresentation {
|
||||
public let keepDuration: CachedMediaRepresentationKeepDuration = .shortLived
|
||||
|
||||
public var uniqueId: String {
|
||||
return "cached"
|
||||
}
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
public func isEqual(to: CachedMediaResourceRepresentation) -> Bool {
|
||||
if let to = to as? MapSnapshotMediaResourceRepresentation {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let TGGoogleMapsOffset: Int = 268435456
|
||||
let TGGoogleMapsRadius = Double(TGGoogleMapsOffset) / Double.pi
|
||||
|
||||
@ -85,7 +104,7 @@ private func adjustGMapLatitude(_ latitude: Double, offset: Int, zoom: Int) -> D
|
||||
return yToLatitude(latitudeToY(latitude) + t)
|
||||
}
|
||||
|
||||
public func fetchMapSnapshotResource(resource: MapSnapshotMediaResource) -> Signal<MediaResourceDataFetchResult, MediaResourceDataFetchError> {
|
||||
public func fetchMapSnapshotResource(resource: MapSnapshotMediaResource) -> Signal<CachedMediaResourceRepresentationResult, NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
@ -96,14 +115,17 @@ public func fetchMapSnapshotResource(resource: MapSnapshotMediaResource) -> Sign
|
||||
options.mapType = .standard
|
||||
options.showsPointsOfInterest = false
|
||||
options.showsBuildings = true
|
||||
options.size = CGSize(width: CGFloat(resource.width + 1), height: CGFloat(resource.height + 24))
|
||||
options.size = CGSize(width: CGFloat(resource.width + 1), height: CGFloat(resource.height + 10))
|
||||
options.scale = 2.0
|
||||
let snapshotter = MKMapSnapshotter(options: options)
|
||||
snapshotter.start(with: DispatchQueue.global(), completionHandler: { result, error in
|
||||
if let image = result?.image {
|
||||
if let data = image.jpegData(compressionQuality: 0.9) {
|
||||
subscriber.putNext(MediaResourceDataFetchResult.dataPart(resourceOffset: 0, data: data, range: 0 ..< data.count, complete: true))
|
||||
subscriber.putCompletion()
|
||||
let tempFile = TempBox.shared.tempFile(fileName: "image.jpg")
|
||||
if let _ = try? data.write(to: URL(fileURLWithPath: tempFile.path), options: .atomic) {
|
||||
subscriber.putNext(.tempFile(tempFile))
|
||||
subscriber.putCompletion()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -179,8 +179,9 @@ private final class OverlayStatusControllerImpl: ViewController, StandalonePrese
|
||||
}
|
||||
}
|
||||
|
||||
public func dismiss() {
|
||||
override public func dismiss(completion: (() -> Void)? = nil) {
|
||||
self.controllerNode.dismiss()
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,6 +191,10 @@ public final class PasscodeEntryController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
public func ensureInputFocused() {
|
||||
self.controllerNode.activateInput()
|
||||
}
|
||||
|
||||
public func requestBiometrics(force: Bool = false) {
|
||||
guard case let .enabled(data) = self.biometrics, let _ = LocalAuth.biometricAuthentication else {
|
||||
return
|
||||
|
@ -218,6 +218,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
|
||||
let navigationController: NavigationController? = nil
|
||||
|
||||
init(controller: ViewController, sourceNode: ASDisplayNode?) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
|
@ -2471,15 +2471,13 @@ public func chatAvatarGalleryPhoto(account: Account, representations: [ImageRepr
|
||||
|
||||
public func chatMapSnapshotData(account: Account, resource: MapSnapshotMediaResource) -> Signal<Data?, NoError> {
|
||||
return Signal<Data?, NoError> { subscriber in
|
||||
let fetchedDisposable = account.postbox.mediaBox.fetchedResource(resource, parameters: nil).start()
|
||||
let dataDisposable = account.postbox.mediaBox.resourceData(resource).start(next: { next in
|
||||
let dataDisposable = account.postbox.mediaBox.cachedResourceRepresentation(resource, representation: MapSnapshotMediaResourceRepresentation(), complete: true).start(next: { next in
|
||||
if next.size != 0 {
|
||||
subscriber.putNext(next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: []))
|
||||
}
|
||||
}, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
|
||||
return ActionDisposable {
|
||||
fetchedDisposable.dispose()
|
||||
dataDisposable.dispose()
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,3 @@
|
||||
//
|
||||
// SSignalKit.h
|
||||
// SSignalKit
|
||||
//
|
||||
// Created by Peter on 31/01/15.
|
||||
// Copyright (c) 2015 Telegram. All rights reserved.
|
||||
//
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <UIKit/UIKit.h>
|
||||
#else
|
||||
|
@ -44,6 +44,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
|
||||
let navigationController: NavigationController? = nil
|
||||
|
||||
init(controller: ViewController, sourceNode: ASDisplayNode?) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
|
@ -20,6 +20,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
|
||||
let navigationController: NavigationController? = nil
|
||||
|
||||
init(controller: ViewController, sourceNode: ASDisplayNode?) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
|
Loading…
x
Reference in New Issue
Block a user