KMSignUpView.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. //
  2. // KMSignUpView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/10/23.
  6. //
  7. import Cocoa
  8. import Combine
  9. class KMSignUpView: KMBaseXibView {
  10. @IBOutlet weak var signUpLabel: NSTextField!
  11. @IBOutlet weak var loginModeBox: NSBox!
  12. @IBOutlet weak var verificationCodeButton: NSButton!
  13. @IBOutlet weak var selectBox1: NSBox!
  14. @IBOutlet weak var passwordButton: NSButton!
  15. @IBOutlet weak var selectBox2: NSBox!
  16. @IBOutlet weak var emailBox: NSBox!
  17. @IBOutlet weak var emailTextField: NSTextField!
  18. @IBOutlet weak var emailErrorLabel: NSTextField!
  19. @IBOutlet weak var passwordBox: NSBox!
  20. @IBOutlet weak var verifficationView: NSView!
  21. @IBOutlet weak var verifficationBox: NSBox!
  22. @IBOutlet weak var verifficationTextField: NSTextField!
  23. @IBOutlet weak var sendBox: KMBox!
  24. @IBOutlet weak var sendLabel: NSTextField!
  25. @IBOutlet weak var passwordView: NSView!
  26. @IBOutlet weak var passwordTextField: NSTextField!
  27. @IBOutlet weak var passwordTextField1: NSSecureTextField!
  28. @IBOutlet weak var visibleButton: NSButton!
  29. @IBOutlet weak var passwordErrorLabel: NSTextField!
  30. @IBOutlet weak var stayCheckButton: NSButton!
  31. @IBOutlet weak var stayLabel: NSTextField!
  32. @IBOutlet weak var forgetButton: NSButton!
  33. @IBOutlet weak var signUpBox: NSBox!
  34. @IBOutlet weak var signUpButton: NSButton!
  35. @IBOutlet weak var privacyCheckButton: NSButton!
  36. @IBOutlet weak var privacyLabel: NSTextField!
  37. private var viewModel = KMSignUpViewModel()
  38. private var cancellables = Set<AnyCancellable>()
  39. convenience init(model: KMSignUpViewModel, superView: NSView) {
  40. self.init(frame: superView.bounds)
  41. viewModel = model
  42. viewModel.screenType = .signUp
  43. bindViewModel()
  44. languageLocalized()
  45. initializeUI()
  46. if model.sendCode {
  47. self.viewModel.countDown(type: .login, callback: nil)
  48. model.sendCode = false
  49. }
  50. }
  51. public override init(frame frameRect: NSRect) {
  52. super.init(frame: frameRect)
  53. }
  54. public required init?(coder decoder: NSCoder) {
  55. fatalError("init(coder:) has not been implemented")
  56. }
  57. public func resetTextFileData() {
  58. if(self.superview != nil) {
  59. emailTextField.stringValue = ""
  60. passwordTextField.stringValue = ""
  61. passwordTextField1.stringValue = ""
  62. verifficationTextField.stringValue = ""
  63. emailErrorLabel.isHidden = true
  64. passwordErrorLabel.isHidden = true
  65. sendLabel.stringValue = NSLocalizedString("Send", tableName: "MemberCenterLocalizable", comment: "")
  66. viewModel.sendContent = NSLocalizedString("Send", tableName: "MemberCenterLocalizable", comment: "")
  67. viewModel.email = ""
  68. sendBoxRefresh()
  69. }
  70. }
  71. override func updateUI() {
  72. super.updateUI()
  73. NotificationCenter.default.addObserver(self, selector: #selector(loginSuccessNotification), name: NSNotification.Name(rawValue: "MemberCenterLoginSuccess"), object: nil)
  74. bindViewModel()
  75. languageLocalized()
  76. initializeUI()
  77. }
  78. // MARK: Private Method
  79. private func languageLocalized() -> Void {
  80. signUpLabel.stringValue = NSLocalizedString("Sign in(titile)", tableName: "MemberCenterLocalizable", comment: "")
  81. verificationCodeButton.title = NSLocalizedString("Verification Code", tableName: "MemberCenterLocalizable", comment: "")
  82. passwordButton.title = NSLocalizedString("Password", tableName: "MemberCenterLocalizable", comment: "")
  83. stayLabel.stringValue = NSLocalizedString("Stay signed in", tableName: "MemberCenterLocalizable", comment: "")
  84. forgetButton.title = NSLocalizedString("Forgot password?", tableName: "MemberCenterLocalizable", comment: "")
  85. signUpButton.title = NSLocalizedString("Sign in(button)", tableName: "MemberCenterLocalizable", comment: "")
  86. emailErrorLabel.stringValue = String(format: "*%@", NSLocalizedString("Email format error. Please enter the correct email.", tableName: "MemberCenterLocalizable", comment: ""))
  87. passwordErrorLabel.stringValue = String(format: "*%@", NSLocalizedString("Verification code error.", tableName: "MemberCenterLocalizable", comment: ""))
  88. emailTextField.placeholderString = NSLocalizedString("Please enter email address", tableName: "MemberCenterLocalizable", comment: "")
  89. verifficationTextField.placeholderString = NSLocalizedString("Please enter code", tableName: "MemberCenterLocalizable", comment: "")
  90. passwordTextField.placeholderString = NSLocalizedString("Please enter password", tableName: "MemberCenterLocalizable", comment: "")
  91. passwordTextField1.placeholderString = NSLocalizedString("Please enter password", tableName: "MemberCenterLocalizable", comment: "")
  92. privacyCheckButton.toolTip = NSLocalizedString("Please agree and check the above agreement first.", tableName: "MemberCenterLocalizable", comment: "")
  93. emailTextField.stringValue = viewModel.email
  94. verifficationTextField.stringValue = viewModel.verificationCode
  95. passwordTextField.stringValue = viewModel.password
  96. passwordTextField1.stringValue = viewModel.password
  97. }
  98. private func initializeUI() -> Void {
  99. emailBox.fillColor = NSColor(named: "texefiedfillcolor") ?? NSColor.white
  100. passwordBox.fillColor = NSColor(named: "texefiedfillcolor") ?? NSColor.white
  101. emailTextField.delegate = self
  102. verifficationTextField.delegate = self
  103. passwordTextField.delegate = self
  104. passwordTextField1.delegate = self
  105. emailErrorLabel.isHidden = !viewModel.emailError()
  106. passwordErrorLabel.isHidden = !viewModel.passwordError()
  107. signUpLabel.textColor = NSColor(named: "000000")
  108. signUpLabel.font = NSFont.SFMediumFontWithSize(20)
  109. selectBox1.fillColor = NSColor(named: "4982E6") ?? NSColor.blue
  110. emailErrorLabel.textColor = NSColor(named: "FA1E5D")
  111. emailErrorLabel.font = NSFont.SFProTextRegularFont(9)
  112. passwordBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  113. verifficationBox.borderColor = NSColor(named: "FA1E5D") ?? NSColor.gray
  114. if viewModel.isValidEmail() {
  115. sendBox.fillColor = NSColor(named: "273C62") ?? NSColor.blue
  116. } else {
  117. sendBox.fillColor = NSColor(named: "273C62_0.4") ?? NSColor.blue
  118. }
  119. sendBox.borderColor = NSColor(named: "273C62") ?? NSColor.blue
  120. sendLabel.textColor = NSColor(named: "FFFFFF") ?? NSColor.white
  121. sendLabel.font = NSFont.SFProTextRegularFont(13)
  122. passwordErrorLabel.textColor = NSColor(named: "FA1E5D")
  123. passwordErrorLabel.font = NSFont.SFProTextRegularFont(9)
  124. stayCheckButton.image = NSImage(named: "CheckBoxNor")
  125. stayLabel.textColor = NSColor(named: "0E1114") ?? NSColor.black
  126. stayLabel.font = NSFont.SFProTextRegularFont(12)
  127. forgetButton.setTitleColor(color: NSColor(named: "4982E6") ?? NSColor.blue, font: NSFont.SFProTextRegularFont(12))
  128. signUpBox.fillColor = NSColor(named: "273C62") ?? NSColor.blue
  129. signUpButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(16))
  130. privacyCheckButton.image = NSImage(named: "CheckBoxNor")
  131. privacyLabel.isEditable = false
  132. privacyLabel.isSelectable = true
  133. privacyLabel.allowsEditingTextAttributes = true
  134. privacyLabel.textColor = NSColor.black
  135. privacyLabel.font = NSFont.SFProTextRegularFont(16.0)
  136. let tipsString = NSLocalizedString("I have read and agreed to the %@ and %@. An account will be automatically created after signing in with an unregistered email address.", tableName: "MemberCenterLocalizable", comment: "")
  137. let specialOffer = NSLocalizedString("Terms of Service", tableName: "MemberCenterLocalizable", comment: "")
  138. let contactsUs = NSLocalizedString("Privacy Policy", tableName: "MemberCenterLocalizable", comment: "")
  139. let fullString = String(format: tipsString, specialOffer, contactsUs)
  140. let attributedString = NSMutableAttributedString(string: fullString)
  141. // 定义链接的范围
  142. let specialOfferRange = (fullString as NSString).range(of: specialOffer)
  143. let contactsUsRange = (fullString as NSString).range(of: contactsUs)
  144. let linkColor = NSColor(named: "4982E6") ?? NSColor.blue
  145. let font = NSFont.SFProTextRegularFont(11.0) // 与普通文本相同的字体
  146. attributedString.addAttributes([
  147. .foregroundColor: NSColor(named: "0E1114") ?? NSColor.black as Any,
  148. .font: font
  149. ], range: (fullString as NSString).range(of: fullString))
  150. attributedString.addAttributes([
  151. .foregroundColor: linkColor,
  152. .link: NSLocalizedString("https://www.pdfreaderpro.com/terms_of_service", comment: ""),
  153. .font: font
  154. ], range: specialOfferRange)
  155. attributedString.addAttributes([
  156. .foregroundColor: linkColor,
  157. .link: NSLocalizedString("https://www.pdfreaderpro.com/privacy-policy", comment: ""),
  158. .font: font
  159. ], range: contactsUsRange)
  160. privacyLabel.attributedStringValue = attributedString
  161. signUpStateChange()
  162. visibleStateChange()
  163. textfieldInputState(isEmail: true)
  164. textfieldInputState(isEmail: false)
  165. sendBoxRefresh()
  166. sendBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  167. guard let self = self else { return }
  168. if self.viewModel.email.count <= 0 { return }
  169. if self.viewModel.sendBoxSelect { return }
  170. if !self.viewModel.isValidEmail() { return }
  171. if mouseEntered {
  172. self.sendBox.fillColor = NSColor(named: "000000_0.1") ?? NSColor.blue
  173. } else {
  174. self.sendBox.fillColor = NSColor(named: "273C62") ?? NSColor.blue
  175. }
  176. }
  177. sendBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  178. guard let self = self else { return }
  179. if self.viewModel.email.count <= 0 { return }
  180. if self.viewModel.sendBoxSelect { return }
  181. if downEntered {
  182. self.sendBox.fillColor = NSColor(named: "273C62_0.4") ?? NSColor.blue
  183. self.viewModel.countDown(type: .login, callback: nil)
  184. }
  185. }
  186. }
  187. private func signUpStateChange() -> Void {
  188. if viewModel.signUpState == .verificationCode {
  189. selectBox1.isHidden = false
  190. selectBox2.isHidden = true
  191. verificationCodeButton.setTitleColor(color: NSColor(named: "4982E6") ?? NSColor.systemBlue, font: NSFont.SFProTextRegularFont(14))
  192. passwordButton.setTitleColor(color: NSColor(named: "42464D") ?? NSColor.black, font: NSFont.SFProTextRegularFont(14))
  193. verifficationView.isHidden = false
  194. passwordView.isHidden = true
  195. verifficationTextField.placeholderString = NSLocalizedString("Please enter code", tableName: "MemberCenterLocalizable", comment: "")
  196. forgetButton.isHidden = true
  197. } else if viewModel.signUpState == .password {
  198. selectBox1.isHidden = true
  199. selectBox2.isHidden = false
  200. verificationCodeButton.setTitleColor(color: NSColor(named: "42464D") ?? NSColor.black, font: NSFont.SFProTextRegularFont(14))
  201. passwordButton.setTitleColor(color: NSColor(named: "4982E6") ?? NSColor.black, font: NSFont.SFProTextRegularFont(14))
  202. verifficationView.isHidden = true
  203. passwordView.isHidden = false
  204. passwordTextField.placeholderString = NSLocalizedString("Please enter password", tableName: "MemberCenterLocalizable", comment: "")
  205. passwordTextField1.placeholderString = NSLocalizedString("Please enter password", tableName: "MemberCenterLocalizable", comment: "")
  206. forgetButton.isHidden = false
  207. }
  208. }
  209. private func checkStateChange(button: NSButton!, state: Bool) -> Void {
  210. button.state = state ? .on : .off
  211. if button.state == .on {
  212. button.image = NSImage(named: "CheckBoxSel")
  213. } else {
  214. button.image = NSImage(named: "CheckBoxNor")
  215. }
  216. }
  217. private func visibleStateChange() -> Void {
  218. if viewModel.isVisible {
  219. visibleButton.image = NSImage(named: "passwordVisible")
  220. passwordTextField.isHidden = false
  221. passwordTextField1.isHidden = true
  222. passwordTextField.stringValue = viewModel.password
  223. } else {
  224. visibleButton.image = NSImage(named: "passwordUnVisible")
  225. passwordTextField.isHidden = true
  226. passwordTextField1.isHidden = false
  227. passwordTextField1.stringValue = viewModel.password
  228. }
  229. }
  230. private func textfieldInputState(isEmail: Bool) -> Void {
  231. if isEmail {
  232. if viewModel.emailError() {
  233. emailBox.borderColor = NSColor(named: "FA1E5D") ?? NSColor.red
  234. } else {
  235. emailBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  236. }
  237. emailErrorLabel.isHidden = !viewModel.emailError()
  238. } else {
  239. if viewModel.passwordError() {
  240. if viewModel.signUpState == .verificationCode {
  241. passwordBox.borderWidth = 0
  242. verifficationBox.borderWidth = 1
  243. passwordBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  244. verifficationBox.borderColor = NSColor(named: "FA1E5D") ?? NSColor.red
  245. } else if viewModel.signUpState == .password {
  246. passwordBox.borderWidth = 1
  247. verifficationBox.borderWidth = 0
  248. verifficationBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  249. passwordBox.borderColor = NSColor(named: "FA1E5D") ?? NSColor.red
  250. }
  251. } else {
  252. if viewModel.signUpState == .verificationCode {
  253. passwordBox.borderWidth = 1
  254. verifficationBox.borderWidth = 0
  255. } else if viewModel.signUpState == .password {
  256. passwordBox.borderWidth = 1
  257. verifficationBox.borderWidth = 0
  258. }
  259. }
  260. passwordErrorLabel.isHidden = !viewModel.passwordError()
  261. }
  262. }
  263. private func sendBoxRefresh() -> Void {
  264. sendLabel.stringValue = viewModel.sendContent
  265. if viewModel.sendContent == NSLocalizedString("Send", tableName: "MemberCenterLocalizable", comment: "") ||
  266. viewModel.sendContent == NSLocalizedString("Resend", tableName: "MemberCenterLocalizable", comment: "") {
  267. if viewModel.email.count > 0 {
  268. if viewModel.isValidEmail() {
  269. sendBox.fillColor = NSColor(named: "273C62") ?? NSColor.blue
  270. } else {
  271. sendBox.fillColor = NSColor(named: "273C62_0.4") ?? NSColor.blue
  272. }
  273. } else {
  274. sendBox.fillColor = NSColor(named: "273C62_0.4") ?? NSColor.blue
  275. }
  276. sendLabel.textColor = NSColor(named: "FFFFFF") ?? NSColor.white
  277. } else {
  278. sendBox.fillColor = NSColor(named: "DADBDE") ?? NSColor.gray
  279. sendLabel.stringValue = String(format: "%@s", viewModel.sendContent)
  280. sendLabel.textColor = NSColor(named: "0E1114") ?? NSColor.black
  281. }
  282. }
  283. // MARK: Bind Method
  284. func bindViewModel() -> Void {
  285. viewModel.$isVisible
  286. .receive(on: RunLoop.main)
  287. .sink { [weak self] newValue in
  288. self?.visibleStateChange()
  289. }
  290. .store(in: &cancellables)
  291. viewModel.$stayState
  292. .receive(on: RunLoop.main)
  293. .sink { [weak self] newValue in
  294. self?.checkStateChange(button: self?.stayCheckButton, state: newValue)
  295. }
  296. .store(in: &cancellables)
  297. viewModel.$privacyState
  298. .receive(on: RunLoop.main)
  299. .sink { [weak self] newValue in
  300. self?.checkStateChange(button: self?.privacyCheckButton, state: newValue)
  301. }
  302. .store(in: &cancellables)
  303. viewModel.$signUpState
  304. .receive(on: RunLoop.main)
  305. .sink { [weak self] newValue in
  306. self?.signUpStateChange()
  307. }
  308. .store(in: &cancellables)
  309. viewModel.$emailErrorMessage
  310. .receive(on: RunLoop.main)
  311. .sink { [weak self] newValue in
  312. self?.emailErrorLabel.stringValue = newValue
  313. self?.emailErrorLabel.isHidden = false
  314. self?.textfieldInputState(isEmail: true)
  315. }
  316. .store(in: &cancellables)
  317. viewModel.$passwordErrorMessage
  318. .receive(on: RunLoop.main)
  319. .sink { [weak self] newValue in
  320. self?.passwordErrorLabel.stringValue = newValue
  321. if self?.viewModel.passwordErrorMessage == "" {
  322. self?.passwordErrorLabel.isHidden = true
  323. } else {
  324. self?.passwordErrorLabel.isHidden = false
  325. }
  326. }
  327. .store(in: &cancellables)
  328. viewModel.$sendContent
  329. .receive(on: RunLoop.main)
  330. .sink { [weak self] newValue in
  331. self?.sendBoxRefresh()
  332. }
  333. .store(in: &cancellables)
  334. viewModel.$email
  335. .receive(on: RunLoop.main)
  336. .sink { [weak self] newValue in
  337. self?.sendBoxRefresh()
  338. }
  339. .store(in: &cancellables)
  340. viewModel.$verificationCode
  341. .receive(on: RunLoop.main)
  342. .sink { [weak self] newValue in
  343. if newValue.count <= 6 && newValue.count >= 0 {
  344. self?.viewModel.passwordErrorMessage = ""
  345. } else {
  346. self?.viewModel.passwordErrorMessage = NSLocalizedString("Verification code error.", tableName: "MemberCenterLocalizable", comment: "")
  347. }
  348. }
  349. .store(in: &cancellables)
  350. viewModel.$password
  351. .receive(on: RunLoop.main)
  352. .sink { [weak self] newValue in
  353. if newValue.count <= 30 && newValue.count >= 0 {
  354. self?.viewModel.passwordErrorMessage = ""
  355. } else {
  356. self?.viewModel.passwordErrorMessage = NSLocalizedString("Password cannot exceed 30 characters.", tableName: "MemberCenterLocalizable", comment: "")
  357. }
  358. }
  359. .store(in: &cancellables)
  360. }
  361. // MARK: Action Method
  362. @IBAction func verificationCodeAction(_ sender: NSButton) {
  363. viewModel.signUpStateChange(state: .verificationCode)
  364. }
  365. @IBAction func passwordAction(_ sender: NSButton) {
  366. viewModel.signUpStateChange(state: .password)
  367. }
  368. @IBAction func visibleAction(_ sender: NSButton) {
  369. viewModel.isVisible.toggle()
  370. }
  371. @IBAction func stayCheckAction(_ sender: NSButton) {
  372. viewModel.stayState.toggle()
  373. viewModel.stayStateAction()
  374. }
  375. @IBAction func signUpAction(_ sender: NSButton) {
  376. self.window?.makeFirstResponder(nil)
  377. viewModel.emailErrorMessage = ""
  378. viewModel.passwordErrorMessage = ""
  379. window?.showWaitingView()
  380. viewModel.signUpAction { [weak self] result, _ in
  381. self?.window?.hideWaitingView()
  382. }
  383. }
  384. @IBAction func forgetAction(_ sender: NSButton) {
  385. guard let parentView = self.superview else { return }
  386. if parentView is NSBox {
  387. let model = KMSignUpViewModel()
  388. model.email = viewModel.email
  389. let forgotView = KMForgotPasswordView(model: model, superView: parentView)
  390. NSAnimationContext.runAnimationGroup { context in
  391. context.duration = 0.3
  392. self.animator().alphaValue = 0
  393. } completionHandler: {
  394. self.removeFromSuperview()
  395. forgotView.alphaValue = 0
  396. (parentView as! NSBox).contentView = forgotView
  397. NSAnimationContext.runAnimationGroup({ context in
  398. context.duration = 0.3
  399. forgotView.animator().alphaValue = 1
  400. }, completionHandler: nil)
  401. }
  402. } else {
  403. let model = KMSignUpViewModel()
  404. model.email = viewModel.email
  405. let forgotView = KMForgotPasswordView(model: model, superView: parentView)
  406. NSAnimationContext.runAnimationGroup { context in
  407. context.duration = 0.3
  408. self.animator().alphaValue = 0
  409. } completionHandler: {
  410. self.removeFromSuperview()
  411. forgotView.alphaValue = 0
  412. parentView.addSubview(forgotView)
  413. NSAnimationContext.runAnimationGroup({ context in
  414. context.duration = 0.3
  415. forgotView.animator().alphaValue = 1
  416. }, completionHandler: nil)
  417. }
  418. }
  419. }
  420. @IBAction func privacyCheckAction(_ sender: NSButton) {
  421. viewModel.privacyState.toggle()
  422. }
  423. }
  424. extension KMSignUpView: NSTextFieldDelegate {
  425. func controlTextDidEndEditing(_ obj: Notification) {
  426. let textField = obj.object as? NSTextField
  427. if textField == emailTextField {
  428. viewModel.email = textField!.stringValue
  429. } else if textField == verifficationTextField {
  430. viewModel.verificationCode = textField!.stringValue
  431. } else if textField == passwordTextField {
  432. viewModel.password = textField!.stringValue
  433. } else if textField == passwordTextField1 {
  434. viewModel.password = textField!.stringValue
  435. }
  436. }
  437. func controlTextDidChange(_ obj: Notification) {
  438. let textField = obj.object as? NSTextField
  439. if textField == emailTextField {
  440. viewModel.emailErrorMessage = ""
  441. viewModel.email = textField!.stringValue
  442. emailBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  443. } else if textField == verifficationTextField {
  444. viewModel.passwordErrorMessage = ""
  445. viewModel.verificationCode = textField!.stringValue
  446. verifficationBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  447. } else if textField == passwordTextField {
  448. viewModel.passwordErrorMessage = ""
  449. viewModel.password = textField!.stringValue
  450. passwordBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  451. } else if textField == passwordTextField1 {
  452. viewModel.passwordErrorMessage = ""
  453. viewModel.password = textField!.stringValue
  454. passwordBox.borderColor = NSColor(named: "DADBDE") ?? NSColor.gray
  455. }
  456. }
  457. @objc func loginSuccessNotification() -> Void {
  458. resetTextFileData()
  459. }
  460. }