Skip to content

Conversation

PedroCavaleiro
Copy link

@PedroCavaleiro PedroCavaleiro commented Apr 8, 2020

Hi,

I suggested a Loading View a few months back and you pointed me to this repo mlouli/SPAlert

I grabbed his changes but also made a few of my own

you can show a alert in a simple yet fast way

let alert = SPAlert.presentLoader(message: "Loading...")
alert.dismis()

If you want using the timeout it's also possible

let _ = SPAlert.presentLoader(message: "Loading...", timeout: 5)

by default it makes the loading view as a rectangle, this is a preference of my own, but you may disable this option by

let loadingView = SPAlertView(loadingMessage = "Loading...")
loadingView.makeLoadingViewRectangular = false
loadingView.present()

this way it will use the normal calculations.

I also updated the README.md to include this changes.

This library was tested in SwiftUI and found no errors

A loading view was added with dismiss and timeout, currently does not have the UIActivityIndicatorView
@ivanvorobei
Copy link
Member

Thanks for changes! You solve many problems. I soon check it. Thanks!

@PedroCavaleiro
Copy link
Author

It's now possible to change the foreground color and made a small change on the initialization of the activity view

let alertWithDismiss = SPAlertView(loadingMessage: "Loading...")
let alertWithTimeout = SPAlertView(loadingMessage: "Loading...", timeout: 3)

alertWithDismiss.foregroundColor = UIColor.white

If no color is passed it uses the default check the private var foregroundColorDefault: UIColor

The foregroundColor is now working properly 
There's now a option to blur the background of an alert or loading view, being disabled by default for the alerts and enabled by default for loading views
@PedroCavaleiro
Copy link
Author

It's now possible to add a blur to the views under the alert.

By default the blur is disabled for the alerts and enabled for the loading views

let alert = SPAlertView(loadingMessage: "Loading...")
alert.blurBackground = false

In case of the loading views you can disable on the initialization

let alert = SPAlertView(loadingMessage: "Loading...", blurBackground: false)

@kuwait
Copy link

kuwait commented Apr 12, 2020

Looks very nice! waiting on this as well asap!

@PedroCavaleiro
Copy link
Author

As I'm also using this for an app that supports macOS Catalyst, this would give me a warning, to suppress the warning I added the following code.

public var keyWindow: UIView {
        if #available(iOS 13, macCatalyst 13, *) {
            return UIApplication.shared.connectedScenes
                .filter({$0.activationState == .foregroundActive})
                .map({$0 as? UIWindowScene})
                .compactMap({$0})
                .first?.windows
                .filter({$0.isKeyWindow}).first ?? UIWindow()
        } else {
            return (UIApplication.shared.keyWindow ?? UIWindow())
        }
    }

Allowing the newest versions of iOS, and macCatalyst to work but also older versions will still work

@ivanvorobei
Copy link
Member

Hi!
Sorry for big delay. I am open talk about loading if its still need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants