Skip to content

Blocking progress view #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions SwiftOverlays/SwiftOverlays.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,22 @@ open class SwiftOverlays: NSObject {

return blocker
}

/**
Shows *blocking* overlay *with progress view and text*,, centered in the app's main window

- parameter text: Text to be shown on overlay

- returns: Created overlay
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it returns UIProgressView!

*/
open class func showBlockingProgressOverlay(_ text: String) -> UIProgressView {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check how showProgressOverlay works. It returns UIView, if programmer needs to update progress, he should use updateOverlayProgress

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the updateOverlayProgress part. I will make an update to return a UIView and use updateOverlayProgress accordingly.

let blocker = addMainWindowBlocker()
let pv = UIProgressView(progressViewStyle: .default)

showGenericOverlay(blocker, text: text, accessoryView: pv)

return pv
}

/**
Removes all *blocking* overlays from application's main window
Expand Down Expand Up @@ -313,11 +329,12 @@ open class SwiftOverlays: NSObject {
accessoryView.frame = accessoryView.frame.offsetBy(dx: padding, dy: (actualSize.height - accessoryView.frame.size.height)/2)
} else {
actualSize = CGSize(width: max(accessoryView.frame.size.width, label.frame.size.width) + padding * 2,
height: label.frame.size.height + accessoryView.frame.size.height + padding * 3)

label.frame = label.frame.offsetBy(dx: padding, dy: accessoryView.frame.size.height + padding * 2)
height: label.frame.size.height + accessoryView.frame.size.height + padding * 2)

accessoryView.frame = accessoryView.frame.offsetBy(dx: (actualSize.width - accessoryView.frame.size.width)/2, dy: padding)

label.center.x = accessoryView.center.x
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work with multi-line label?

label.center.y = accessoryView.center.y + (accessoryView.frame.height * 2) + padding
}

// Container view
Expand Down