https://github.com/mishadovhiy/alertviewlibrary
Swift package to display Loading indicator or Alert (UIView)
https://github.com/mishadovhiy/alertviewlibrary
package-dependency swift uikit uiwindow xib
Last synced: 3 months ago
JSON representation
Swift package to display Loading indicator or Alert (UIView)
- Host: GitHub
- URL: https://github.com/mishadovhiy/alertviewlibrary
- Owner: mishadovhiy
- Created: 2022-06-06T20:45:41.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T08:48:45.000Z (over 1 year ago)
- Last Synced: 2024-11-10T15:38:34.240Z (7 months ago)
- Topics: package-dependency, swift, uikit, uiwindow, xib
- Language: Swift
- Homepage: https://mishadovhiy.com/#AlertLib
- Size: 228 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AlertViewLibrary
![]()
# Compatibility
- iOS 11 and higher
- MacOS 10.15 and higher# Installation
### Add AlertViewLibrary Package Dependency to your project
###
Search for: https://github.com/mishadovhiy/AlertViewLibrary
![]()
# Usage
## Initialization
### Import Library
```
import AlertViewLibrary
```
### Initialize Library
```
lazy var alert:AlertManager = .init()
```// performs instantialization of UIView from xib
Done! And now you can use the Library
## Basic Usage Examples
![]()
![]()
### Show Loading indicator
```
alert.showLoading(description: "Your loading description")
```// Adds self (UIView) to UIWindow of active UIScene
### Show Alert
```
alert.showAlert(title: "Your Title", description: "Your Description", appearence: .with({
$0.image = .image(.init(named: "screen1")!)
}))
```// Adds self (UIView) to UIWindow of active UIScene
### Alert Types
https://github.com/mishadovhiy/AlertViewLibrary/assets/44978117/662eb63e-11e4-4b16-a1d8-937e0b197c8b
```
alert.showAlert(title: nil, appearence: .type(.error))
```appearence: Declared in https://github.com/mishadovhiy/AlertViewLibrary/blob/main/Sources/AlertViewLibrary/AlertViewLibrary/Extensions_AlertViewLibrary.swift#L74
#### ViewType
primary types:
- error
- standard (default)
- succsessNote: .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 AlertManagerTo 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)# Customization

```
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#L10All parameters are optional
![]()
# Features
- 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)
# Usage example in apps
- 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