1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // KMNSearchReplaceItemView.swift
- // PDF Reader Pro
- //
- // Created by User-Tangchao on 2024/12/2.
- //
- import Cocoa
- import KMComponentLibrary
- class KMNSearchReplaceItemView: NSView {
- private lazy var input_: ComponentInput = {
- let view = ComponentInput()
- let prop = ComponentInputProperty()
- prop.size = .s
- prop.showPrefix = true
- prop.placeholder = KMLocalizedString("Replace with...")
- // KMImagenameBotaSearchInputPrefiex
- view.properties = prop
- return view
- }()
-
- private lazy var replaceAllButton_: ComponentButton = {
- let view = ComponentButton()
- let prop = ComponentButtonProperty()
- prop.type = .default_tertiary
- prop.size = .xxs
- prop.buttonText = KMLocalizedString("Replace All")
- view.properties = prop
- return view
- }()
-
- private lazy var replaceButton_: ComponentButton = {
- let view = ComponentButton()
- let prop = ComponentButtonProperty()
- prop.type = .primary
- prop.size = .xxs
- prop.buttonText = KMLocalizedString("Replace")
- view.properties = prop
- return view
- }()
-
-
- convenience init() {
- self.init(frame: .init(x: 0, y: 0, width: 300, height: 60))
-
- initSubviews()
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- initSubviews()
- }
-
- func initSubviews() {
- addSubview(input_)
- addSubview(replaceAllButton_)
- addSubview(replaceButton_)
-
- input_.km_add_leading_constraint(constant: 12)
- input_.km_add_top_constraint(constant: 8)
- input_.km_add_trailing_constraint(constant: -12)
- input_.km_add_height_constraint(constant: 32)
-
- replaceButton_.km_add_height_constraint(constant: 24)
- replaceButton_.km_add_trailing_constraint(constant: -12)
- replaceButton_.km_add_bottom_constraint()
- replaceButton_.km_add_width_constraint(constant: replaceButton_.properties.propertyInfo.viewWidth)
-
- replaceAllButton_.km_add_height_constraint(constant: 24)
- replaceAllButton_.km_add_trailing_constraint(equalTo: replaceButton_, attribute: .leading, constant: -8)
- replaceAllButton_.km_add_bottom_constraint()
- replaceAllButton_.km_add_width_constraint(constant: replaceAllButton_.properties.propertyInfo.viewWidth)
- }
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- }
|