JustPopup is a lightweight library used to display custom popups
Show animated popups made up from any views (either UIKit and SwiftUI) or view controllers.
let popup = Popup(SwiftUIView())
.withCornerRadius(20)
.withPresentationStyle(.crossDisolve)
popup.show()
var popup: Popup
// from SwiftUI view
popup = Popup(SwiftUIView())
.withPresentationDuration(2)
// from UIView
popup = Popup(someUIView)
// from controller
popup = Popup(ExistingPopupController())
JustPopup currently provides four possibilities to hide a popup:
.hide()
:popup.hide()
popup
.subscribeToClosingPublisher(somePublisher)
.showPopup()
popup
.subscribeToClosingPublisher(somePublisher)
.showPopup()
let popup = Popup(SwiftUIView())
.withPresentationDuration(2)
// four years later
popup.show()
// it'll be dismissed in 2 seconds after showing
Additionally, why not combining them?
let popup = Popup(SomeView())
.dismissOnTap()
.withPresentationDuration(2)
popup.show()
// it'll be dismissed in 2 seconds or sooner if user taps it
Popups are very easy to customize as you can use cool functional-style syntax:
popup
.withAnimationDuration(2)
.withPresentationStyle(.fromBottom)
.withDismissionStyle(.fromUp)
.withCornerRadius(5)
.fadesBackground(false)
As far as I know .onAppear
-based animations in SwiftUI views aren't working at all and here's a way to make everything work properly:
Conform your view to PopupSwiftUIAnimatedView protocol. This protocol hasn't any requirements. It's up to you what to use for tracking the state of the view
struct CoolView: View, PopupSwiftUIAnimatedView {
@State private var appeared = false
var body: some View {
// code
.onReceive(swiftUIViewAppearPublisher()) { value in
self.appeared = value
}
}
}
JustPopup will fire a notification when all presentation animations are finished so animations of this view will work correctly.
Scenes are the new pattern introduced in iOS 13 and if you're using them you should tell about this JustPopup somewhere early:
JustPopupPreferences.shared.shouldFollowScenePattern = true
JustPopup assumes that you're using top window so If you have complex windows scheme you may pass needed window in popup initializer:
let popup = Popup(someView, fromWindow: someWindow)
It's available via SPM! Isn't that cool?
CocoaPods is a dependency manager for Cocoa projects.
To integrate JustPopup into your Xcode project using CocoaPods, specify it in your Podfile
:
use_frameworks!
pod 'JustPopup'
You may also try this pod just printing in console:
pod try https://github.com/glassomoss/JustPopup.git
I doubt someone is ever going to do it.. Surprise me!
link |
Stars: 3 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics