SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

Overview

SSToastMessage

CocoaPods Version Platform License swiftUI Swift Version PRs Welcome Twitter

SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

Screenshots

SSToastMessage Screenshots

Setup Instructions

CocoaPods

To integrate Toast-Swift into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'SSToastMessage', '~> 1.0.0'

and in your code add import SSToastMessage.

Swift Package Manager

When using Xcode 11 or later, you can install SSToastMessage by going to your Project settings > Swift Packages and add the repository by providing the GitHub URL. Alternatively, you can go to File > Swift Packages > Add Package Dependencies...

Manually

  1. Add MessageView.swift, DispatchWorkHolder.swift and View+Extension.swift to your project.
  2. Grab yourself a cold 🍺 .

Requirements

  • iOS 13+
  • Xcode 11+

Usage

  1. Put all your body code into a ZStack, VStack, or HStack.
  2. Add a binding bool to control popup presentation state
  3. Add .present modifier to your stack
  4. If you are using NavigationBar or Custom Navigation view then add .present modifier to NavigationBar or Custom Navigation view.

Basic Examples

struct ContentView: View {
    @State var showToast = false
    var body: some View {
        VStack {
            // your screen main stack
            Button(action: {
                self.showToast.toggle()
            }) {
                Text("Show Toast")
                    .foregroundColor(.black)
            }
        }
        .present(isPresented: self.$showToast, type: .toast, position: .top) {
           /// create your own view for toast
            self.createTopToastView()
        }
    }
    
    func createTopToastView() -> some View {
        VStack {
            Spacer(minLength: 20)
            HStack() {
                Image("mike")
                    .resizable()
                    .aspectRatio(contentMode: ContentMode.fill)
                    .frame(width: 50, height: 50)
                    .cornerRadius(25)

                VStack(alignment: .leading, spacing: 2) {
                    HStack {
                        Text("Mike")
                            .foregroundColor(.white)
                            .fontWeight(.bold)
                        Spacer()
                        Text("10:10")
                            .font(.system(size: 12))
                            .foregroundColor(Color(red: 0.9, green: 0.9, blue: 0.9))
                    }

                    Text("Hey, Don't miss the WWDC on tonight at 10 AM PST.")
                        .lineLimit(2)
                        .font(.system(size: 14))
                        .foregroundColor(.white)
                }
            }.padding(15)
        }
        .frame(width: UIScreen.main.bounds.width, height: 110)
        .background(Color(red: 0.85, green: 0.65, blue: 0.56))
    }
}





Way easy to customize!

Required parameters

presented - binding to determine if the message view should be seen on-screen or hidden
view - view you want to display on your message view

Available customizations - optional parameters

Element Declaration Description
type type: MessageType set type of view alert, toast and float.
position position: Position top or bottom (for default case it just determines animation direction).
animation animation: Animation custom animation for message view sliding onto screen.
autohideDuration autohideDuration: Double? time after which message view should disappear.
closeOnTap closeOnTap: Bool on message view tap it should disappear.
onTap onTap: () -> Void on message view tap perform any action or navigation.
closeOnTapOutside closeOnTapOutside: Bool on outside tap message view should disappear.

See the demo project for more examples.

🗂 Check out our other libraries→

MIT License

Copyright (c) 2020 Simform Solutions

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...
A framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.
A framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

PBPopupController PBPopupController is a framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

PopupController is a controller for showing temporary popup view.
PopupController is a controller for showing temporary popup view.

PopupController PopupController is a controller for showing temporary popup view. Demo Try PopupController on Appetize.io Installation CocoaPods pod '

Pop-up based view(e.g. alert sheet), can be easily customized.
Pop-up based view(e.g. alert sheet), can be easily customized.

MMPopupView 中文介绍 A basic Pop-Up Kit allows you to easily create Pop-Up view. You can focus on the only view you want to show. Besides, it comes with 2

⛩ Presenting custom views as a popup in iOS.
⛩ Presenting custom views as a popup in iOS.

FFPopup is a lightweight library for presenting custom views as a popup. Bounce from Top & Bounce to Bottom Bounce from Top & Bounce to Top Bounce in

WKWebView handling popup windows

WKWebViewWithPopUp WKWebView handling pop-up windows Property If there is a pop-up window, use the pop-up window. If there is no pop-up window, use th

Toasts and popups library written with SwiftUI
Toasts and popups library written with SwiftUI

Popup View Toasts and popups library written with SwiftUI We are a development agency building phenomenal apps. Usage Put all your body code into a ZS

LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.

LNPopupController LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and

Popover is a balloon library like Facebook app. It is written in pure swift.
Popover is a balloon library like Facebook app. It is written in pure swift.

Popover Description and appetize.io`s DEMO Usage To run the example project, clone the repo, and run pod install from the Example directory first. Sim

Simple selection dialog
Simple selection dialog

SelectionDialog Simple selection dialog inspired from ios-custom-alertview Preview Requirements iOS 8.0+ Swift 3 Xcode 8.0 Installation CocoaPods use_

Comments
  • When ToastMessage on .Top AutoCloses.  App no longer honors safe area

    When ToastMessage on .Top AutoCloses. App no longer honors safe area

    Describe the bug When ToastMessage on .Top AutoCloses. App no longer honors safe area

    To Reproduce Steps to reproduce the behavior:

    1. Present toast (copied directly from sample on github). .present(isPresented: $showSubmitConfirmation, type: .toast, position: .top, autohideDuration: 6, closeOnTap: true) { /// create your own view for toast self.createTopToastView() } func createTopToastView() -> some View { VStack { Spacer(minLength: 20) HStack() { Image("mike") .resizable() .aspectRatio(contentMode: ContentMode.fill) .frame(width: 50, height: 50) .cornerRadius(25)

               VStack(alignment: .leading, spacing: 2) {
                   HStack {
                       Text("Mike")
                           .foregroundColor(.white)
                           .fontWeight(.bold)
                       Spacer()
                       Text("10:10")
                           .font(.system(size: 12))
                           .foregroundColor(Color(red: 0.9, green: 0.9, blue: 0.9))
                   }
      
                   Text("Hey, Don't miss the WWDC on tonight at 10 AM PST.")
                       .lineLimit(2)
                       .font(.system(size: 14))
                       .foregroundColor(.white)
               }
           }.padding(15)
       }
       .frame(width: UIScreen.main.bounds.width, height: 110)
       .background(Color(red: 0.85, green: 0.65, blue: 0.56))
      

      }

    2. Let message auto close

    3. top line of app is now inside unsafe area. It is almost like the app is changing the main window to unsafe and not back when done.

    Expected behavior A clear and concise description of what you expected to happen.

    Screenshots

    1. Before toast image
    2. Toast image
    3. After Toast image

    Smartphone (please complete the following information):

    • Device: iPad mini 15.5 (simulator)
    • OS:IOS 15.5

    Additional context Add any other context about the problem here.

    opened by dstrickland67 0
  • Having a callback when toast did hide

    Having a callback when toast did hide

    It would be quite nice that there is a callback that says to us when animation is finished.

    I am not sure, but it seems this is not possible at the moment.

    opened by Wh1rlw1nd 0
  • When using closeOnTapOutside intercept tap gesture

    When using closeOnTapOutside intercept tap gesture

    When using closeOnTapOutside the gesture should be intercepted and not go through to the underlying view, otherwise buttons, or tap gestures in other views are executed too, while the expected behaviour is to just hide the Toast.

    opened by victorelcaminas 0
Releases(1.0.0)
  • 1.0.0(Sep 10, 2020)

Owner
Simform Solutions
Simform Solutions
A Swift Popup Module help you popup your custom view easily

JFPopup JFPopup is a Swift Module help you popup your custom view easily. Support 3 way to popup, Drawer, Dialog and BottomSheet. Example To run the e

逸风 77 Dec 14, 2022
A highly customizable alert dialog controller that mimics Snapchat's alert dialog.

AZDialogViewController A highly customizable alert dialog controller that mimics Snapchat's alert dialog. Screenshots Installation CocoaPods: pod 'AZD

Antonio Zaitoun 771 Dec 11, 2022
A lightweight library for popup view

SHPopup SHPop is lightweight library used for popup view Sample One Sample Two Sample Three Features SHPopup supports a popup inside another popup wit

Shezad Ahamed 37 Oct 2, 2022
A simple way to show toast in SwiftUI.

A simple way to show toast in SwiftUI Documentation • Example • Change Log Overview ToastUI provides you a simple way to present toast, head-up displa

Quan Tran 384 Dec 29, 2022
STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Objective-C and compatible with Swift.

STPopup STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Obj

Kevin Lin 2.6k Jan 6, 2023
Simple way to present custom views as a popup in iOS and tvOS.

PopupKit PopupKit is a simple and flexible iOS framework for presenting any custom view as a popup. It includes a variety of options for controlling h

Pointwelve 59 Mar 1, 2022
Simple Swift class for iOS that shows nice popup windows with animation.

NMPopUpView Simple class for iOS that shows nice popup windows, written in Swift. The project is build with Swift 4.0, so you need Xcode 9.0 or higher

Nikos Maounis 194 Jun 5, 2022
PopupWindow is a simple Popup using another UIWindow in Swift

PopupWindow PopupWindow is a simple Popup using another UIWindow Feature PopupWindow can be displayed at the top or bottom of the screen. Popup can se

shinji hayashi 415 Dec 5, 2022
The library allows to create simple popup menus

react-native-popup-menu This library allows to create simple popup menus Installation "react-native-popup-menu": "sergeymild/react-native-popup-menu"

SergeyMild 0 Aug 20, 2022
IAMPopup is a simple class for expressing custom popup in various forms.

IAMPopup Introduction IAMPopup is a simple class for expressing custom popup in various forms. This includes where to display the popup and space to d

Hosung Kang 18 Dec 29, 2022