|
@@ -11,115 +11,115 @@ extension KMHomeViewController {
|
|
|
|
|
|
// MARK: Private Methods
|
|
// MARK: Private Methods
|
|
func productPromotionShow(_ pdfProSeries: NSArray, withOthers others: NSArray, isInitialize initialize: Bool) {
|
|
func productPromotionShow(_ pdfProSeries: NSArray, withOthers others: NSArray, isInitialize initialize: Bool) {
|
|
- if pdfProSeries.count > 0 {
|
|
|
|
- if (self.pdfProSeriesBoxHeightConstraint.constant == 0.0) || initialize {
|
|
|
|
- var height = CGFloat(pdfProSeries.count) * 32.0
|
|
|
|
- for name in pdfProSeries {
|
|
|
|
- height -= 32.0
|
|
|
|
-
|
|
|
|
- let dict: Dictionary = self.productPromotionData[name] as! Dictionary<NSString, NSString>
|
|
|
|
- let subBox = KMBox(frame: CGRect(origin: CGPoint(x: 0, y: height), size: CGSize(width: self.pdfProSeriesBox.frame.width, height: 32.0)))
|
|
|
|
- subBox.boxType = .custom
|
|
|
|
- subBox.borderWidth = 0.0
|
|
|
|
- self.pdfProSeriesBox.contentView?.addSubview(subBox)
|
|
|
|
- subBox.downCallback = {(downEntered, mouseBox, event) -> Void in
|
|
|
|
- if downEntered {
|
|
|
|
- self.productPromotionClickAction(dict["Name"]!)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let subImageView = NSImageView(frame: NSZeroRect)
|
|
|
|
- subImageView.image = NSImage(named: dict["Image"]! as NSImage.Name)
|
|
|
|
- subBox.addSubview(subImageView)
|
|
|
|
- subImageView.mas_makeConstraints { (make) in
|
|
|
|
- make?.width.height().equalTo()(16)
|
|
|
|
- make?.centerY.equalTo()(0)
|
|
|
|
- make?.left.equalTo()(18)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let subLabel = NSTextField(frame: NSZeroRect)
|
|
|
|
- subLabel.isBezeled = false
|
|
|
|
- subLabel.isEditable = false
|
|
|
|
- subLabel.backgroundColor = .clear
|
|
|
|
- let paragraphStyle = NSMutableParagraphStyle()
|
|
|
|
- paragraphStyle.lineSpacing = 22.0
|
|
|
|
- subLabel.attributedStringValue = NSAttributedString(string: dict["Name"]! as String, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
|
- subLabel.font = NSFont(name: "SFProText-Regular", size: 14)
|
|
|
|
- subLabel.textColor = NSColor(hex: "#616469")
|
|
|
|
- subLabel.sizeToFit()
|
|
|
|
- subBox.addSubview(subLabel)
|
|
|
|
- subLabel.mas_makeConstraints { (make) in
|
|
|
|
- make?.left.equalTo()(subImageView.mas_right)?.offset()(10)
|
|
|
|
- make?.centerY.equalTo()(0)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
|
|
|
|
- self.pdfProSeriesBoxHeightConstraint.constant = CGFloat(pdfProSeries.count) * 32.0
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_right_false")!
|
|
|
|
- self.pdfProSeriesBox.contentView = NSView.init()
|
|
|
|
- self.pdfProSeriesBoxHeightConstraint.constant = 0.0
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if others.count > 0 {
|
|
|
|
- if (self.othersBoxHeightConstraint.constant == 0.0) || initialize {
|
|
|
|
- var height = CGFloat(others.count) * 32.0
|
|
|
|
- for name in others {
|
|
|
|
- height -= 32.0
|
|
|
|
-
|
|
|
|
- let dict: Dictionary = self.productPromotionData[name] as! Dictionary<NSString, NSString>
|
|
|
|
- let subBox = KMBox(frame: CGRect(x: 0, y: height, width: self.othersBox.frame.width, height: 32.0))
|
|
|
|
- subBox.boxType = .custom
|
|
|
|
- subBox.borderWidth = 0.0
|
|
|
|
- self.othersBox.contentView?.addSubview(subBox)
|
|
|
|
- subBox.downCallback = {(downEntered, mouseBox, event) -> Void in
|
|
|
|
- if downEntered {
|
|
|
|
- self.productPromotionClickAction(dict["Name"]!)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let subImageView = NSImageView(frame: NSZeroRect)
|
|
|
|
- subImageView.image = NSImage(named: dict["Image"]! as NSImage.Name)
|
|
|
|
- subImageView.imageScaling = .scaleProportionallyDown
|
|
|
|
- subImageView.imageAlignment = .alignCenter
|
|
|
|
- subImageView.sizeToFit()
|
|
|
|
- subBox.addSubview(subImageView)
|
|
|
|
- subImageView.mas_makeConstraints { (make) in
|
|
|
|
- make?.width.height().equalTo()(16)
|
|
|
|
- make?.centerY.equalTo()(0)
|
|
|
|
- make?.left.equalTo()(18)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let subLabel = NSTextField(frame: NSZeroRect)
|
|
|
|
- subLabel.isBezeled = false
|
|
|
|
- subLabel.isEditable = false
|
|
|
|
- subLabel.backgroundColor = .clear
|
|
|
|
- let paragraphStyle = NSMutableParagraphStyle()
|
|
|
|
- paragraphStyle.lineSpacing = 22.0
|
|
|
|
- subLabel.attributedStringValue = NSAttributedString(string: dict["Name"]! as String, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
|
- subLabel.font = NSFont(name: "SFProText-Regular", size: 14)
|
|
|
|
- subLabel.textColor = NSColor(red: 0.38, green: 0.392, blue: 0.412, alpha: 1.0)
|
|
|
|
- subLabel.sizeToFit()
|
|
|
|
- subBox.addSubview(subLabel)
|
|
|
|
- subLabel.mas_makeConstraints { (make) in
|
|
|
|
- make?.left.equalTo()(subImageView.mas_right)?.offset()(10)
|
|
|
|
- make?.centerY.equalTo()(0)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- self.pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
|
|
|
|
- self.othersBoxHeightConstraint.constant = CGFloat(others.count) * 32.0
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- self.pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_right_false")!
|
|
|
|
- self.othersBox.contentView = NSView.init()
|
|
|
|
- self.othersBoxHeightConstraint.constant = 0.0
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- pdfSeriesButtonVC.updateUI()
|
|
|
|
- pdfOthersButtonVC.updateUI()
|
|
|
|
|
|
+// if pdfProSeries.count > 0 {
|
|
|
|
+// if (self.pdfProSeriesBoxHeightConstraint.constant == 0.0) || initialize {
|
|
|
|
+// var height = CGFloat(pdfProSeries.count) * 32.0
|
|
|
|
+// for name in pdfProSeries {
|
|
|
|
+// height -= 32.0
|
|
|
|
+//
|
|
|
|
+// let dict: Dictionary = self.productPromotionData[name] as! Dictionary<NSString, NSString>
|
|
|
|
+// let subBox = KMBox(frame: CGRect(origin: CGPoint(x: 0, y: height), size: CGSize(width: self.pdfProSeriesBox.frame.width, height: 32.0)))
|
|
|
|
+// subBox.boxType = .custom
|
|
|
|
+// subBox.borderWidth = 0.0
|
|
|
|
+// self.pdfProSeriesBox.contentView?.addSubview(subBox)
|
|
|
|
+// subBox.downCallback = {(downEntered, mouseBox, event) -> Void in
|
|
|
|
+// if downEntered {
|
|
|
|
+// self.productPromotionClickAction(dict["Name"]!)
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// let subImageView = NSImageView(frame: NSZeroRect)
|
|
|
|
+// subImageView.image = NSImage(named: dict["Image"]! as NSImage.Name)
|
|
|
|
+// subBox.addSubview(subImageView)
|
|
|
|
+// subImageView.mas_makeConstraints { (make) in
|
|
|
|
+// make?.width.height().equalTo()(16)
|
|
|
|
+// make?.centerY.equalTo()(0)
|
|
|
|
+// make?.left.equalTo()(18)
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// let subLabel = NSTextField(frame: NSZeroRect)
|
|
|
|
+// subLabel.isBezeled = false
|
|
|
|
+// subLabel.isEditable = false
|
|
|
|
+// subLabel.backgroundColor = .clear
|
|
|
|
+// let paragraphStyle = NSMutableParagraphStyle()
|
|
|
|
+// paragraphStyle.lineSpacing = 22.0
|
|
|
|
+// subLabel.attributedStringValue = NSAttributedString(string: dict["Name"]! as String, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
|
+// subLabel.font = NSFont(name: "SFProText-Regular", size: 14)
|
|
|
|
+// subLabel.textColor = NSColor(hex: "#616469")
|
|
|
|
+// subLabel.sizeToFit()
|
|
|
|
+// subBox.addSubview(subLabel)
|
|
|
|
+// subLabel.mas_makeConstraints { (make) in
|
|
|
|
+// make?.left.equalTo()(subImageView.mas_right)?.offset()(10)
|
|
|
|
+// make?.centerY.equalTo()(0)
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
|
|
|
|
+// self.pdfProSeriesBoxHeightConstraint.constant = CGFloat(pdfProSeries.count) * 32.0
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_right_false")!
|
|
|
|
+// self.pdfProSeriesBox.contentView = NSView.init()
|
|
|
|
+// self.pdfProSeriesBoxHeightConstraint.constant = 0.0
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if others.count > 0 {
|
|
|
|
+// if (self.othersBoxHeightConstraint.constant == 0.0) || initialize {
|
|
|
|
+// var height = CGFloat(others.count) * 32.0
|
|
|
|
+// for name in others {
|
|
|
|
+// height -= 32.0
|
|
|
|
+//
|
|
|
|
+// let dict: Dictionary = self.productPromotionData[name] as! Dictionary<NSString, NSString>
|
|
|
|
+// let subBox = KMBox(frame: CGRect(x: 0, y: height, width: self.othersBox.frame.width, height: 32.0))
|
|
|
|
+// subBox.boxType = .custom
|
|
|
|
+// subBox.borderWidth = 0.0
|
|
|
|
+// self.othersBox.contentView?.addSubview(subBox)
|
|
|
|
+// subBox.downCallback = {(downEntered, mouseBox, event) -> Void in
|
|
|
|
+// if downEntered {
|
|
|
|
+// self.productPromotionClickAction(dict["Name"]!)
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// let subImageView = NSImageView(frame: NSZeroRect)
|
|
|
|
+// subImageView.image = NSImage(named: dict["Image"]! as NSImage.Name)
|
|
|
|
+// subImageView.imageScaling = .scaleProportionallyDown
|
|
|
|
+// subImageView.imageAlignment = .alignCenter
|
|
|
|
+// subImageView.sizeToFit()
|
|
|
|
+// subBox.addSubview(subImageView)
|
|
|
|
+// subImageView.mas_makeConstraints { (make) in
|
|
|
|
+// make?.width.height().equalTo()(16)
|
|
|
|
+// make?.centerY.equalTo()(0)
|
|
|
|
+// make?.left.equalTo()(18)
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// let subLabel = NSTextField(frame: NSZeroRect)
|
|
|
|
+// subLabel.isBezeled = false
|
|
|
|
+// subLabel.isEditable = false
|
|
|
|
+// subLabel.backgroundColor = .clear
|
|
|
|
+// let paragraphStyle = NSMutableParagraphStyle()
|
|
|
|
+// paragraphStyle.lineSpacing = 22.0
|
|
|
|
+// subLabel.attributedStringValue = NSAttributedString(string: dict["Name"]! as String, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
|
+// subLabel.font = NSFont(name: "SFProText-Regular", size: 14)
|
|
|
|
+// subLabel.textColor = NSColor(red: 0.38, green: 0.392, blue: 0.412, alpha: 1.0)
|
|
|
|
+// subLabel.sizeToFit()
|
|
|
|
+// subBox.addSubview(subLabel)
|
|
|
|
+// subLabel.mas_makeConstraints { (make) in
|
|
|
|
+// make?.left.equalTo()(subImageView.mas_right)?.offset()(10)
|
|
|
|
+// make?.centerY.equalTo()(0)
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// self.pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
|
|
|
|
+// self.othersBoxHeightConstraint.constant = CGFloat(others.count) * 32.0
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// self.pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_right_false")!
|
|
|
|
+// self.othersBox.contentView = NSView.init()
|
|
|
|
+// self.othersBoxHeightConstraint.constant = 0.0
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// pdfSeriesButtonVC.updateUI()
|
|
|
|
+// pdfOthersButtonVC.updateUI()
|
|
}
|
|
}
|
|
|
|
|
|
func refreshRightBoxUI(_ state: KMHomeToolState) {
|
|
func refreshRightBoxUI(_ state: KMHomeToolState) {
|