|
@@ -42,6 +42,8 @@ class KMSignUpView: KMBaseXibView {
|
|
|
private var viewModel = KMSignUpViewModel()
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
|
|
+ private var popOver_: NSPopover?
|
|
|
+
|
|
|
convenience init(model: KMSignUpViewModel, superView: NSView) {
|
|
|
self.init(frame: superView.bounds)
|
|
|
viewModel = model
|
|
@@ -308,6 +310,39 @@ class KMSignUpView: KMBaseXibView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private func _showPop() {
|
|
|
+ guard let _ = self.window else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.popOver_ != nil) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let popViewController = KMToolbarItemPopViewController()
|
|
|
+ self.popOver_ = NSPopover()
|
|
|
+ self.popOver_?.contentViewController = popViewController
|
|
|
+ self.popOver_?.animates = false
|
|
|
+ self.popOver_?.behavior = .semitransient
|
|
|
+ self.popOver_?.contentSize = popViewController.view.frame.size
|
|
|
+ self.popOver_?.delegate = self
|
|
|
+
|
|
|
+ // 0.8
|
|
|
+ var color = NSColor(hex: "#273C62").withAlphaComponent(1)
|
|
|
+ if KMAppearance.isDarkMode() {
|
|
|
+ color = NSColor(hex: "#4E7FDB").withAlphaComponent(1)
|
|
|
+ }
|
|
|
+ popViewController.view.wantsLayer = true
|
|
|
+ popViewController.view.layer?.backgroundColor = color.cgColor
|
|
|
+ self.popOver_?.setBackgroundColor(color)
|
|
|
+ popViewController.toolbarHelpTipLabel.textColor = .white
|
|
|
+ popViewController.toolbarHelpTipLabel.font = .SFProTextRegularFont(13)
|
|
|
+
|
|
|
+ popViewController.contentInset = .init(top: 12, left: 8, bottom: 12, right: 8)
|
|
|
+
|
|
|
+ popViewController.updateWithHelpTip(helpTip: NSLocalizedString("Please agree and check the agreement first.", tableName: "MemberCenterLocalizable", comment: ""))
|
|
|
+ self.popOver_?.show(relativeTo: NSMakeRect(0, 0, 0, 12), of: privacyCheckButton, preferredEdge: .maxY)
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: Bind Method
|
|
|
|
|
|
func bindViewModel() -> Void {
|
|
@@ -327,6 +362,7 @@ class KMSignUpView: KMBaseXibView {
|
|
|
.receive(on: RunLoop.main)
|
|
|
.sink { [weak self] newValue in
|
|
|
self?.checkStateChange(button: self?.privacyCheckButton, state: newValue)
|
|
|
+ self?.popOver_?.close()
|
|
|
}
|
|
|
.store(in: &cancellables)
|
|
|
viewModel.$signUpState
|
|
@@ -386,8 +422,18 @@ class KMSignUpView: KMBaseXibView {
|
|
|
}
|
|
|
}
|
|
|
.store(in: &cancellables)
|
|
|
+
|
|
|
+ viewModel.$privacyPopShow
|
|
|
+ .receive(on: RunLoop.main)
|
|
|
+ .sink { [weak self] newValue in
|
|
|
+ if newValue {
|
|
|
+ KMMainThreadExecute {
|
|
|
+ self?._showPop()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .store(in: &cancellables)
|
|
|
}
|
|
|
-
|
|
|
|
|
|
// MARK: Action Method
|
|
|
|
|
@@ -501,3 +547,11 @@ extension KMSignUpView: NSTextFieldDelegate {
|
|
|
resetTextFileData()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+extension KMSignUpView: NSPopoverDelegate {
|
|
|
+ func popoverDidClose(_ notification: Notification) {
|
|
|
+ if let data = self.popOver_?.isEqual(to: notification.object), data {
|
|
|
+ self.popOver_ = nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|