|
@@ -71,6 +71,7 @@ final class CVTemplatePreviewView: NSView {
|
|
|
super.init(frame: .zero)
|
|
super.init(frame: .zero)
|
|
|
wantsLayer = true
|
|
wantsLayer = true
|
|
|
translatesAutoresizingMaskIntoConstraints = false
|
|
translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
+ userInterfaceLayoutDirection = .leftToRight
|
|
|
configurePaper()
|
|
configurePaper()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -100,6 +101,7 @@ final class CVTemplatePreviewView: NSView {
|
|
|
|
|
|
|
|
let root = buildResumeRoot()
|
|
let root = buildResumeRoot()
|
|
|
root.translatesAutoresizingMaskIntoConstraints = false
|
|
root.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
+ enforceLeftToRightLayout(on: root)
|
|
|
paper.addSubview(root)
|
|
paper.addSubview(root)
|
|
|
NSLayoutConstraint.activate([
|
|
NSLayoutConstraint.activate([
|
|
|
root.leadingAnchor.constraint(equalTo: paper.leadingAnchor, constant: 7),
|
|
root.leadingAnchor.constraint(equalTo: paper.leadingAnchor, constant: 7),
|
|
@@ -894,7 +896,7 @@ final class CVTemplatePreviewView: NSView {
|
|
|
row.orientation = .horizontal
|
|
row.orientation = .horizontal
|
|
|
row.spacing = 5
|
|
row.spacing = 5
|
|
|
row.translatesAutoresizingMaskIntoConstraints = false
|
|
row.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- let lab = makeLabel("PORTFOLIO SNAPSHOT", font: .systemFont(ofSize: 6.5, weight: .black), color: palette.previewInk, alignment: .left, maxLines: 1)
|
|
|
|
|
|
|
+ let lab = makeLabel(L("PORTFOLIO SNAPSHOT"), font: .systemFont(ofSize: 6.5, weight: .black), color: palette.previewInk, alignment: .left, maxLines: 1)
|
|
|
row.addArrangedSubview(stripe)
|
|
row.addArrangedSubview(stripe)
|
|
|
row.addArrangedSubview(lab)
|
|
row.addArrangedSubview(lab)
|
|
|
v.addSubview(row)
|
|
v.addSubview(row)
|
|
@@ -1002,6 +1004,13 @@ final class CVTemplatePreviewView: NSView {
|
|
|
return row
|
|
return row
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private func enforceLeftToRightLayout(on view: NSView) {
|
|
|
|
|
+ view.userInterfaceLayoutDirection = .leftToRight
|
|
|
|
|
+ for child in view.subviews {
|
|
|
|
|
+ enforceLeftToRightLayout(on: child)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private func makeLabel(
|
|
private func makeLabel(
|
|
|
_ text: String,
|
|
_ text: String,
|
|
|
font: NSFont,
|
|
font: NSFont,
|
|
@@ -1016,6 +1025,7 @@ final class CVTemplatePreviewView: NSView {
|
|
|
tf = NSTextField(wrappingLabelWithString: text)
|
|
tf = NSTextField(wrappingLabelWithString: text)
|
|
|
tf.maximumNumberOfLines = maxLines
|
|
tf.maximumNumberOfLines = maxLines
|
|
|
}
|
|
}
|
|
|
|
|
+ tf.translatesAutoresizingMaskIntoConstraints = false
|
|
|
tf.font = font
|
|
tf.font = font
|
|
|
tf.textColor = color
|
|
tf.textColor = color
|
|
|
tf.alignment = alignment
|
|
tf.alignment = alignment
|
|
@@ -1024,6 +1034,15 @@ final class CVTemplatePreviewView: NSView {
|
|
|
tf.drawsBackground = false
|
|
tf.drawsBackground = false
|
|
|
tf.isBordered = false
|
|
tf.isBordered = false
|
|
|
tf.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
tf.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
|
|
|
+ let paragraph = NSMutableParagraphStyle()
|
|
|
|
|
+ paragraph.alignment = alignment
|
|
|
|
|
+ paragraph.baseWritingDirection = .leftToRight
|
|
|
|
|
+ paragraph.lineBreakMode = maxLines == 1 ? .byTruncatingTail : .byWordWrapping
|
|
|
|
|
+ tf.attributedStringValue = NSAttributedString(string: text, attributes: [
|
|
|
|
|
+ .font: font,
|
|
|
|
|
+ .foregroundColor: color,
|
|
|
|
|
+ .paragraphStyle: paragraph
|
|
|
|
|
+ ])
|
|
|
return tf
|
|
return tf
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|