Skip to content
DigitalRGS

DigitalRGS

Journey through the Gaming World, Navigate the Social Media Landscape, and Dive into the Tech Realm

Primary Menu
  • Home
  • Gaming World
  • Social Media World
  • Tech World
  • Contact Us
  • Gaming World
    • Freshest Facts
  • Home
  • Latest
  • A SwiftUI-friendly API for the LNPopupController framework

A SwiftUI-friendly API for the LNPopupController framework

Renee Straphorn 6 min read
1949

SwiftUI is a UI framework for iOS that is both powerful and easy to use. It has been used in several apps, including the popular Tinder app. However, it does not support LNPopupController, which is an open source library that can be used with any UI framework. This article discusses how to make your SwiftUI-based app work with LNPopupController by using a custom controller.

The SwiftEntryKit is a SwiftUI-friendly API for the LNPopupController framework. It provides a way to create a popup in an app that will be dismissed when the user taps outside of it, or dismisses itself when the user clicks on another view in your app.

LNPopupUI is a SwiftUI library that allows you to display views as popups, similar to how the Apple Music and Podcasts applications do.

This is a SwiftUI wrapper for my LNPopupController framework, which has been modified for use with SwiftUI.

PayPal Donation Button

Swift Package Manager compatible

open_modern_popup

A video of the contemporary popup appearance and feel can be seen here, as well as a video of the old popup look and feel.

The user may slide or touch the popup bar at any time to display the content view after it has been provided with a content view. The user closes the popup by swiping or clicking the close button once it has finished.

The library adds additional capabilities to SwiftUI’s View for displaying and modifying popups with content views, as well as specifying information like the title, picture, and bar button items for the popup bar. When a popup bar is shown, it adjusts to the view it is displayed on for the greatest possible look.

In general, the popup bar should be shown on the outermost view, such as TabView or NavigationView. It is suggested to display the popup on the tab view if the view is included in a navigation view, which is then contained in a tab view.

For a fast replica of Apple’s music app, check out the sample project.

Features

  • Available as a SwiftUI SPM package for iOS 13 and above.
  • A SwiftUI library that wraps my LNPopupController framework; the library uses SwiftUI’s produced UIKit content internally to display the framework in a native way.

Contributing to Your Project

Swift Package Manager is a program that allows you to manage your

SPM versions 5.1.0 (Xcode 11) and above are supported with LNPopupUI. To add a package dependency in Xcode, go to File -> Swift Packages -> Add Package Dependency and type https://github.com/LeoNatan/LNPopupUI. Choose the version you want to use.

Manually adding the package to your Package.swift file is also an option:

.package(from: “1.0.0”, url: “https://github.com/LeoNatan/LNPopupUI.git”)

And there’s the issue of your target’s reliance:

.objective (name: “BestExampleApp”, dependencies: [“LNPopupUI”]),

Making Use of the Library

Integration of projects

Incorporate the module into your project as follows:

LNPopupUI is imported.

A popup is made up of two parts: a popup bar and a popup content view. The supplied modifier API is used to get information for the popup bar, such as the title, picture, and bar button elements.

Call the popup(isBarPresented:isPopupOpen:content) function to show the popup:

TabView /Content view at the top. popup(isBar $isPopupBarPresented, $isPopupOpen))))))))))))))))))))))))))))))))))))) PlayerView(currentSong, song: currentSong)

A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Toggle the isPopupBarPresented bound property to present and dismiss the popup bar programmatically. Toggle the isPopupOpen bound var to open or dismiss the popup programmatically.

See the documentation in LNPopupUI.swift for additional details.

Modifiers of the popup content view are given for the popup bar content.

VStack /Popup content view.popupTitle(song.title).popupImage(Image(song.imageName)).popupText(song.text).popupText(song.text).popupText(song.text).popupText(song.text).popup popupProgress(playbackProgress) is a method for displaying the progress of a video. HStack.popupBarItems (spacing: 20) Button(action: isPlaying.toggle() ) Button(action: isPlaying.toggle() ) Button(action: isPlaying.toggle() ) image(systemName: “play.fill”) image(systemName: “play.fill”) image(systemName: “play.fill”) image(systemName: action: next() Button(action: next() Button(action: next() Button(action: next() Button(action: next ) (image(systemName: “forward.fill”) ) (image(systemName: “forward.fill”) ) (image(systemName: “forward.fill”) ) (image(system

Appearance and Personality

LNPopupUI has two different popup styles: one based on the current Music app look and feel, and the other based on the old, iOS 9-style appearance and feel. Modern popup bar types are called “prominent,” whereas iOS 9-style popup bars are branded “compact.” For contemporary style snapping popups, “snap” is used, while “drag” is used for iOS 9 interactive popup interaction. The contemporary style chevron close button is called “chevron,” while the iOS 9-style close button is labeled “round.” There is a “default” style for each that may be used to choose the most appropriate one for the current platform and operating system version.

The defaults are as follows:

  • Bar with a prominent design
  • Interaction style: snap
  • Closing button with a chevron pattern
  • There is no progress view style.

Popup bars may also be fully customized. See Custom Popup Bar View for additional details.

The appearance of the popup bar in navigation and tab views is controlled by the look of the container’s bottom bar by default. A default look is utilized for other container views, which is the best appropriate for the present context.

1631684104_597_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Call the popupBarInheritsAppearanceFromDockingView() modification with false to prevent inheriting the bottom bar’s appearance.

Bar Style

The.popupBarStyle() modification is used to change the style of the popup bar.

/Popup content view. popup(isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen) popupBarStyle(.compact)

1631684105_908_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Interaction Methodology

The.popupInteractionStyle() modification is used to customize the popup interaction style.

/Popup content view. popup(isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen) popupInteractionStyle(.drag)

1631684105_548_A-SwiftUI-friendly-API-for-the-LNPopupController-framework interaction_drag

Style of Progress View

The.popupBarProgressViewStyle() modification is used to customize the progress view style of the popup bar.

/Popup content view. popup(isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen) popupBarProgressViewStyle(.top)

Set the bar progress view style to.none to conceal the progress view.

A-SwiftUI-friendly-API-for-the-LNPopupController-framework

1631684108_883_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

1631684108_69_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Button Closure Style

The.popupCloseButtonStyle() modification is used to customize the popup close button style.

/Popup content view. popup(isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen) popupCloseButtonStyle(.round)

Set the popupCloseButtonStyle to to conceal the popup close button. none.

1631684109_26_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

1631684110_352_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

1631684111_978_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Scrolling Text Marquee

If text marquee scroll is enabled, lengthy text for the title and/or subtitle will result in scrolling text. The text will be shortened otherwise. Use the popupBarMarqueeScrollEnabled() modification to enable text marquee scrolling.

1631684105_908_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Using the.popupBarCustomView() modification, you may show your own view as the popup bar instead of the system-provided ones.

isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen).popup(isBarPresented: $isPopupPresented, isPopupOpen: $isPopupOpen) /Content view in a popup . customViewPopupBar (wantsDefaultTapGesture: false, wantsDefaultPanGesture: false, wantsDefaultHighlightGesture: false) /View the content of a custom popup bar

The parameters wantsDefaultTapGesture, wantsDefaultPanGesture, and wantsDefaultHighlightGesture determine whether the popup bar’s default system gestures are enabled or disabled.

1631684112_137_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

The.popupBarContextMenu() modification may be used to add a context menu to your popup bar.

.popup(isBar $isPopupPresented, $isPopupOpen)))))))))))))))))))))))))))))))))))) /Content view in a popup window. popupBar ContextMenu print(“Context Menu Item 1”) Button(action: print(“Context Menu Item 1”) Button(action: print(“Context Menu Item 1”) Button(action: print(“Context Menu Image(systemName: “globe”) Text(“Context Menu Item 1”) print(“Context Menu Item 2”) Button(action: print(“Context Menu Item 2”) Button(action: print(“Context Menu Item 2”) Button(action: print( Image(systemName: “location.circle”) Text(“Context Menu Item 2”)

1631684113_790_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Bar Customization at a Lower Level

The.popupBarCustomizer() modification in LNPopupUI enables for lower-level customisation through the UIKit LNPopupBar object.

.popup(isBar $isPopup $isPopup $isPopup $isPopup $isPopup $ $isPopupOpen) /Popup content view Presented, isPopupOpen: $isPopupOpen) Presented, isPopupOpen: $isPopupOpen) Presented, isPopupOpen: $isPopupOpen) Presented, is popupBarInheritsAppearanceFromDockingView(false) is a function that inherits the appearance of the popup bar from the docking view. popupBar popupBar in the Customizer NSMutableParagraphStyle = paragraphStyle () paragraphStyle.alignment =.right; paragraphStyle.alignment =.left; paragraphStyle.alignment = byTruncating = paragraphStyle.lineBreakMode Tail UIBlurEffect.backgroundEffect = popupBar.standardAppearance.backgroundEffect (style: .dark) popupBar.standardAppearance.title [.paragraphStyle: paragraphStyle,.font: UIFont(name: “Chalkduster”, size: 14)!,.foregroundColor: UIColor.yellow ] TextAttributes = [.paragraphStyle: paragraphStyle,.font: UIFont(name: “Chalkduster”, size: 14)!,.foregroundColor: UIColor.yellow ] popupBar.standardAppearance.subtitle [.paragraphStyle: paragraphStyle,.font: UIFont(name: “Chalkduster”, size: 12)!,.foregroundColor: UIColor.green ] TextAttributes = [.paragraphStyle: paragraphStyle,.font: UIFont(name: “Chalkduster”, size: 12)!,.foregroundColor: UIColor.green ] popupBar.tintColor =.yellow; popupBar.tintColor =.yellow; popupBar.tintColor =.

1631684114_501_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Support for the whole Right-to-Left spectrum

Right-to-left support is included throughout the library.

1631684116_526_A-SwiftUI-friendly-API-for-the-LNPopupController-framework

Acknowledgements

The library makes use of:

In addition, the demonstration project makes use of:

GitHub

https://github.com/LeoNatan/LNPopupUI

The swiftui toast is a framework that allows developers to create UI elements with the SwiftUI library. LNPopupController is the API that SwiftUI uses to display its popups.

Related Tags

  • bottom sheet view controller swift github
  • ios slide view up from bottom github
  • draggable view controller swift github
  • popup swift github
  • hwpanmodal

About The Author

Renee Straphorn

See author's posts

Tags: images

Continue Reading

Previous: 4 best hand-drawn animation software
Next: Top Trends to Know About RPA in 2021

Related Stories

Worldcoin: Unique Features that Make this Crypto Project Stand Out Image1
4 min read

Worldcoin: Unique Features that Make this Crypto Project Stand Out

Maggie Hopworth 32
BNB’s Journey From A Bold Ico To The Fifth-Largest Crypto In A Sea Of 17,000+ Free Silver cryptocurrency coins arranged on a wooden surface spelling 'crypto'. Stock Photo
5 min read

BNB’s Journey From A Bold Ico To The Fifth-Largest Crypto In A Sea Of 17,000+

Renee Straphorn 55
Has Your Email Been Hacked? Here’s How to Check and What to Do
5 min read

Has Your Email Been Hacked? Here’s How to Check and What to Do

Renee Straphorn 76
The Betting Ladder: Climbing from Low Stakes Fun to High Roller Territory Image2
5 min read

The Betting Ladder: Climbing from Low Stakes Fun to High Roller Territory

Renee Straphorn 79
Ukrainian Brides: Myths & Facts Image2
4 min read

Ukrainian Brides: Myths & Facts

Renee Straphorn 88
What Are the Advantages of Playing in Mobile Online Casinos?
5 min read

What Are the Advantages of Playing in Mobile Online Casinos?

Renee Straphorn 94

What’s Hot

What are the key features of Ometria? ometria crm 40m 75m butchertechcrunch

What are the key features of Ometria?

March 27, 2023
Moss is a spend management app that helps businesses keep track of their spending moss 75m series tiger 500mdillettechcrunch

Moss is a spend management app that helps businesses keep track of their spending

March 27, 2023
Bibit is a robo-advisor app for Indonesian investors bibit 30m sequoia capital 45mshutechcrunch

Bibit is a robo-advisor app for Indonesian investors

March 27, 2023
What are the key features of Ometria? ometria crm 40m 75m butchertechcrunch

What are the key features of Ometria?

March 27, 2023
Why the Alexa Turing Test is Important the alexa turing test fastcompany

Why the Alexa Turing Test is Important

December 20, 2022

3981 Solmonel Avenue
Melos, SC 10486

  • Privacy Policy
  • Terms & Conditions
  • About Us
  • Freshest Facts
© 2022 Digitalrgs.org
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT