|
@@ -28,6 +28,8 @@ import Cocoa
|
|
|
|
|
|
static let shared = KMNewUserGuideWindowController(windowNibName: "KMNewUserGuideWindowController")
|
|
|
|
|
|
+ private lazy var displayView_ = KMNewUserGuideDisplayView()
|
|
|
+
|
|
|
private var datas_: [KMNewUserGuideModel] = []
|
|
|
|
|
|
var showType: KMNewUserGuideType = .ai {
|
|
@@ -41,15 +43,26 @@ import Cocoa
|
|
|
|
|
|
override func windowDidLoad() {
|
|
|
super.windowDidLoad()
|
|
|
+
|
|
|
+ window?.title = ""
|
|
|
+ window?.standardWindowButton(.zoomButton)?.isHidden = true
|
|
|
+ window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
|
|
|
|
|
backgroundIv.image = NSImage(named: "KMImageNameNewUserGuideBg")
|
|
|
backgroundIv.image?.size = window?.frame.size ?? .zero
|
|
|
+ titleLabel.font = .SFProTextRegularFont(20)
|
|
|
+ titleLabel.stringValue = NSLocalizedString("The Beginner's Guide", comment: "")
|
|
|
+
|
|
|
tableView.delegate = self
|
|
|
tableView.dataSource = self
|
|
|
tableView.enclosingScrollView?.borderType = .noBorder
|
|
|
tableView.backgroundColor = .clear
|
|
|
tableView.enclosingScrollView?.drawsBackground = false
|
|
|
|
|
|
+ rightBox.borderWidth = 0
|
|
|
+ rightBox.contentView = displayView_
|
|
|
+ displayView_.contentInset = .init(top: 0, left: 10, bottom: 34, right: 18)
|
|
|
+
|
|
|
interfaceThemeDidChanged(self.window?.appearance?.name ?? .vibrantLight)
|
|
|
|
|
|
_initData()
|
|
@@ -71,8 +84,6 @@ import Cocoa
|
|
|
model.type = type
|
|
|
let maxWidth: CGFloat = 224
|
|
|
if type == .ai {
|
|
|
- let font = NSFont.SFProTextBoldFont(14)
|
|
|
- let color = NSColor(hex: "#42464D")
|
|
|
model.name = NSLocalizedString("AI Credits Giveaway", comment: "")
|
|
|
let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
@@ -82,7 +93,7 @@ import Cocoa
|
|
|
model.viewH = _calculateViewHeight(model: model, maxWidth: maxWidth)
|
|
|
} else if type == .note {
|
|
|
model.name = NSLocalizedString("Annotate PDF", comment: "")
|
|
|
- let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
+ let attri = NSAttributedString(string: NSLocalizedString("Add Annotations, Images, and Stamps to PDFs", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
|
.foregroundColor : NSColor(hex: "#42464D")
|
|
|
])
|
|
@@ -90,7 +101,7 @@ import Cocoa
|
|
|
model.viewH = _calculateViewHeight(model: model, maxWidth: maxWidth)
|
|
|
} else if type == .editPDF {
|
|
|
model.name = NSLocalizedString("Edit PDF", comment: "")
|
|
|
- let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
+ let attri = NSAttributedString(string: NSLocalizedString("Edit PDF Text, Images, and Watermarks", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
|
.foregroundColor : NSColor(hex: "#42464D")
|
|
|
])
|
|
@@ -98,7 +109,8 @@ import Cocoa
|
|
|
model.viewH = _calculateViewHeight(model: model, maxWidth: maxWidth)
|
|
|
} else if type == .pageEdit {
|
|
|
model.name = NSLocalizedString("Page Edit", comment: "")
|
|
|
- let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
+ model.imageName = "KMImageNameNewUserGuidePageEdit"
|
|
|
+ let attri = NSAttributedString(string: NSLocalizedString("Insert, Delete, Rotate, and Extract the Pages in PDFs", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
|
.foregroundColor : NSColor(hex: "#42464D")
|
|
|
])
|
|
@@ -106,7 +118,8 @@ import Cocoa
|
|
|
model.viewH = _calculateViewHeight(model: model, maxWidth: maxWidth)
|
|
|
} else if type == .convert {
|
|
|
model.name = NSLocalizedString("PDF Converter", comment: "")
|
|
|
- let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
+ model.imageName = "KMImageNameNewUserGuideConvert"
|
|
|
+ let attri = NSAttributedString(string: NSLocalizedString("Convert to/from MS Office, Images, and More", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
|
.foregroundColor : NSColor(hex: "#42464D")
|
|
|
])
|
|
@@ -114,7 +127,8 @@ import Cocoa
|
|
|
model.viewH = _calculateViewHeight(model: model, maxWidth: maxWidth)
|
|
|
} else if type == .ocr {
|
|
|
model.name = NSLocalizedString("OCR", comment: "")
|
|
|
- let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
+ model.imageName = "KMImageNameNewUserGuideOCR"
|
|
|
+ let attri = NSAttributedString(string: NSLocalizedString("Scanned PDFs to Editable & Searchable PDFs in 90+ Languages", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
|
.foregroundColor : NSColor(hex: "#42464D")
|
|
|
])
|
|
@@ -122,7 +136,8 @@ import Cocoa
|
|
|
model.viewH = _calculateViewHeight(model: model, maxWidth: maxWidth)
|
|
|
} else if type == .fillForms {
|
|
|
model.name = NSLocalizedString("Create & Fill Forms", comment: "")
|
|
|
- let attri = NSAttributedString(string: NSLocalizedString("Free 40 AI Credits for 7-day VIP Free Trial Users", comment: ""), attributes: [
|
|
|
+ model.imageName = "KMImageNameNewUserGuideFillForms"
|
|
|
+ let attri = NSAttributedString(string: NSLocalizedString("Support to Create & Fill Interactive PDF Forms", comment: ""), attributes: [
|
|
|
.font : NSFont.SFProTextRegularFont(11),
|
|
|
.foregroundColor : NSColor(hex: "#42464D")
|
|
|
])
|
|
@@ -143,7 +158,15 @@ import Cocoa
|
|
|
override func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
|
|
|
super.interfaceThemeDidChanged(appearance)
|
|
|
|
|
|
-
|
|
|
+ KMMainThreadExecute {
|
|
|
+ if KMAppearance.isDarkMode() {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ self.titleLabel.textColor = NSColor(hex: "#002143")
|
|
|
+ }
|
|
|
+
|
|
|
+ self.tableView.reloadData()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: - public Methods
|
|
@@ -157,12 +180,22 @@ import Cocoa
|
|
|
}
|
|
|
|
|
|
public func selectType(_ type: KMNewUserGuideType) {
|
|
|
+ var selectedModel: KMNewUserGuideModel?
|
|
|
for model in datas_ {
|
|
|
model.isSelected = (model.type == type)
|
|
|
+ if model.isSelected {
|
|
|
+ selectedModel = model
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
KMMainThreadExecute {
|
|
|
- self.tableView.reloadData()
|
|
|
+// self.tableView.reloadData()
|
|
|
+ self.tableView.animator().reloadData()
|
|
|
+
|
|
|
+ if let data = selectedModel?.imageName {
|
|
|
+ self.displayView_.imageView.image = NSImage(named: data)
|
|
|
+ self.displayView_.imageView.image?.size = NSMakeSize(480, 320)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -194,32 +227,61 @@ extension KMNewUserGuideWindowController: NSTableViewDelegate, NSTableViewDataSo
|
|
|
return model?.viewH ?? defaultViewH_
|
|
|
}
|
|
|
|
|
|
+ func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
|
|
+ let rowView = KMTableRowView()
|
|
|
+ rowView.selectionBackgroundColorBlock = {
|
|
|
+ return .clear
|
|
|
+ }
|
|
|
+ return rowView
|
|
|
+ }
|
|
|
+
|
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
|
var cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "CellId"), owner: self) as? KMNewUserGuideCellView
|
|
|
if cell == nil {
|
|
|
cell = KMNewUserGuideCellView()
|
|
|
}
|
|
|
|
|
|
+ cell?.contentInset = .init(top: 4, left: 0, bottom: 4, right: 0)
|
|
|
+
|
|
|
guard let model = datas_.safe_element(for: row) as? KMNewUserGuideModel else {
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
+ cell?.titleLabel.font = .SFProTextBoldFont(14)
|
|
|
+
|
|
|
cell?.titleLabel.stringValue = model.name
|
|
|
if let data = model.despAttri {
|
|
|
cell?.subTitleLabel.attributedStringValue = data
|
|
|
}
|
|
|
|
|
|
let isSelected = model.isSelected
|
|
|
+ cell?.subTitleLabel.isHidden = !isSelected
|
|
|
+ cell?.leftLine.isHidden = !isSelected
|
|
|
if KMAppearance.isDarkMode() {
|
|
|
|
|
|
} else {
|
|
|
+ cell?.titleLabel.textColor = NSColor(hex: "#42464D")
|
|
|
+ cell?.leftLine.layer?.backgroundColor = NSColor(hex: "#4982E6").cgColor
|
|
|
+
|
|
|
+ cell?.backgroundView.layer?.cornerRadius = 4
|
|
|
if isSelected {
|
|
|
+ cell?.backgroundView.layer?.backgroundColor = NSColor(hex: "#DCF4FF").withAlphaComponent(0.4).cgColor
|
|
|
} else {
|
|
|
- cell?.backgroundView.layer?.cornerRadius = 4
|
|
|
cell?.backgroundView.layer?.backgroundColor = .white
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return cell
|
|
|
}
|
|
|
+
|
|
|
+ func tableViewSelectionDidChange(_ notification: Notification) {
|
|
|
+ if tableView.isEqual(to: notification.object) {
|
|
|
+ let row = tableView.selectedRow
|
|
|
+ guard let model = datas_.safe_element(for: row) as? KMNewUserGuideModel else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ selectType(model.type)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|