Skip to content

Commit

Permalink
fixing timing for animation when logging in; tweaked UI
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed Dec 9, 2023
1 parent f83d523 commit 9c659db
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 155 deletions.
15 changes: 6 additions & 9 deletions MainLoginWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class MainLoginWindowController: NSWindowController {
super.windowDidLoad()

window?.canBecomeVisibleWithoutLogin=true
// window?.level = .normal
// window?.backgroundColor = NSColor.white
// window?.titlebarAppearsTransparent = true
// window?.isMovable = false
let screenRect = NSScreen.screens[0].frame
window?.setFrame(screenRect, display: true, animate: false)
window?.alphaValue=0.9
Expand Down Expand Up @@ -94,9 +90,6 @@ class MainLoginWindowController: NSWindowController {

TCSLogWithMark("setting up window...")

self.window?.level = .normal
self.window?.orderFrontRegardless()
self.window?.makeKeyAndOrderFront(self)

self.window?.backgroundColor = NSColor.blue
self.window?.titlebarAppearsTransparent = true
Expand All @@ -121,6 +114,10 @@ class MainLoginWindowController: NSWindowController {
self.backgroundImageView.frame=NSMakeRect(screenRect.origin.x, screenRect.origin.y, screenRect.size.width, screenRect.size.height-100)

}
self.window?.level = .normal
// self.window?.orderFrontRegardless()
self.window?.makeKeyAndOrderFront(self)

TCSLogWithMark()
}
// self.window?.setFrame(NSMakeRect((screenWidth-CGFloat(width))/2,(screenHeight-CGFloat(height))/2, CGFloat(width), CGFloat(height)), display: true, animate: false)
Expand All @@ -131,7 +128,7 @@ class MainLoginWindowController: NSWindowController {
// @objc override var windowNibName: NSNib.Name {
// return NSNib.Name("LoginWebView")
// }
func loginTransition() {
func loginTransition( completion:@escaping ()->Void) {
TCSLogWithMark()
let screenRect = NSScreen.screens[0].frame
let progressIndicator=NSProgressIndicator.init(frame: NSMakeRect(screenRect.width/2-16 , 3*screenRect.height/4-16,32, 32))
Expand Down Expand Up @@ -170,7 +167,7 @@ class MainLoginWindowController: NSWindowController {
self.centerView?.removeFromSuperview()
// self.window?.orderOut(self)
self.controlsViewController?.view.removeFromSuperview()

completion()
})

}
Expand Down
85 changes: 29 additions & 56 deletions NomadLogin/UI/SignInWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ let checkADLog = OSLog(subsystem: "menu.nomad.login.ad", category: "CheckADMech"
@IBOutlet weak var usernameTextField: NSTextField!
@IBOutlet weak var passwordTextField: NSSecureTextField!
@IBOutlet weak var localOnlyCheckBox: NSButton!
@IBOutlet weak var stackView: NSStackView!

// @IBOutlet weak var domain: NSPopUpButton!
@IBOutlet weak var signIn: NSButton!
@IBOutlet weak var imageView: NSImageView!
Expand Down Expand Up @@ -65,8 +67,10 @@ let checkADLog = OSLog(subsystem: "menu.nomad.login.ad", category: "CheckADMech"
override func awakeFromNib() {
super.awakeFromNib()
TCSLogWithMark()
setupLoginAppearance()
//awakeFromNib gets called multiple times. guard against that.
if setupDone == false {

// updateLoginWindowInfo()
setupDone=true

Expand Down Expand Up @@ -153,72 +157,41 @@ let checkADLog = OSLog(subsystem: "menu.nomad.login.ad", category: "CheckADMech"
// }
//

func loginAppearance() {
// TCSLogWithMark()
// os_log("Setting window level", log: uiLog, type: .debug)
//
// self.window?.level = .normal
// self.window?.orderFrontRegardless()
func setupLoginAppearance() {
TCSLogWithMark()

self.view.wantsLayer=true
self.view.layer?.backgroundColor = CGColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 0.4)
localOnlyCheckBox.isEnabled=true

// let color = NSColor.white
// let colorTitle = NSMutableAttributedString(attributedString: localOnlyCheckBox.attributedTitle)
// let titleRange = NSMakeRange(0,colorTitle.length)
//
// localOnlyCheckBox.isEnabled=true
// signIn.isEnabled=true
// signIn.isHidden = false
// colorTitle.addAttributes([NSAttributedString.Key.foregroundColor : color], range: titleRange)
// localOnlyCheckBox.attributedTitle=colorTitle
//
// // make things look better
// os_log("Tweaking appearance", log: uiLog, type: .debug)
//
// if let usernamePlaceholder = UserDefaults.standard.string(forKey: PrefKeys.usernamePlaceholder.rawValue){
// TCSLogWithMark("Setting username placeholder: \(usernamePlaceholder)")
// self.username.placeholderString=usernamePlaceholder
// }
//
// if let passwordPlaceholder = UserDefaults.standard.string(forKey: PrefKeys.passwordPlaceholder.rawValue){
// TCSLogWithMark("Setting password placeholder")
//
// self.password.placeholderString=passwordPlaceholder
//
// }
TCSLog("Tweaking appearance")

if let usernamePlaceholder = UserDefaults.standard.string(forKey: PrefKeys.usernamePlaceholder.rawValue){
TCSLogWithMark("Setting username placeholder: \(usernamePlaceholder)")
self.usernameTextField.placeholderString=usernamePlaceholder
}

if let passwordPlaceholder = UserDefaults.standard.string(forKey: PrefKeys.passwordPlaceholder.rawValue){
TCSLogWithMark("Setting password placeholder")

self.passwordTextField.placeholderString=passwordPlaceholder

}
// if UserDefaults.standard.bool(forKey: PrefKeys.shouldShowLocalOnlyCheckbox.rawValue) == false {
// self.localOnlyCheckBox.isHidden = true
// }
// else {
// //show based on if there is an AD domain or not
// self.localOnlyCheckBox.isHidden = self.domainName.isEmpty
// }
//
// if getManagedPreference(key: .LoginScreen) as? Bool == false {
// os_log("Present as login screen", log: uiLog, type: .debug)
// self.window?.isOpaque = false
// self.window?.hasShadow = false
// self.window?.backgroundColor = .clear
// } else {
// os_log("Present as login window", log: uiLog, type: .debug)
// self.window?.backgroundColor = NSColor.lightGray
// }
// self.window?.titlebarAppearsTransparent = true
// if !self.domainName.isEmpty {
// self.isDomainManaged = true
// }
//
// let screenRect = NSScreen.screens[0].frame
// let screenWidth = screenRect.width
// let screenHeight = screenRect.height
//
// self.window?.setFrame(NSMakeRect(0,0 , screenWidth, screenHeight), display: true)
// self.window?.isMovable = false
// self.window?.canBecomeVisibleWithoutLogin = true
// self.window?.level = .normal
// self.window?.titlebarAppearsTransparent = true
//
// if let logoPath = getManagedPreference(key: .LoginLogo) as? String {
// os_log("Found logoPath: %{public}@", log: uiLog, type: .debug, logoPath)
// if logoPath == "NONE" {
// imageView.image = nil
// } else {
// imageView.image = NSImage(contentsOf: URL(fileURLWithPath: logoPath))
// }
// }
//
// if let logoData = getManagedPreference(key: .LoginLogoData) as? Data {
// os_log("Found LoginLogoData key has a value", log: uiLog, type: .debug)
// if let image = NSImage(data: logoData) as NSImage? {
Expand Down
4 changes: 2 additions & 2 deletions XCredsLoginPlugIn/LoginWindow/ControlsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ class ControlsViewController: NSViewController {
TCSLogWithMark("Trial")
self.trialVersionStatusTextField?.isHidden = false
if daysRemaining==1 {
self.trialVersionStatusTextField.stringValue = "XCreds Trial. One day remaining on trial."
self.trialVersionStatusTextField.stringValue = "XCreds Trial. One day remaining."

}
else {
self.trialVersionStatusTextField.stringValue = "XCreds Trial. \(daysRemaining) days remaining on trial."
self.trialVersionStatusTextField.stringValue = "XCreds Trial. \(daysRemaining) days remaining."
}

case .trialExpired:
Expand Down
2 changes: 1 addition & 1 deletion XCredsLoginPlugIn/LoginWindow/ControlsViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<rect key="frame" x="10" y="-1" width="122" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="XCreds 1.1.1 (2000)" id="RPn-fH-Reb">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="alternateSelectedControlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
Expand Down

0 comments on commit 9c659db

Please sign in to comment.