AlertToast-SwiftUI

Currently in Swift the only way to inform the user of the process is to use Alert. Sometimes a popup message is enough to let the user know that something has been done or that his message has been sent. Apple offers no other option but to use Alert, even though Apple uses all kinds of pop-ups. The result is a poor UX where the user has to click “OK/Diss” for every little piece of information they want to be informed about.

AlertToast-SwiftUI

Alert Toast is an open source library on Github for use with SwiftUI. It allows you to present pop-ups that require no action from the user to reject or confirm them. Some common cases: Sent messages, bad network connection, profile update, login/disconnect, favorites, downloads, etc. ….

  • Built with a clean SwiftUI.
  • 2 display modes: alarm (appears in center), HUD (disappears).
  • Completion, system error, image, loading and normal (text only).
  • Supports light and dark modes.
  • Works with any supervision from the manufacturer.
  • Location support.
  • Set the font and background.

💻 Installation

Cocoapods

AlertToast Cocapods website

CocoaPods is the dependency manager for cocoa projects. Visit their website for instructions for use and installation. To integrate AlertToast into your Xcode project with CocoaPods, specify it in your pod file :

Pod AlertToast

Quick package manager

The Swift package manager is a tool for managing the distribution of Swift codes. It integrates with the Swift build system to automate the process of loading, compiling and linking dependencies.

To integrate AlertToast with Xcode 12 in an Xcode project, specify it under File > Quick Packages > Add Package Dependencies :

https://github.com/elai950/AlertToast.git

Manual

If you prefer not to use dependency managers, you can manually integrate AlertToast into your project. Place the Sources/AlertToast folder in the Xcode project. Make sure the Copy Items on Demand and Create Groups options are enabled.

Requirements

  • iOS 13.0+ | macOS 11+
  • Xcode 12.0+ | Swift 5+

🛠 Use

First, add an AlertToast import to any fast file you want to use with AlertToast.

Then use the . presentAlert view modifier :

Parameters :

  • Presented: (MUST) assign a link for showing or rejecting an alarm.
  • Duration: The default value is 2, set it to 0 to disable automatic dismissal.
  • tapToDismiss: the default value is true, the default value is false – deactivate.
  • Alarm: (MUST) Wait for Toast Alert.

Example of use with ordinary notice

import AlertToastimport SwiftUI

structured ContentView : See.

@State private var showAlert = false

var body : some View{
VStack{

button( showAlert.)
showAlert.toggle()}}
. presentAlert(isPresenting: $showAlert){.

// “Alert” is the default display mode/
AlertToast(type: .regular, header: “Message sent!”)

//Wählen Sie aus. hud toast alert from the top of the screen//AlertToast(displayMode : . hud, type : .regular, title : “Message Sent !”)}}}}

Full example of a modifier

. presentAlert(isPresenting: $showAlert, duration: 2, tapToDismiss: true, alert: {

//AlertToast goes here // AlertToast goes here //

}, Completion: { Dismissed
in// Completion block
after dismissal (becomes true)}
).

Alarm toast parameter

AlertToast(display mode: Display mode,
type: AlertType,
title: Optional(String),
Beschriftung : Optional(String),
titleFont : Optional(Schriftart),
subTitleFont : Optional(Font),
fett titleFont : Optional(Wolle),
backgroundColor : Optional(Farbe))

Types of available alarms :

  • Normal: text only (title and subtitle).
  • Completed: animated check mark.
  • Error: animated xmark.
  • System image: Name of the image with the SFS character.
  • Image: Provide an image of the property.
  • Charging: Activity indicator (Spinner).

Modifier for the display of the notification dialog (with default settings) :

. presentAlert(isPresenting: Obligation, duration: Double = 2, tapToDismiss: true, alert: {() -> AlertToast }, completion: {(Bool) -> () }).

A simple text message:

ToastAlert(type: .regular, title: Optional(String), subtitle: Optional(String))

Error warning :

AlertToast(type: .complete(color)/.error(color), title: Optional(String), subtitle: Optional(String))

System Image Warning :

AlertToast(type: . systemImage(String, Color), title: Extra(String), subtitle: Extra(String))

Alarm:

AlertToast(type: .image(String), title: Optional(String), subtitle: Optional(String))

Loading Alert :

// When loading is in use, time is not automatically terminated and tapToDismiss is set to false.
AlertToast(type: .load, title: Optional(String), subtitle: Optional(String))

You can have multiple . presentAlerts in one view.

GitHub

swiftui custom alert,swiftui show alert from viewmodel,swiftui multiple alerts,swiftui primarybutton,swiftui message,swift 5 alert,swiftui alert with image,custom alert swiftui,swiftui alert color,swiftui custom actionsheet,swiftui alert item,swiftui alert sheet,swiftui alert action,swiftui alert modifier,swiftui alert action sheet,result of ‘alert’ initializer is unused,connect apple watch to xcode,apple watch app development tutorial,watchos 5 tutorial,watch app for ios app vs watch app,watchos 6 tutorial,swiftui watchos page navigation,Privacy settings,How Search works,alert button with action swiftui,using sheet in swiftui,swiftui are you sure alert,swiftui actions,swiftui modal alert,swiftui add textfield to alert

You May Also Like

🥇 Tails  What is it? + Features and Tools ▷ 2020

SO Tails, based on the Linux kernel, is designed to protect the…

A library provide an input view present in multiple block style

BlockEdit Text Block EditText is a library that provides a common input…

CRED’s inbuilt library for using Neumorphic components with swift

Summary Synth is the library integrated in CRED for using neuromorphic components…

15 Solutions To Fix Windows 10 Apps Won’t Open Issue

Related Tags:   program won't open when i click on it windows…