feat: cleaner layout and explanation text
This commit is contained in:
1 parent
a14f96550b
commit
fd3e7680f4
2 files changed
+14
-7
No files matched your search
@@ -46,8 +46,8 @@ class FeedbackWindow: NSWindow, NSTextViewDelegate {
|
|||||||
buttons.spacing = GridView.interPadding
|
buttons.spacing = GridView.interPadding
|
||||||
body = TextArea(80, 20, "I think the app could be improved with…")
|
body = TextArea(80, 20, "I think the app could be improved with…")
|
||||||
body.delegate = self
|
body.delegate = self
|
||||||
email = TextArea(80, 1.1, "Optional: email (if you want a reply)")
|
email = TextArea(80, 1, "Optional: email (if you want a reply)")
|
||||||
debugProfile = NSButton(checkboxWithTitle: "Send debug profile", target: nil, action: nil)
|
debugProfile = NSButton(checkboxWithTitle: "Send debug profile (CPU, memory, etc)", target: nil, action: nil)
|
||||||
debugProfile.state = .on
|
debugProfile.state = .on
|
||||||
let view = GridView.make([
|
let view = GridView.make([
|
||||||
[header],
|
[header],
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class TextArea: NSTextView {
|
class TextArea: NSTextView {
|
||||||
static let paddingX = CGFloat(5)
|
static let padding = CGFloat(10)
|
||||||
static let paddingY = CGFloat(10)
|
static let magicOffset = CGFloat(3)
|
||||||
@objc var placeholderAttributedString: NSAttributedString?
|
@objc var placeholderAttributedString: NSAttributedString?
|
||||||
|
|
||||||
convenience init(_ width: CGFloat, _ height: CGFloat, _ placeholder: String) {
|
convenience init(_ width: CGFloat, _ height: CGFloat, _ placeholder: String) {
|
||||||
self.init(frame: .zero)
|
self.init(frame: .zero)
|
||||||
font = NSFont.systemFont(ofSize: NSFont.systemFontSize)
|
font = NSFont.systemFont(ofSize: NSFont.systemFontSize)
|
||||||
textContainerInset = NSSize(width: TextArea.paddingX, height: TextArea.paddingY)
|
textContainerInset = NSSize(width: TextArea.padding, height: TextArea.padding)
|
||||||
fit(font!.xHeight * width + TextArea.paddingX * 2, NSFont.systemFontSize * height + TextArea.paddingY * 2)
|
textContainer!.lineFragmentPadding = 0
|
||||||
placeholderAttributedString = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor: NSColor.gray])
|
let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
|
||||||
|
paragraphStyle.maximumLineHeight = NSFont.systemFontSize + TextArea.magicOffset
|
||||||
|
placeholderAttributedString = NSAttributedString(string: placeholder, attributes: [
|
||||||
|
NSAttributedString.Key.font : NSFont.systemFont(ofSize: NSFont.systemFontSize),
|
||||||
|
NSAttributedString.Key.foregroundColor: NSColor.gray,
|
||||||
|
NSAttributedString.Key.paragraphStyle: paragraphStyle,
|
||||||
|
])
|
||||||
|
fit(font!.xHeight * width + TextArea.padding * 2, NSFont.systemFontSize * height + TextArea.padding * 2 + TextArea.magicOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user