123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //
- // 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?()
- }
-
- }
|