KMConvertSettingLimitTipView.swift 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // KMConvertSettingLimitTipView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/6/26.
  6. //
  7. import Cocoa
  8. class KMConvertSettingLimitTipView: NSView {
  9. private var _contentView = NSView()
  10. private var _iconIv = NSImageView()
  11. private var _textField = NSTextField(labelWithString: "")
  12. private var _funcBox = NSBox()
  13. // private var _funcButtonVC: KMDesignButton?
  14. var contentView: NSView {
  15. get {
  16. return self._contentView
  17. }
  18. }
  19. var itemClick: KMCommonClickBlock?
  20. override init(frame frameRect: NSRect) {
  21. super.init(frame: frameRect)
  22. self.initSubViews()
  23. self.initDefaultValue()
  24. }
  25. required init?(coder: NSCoder) {
  26. super.init(coder: coder)
  27. self.initSubViews()
  28. self.initDefaultValue()
  29. }
  30. func initSubViews() {
  31. self.addSubview(self.contentView)
  32. self.contentView.addSubview(self._iconIv)
  33. self.contentView.addSubview(self._textField)
  34. self.contentView.addSubview(self._funcBox)
  35. // self._funcButtonVC = KMDesignButton(withType: .Text)
  36. // self._funcBox.contentView = self._funcButtonVC!.view
  37. // self._funcButtonVC?.stringValue = NSLocalizedString("Unlock", comment: "")
  38. // self._funcButtonVC?.button(type: .Text, size: .m)
  39. // self._funcButtonVC?.target = self
  40. // self._funcButtonVC?.action = #selector(funcAction)
  41. self.contentView.km_add_inset_constraint()
  42. self._iconIv.km_add_leading_constraint(constant: 10)
  43. self._iconIv.km_add_centerY_constraint()
  44. self._textField.km_add_leading_constraint(equalTo: self._iconIv, attribute: .trailing, constant: 5)
  45. self._textField.km_add_centerY_constraint(equalTo: self._iconIv)
  46. self._funcBox.km_add_leading_constraint(equalTo: self._textField, attribute: .trailing)
  47. self._funcBox.km_add_centerY_constraint(equalTo: self._iconIv)
  48. self._funcBox.km_add_size_constraint(size: NSMakeSize(60, 30))
  49. }
  50. func initDefaultValue() {
  51. self._iconIv.image = NSImage(named: "KMImageNameTipNormal")
  52. self._textField.stringValue = NSLocalizedString("Convert the first 10 pages for free", comment: "")
  53. self._textField.font = .SFProTextRegularFont(12)
  54. self._textField.textColor = KMAppearance.titleColor()
  55. self._textField.textColor = NSColor.km_init(hex: "#F3465B")
  56. self._funcBox.boxType = .custom
  57. self._funcBox.titlePosition = .noTitle
  58. self._funcBox.borderWidth = 0.0
  59. }
  60. @objc private func funcAction() {
  61. guard let callback = self.itemClick else {
  62. return
  63. }
  64. callback(1)
  65. }
  66. }