mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-11 08:50:24 +00:00
no message
This commit is contained in:
parent
2e9350d717
commit
9a84348e22
@ -1,82 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
LastUpgradeVersion = "0920"
|
|
||||||
version = "1.3">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES">
|
|
||||||
<BuildActionEntries>
|
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "YES"
|
|
||||||
buildForArchiving = "YES"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "D01159B61F40E96B0039383E"
|
|
||||||
BuildableName = "DisplayMac.framework"
|
|
||||||
BlueprintName = "DisplayMac"
|
|
||||||
ReferencedContainer = "container:Display.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
buildConfiguration = "Debug Hockeyapp"
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
language = ""
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
||||||
<Testables>
|
|
||||||
</Testables>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</TestAction>
|
|
||||||
<LaunchAction
|
|
||||||
buildConfiguration = "Debug Hockeyapp"
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
language = ""
|
|
||||||
launchStyle = "0"
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
|
||||||
debugDocumentVersioning = "YES"
|
|
||||||
debugServiceExtension = "internal"
|
|
||||||
allowLocationSimulation = "YES">
|
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "D01159B61F40E96B0039383E"
|
|
||||||
BuildableName = "DisplayMac.framework"
|
|
||||||
BlueprintName = "DisplayMac"
|
|
||||||
ReferencedContainer = "container:Display.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
buildConfiguration = "Release Hockeyapp"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
debugDocumentVersioning = "YES">
|
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "D01159B61F40E96B0039383E"
|
|
||||||
BuildableName = "DisplayMac.framework"
|
|
||||||
BlueprintName = "DisplayMac"
|
|
||||||
ReferencedContainer = "container:Display.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug Hockeyapp">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release Hockeyapp"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Scheme
|
|
||||||
LastUpgradeVersion = "0900"
|
|
||||||
version = "1.3">
|
|
||||||
<BuildAction
|
|
||||||
parallelizeBuildables = "YES"
|
|
||||||
buildImplicitDependencies = "YES">
|
|
||||||
</BuildAction>
|
|
||||||
<TestAction
|
|
||||||
buildConfiguration = "Debug"
|
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
||||||
<Testables>
|
|
||||||
<TestableReference
|
|
||||||
skipped = "NO">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "D05CC26C1B69316F00E235A3"
|
|
||||||
BuildableName = "DisplayTests.xctest"
|
|
||||||
BlueprintName = "DisplayTests"
|
|
||||||
ReferencedContainer = "container:Display.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</TestableReference>
|
|
||||||
</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">
|
|
||||||
<AdditionalOptions>
|
|
||||||
</AdditionalOptions>
|
|
||||||
</LaunchAction>
|
|
||||||
<ProfileAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
||||||
savedToolIdentifier = ""
|
|
||||||
useCustomWorkingDirectory = "NO"
|
|
||||||
debugDocumentVersioning = "YES">
|
|
||||||
</ProfileAction>
|
|
||||||
<AnalyzeAction
|
|
||||||
buildConfiguration = "Debug">
|
|
||||||
</AnalyzeAction>
|
|
||||||
<ArchiveAction
|
|
||||||
buildConfiguration = "Release"
|
|
||||||
revealArchiveInOrganizer = "YES">
|
|
||||||
</ArchiveAction>
|
|
||||||
</Scheme>
|
|
||||||
@ -7,17 +7,7 @@
|
|||||||
<key>Display.xcscheme</key>
|
<key>Display.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>6</integer>
|
<integer>4</integer>
|
||||||
</dict>
|
|
||||||
<key>DisplayMac.xcscheme</key>
|
|
||||||
<dict>
|
|
||||||
<key>orderHint</key>
|
|
||||||
<integer>25</integer>
|
|
||||||
</dict>
|
|
||||||
<key>DisplayTests.xcscheme</key>
|
|
||||||
<dict>
|
|
||||||
<key>orderHint</key>
|
|
||||||
<integer>8</integer>
|
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
|||||||
@ -11,7 +11,20 @@ private let defaultOrientations: UIInterfaceOrientationMask = {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
private class WindowRootViewController: UIViewController {
|
private final class WindowRootViewControllerView: UIView {
|
||||||
|
override var frame: CGRect {
|
||||||
|
get {
|
||||||
|
return super.frame
|
||||||
|
} set(value) {
|
||||||
|
var value = value
|
||||||
|
value.size.height += value.minY
|
||||||
|
value.origin.y = 0.0
|
||||||
|
super.frame = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class WindowRootViewController: UIViewController {
|
||||||
var presentController: ((UIViewController, PresentationSurfaceLevel, Bool, (() -> Void)?) -> Void)?
|
var presentController: ((UIViewController, PresentationSurfaceLevel, Bool, (() -> Void)?) -> Void)?
|
||||||
var transitionToSize: ((CGSize, Double) -> Void)?
|
var transitionToSize: ((CGSize, Double) -> Void)?
|
||||||
|
|
||||||
@ -62,6 +75,16 @@ private class WindowRootViewController: UIViewController {
|
|||||||
return orientations
|
return orientations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
||||||
|
self.extendedLayoutIncludesOpaqueBars = true
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
|
override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
|
||||||
return self.gestureEdges
|
return self.gestureEdges
|
||||||
}
|
}
|
||||||
@ -78,7 +101,7 @@ private class WindowRootViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func loadView() {
|
override func loadView() {
|
||||||
self.view = UIView()
|
self.view = WindowRootViewControllerView()
|
||||||
self.view.isOpaque = false
|
self.view.isOpaque = false
|
||||||
self.view.backgroundColor = nil
|
self.view.backgroundColor = nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,15 +25,43 @@ public enum TextNodeCutoutPosition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct TextNodeCutout: Equatable {
|
public struct TextNodeCutout: Equatable {
|
||||||
public let position: TextNodeCutoutPosition
|
public var topLeft: CGSize?
|
||||||
public let size: CGSize
|
public var topRight: CGSize?
|
||||||
|
public var bottomRight: CGSize?
|
||||||
|
|
||||||
public init(position: TextNodeCutoutPosition, size: CGSize) {
|
public init(topLeft: CGSize? = nil, topRight: CGSize? = nil, bottomRight: CGSize? = nil) {
|
||||||
self.position = position
|
self.topLeft = topLeft
|
||||||
self.size = size
|
self.topRight = topRight
|
||||||
|
self.bottomRight = bottomRight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func displayLineFrame(frame: CGRect, isRTL: Bool, boundingRect: CGRect, cutout: TextNodeCutout?) -> CGRect {
|
||||||
|
if frame.width.isEqual(to: boundingRect.width) {
|
||||||
|
return frame
|
||||||
|
}
|
||||||
|
var lineFrame = frame
|
||||||
|
let intersectionFrame = lineFrame.offsetBy(dx: 0.0, dy: -lineFrame.height)
|
||||||
|
if isRTL {
|
||||||
|
lineFrame.origin.x = max(0.0, floor(boundingRect.width - lineFrame.size.width))
|
||||||
|
if let topRight = cutout?.topRight {
|
||||||
|
let topRightRect = CGRect(origin: CGPoint(x: boundingRect.width - topRight.width, y: 0.0), size: topRight)
|
||||||
|
if intersectionFrame.intersects(topRightRect) {
|
||||||
|
lineFrame.origin.x -= topRight.width
|
||||||
|
return lineFrame
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let bottomRight = cutout?.bottomRight {
|
||||||
|
let bottomRightRect = CGRect(origin: CGPoint(x: boundingRect.width - bottomRight.width, y: boundingRect.height - bottomRight.height), size: bottomRight)
|
||||||
|
if intersectionFrame.intersects(bottomRightRect) {
|
||||||
|
lineFrame.origin.x -= bottomRight.width
|
||||||
|
return lineFrame
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lineFrame
|
||||||
|
}
|
||||||
|
|
||||||
public final class TextNodeLayoutArguments {
|
public final class TextNodeLayoutArguments {
|
||||||
public let attributedString: NSAttributedString?
|
public let attributedString: NSAttributedString?
|
||||||
public let backgroundColor: UIColor?
|
public let backgroundColor: UIColor?
|
||||||
@ -111,7 +139,6 @@ public final class TextNodeLayout: NSObject {
|
|||||||
if let attributedString = self.attributedString {
|
if let attributedString = self.attributedString {
|
||||||
let transformedPoint = CGPoint(x: point.x - self.insets.left, y: point.y - self.insets.top)
|
let transformedPoint = CGPoint(x: point.x - self.insets.left, y: point.y - self.insets.top)
|
||||||
var lineIndex = -1
|
var lineIndex = -1
|
||||||
let lineCount = self.lines.count
|
|
||||||
for line in self.lines {
|
for line in self.lines {
|
||||||
lineIndex += 1
|
lineIndex += 1
|
||||||
var lineFrame = CGRect(origin: CGPoint(x: line.frame.origin.x, y: line.frame.origin.y - line.frame.size.height + self.firstLineOffset), size: line.frame.size)
|
var lineFrame = CGRect(origin: CGPoint(x: line.frame.origin.x, y: line.frame.origin.y - line.frame.size.height + self.firstLineOffset), size: line.frame.size)
|
||||||
@ -120,11 +147,9 @@ public final class TextNodeLayout: NSObject {
|
|||||||
lineFrame.origin.x = floor((self.size.width - lineFrame.size.width) / 2.0)
|
lineFrame.origin.x = floor((self.size.width - lineFrame.size.width) / 2.0)
|
||||||
case .natural:
|
case .natural:
|
||||||
if line.isRTL {
|
if line.isRTL {
|
||||||
lineFrame.origin.x = floor(self.size.width - lineFrame.size.width)
|
lineFrame.origin.x = self.size.width - lineFrame.size.width
|
||||||
if lineIndex == lineCount - 1, let cutout = self.cutout, case .BottomRight = cutout.position {
|
|
||||||
lineFrame.origin.x -= cutout.size.width
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: self.size), cutout: self.cutout)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -155,10 +180,8 @@ public final class TextNodeLayout: NSObject {
|
|||||||
case .natural:
|
case .natural:
|
||||||
if line.isRTL {
|
if line.isRTL {
|
||||||
lineFrame.origin.x = floor(self.size.width - lineFrame.size.width)
|
lineFrame.origin.x = floor(self.size.width - lineFrame.size.width)
|
||||||
if lineIndex == lineCount - 1, let cutout = self.cutout, case .BottomRight = cutout.position {
|
|
||||||
lineFrame.origin.x -= cutout.size.width
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: self.size), cutout: self.cutout)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -208,10 +231,7 @@ public final class TextNodeLayout: NSObject {
|
|||||||
let _ = attributedString.attribute(NSAttributedStringKey(rawValue: name), at: index, effectiveRange: &range)
|
let _ = attributedString.attribute(NSAttributedStringKey(rawValue: name), at: index, effectiveRange: &range)
|
||||||
if range.length != 0 {
|
if range.length != 0 {
|
||||||
var rects: [(CGRect, CGRect)] = []
|
var rects: [(CGRect, CGRect)] = []
|
||||||
var lineIndex = -1
|
|
||||||
let lineCount = self.lines.count
|
|
||||||
for line in self.lines {
|
for line in self.lines {
|
||||||
lineIndex += 1
|
|
||||||
let lineRange = NSIntersectionRange(range, line.range)
|
let lineRange = NSIntersectionRange(range, line.range)
|
||||||
if lineRange.length != 0 {
|
if lineRange.length != 0 {
|
||||||
var leftOffset: CGFloat = 0.0
|
var leftOffset: CGFloat = 0.0
|
||||||
@ -220,12 +240,17 @@ public final class TextNodeLayout: NSObject {
|
|||||||
}
|
}
|
||||||
var rightOffset: CGFloat = line.frame.width
|
var rightOffset: CGFloat = line.frame.width
|
||||||
if lineRange.location + lineRange.length != line.range.length {
|
if lineRange.location + lineRange.length != line.range.length {
|
||||||
rightOffset = ceil(CTLineGetOffsetForStringIndex(line.line, lineRange.location + lineRange.length, nil))
|
var secondaryOffset: CGFloat = 0.0
|
||||||
|
let rawOffset = CTLineGetOffsetForStringIndex(line.line, lineRange.location + lineRange.length, &secondaryOffset)
|
||||||
|
rightOffset = ceil(rawOffset)
|
||||||
|
if !rawOffset.isEqual(to: secondaryOffset) {
|
||||||
|
rightOffset = ceil(secondaryOffset)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var lineFrame = CGRect(origin: CGPoint(x: line.frame.origin.x, y: line.frame.origin.y - line.frame.size.height + self.firstLineOffset), size: line.frame.size)
|
var lineFrame = CGRect(origin: CGPoint(x: line.frame.origin.x, y: line.frame.origin.y - line.frame.size.height + self.firstLineOffset), size: line.frame.size)
|
||||||
if lineIndex == lineCount - 1, let cutout = self.cutout, case .BottomRight = cutout.position {
|
|
||||||
lineFrame.origin.x -= cutout.size.width
|
lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: self.size), cutout: self.cutout)
|
||||||
}
|
|
||||||
rects.append((lineFrame, CGRect(origin: CGPoint(x: lineFrame.minX + leftOffset + self.insets.left, y: lineFrame.minY + self.insets.top), size: CGSize(width: rightOffset - leftOffset, height: lineFrame.size.height))))
|
rects.append((lineFrame, CGRect(origin: CGPoint(x: lineFrame.minX + leftOffset + self.insets.left, y: lineFrame.minY + self.insets.top), size: CGSize(width: rightOffset - leftOffset, height: lineFrame.size.height))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,14 +340,26 @@ public class TextNode: ASDisplayNode {
|
|||||||
var cutoutMaxY: CGFloat = 0.0
|
var cutoutMaxY: CGFloat = 0.0
|
||||||
var cutoutWidth: CGFloat = 0.0
|
var cutoutWidth: CGFloat = 0.0
|
||||||
var cutoutOffset: CGFloat = 0.0
|
var cutoutOffset: CGFloat = 0.0
|
||||||
if let cutout = cutout {
|
|
||||||
|
var bottomCutoutEnabled = false
|
||||||
|
var bottomCutoutSize = CGSize()
|
||||||
|
|
||||||
|
if let topLeft = cutout?.topLeft {
|
||||||
cutoutMinY = -fontLineSpacing
|
cutoutMinY = -fontLineSpacing
|
||||||
cutoutMaxY = cutout.size.height + fontLineSpacing
|
cutoutMaxY = topLeft.height + fontLineSpacing
|
||||||
cutoutWidth = cutout.size.width
|
cutoutWidth = topLeft.width
|
||||||
if case .TopLeft = cutout.position {
|
cutoutOffset = cutoutWidth
|
||||||
cutoutOffset = cutoutWidth
|
|
||||||
}
|
|
||||||
cutoutEnabled = true
|
cutoutEnabled = true
|
||||||
|
} else if let topRight = cutout?.topRight {
|
||||||
|
cutoutMinY = -fontLineSpacing
|
||||||
|
cutoutMaxY = topRight.height + fontLineSpacing
|
||||||
|
cutoutWidth = topRight.width
|
||||||
|
cutoutEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if let bottomRight = cutout?.bottomRight {
|
||||||
|
bottomCutoutSize = bottomRight
|
||||||
|
bottomCutoutEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
let firstLineOffset = floorToScreenPixels(fontDescent)
|
let firstLineOffset = floorToScreenPixels(fontDescent)
|
||||||
@ -437,6 +474,10 @@ public class TextNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !lines.isEmpty && bottomCutoutEnabled {
|
||||||
|
layoutSize.width = max(layoutSize.width, lines[lines.count - 1].frame.width + bottomCutoutSize.width)
|
||||||
|
}
|
||||||
|
|
||||||
return TextNodeLayout(attributedString: attributedString, maximumNumberOfLines: maximumNumberOfLines, truncationType: truncationType, constrainedSize: constrainedSize, alignment: alignment, lineSpacing: lineSpacingFactor, cutout: cutout, insets: insets, size: CGSize(width: ceil(layoutSize.width) + insets.left + insets.right, height: ceil(layoutSize.height) + insets.top + insets.bottom), firstLineOffset: firstLineOffset, lines: lines, backgroundColor: backgroundColor)
|
return TextNodeLayout(attributedString: attributedString, maximumNumberOfLines: maximumNumberOfLines, truncationType: truncationType, constrainedSize: constrainedSize, alignment: alignment, lineSpacing: lineSpacingFactor, cutout: cutout, insets: insets, size: CGSize(width: ceil(layoutSize.width) + insets.left + insets.right, height: ceil(layoutSize.height) + insets.top + insets.bottom), firstLineOffset: firstLineOffset, lines: lines, backgroundColor: backgroundColor)
|
||||||
} else {
|
} else {
|
||||||
return TextNodeLayout(attributedString: attributedString, maximumNumberOfLines: maximumNumberOfLines, truncationType: truncationType, constrainedSize: constrainedSize, alignment: alignment, lineSpacing: lineSpacingFactor, cutout: cutout, insets: insets, size: CGSize(), firstLineOffset: 0.0, lines: [], backgroundColor: backgroundColor)
|
return TextNodeLayout(attributedString: attributedString, maximumNumberOfLines: maximumNumberOfLines, truncationType: truncationType, constrainedSize: constrainedSize, alignment: alignment, lineSpacing: lineSpacingFactor, cutout: cutout, insets: insets, size: CGSize(), firstLineOffset: 0.0, lines: [], backgroundColor: backgroundColor)
|
||||||
@ -483,21 +524,20 @@ public class TextNode: ASDisplayNode {
|
|||||||
let alignment = layout.alignment
|
let alignment = layout.alignment
|
||||||
let offset = CGPoint(x: layout.insets.left, y: layout.insets.top)
|
let offset = CGPoint(x: layout.insets.left, y: layout.insets.top)
|
||||||
|
|
||||||
let lineCount = layout.lines.count
|
|
||||||
for i in 0 ..< layout.lines.count {
|
for i in 0 ..< layout.lines.count {
|
||||||
let line = layout.lines[i]
|
let line = layout.lines[i]
|
||||||
var lineOffset: CGFloat
|
|
||||||
|
var lineFrame = line.frame
|
||||||
|
lineFrame.origin.y += offset.y
|
||||||
|
|
||||||
if alignment == .center {
|
if alignment == .center {
|
||||||
lineOffset = floor((bounds.size.width - line.frame.size.width) / 2.0)
|
lineFrame.origin.x = offset.x + floor((bounds.size.width - lineFrame.width) / 2.0)
|
||||||
} else if alignment == .natural, line.isRTL {
|
} else if alignment == .natural, line.isRTL {
|
||||||
lineOffset = floor(bounds.size.width - line.frame.size.width)
|
lineFrame.origin.x = offset.x + floor(bounds.size.width - lineFrame.width)
|
||||||
if i == lineCount - 1, let cutout = layout.cutout, case .BottomRight = cutout.position {
|
|
||||||
lineOffset -= cutout.size.width
|
lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: bounds.size), cutout: layout.cutout)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lineOffset = 0.0
|
|
||||||
}
|
}
|
||||||
context.textPosition = CGPoint(x: line.frame.origin.x + lineOffset + offset.x, y: line.frame.origin.y + offset.y)
|
context.textPosition = CGPoint(x: lineFrame.minX, y: lineFrame.minY)
|
||||||
CTLineDraw(line.line, context)
|
CTLineDraw(line.line, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -554,6 +554,10 @@ public class Window1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||||
|
if let coveringView = self.coveringView, !coveringView.isHidden, coveringView.superview != nil, coveringView.frame.contains(point) {
|
||||||
|
return coveringView.hitTest(point, with: event)
|
||||||
|
}
|
||||||
|
|
||||||
for view in self.hostView.eventView.subviews.reversed() {
|
for view in self.hostView.eventView.subviews.reversed() {
|
||||||
if NSStringFromClass(type(of: view)) == "UITransitionView" {
|
if NSStringFromClass(type(of: view)) == "UITransitionView" {
|
||||||
if let result = view.hitTest(point, with: event) {
|
if let result = view.hitTest(point, with: event) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user