PopupView is a free and open-source library dedicated for SwiftUI that makes the process of presenting popups easier and much cleaner.
Improves code quality. Show your popup using the showAndStack() or showAndReplace() method.
Hide the selected one with dismiss(). Simple as never.
Create any popup. We know how important customisation is; that’s why we give you the opportunity to design your popup in any way you like.
Designed for SwiftUI. While developing the library, we have used the power of SwiftUI to give you powerful tool to speed up your implementation process.
Getting Started
✋ Requirements
Platforms
Minimum Swift Version
iOS 15+, iPadOS 15+
5.0
⏳ Installation
Swift package manager
The Swift package manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding PopupView as a dependency is as easy as adding it to the dependencies value of your Package.swift.
Inside your @main structure call the implementPopupView method
var body: some Scene {
WindowGroup(content: ContentView().implementPopupView)
}
2. Declare a structure of your popup
The library provides an ability to present your custom view in three predefinied places - Top, Centre and Bottom.
In order to present it, it is necessary to confirm to one of the protocols during your view declaration:
TopPopup - presents popup view from the top
CentrePopup - presents popup view from the center
BottomPopup - presents popup view from the bottom
So that an example view you want to present will have the following declaration:
struct BottomCustomPopup: BottomPopup {
...
}
3. Implement createContent() method
The function above is used instead of the body property, and declares the design of the popup view.
Declaring this step is optional - if you wish, you can skip this step and leave the UI configuration to us.
Each protocol has its own set of methods that can be used to create a unique appearance for every popup.
Popups presentation made simple
Create beautiful and fully customisable popups in no time. Keep your code clean
Try demo we prepared
PopupView is a free and open-source library dedicated for SwiftUI that makes the process of presenting popups easier and much cleaner.
showAndStack()
orshowAndReplace()
method.Hide the selected one with
dismiss()
. Simple as never.Getting Started
✋ Requirements
⏳ Installation
Swift package manager
The Swift package manager is a tool for automating the distribution of Swift code and is integrated into the
swift
compiler.Once you have your Swift package set up, adding PopupView as a dependency is as easy as adding it to the
dependencies
value of yourPackage.swift
.Cocoapods
Cocoapods is a dependency manager for Swift and Objective-C Cocoa projects that helps to scale them elegantly.
Installation steps:
Podfile
.xcworkspace
file.xcworkspace
Usage
1. Setup library
Inside your
@main
structure call theimplementPopupView
method2. Declare a structure of your popup
The library provides an ability to present your custom view in three predefinied places - Top, Centre and Bottom.
In order to present it, it is necessary to confirm to one of the protocols during your view declaration:
TopPopup
- presents popup view from the topCentrePopup
- presents popup view from the centerBottomPopup
- presents popup view from the bottomSo that an example view you want to present will have the following declaration:
3. Implement
createContent()
methodThe function above is used instead of the body property, and declares the design of the popup view.
4. Implement
configurePopup(popup: Config) -> Config
methodDeclaring this step is optional - if you wish, you can skip this step and leave the UI configuration to us.
Each protocol has its own set of methods that can be used to create a unique appearance for every popup.
5. Present your popup from any place you want!
Just call
BottomCustomPopup().showAndStack()
from the selected place6. Closing popups
There are two methods to do so:
dismiss
,dismiss(_ popup: Popup.Type)
,dismissAll
inside the popup you createdPopupManager.dismiss()
PopupManager.dismiss(id: "some_id")
where id is the identifier of the popup you want to closePopupManager.dismiss(_ popup: Popup.Type)
where popup is the popup you want to closePopupManager.dismissAll()
Try our demo
See for yourself how does it work by cloning project we created
License
PopupView is released under the MIT license. See LICENSE for details.