123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // KMSignUpBuyView.swift
- // PDF Reader Pro
- //
- // Created by User-Tangchao on 2024/12/11.
- //
- import Cocoa
- class KMSignUpBuyView: KMHoverView {
- private lazy var contentBox_: NSBox = {
- let view = NSBox()
- view.boxType = .custom
- view.titlePosition = .noTitle
- view.contentViewMargins = .zero
- view.borderWidth = 0
- return view
- }()
-
- private lazy var titleLabel_: NSTextField = {
- let view = NSTextField(labelWithString: NSLocalizedString("Buy without Logging in", tableName: "MemberCenterLocalizable", comment: ""))
- view.font = .SFProTextBoldFont(12)
- return view
- }()
-
- private lazy var subTitleLabel_: NSTextField = {
- let view = NSTextField(wrappingLabelWithString: NSLocalizedString("Cross-platform not supported, 1-year free AI not available", tableName: "MemberCenterLocalizable", comment: ""))
- view.font = .SFProTextRegularFont(11)
- return view
- }()
-
- private lazy var arrowButton_: NSButton = {
- let view = NSButton()
- view.isBordered = false
- view.imagePosition = .imageOnly
- view.image = NSImage(named: "BuyNewArrowImage2Hover")
- return view
- }()
-
- private lazy var actionButton_: NSButton = {
- let view = NSButton()
- view.isBordered = false
- view.title = ""
- view.target = self
- view.action = #selector(buttonAction)
- return view
- }()
-
- private lazy var leftLine_: NSView = {
- let view = NSView()
- view.wantsLayer = true
- return view
- }()
-
- var contentBox: NSBox {
- get {
- return contentBox_
- }
- }
-
- var titleLabel: NSTextField {
- get {
- return titleLabel_
- }
- }
- var subTitleLabel: NSTextField {
- get {
- return subTitleLabel_
- }
- }
-
- var leftLine: NSView {
- get {
- return leftLine_
- }
- }
-
- var itemClick: KMCommonClickBlock?
-
- convenience init() {
- self.init(frame: .init(x: 0, y: 0, width: 200, height: 40))
-
- initSubViews()
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- initSubViews()
- }
-
- func initSubViews() {
- let contentInset = NSEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
-
- addSubview(contentBox_)
- contentBox_.km_add_inset_constraint()
-
- let wh: CGFloat = 16
- contentBox_.contentView?.addSubview(arrowButton_)
- arrowButton_.km_add_size_constraint(size: .init(width: wh, height: wh))
- arrowButton_.km_add_trailing_constraint(constant: -contentInset.right)
- arrowButton_.km_add_centerY_constraint()
-
- let hSpace: CGFloat = 4
- contentBox_.contentView?.addSubview(titleLabel_)
- titleLabel_.km_add_leading_constraint(constant: contentInset.left)
- titleLabel_.km_add_top_constraint(constant: 4)
- titleLabel_.km_add_trailing_constraint(equalTo: arrowButton_, attribute: .leading, constant: hSpace)
-
- contentBox_.contentView?.addSubview(subTitleLabel_)
- subTitleLabel_.km_add_leading_constraint(constant: contentInset.left)
- // subTitleLabel_.km_add_top_constraint(equalTo: titleLabel_, attribute: .bottom, constant: 4)
- subTitleLabel.km_add_centerY_constraint(constant: 8)
- subTitleLabel_.km_add_trailing_constraint(equalTo: arrowButton_, attribute: .leading, constant: hSpace)
-
- contentBox.contentView?.addSubview(leftLine_)
- leftLine_.km_add_leading_constraint(constant: 0)
- leftLine_.km_add_top_constraint(constant: 0)
- leftLine_.km_add_width_constraint(constant: 2)
- leftLine_.km_add_bottom_constraint(constant: 0)
-
- contentBox.contentView?.addSubview(actionButton_)
- actionButton_.km_add_inset_constraint()
- }
-
- @objc func buttonAction() {
- itemClick?(1)
- }
- }
|