- iOS 11 and higher
- MacOS 10.15 and higher
Search for: https://github.com/mishadovhiy/AlertViewLibrary
import AlertViewLibrary
lazy var alert:AlertManager = .init()
// performs instantialization of UIView from xib
Done! And now you can use the Library
alert.showLoading(description: "Your loading description")
// Adds self (UIView) to UIWindow of active UIScene
alert.showAlert(title: "Your Title", description: "Your Description", appearence: .with({
$0.image = .image(.init(named: "screen1")!)
}))
// Adds self (UIView) to UIWindow of active UIScene
error.mp4
alert.showAlert(title: nil, appearence: .type(.error))
appearence: Declared in https://github.com/mishadovhiy/AlertViewLibrary/blob/main/Sources/AlertViewLibrary/AlertViewLibrary/Extensions_AlertViewLibrary.swift#L74
primary types:
- error
- standard (default)
- succsess
Note: .error and .success types are setting default title (when alert title is nill) and default image
default image or title can be setted when initializing AlertManager
To Show error or success without default image, set
alert.showAlert(title: nil, appearence: .with({
$0.type = .error
$0.image = AlertViewLibrary.AIImage.none
}))
And you can set primary and secondary button (with type, title and completion handler) if primaryButton or secondaryButton is not initialized in showAlert method - would be displayed single ok button that hides an alert (default ok title text could be setted when initializing the Library)
AlertManager.init(appearence:.with({
$0.colors = .with({
$0.alertState = .with({
$0.view = blue
$0.background = .black.withAlphaComponent(0.5)
})
$0.activityState = .with({
$0.view = orange.withAlphaComponent(0.8)
$0.background = .black.withAlphaComponent(0.1)
})
$0.texts = .with({
$0.title = .black
$0.description = .black.withAlphaComponent(0.5)
})
$0.buttom = .with({
$0.link = .black
$0.normal = .gray
})
})
$0.animations = .with({
$0.setBackground = 0.8
$0.alertShow = 0.5
$0.performHide1 = 0.5
$0.performHide2 = 0.3
$0.loadingShow1 = 0.4
$0.loadingShow2 = 0.5
})
$0.images = .with({
$0.alertError = nil
$0.alertSuccess = nil
})
}))
Appearence declaration: https://github.com/mishadovhiy/AlertViewLibrary/blob/main/Sources/AlertViewLibrary/Model/AIAppearence.swift#L10
All parameters are optional
- Manages unseen alerts When Alert View is presenting - all new alerts would be added to the query and would be presented later
- Customize animation, default texts, default images, colors, layer (corner radius, etc)
- Budget Tracker App https://github.com/mishadovhiy/Budget-Tracker/blob/master/Budget%20Tracker/AppDelegate/AppDelegate.swift#L31
- Random Moview App https://github.com/mishadovhiy/randomMovie/blob/main/MovieList/Model/TestAlert.swift#L11
Created by Misha Dovhiy