// // KMCancelSubscribeSuccessCellView.swift // PDF Reader Pro // // Created by User-Tangchao on 2024/12/22. // import Cocoa class KMCancelSubscribeSuccessOtherCellView: KMCancelSubscribeSuccessCellView { private lazy var inputBox_: NSBox = { let view = NSBox() view.boxType = .custom view.titlePosition = .noTitle view.contentViewMargins = .zero view.borderWidth = 2 return view }() private lazy var scrollView_: NSScrollView = { let view = NSScrollView() return view }() private lazy var textView_: NSTextView = { let view = NSTextView() view.km_placeholderString = NSLocalizedString("What is your problem?", comment: "") return view }() var inputBox: NSBox { get { return inputBox_ } } var textView: NSTextView { get { return textView_ } } var valueDidChange: KMValueDidChangeBlock? override func initSubViews() { super.initSubViews() addSubview(inputBox_) inputBox_.contentView?.addSubview(scrollView_) scrollView_.documentView = textView_ scrollView_.drawsBackground = false textView_.backgroundColor = .clear textView.delegate = self contentBox.mas_remakeConstraints { make in make?.leading.mas_equalTo()(0) make?.trailing.mas_equalTo()(0) make?.top.mas_equalTo()(7) } inputBox_.mas_makeConstraints { make in make?.leading.mas_equalTo()(0) make?.trailing.mas_equalTo()(0) make?.top.equalTo()(self.contentBox.mas_bottom)?.offset()(12) make?.height.mas_equalTo()(80) make?.bottom.mas_equalTo()(-7) } scrollView_.mas_makeConstraints { make in make?.leading.mas_equalTo()(16) make?.trailing.mas_equalTo()(-16) make?.top.mas_equalTo()(16) make?.bottom.mas_equalTo()(0) } // textView_.mas_makeConstraints { make in // make?.leading.mas_equalTo()(0) // make?.trailing.mas_equalTo()(0) // make?.top.mas_equalTo()(0) // make?.height.mas_equalTo()(64) // } } override func layout() { super.layout() textView_.frame = scrollView_.contentView.bounds } } extension KMCancelSubscribeSuccessOtherCellView: NSTextViewDelegate { func textDidChange(_ notification: Notification) { if textView.isEqual(to: notification.object) { textView.placeholderLabel.isHidden = (textView.string.isEmpty == false) valueDidChange?(textView.string, nil) } } func textDidEndEditing(_ notification: Notification) { if textView.isEqual(to: notification.object) { textView.placeholderLabel.isHidden = (textView.string.isEmpty == false) } } } class KMCancelSubscribeSuccessCellView: NSTableCellView { private lazy var contentBox_: NSBox = { let view = NSBox() view.boxType = .custom view.titlePosition = .noTitle view.contentViewMargins = .zero view.borderWidth = 2 return view }() private lazy var radio_: NSButton = { let view = NSButton(radioButtonWithTitle: "", target: self, action: #selector(radioAction)) return view }() var contentBox: NSBox { get { return contentBox_ } } var radio: NSButton { get { return radio_ } } var itemClick: KMEmptyBlock? convenience init() { self.init(frame: .init(x: 0, y: 0, width: 200, height: 30)) initSubViews() } override func awakeFromNib() { super.awakeFromNib() initSubViews() } func initSubViews() { addSubview(contentBox_) contentBox_.contentView?.addSubview(radio_) contentBox_.mas_makeConstraints { make in make?.leading.mas_equalTo()(0) make?.trailing.mas_equalTo()(0) make?.top.mas_equalTo()(7) make?.bottom.mas_equalTo()(-7) } radio_.mas_makeConstraints { make in make?.leading.mas_equalTo()(16) make?.trailing.mas_equalTo()(-16) make?.top.mas_equalTo()(11) make?.bottom.mas_equalTo()(-11) } } @objc func radioAction() { itemClick?() } }