|
@@ -49,8 +49,19 @@ class KMLoginWindowsController: NSWindowController {
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccessNotification), name: NSNotification.Name(rawValue: "MemberCenterLoginSuccess"), object: nil)
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccessNotification), name: NSNotification.Name(rawValue: "MemberCenterLogoutSuccess"), object: nil)
|
|
|
+
|
|
|
+ rightBox.addObserver(self, forKeyPath: "contentView", options: [.new, .old], context: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func showWindow(_ sender: Any?) {
|
|
|
+ super.showWindow(sender)
|
|
|
+
|
|
|
+ initializeUI()
|
|
|
}
|
|
|
|
|
|
+ deinit {
|
|
|
+ rightBox.removeObserver(self, forKeyPath: "contentView")
|
|
|
+ }
|
|
|
|
|
|
// MARK: Private Action
|
|
|
|
|
@@ -140,4 +151,21 @@ class KMLoginWindowsController: NSWindowController {
|
|
|
.store(in: &cancellables)
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
|
|
+ if keyPath == "contentView" {
|
|
|
+ if let newContentView = change?[.newKey] as? NSView {
|
|
|
+ if newContentView is KMSignUpView {
|
|
|
+ viewModel.screenType = .signUp
|
|
|
+ } else if newContentView is KMForgotPasswordView {
|
|
|
+ viewModel.screenType = .forgotPassword
|
|
|
+ } else if newContentView is KMEnterVerificationCodeView {
|
|
|
+ viewModel.screenType = .enterVerificationCode
|
|
|
+ } else if newContentView is KMEnterNewPasswordView {
|
|
|
+ viewModel.screenType = .enterNewPassword
|
|
|
+ }
|
|
|
+ refreshSplitView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|