Skip to content

mishadovhiy/AlertViewLibrary

Repository files navigation

AlertViewLibrary

Compatibility

  • iOS 11 and higher
  • MacOS 10.15 and higher

Installation

Add AlertViewLibrary Package Dependency to your project

Screenshot 2023-12-25 at 03 03 42



Screenshot 2023-12-25 at 03 04 25

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

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

ViewType

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)

Customization

customAlert

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

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




Created by Misha Dovhiy

About

Swift package to display Loading indicator or Alert (UIView)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages