Просмотр исходного кода

Fix mirrored alignment in the create meeting popover.

Force left-to-right label layout and anchor field rows to full width so headings remain on the left side of the popup.

Made-with: Cursor
huzaifahayat12 1 неделя назад
Родитель
Сommit
959e77f27d
1 измененных файлов с 22 добавлено и 1 удалено
  1. 22 1
      meetings_app/ViewController.swift

+ 22 - 1
meetings_app/ViewController.swift

@@ -4895,20 +4895,28 @@ private final class CreateMeetingPopoverViewController: NSViewController {
4895
     override func loadView() {
4895
     override func loadView() {
4896
         let root = NSView()
4896
         let root = NSView()
4897
         root.translatesAutoresizingMaskIntoConstraints = false
4897
         root.translatesAutoresizingMaskIntoConstraints = false
4898
+        root.userInterfaceLayoutDirection = .leftToRight
4898
 
4899
 
4899
         let stack = NSStackView()
4900
         let stack = NSStackView()
4900
         stack.translatesAutoresizingMaskIntoConstraints = false
4901
         stack.translatesAutoresizingMaskIntoConstraints = false
4901
         stack.orientation = .vertical
4902
         stack.orientation = .vertical
4902
-        stack.alignment = .width
4903
+        stack.alignment = .leading
4903
         stack.spacing = 12
4904
         stack.spacing = 12
4905
+        stack.userInterfaceLayoutDirection = .leftToRight
4904
 
4906
 
4905
         let header = NSTextField(labelWithString: "Schedule meeting")
4907
         let header = NSTextField(labelWithString: "Schedule meeting")
4906
         header.font = NSFont.systemFont(ofSize: 14, weight: .semibold)
4908
         header.font = NSFont.systemFont(ofSize: 14, weight: .semibold)
4907
         header.textColor = palette.textPrimary
4909
         header.textColor = palette.textPrimary
4910
+        header.alignment = .left
4911
+        header.userInterfaceLayoutDirection = .leftToRight
4912
+        header.baseWritingDirection = .leftToRight
4908
 
4913
 
4909
         let titleLabel = NSTextField(labelWithString: "Title")
4914
         let titleLabel = NSTextField(labelWithString: "Title")
4910
         titleLabel.font = typography.fieldLabel
4915
         titleLabel.font = typography.fieldLabel
4911
         titleLabel.textColor = palette.textSecondary
4916
         titleLabel.textColor = palette.textSecondary
4917
+        titleLabel.alignment = .left
4918
+        titleLabel.userInterfaceLayoutDirection = .leftToRight
4919
+        titleLabel.baseWritingDirection = .leftToRight
4912
 
4920
 
4913
         let titleShell = NSView()
4921
         let titleShell = NSView()
4914
         titleShell.translatesAutoresizingMaskIntoConstraints = false
4922
         titleShell.translatesAutoresizingMaskIntoConstraints = false
@@ -4945,6 +4953,9 @@ private final class CreateMeetingPopoverViewController: NSViewController {
4945
         let startLabel = NSTextField(labelWithString: "Start")
4953
         let startLabel = NSTextField(labelWithString: "Start")
4946
         startLabel.font = typography.fieldLabel
4954
         startLabel.font = typography.fieldLabel
4947
         startLabel.textColor = palette.textSecondary
4955
         startLabel.textColor = palette.textSecondary
4956
+        startLabel.alignment = .left
4957
+        startLabel.userInterfaceLayoutDirection = .leftToRight
4958
+        startLabel.baseWritingDirection = .leftToRight
4948
 
4959
 
4949
         let pickerShell = NSView()
4960
         let pickerShell = NSView()
4950
         pickerShell.translatesAutoresizingMaskIntoConstraints = false
4961
         pickerShell.translatesAutoresizingMaskIntoConstraints = false
@@ -4976,6 +4987,9 @@ private final class CreateMeetingPopoverViewController: NSViewController {
4976
         let durationLabel = NSTextField(labelWithString: "Duration (min)")
4987
         let durationLabel = NSTextField(labelWithString: "Duration (min)")
4977
         durationLabel.font = typography.fieldLabel
4988
         durationLabel.font = typography.fieldLabel
4978
         durationLabel.textColor = palette.textSecondary
4989
         durationLabel.textColor = palette.textSecondary
4990
+        durationLabel.alignment = .left
4991
+        durationLabel.userInterfaceLayoutDirection = .leftToRight
4992
+        durationLabel.baseWritingDirection = .leftToRight
4979
 
4993
 
4980
         let durationShell = NSView()
4994
         let durationShell = NSView()
4981
         durationShell.translatesAutoresizingMaskIntoConstraints = false
4995
         durationShell.translatesAutoresizingMaskIntoConstraints = false
@@ -5021,6 +5035,9 @@ private final class CreateMeetingPopoverViewController: NSViewController {
5021
         let notesLabel = NSTextField(labelWithString: "Notes")
5035
         let notesLabel = NSTextField(labelWithString: "Notes")
5022
         notesLabel.font = typography.fieldLabel
5036
         notesLabel.font = typography.fieldLabel
5023
         notesLabel.textColor = palette.textSecondary
5037
         notesLabel.textColor = palette.textSecondary
5038
+        notesLabel.alignment = .left
5039
+        notesLabel.userInterfaceLayoutDirection = .leftToRight
5040
+        notesLabel.baseWritingDirection = .leftToRight
5024
 
5041
 
5025
         let notesScroll = NSScrollView()
5042
         let notesScroll = NSScrollView()
5026
         notesScroll.translatesAutoresizingMaskIntoConstraints = false
5043
         notesScroll.translatesAutoresizingMaskIntoConstraints = false
@@ -5086,6 +5103,10 @@ private final class CreateMeetingPopoverViewController: NSViewController {
5086
             stack.trailingAnchor.constraint(equalTo: root.trailingAnchor, constant: -14),
5103
             stack.trailingAnchor.constraint(equalTo: root.trailingAnchor, constant: -14),
5087
             stack.topAnchor.constraint(equalTo: root.topAnchor, constant: 12),
5104
             stack.topAnchor.constraint(equalTo: root.topAnchor, constant: 12),
5088
             stack.bottomAnchor.constraint(equalTo: root.bottomAnchor, constant: -12),
5105
             stack.bottomAnchor.constraint(equalTo: root.bottomAnchor, constant: -12),
5106
+            titleShell.widthAnchor.constraint(equalTo: stack.widthAnchor),
5107
+            timeRow.widthAnchor.constraint(equalTo: stack.widthAnchor),
5108
+            notesScroll.widthAnchor.constraint(equalTo: stack.widthAnchor),
5109
+            error.widthAnchor.constraint(equalTo: stack.widthAnchor),
5089
             actions.widthAnchor.constraint(equalTo: stack.widthAnchor)
5110
             actions.widthAnchor.constraint(equalTo: stack.widthAnchor)
5090
         ])
5111
         ])
5091
 
5112