mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Merge branch 'master' of gitlab.com:peter-iakovlev/Display
This commit is contained in:
commit
3c4b9ccdc1
14 changed files with 150 additions and 145 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -22,3 +22,4 @@ DerivedData
|
|||
*.dSYM.zip
|
||||
*.ipa
|
||||
*/xcuserdata/*
|
||||
Display.xcodeproj/*
|
||||
|
|
|
|||
8
BUCK
8
BUCK
|
|
@ -1,5 +1,5 @@
|
|||
load('//tools:buck_utils.bzl', 'config_with_updated_linker_flags', 'configs_with_config')
|
||||
load('//tools:buck_defs.bzl', 'combined_config', 'SHARED_CONFIGS', 'LIB_SPECIFIC_CONFIG')
|
||||
load('//tools:buck_utils.bzl', 'config_with_updated_linker_flags', 'configs_with_config', 'combined_config')
|
||||
load('//tools:buck_defs.bzl', 'SHARED_CONFIGS', 'EXTENSION_LIB_SPECIFIC_CONFIG')
|
||||
|
||||
apple_library(
|
||||
name = 'DisplayPrivate',
|
||||
|
|
@ -14,7 +14,7 @@ apple_library(
|
|||
'Display/*.h',
|
||||
], exclude = ['Display/Display.h']),
|
||||
modular = True,
|
||||
configs = configs_with_config(combined_config([SHARED_CONFIGS, LIB_SPECIFIC_CONFIG])),
|
||||
configs = configs_with_config(combined_config([SHARED_CONFIGS, EXTENSION_LIB_SPECIFIC_CONFIG])),
|
||||
compiler_flags = ['-w'],
|
||||
preprocessor_flags = ['-fobjc-arc'],
|
||||
visibility = ['//submodules/Display:Display'],
|
||||
|
|
@ -32,7 +32,7 @@ apple_library(
|
|||
srcs = glob([
|
||||
'Display/*.swift',
|
||||
]),
|
||||
configs = configs_with_config(combined_config([SHARED_CONFIGS, LIB_SPECIFIC_CONFIG])),
|
||||
configs = configs_with_config(combined_config([SHARED_CONFIGS, EXTENSION_LIB_SPECIFIC_CONFIG])),
|
||||
swift_compiler_flags = [
|
||||
'-suppress-warnings',
|
||||
'-application-extension',
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0900"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D05CC2621B69316F00E235A3"
|
||||
BuildableName = "Display.framework"
|
||||
BlueprintName = "Display"
|
||||
ReferencedContainer = "container:Display.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D05CC2621B69316F00E235A3"
|
||||
BuildableName = "Display.framework"
|
||||
BlueprintName = "Display"
|
||||
ReferencedContainer = "container:Display.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D05CC2621B69316F00E235A3"
|
||||
BuildableName = "Display.framework"
|
||||
BlueprintName = "Display"
|
||||
ReferencedContainer = "container:Display.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
|
|
@ -2,7 +2,13 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
|
||||
public enum AlertControllerThemeBackgroundType {
|
||||
case light
|
||||
case dark
|
||||
}
|
||||
|
||||
public final class AlertControllerTheme: Equatable {
|
||||
public let backgroundType: ActionSheetControllerThemeBackgroundType
|
||||
public let backgroundColor: UIColor
|
||||
public let separatorColor: UIColor
|
||||
public let highlightedItemColor: UIColor
|
||||
|
|
@ -12,7 +18,8 @@ public final class AlertControllerTheme: Equatable {
|
|||
public let destructiveColor: UIColor
|
||||
public let disabledColor: UIColor
|
||||
|
||||
public init(backgroundColor: UIColor, separatorColor: UIColor, highlightedItemColor: UIColor, primaryColor: UIColor, secondaryColor: UIColor, accentColor: UIColor, destructiveColor: UIColor, disabledColor: UIColor) {
|
||||
public init(backgroundType: ActionSheetControllerThemeBackgroundType, backgroundColor: UIColor, separatorColor: UIColor, highlightedItemColor: UIColor, primaryColor: UIColor, secondaryColor: UIColor, accentColor: UIColor, destructiveColor: UIColor, disabledColor: UIColor) {
|
||||
self.backgroundType = backgroundType
|
||||
self.backgroundColor = backgroundColor
|
||||
self.separatorColor = separatorColor
|
||||
self.highlightedItemColor = highlightedItemColor
|
||||
|
|
@ -24,6 +31,9 @@ public final class AlertControllerTheme: Equatable {
|
|||
}
|
||||
|
||||
public static func ==(lhs: AlertControllerTheme, rhs: AlertControllerTheme) -> Bool {
|
||||
if lhs.backgroundType != rhs.backgroundType {
|
||||
return false
|
||||
}
|
||||
if lhs.backgroundColor != rhs.backgroundColor {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,15 @@ import UIKit
|
|||
import AsyncDisplayKit
|
||||
|
||||
final class AlertControllerNode: ASDisplayNode {
|
||||
private let dimmingNode: ASDisplayNode
|
||||
private let centerDimView: UIImageView
|
||||
private let topDimView: UIView
|
||||
private let bottomDimView: UIView
|
||||
private let leftDimView: UIView
|
||||
private let rightDimView: UIView
|
||||
|
||||
private let containerNode: ASDisplayNode
|
||||
private let effectNode: ASDisplayNode
|
||||
private let backgroundNode: ASDisplayNode
|
||||
private let contentNode: AlertContentNode
|
||||
private let allowInputInset: Bool
|
||||
|
||||
|
|
@ -15,27 +21,51 @@ final class AlertControllerNode: ASDisplayNode {
|
|||
|
||||
init(contentNode: AlertContentNode, theme: AlertControllerTheme, allowInputInset: Bool) {
|
||||
self.allowInputInset = allowInputInset
|
||||
self.dimmingNode = ASDisplayNode()
|
||||
self.dimmingNode.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
|
||||
|
||||
let dimColor = UIColor(white: 0.0, alpha: 0.5)
|
||||
|
||||
self.centerDimView = UIImageView()
|
||||
self.centerDimView.image = generateStretchableFilledCircleImage(radius: 16.0, color: nil, backgroundColor: dimColor)
|
||||
|
||||
self.topDimView = UIView()
|
||||
self.topDimView.backgroundColor = dimColor
|
||||
self.topDimView.isUserInteractionEnabled = false
|
||||
|
||||
self.bottomDimView = UIView()
|
||||
self.bottomDimView.backgroundColor = dimColor
|
||||
self.bottomDimView.isUserInteractionEnabled = false
|
||||
|
||||
self.leftDimView = UIView()
|
||||
self.leftDimView.backgroundColor = dimColor
|
||||
self.leftDimView.isUserInteractionEnabled = false
|
||||
|
||||
self.rightDimView = UIView()
|
||||
self.rightDimView.backgroundColor = dimColor
|
||||
self.rightDimView.isUserInteractionEnabled = false
|
||||
|
||||
self.containerNode = ASDisplayNode()
|
||||
self.containerNode.backgroundColor = theme.backgroundColor
|
||||
self.containerNode.layer.cornerRadius = 14.0
|
||||
self.containerNode.layer.masksToBounds = true
|
||||
|
||||
self.backgroundNode = ASDisplayNode()
|
||||
self.backgroundNode.backgroundColor = theme.backgroundColor
|
||||
|
||||
self.effectNode = ASDisplayNode(viewBlock: {
|
||||
let view = UIView()
|
||||
return view
|
||||
return UIVisualEffectView(effect: UIBlurEffect(style: theme.backgroundType == .light ? .light : .dark))
|
||||
})
|
||||
|
||||
self.contentNode = contentNode
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.dimmingNode)
|
||||
|
||||
self.addSubnode(self.effectNode)
|
||||
self.view.addSubview(self.centerDimView)
|
||||
self.view.addSubview(self.topDimView)
|
||||
self.view.addSubview(self.bottomDimView)
|
||||
self.view.addSubview(self.leftDimView)
|
||||
self.view.addSubview(self.rightDimView)
|
||||
|
||||
self.containerNode.addSubnode(self.effectNode)
|
||||
self.containerNode.addSubnode(self.backgroundNode)
|
||||
self.containerNode.addSubnode(self.contentNode)
|
||||
self.addSubnode(self.containerNode)
|
||||
|
||||
|
|
@ -49,22 +79,34 @@ final class AlertControllerNode: ASDisplayNode {
|
|||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.dimmingNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimmingNodeTapGesture(_:))))
|
||||
self.topDimView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimmingNodeTapGesture(_:))))
|
||||
self.bottomDimView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimmingNodeTapGesture(_:))))
|
||||
}
|
||||
|
||||
func updateTheme(_ theme: AlertControllerTheme) {
|
||||
if let effectView = self.effectNode.view as? UIVisualEffectView {
|
||||
effectView.effect = UIBlurEffect(style: theme.backgroundType == .light ? .light : .dark)
|
||||
}
|
||||
self.containerNode.backgroundColor = theme.backgroundColor
|
||||
self.contentNode.updateTheme(theme)
|
||||
}
|
||||
|
||||
func animateIn() {
|
||||
self.dimmingNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.centerDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.topDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.bottomDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.leftDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.rightDimView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.containerNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
|
||||
self.containerNode.layer.animateSpring(from: 0.8 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.5, initialVelocity: 0.0, removeOnCompletion: true, additive: false, completion: nil)
|
||||
}
|
||||
|
||||
func animateOut(completion: @escaping () -> Void) {
|
||||
self.dimmingNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.centerDimView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.topDimView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.bottomDimView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.leftDimView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.rightDimView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
|
||||
self.containerNode.layer.animateScale(from: 1.0, to: 0.8, duration: 0.4, removeOnCompletion: false, completion: { _ in
|
||||
completion()
|
||||
|
|
@ -74,8 +116,6 @@ final class AlertControllerNode: ASDisplayNode {
|
|||
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
self.containerLayout = layout
|
||||
|
||||
transition.updateFrame(node: self.dimmingNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||
|
||||
var insetOptions: ContainerViewLayoutInsetOptions = [.statusBar]
|
||||
if self.allowInputInset {
|
||||
insetOptions.insert(.input)
|
||||
|
|
@ -89,8 +129,15 @@ final class AlertControllerNode: ASDisplayNode {
|
|||
let containerSize = CGSize(width: contentSize.width, height: contentSize.height)
|
||||
let containerFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - containerSize.width) / 2.0), y: contentAvailableFrame.minY + floor((contentAvailableFrame.size.height - containerSize.height) / 2.0)), size: containerSize)
|
||||
|
||||
transition.updateFrame(view: self.centerDimView, frame: containerFrame)
|
||||
transition.updateFrame(view: self.topDimView, frame: CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: containerFrame.minY)))
|
||||
transition.updateFrame(view: self.bottomDimView, frame: CGRect(origin: CGPoint(x: 0.0, y: containerFrame.maxY), size: CGSize(width: layout.size.width, height: layout.size.height - containerFrame.maxY)))
|
||||
transition.updateFrame(view: self.leftDimView, frame: CGRect(origin: CGPoint(x: 0.0, y: containerFrame.minY), size: CGSize(width: containerFrame.minX, height: containerFrame.height)))
|
||||
transition.updateFrame(view: self.rightDimView, frame: CGRect(origin: CGPoint(x: containerFrame.maxX, y: containerFrame.minY), size: CGSize(width: layout.size.width - containerFrame.maxX, height: containerFrame.height)))
|
||||
|
||||
transition.updateFrame(node: self.containerNode, frame: containerFrame)
|
||||
transition.updateFrame(node: self.effectNode, frame: containerFrame)
|
||||
transition.updateFrame(node: self.effectNode, frame: CGRect(origin: CGPoint(), size: containerFrame.size))
|
||||
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: containerFrame.size))
|
||||
transition.updateFrame(node: self.contentNode, frame: CGRect(origin: CGPoint(), size: containerFrame.size))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ public enum ImpactHapticFeedbackStyle: Hashable {
|
|||
case heavy
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 10.0, *)
|
||||
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
|
||||
private final class HapticFeedbackImpl {
|
||||
private lazy var impactGenerator: [ImpactHapticFeedbackStyle : UIImpactFeedbackGenerator] = {
|
||||
[.light: UIImpactFeedbackGenerator(style: .light),
|
||||
|
|
@ -65,7 +65,7 @@ public final class HapticFeedback {
|
|||
})
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 10.0, *)
|
||||
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
|
||||
private func withImpl(_ f: (HapticFeedbackImpl) -> Void) {
|
||||
if self.impl == nil {
|
||||
self.impl = HapticFeedbackImpl()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public final class PreviewingHostViewDelegate {
|
|||
}
|
||||
|
||||
public protocol PreviewingHostView {
|
||||
@available(iOSApplicationExtension 9.0, *)
|
||||
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
|
||||
var previewingDelegate: PreviewingHostViewDelegate? { get }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -803,7 +803,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||
|
||||
let appliedLayout = controllerLayout.withUpdatedInputHeight(controller.hasActiveInput ? controllerLayout.inputHeight : nil)
|
||||
controller.containerLayoutUpdated(appliedLayout, transition: .immediate)
|
||||
strongSelf.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { _ in
|
||||
strongSelf.currentPushDisposable.set((controller.ready.get()
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)).start(next: { _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
|
@ -848,7 +850,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||
controllerLayout.inputHeight = nil
|
||||
controller.containerLayoutUpdated(controllerLayout, transition: .immediate)
|
||||
}
|
||||
self.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { [weak self] _ in
|
||||
self.currentPushDisposable.set((controller.ready.get()
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)).start(next: { [weak self] _ in
|
||||
if let strongSelf = self {
|
||||
ready?.set(true)
|
||||
var controllers = strongSelf.viewControllers
|
||||
|
|
@ -877,7 +881,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||
controllerLayout.inputHeight = nil
|
||||
controller.containerLayoutUpdated(controllerLayout, transition: .immediate)
|
||||
}
|
||||
strongSelf.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { _ in
|
||||
strongSelf.currentPushDisposable.set((controller.ready.get()
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)).start(next: { _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
|
@ -901,7 +907,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||
controllerLayout.inputHeight = nil
|
||||
controller.containerLayoutUpdated(controllerLayout, transition: .immediate)
|
||||
}
|
||||
strongSelf.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { _ in
|
||||
strongSelf.currentPushDisposable.set((controller.ready.get()
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)).start(next: { _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
|
||||
private let alertWidth: CGFloat = 270.0
|
||||
|
||||
public enum TextAlertActionType {
|
||||
case genericAction
|
||||
case defaultAction
|
||||
|
|
@ -20,18 +22,20 @@ public struct TextAlertAction {
|
|||
}
|
||||
}
|
||||
|
||||
private final class TextAlertContentActionNode: HighlightableButtonNode {
|
||||
private let backgroundNode: ASDisplayNode
|
||||
|
||||
public final class TextAlertContentActionNode: HighlightableButtonNode {
|
||||
private var theme: AlertControllerTheme
|
||||
let action: TextAlertAction
|
||||
|
||||
init(theme: AlertControllerTheme, action: TextAlertAction) {
|
||||
private let backgroundNode: ASDisplayNode
|
||||
|
||||
public init(theme: AlertControllerTheme, action: TextAlertAction) {
|
||||
self.theme = theme
|
||||
self.action = action
|
||||
|
||||
self.backgroundNode = ASDisplayNode()
|
||||
self.backgroundNode.isLayerBacked = true
|
||||
self.backgroundNode.alpha = 0.0
|
||||
|
||||
self.action = action
|
||||
|
||||
super.init()
|
||||
|
||||
self.titleNode.maximumNumberOfLines = 2
|
||||
|
|
@ -54,16 +58,27 @@ private final class TextAlertContentActionNode: HighlightableButtonNode {
|
|||
self.updateTheme(theme)
|
||||
}
|
||||
|
||||
func updateTheme(_ theme: AlertControllerTheme) {
|
||||
public var actionEnabled: Bool = true {
|
||||
didSet {
|
||||
self.isUserInteractionEnabled = self.actionEnabled
|
||||
self.updateTitle()
|
||||
}
|
||||
}
|
||||
|
||||
public func updateTheme(_ theme: AlertControllerTheme) {
|
||||
self.theme = theme
|
||||
self.backgroundNode.backgroundColor = theme.highlightedItemColor
|
||||
|
||||
self.updateTitle()
|
||||
}
|
||||
|
||||
private func updateTitle() {
|
||||
var font = Font.regular(17.0)
|
||||
var color = theme.accentColor
|
||||
var color: UIColor
|
||||
switch self.action.type {
|
||||
case .defaultAction, .genericAction:
|
||||
break
|
||||
color = self.actionEnabled ? self.theme.accentColor : self.theme.disabledColor
|
||||
case .destructiveAction:
|
||||
color = theme.destructiveColor
|
||||
color = self.actionEnabled ? self.theme.destructiveColor : self.theme.disabledColor
|
||||
}
|
||||
switch self.action.type {
|
||||
case .defaultAction:
|
||||
|
|
@ -74,7 +89,7 @@ private final class TextAlertContentActionNode: HighlightableButtonNode {
|
|||
self.setAttributedTitle(NSAttributedString(string: self.action.title, font: font, textColor: color, paragraphAlignment: .center), for: [])
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
override public func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.addTarget(self, action: #selector(self.pressed), forControlEvents: .touchUpInside)
|
||||
|
|
@ -84,7 +99,7 @@ private final class TextAlertContentActionNode: HighlightableButtonNode {
|
|||
self.action.action()
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
override public func layout() {
|
||||
super.layout()
|
||||
|
||||
self.backgroundNode.frame = self.bounds
|
||||
|
|
@ -201,16 +216,17 @@ public final class TextAlertContentNode: AlertContentNode {
|
|||
override public func updateTheme(_ theme: AlertControllerTheme) {
|
||||
self.theme = theme
|
||||
|
||||
let textFont: UIFont
|
||||
if let titleNode = self.titleNode {
|
||||
titleNode.attributedText = NSAttributedString(string: titleNode.attributedText?.string ?? "", font: Font.medium(17.0), textColor: theme.primaryColor, paragraphAlignment: .center)
|
||||
textFont = Font.regular(13.0)
|
||||
} else {
|
||||
textFont = Font.semibold(17.0)
|
||||
if let titleNode = self.titleNode, let attributedText = titleNode.attributedText {
|
||||
let updatedText = NSMutableAttributedString(attributedString: attributedText)
|
||||
updatedText.addAttribute(NSAttributedStringKey.foregroundColor, value: theme.primaryColor, range: NSRange(location: 0, length: updatedText.length))
|
||||
titleNode.attributedText = updatedText
|
||||
}
|
||||
|
||||
self.textNode.attributedText = NSAttributedString(string: self.textNode.attributedText?.string ?? "", font: textFont, textColor: theme.primaryColor, paragraphAlignment: .center)
|
||||
|
||||
if let attributedText = self.textNode.attributedText {
|
||||
let updatedText = NSMutableAttributedString(attributedString: attributedText)
|
||||
updatedText.addAttribute(NSAttributedStringKey.foregroundColor, value: theme.primaryColor, range: NSRange(location: 0, length: updatedText.length))
|
||||
self.textNode.attributedText = updatedText
|
||||
}
|
||||
|
||||
self.actionNodesSeparator.backgroundColor = theme.separatorColor
|
||||
for actionNode in self.actionNodes {
|
||||
actionNode.updateTheme(theme)
|
||||
|
|
@ -229,6 +245,9 @@ public final class TextAlertContentNode: AlertContentNode {
|
|||
|
||||
let insets = UIEdgeInsets(top: 18.0, left: 18.0, bottom: 18.0, right: 18.0)
|
||||
|
||||
var size = size
|
||||
size.width = min(size.width, alertWidth)
|
||||
|
||||
var titleSize: CGSize?
|
||||
if let titleNode = self.titleNode {
|
||||
titleSize = titleNode.measure(CGSize(width: size.width - insets.left - insets.right, height: CGFloat.greatestFiniteMagnitude))
|
||||
|
|
@ -265,10 +284,8 @@ public final class TextAlertContentNode: AlertContentNode {
|
|||
actionsHeight = actionButtonHeight * CGFloat(self.actionNodes.count)
|
||||
}
|
||||
|
||||
if let titleNode = titleNode, let titleSize = titleSize {
|
||||
var contentWidth = max(max(titleSize.width, textSize.width), minActionsWidth)
|
||||
contentWidth = max(contentWidth, 150.0)
|
||||
|
||||
let contentWidth = alertWidth - insets.left - insets.right
|
||||
if let titleNode = self.titleNode, let titleSize = titleSize {
|
||||
let spacing: CGFloat = 6.0
|
||||
let titleFrame = CGRect(origin: CGPoint(x: insets.left + floor((contentWidth - titleSize.width) / 2.0), y: insets.top), size: titleSize)
|
||||
transition.updateFrame(node: titleNode, frame: titleFrame)
|
||||
|
|
@ -278,9 +295,6 @@ public final class TextAlertContentNode: AlertContentNode {
|
|||
|
||||
resultSize = CGSize(width: contentWidth + insets.left + insets.right, height: titleSize.height + spacing + textSize.height + actionsHeight + insets.top + insets.bottom)
|
||||
} else {
|
||||
var contentWidth = max(textSize.width, minActionsWidth)
|
||||
contentWidth = max(contentWidth, 150.0)
|
||||
|
||||
let textFrame = CGRect(origin: CGPoint(x: insets.left + floor((contentWidth - textSize.width) / 2.0), y: insets.top), size: textSize)
|
||||
transition.updateFrame(node: self.textNode, frame: textFrame)
|
||||
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ open class ViewControllerPresentationArguments {
|
|||
open func dismiss(completion: (() -> Void)? = nil) {
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 9.0, *)
|
||||
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
|
||||
open func registerForPreviewing(with delegate: UIViewControllerPreviewingDelegate, sourceView: UIView, theme: PeekControllerTheme, onlyNative: Bool) {
|
||||
if self.traitCollection.forceTouchCapability == .available {
|
||||
let _ = super.registerForPreviewing(with: delegate, sourceView: sourceView)
|
||||
|
|
@ -455,7 +455,7 @@ open class ViewControllerPresentationArguments {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 9.0, *)
|
||||
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
|
||||
public func registerForPreviewingNonNative(with delegate: UIViewControllerPreviewingDelegate, sourceView: UIView, theme: PeekControllerTheme) {
|
||||
if self.traitCollection.forceTouchCapability != .available {
|
||||
if self.previewingContext == nil {
|
||||
|
|
@ -467,7 +467,7 @@ open class ViewControllerPresentationArguments {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 9.0, *)
|
||||
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
|
||||
open override func unregisterForPreviewing(withContext previewing: UIViewControllerPreviewing) {
|
||||
if self.previewingContext != nil {
|
||||
self.previewingContext = nil
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import UIKit
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
|
||||
@available(iOSApplicationExtension 9.0, *)
|
||||
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
|
||||
private final class ViewControllerPeekContent: PeekControllerContent {
|
||||
private let controller: ViewController
|
||||
private let menu: [PeekControllerMenuItem]
|
||||
|
|
@ -85,7 +85,7 @@ private final class ViewControllerPeekContentNode: ASDisplayNode, PeekController
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 9.0, *)
|
||||
@available(iOSApplicationExtension 9.0, iOS 9.0, *)
|
||||
final class SimulatedViewControllerPreviewing: NSObject, UIViewControllerPreviewing {
|
||||
weak var delegateImpl: UIViewControllerPreviewingDelegate?
|
||||
var delegate: UIViewControllerPreviewingDelegate {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,13 @@ private let volumeParameterKey = "AVSystemController_AudioVolumeNotificationPara
|
|||
private let changeReasonParameterKey = "AVSystemController_AudioVolumeChangeReasonNotificationParameter"
|
||||
private let explicitChangeReasonValue = "ExplicitVolumeChange"
|
||||
|
||||
private final class VolumeView: MPVolumeView {
|
||||
@objc func _updateWirelessRouteStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
final class VolumeControlStatusBar: UIView {
|
||||
private let control: MPVolumeView
|
||||
private let control: VolumeView
|
||||
private var observer: Any?
|
||||
private var currentValue: Float
|
||||
|
||||
|
|
@ -20,7 +25,7 @@ final class VolumeControlStatusBar: UIView {
|
|||
private var ignoreAdjustmentOnce = false
|
||||
|
||||
init(frame: CGRect, shouldBeVisible: Signal<Bool, NoError>) {
|
||||
self.control = MPVolumeView(frame: CGRect(origin: CGPoint(x: -100.0, y: -100.0), size: CGSize(width: 100.0, height: 20.0)))
|
||||
self.control = VolumeView(frame: CGRect(origin: CGPoint(x: -100.0, y: -100.0), size: CGSize(width: 100.0, height: 20.0)))
|
||||
self.control.alpha = 0.0001
|
||||
self.currentValue = AVAudioSession.sharedInstance().outputVolume
|
||||
|
||||
|
|
|
|||
|
|
@ -817,7 +817,7 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = D05CC25D1B69316F00E235A3 /* Build configuration list for PBXProject "Display" */;
|
||||
buildConfigurationList = D05CC25D1B69316F00E235A3 /* Build configuration list for PBXProject "Display_Xcode" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
|
|
@ -1708,7 +1708,7 @@
|
|||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
D05CC25D1B69316F00E235A3 /* Build configuration list for PBXProject "Display" */ = {
|
||||
D05CC25D1B69316F00E235A3 /* Build configuration list for PBXProject "Display_Xcode" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D05CC2751B69316F00E235A3 /* DebugHockeyapp */,
|
||||
Loading…
Add table
Add a link
Reference in a new issue