### Install Accio Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Commands to tap the Accio repository and install the tool via Homebrew. ```bash $ brew tap JamitLabs/Accio https://github.com/JamitLabs/Accio.git $ brew install accio ``` -------------------------------- ### Install Carthage Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Commands to update Homebrew and install Carthage. ```bash $ brew update $ brew install carthage ``` -------------------------------- ### Run CocoaPods Installation Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Command to install dependencies defined in the Podfile. ```bash $ pod install ``` -------------------------------- ### Install CocoaPods Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Command to install the CocoaPods dependency manager. ```bash $ gem install cocoapods ``` -------------------------------- ### Bind Keyboard Offset for Entry Positioning Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Enables keyboard support by binding an offset for the entry's position relative to the keyboard. This example sets a 10pt bottom offset and a 5pt screen edge resistance. ```Swift // 10pt bottom offset from keyboard and at least 5pts from the screen edge while the keyboard is displayed. attributes.positionConstraints.keyboardRelation = .bind(offset: .init(bottom: 10, screenEdgeResistance: 5)) ``` -------------------------------- ### Configure and Display Top Floating Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Example of configuring a top floating entry with custom background gradient, animations, shadow, status bar style, scroll behavior, and size constraints. It then displays a notification message with an image, title, and description. ```Swift // Generate top floating entry and set some properties var attributes = EKAttributes.topFloat attributes.entryBackground = .gradient(gradient: .init(colors: [EKColor(.red), EKColor(.green)], startPoint: .zero, endPoint: CGPoint(x: 1, y: 1))) attributes.popBehavior = .animated(animation: .init(translate: .init(duration: 0.3), scale: .init(from: 1, to: 0.7, duration: 0.7))) attributes.shadow = .active(with: .init(color: .black, opacity: 0.5, radius: 10, offset: .zero)) attributes.statusBar = .dark attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .jolt) attributes.positionConstraints.maxSize = .init(width: .constant(value: UIScreen.main.minEdge), height: .intrinsic) let title = EKProperty.LabelContent(text: titleText, style: .init(font: titleFont, color: textColor)) let description = EKProperty.LabelContent(text: descText, style: .init(font: descFont, color: textColor)) let image = EKProperty.ImageContent(image: UIImage(named: imageName)!, size: CGSize(width: 35, height: 35)) let simpleMessage = EKSimpleMessage(image: image, title: title, description: description) let notificationMessage = EKNotificationMessage(simpleMessage: simpleMessage) let contentView = EKNotificationMessageView(with: notificationMessage) SwiftEntryKit.display(entry: contentView, using: attributes) ``` -------------------------------- ### Initialize Custom View and Attributes Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Create a custom view and an EKAttributes struct to define display properties. ```swift // Customized view let customView = SomeCustomView() /* Do some customization on customView */ // Attributes struct that describes the display, style, user interaction and animations of customView. var attributes = EKAttributes() /* Adjust preferable attributes */ ``` -------------------------------- ### Using EKAttributes Presets Source: https://context7.com/huri000/swiftentrykit/llms.txt Leverage built-in preset configurations for common UI patterns like toasts, notes, and floating pop-ups. ```swift // Top floating entry with rounded corners var topFloat = EKAttributes.topFloat topFloat.entryBackground = .color(color: EKColor(.systemGreen)) // Bottom floating entry var bottomFloat = EKAttributes.bottomFloat bottomFloat.displayDuration = 5 // Top toast (full width, fills safe area) var topToast = EKAttributes.topToast topToast.entryBackground = .color(color: EKColor(.systemBlue)) // Bottom toast var bottomToast = EKAttributes.bottomToast // Center floating entry (popup style) var centerFloat = EKAttributes.centerFloat centerFloat.screenBackground = .color(color: EKColor(UIColor.black.withAlphaComponent(0.6))) // Top note (above status bar) var topNote = EKAttributes.topNote // Bottom note var bottomNote = EKAttributes.bottomNote // Status bar overlay var statusBarEntry = EKAttributes.statusBar ``` -------------------------------- ### Configure and Display Basic Top Toast Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Creates a basic toast entry at the top with a white background and default translation animations for entrance and exit. A custom UIView is then displayed with these attributes. ```Swift // Create a basic toast that appears at the top var attributes = EKAttributes.topToast // Set its background to white attributes.entryBackground = .color(color: .white) // Animate in and out using default translation attributes.entranceAnimation = .translation attributes.exitAnimation = .translation let customView = UIView() /* ... Customize the view as you like ... */ // Display the view with the configuration SwiftEntryKit.display(entry: customView, using: attributes) ``` -------------------------------- ### Display View Controller Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Demonstrates how to display a view controller using SwiftEntryKit. Ensure the view controller and attributes are properly initialized before calling this method. ```Swift SwiftEntryKit.display(entry: customViewController, using: attributes) ``` -------------------------------- ### Configure Entry Size Constraints Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Sets the entry's width to be 20 points less than the screen width and its height to be determined by its content. Also sets a maximum width to prevent excessive growth during orientation changes. ```Swift var attributes = EKAttributes.topFloat // Give the entry the width of the screen minus 20pts from each side, the height is decided by the content's contraint's attributes.positionConstraints.size = .init(width: .offset(value: 20), height: .intrinsic) // Give the entry maximum width of the screen minimum edge - thus the entry won't grow much when the device orientation changes from portrait to landscape mode. let edgeWidth = min(UIScreen.main.bounds.width, UIScreen.main.bounds.height) attributes.positionConstraints.maxSize = .init(width: .constant(value: edgeWidth), height: .intrinsic) let customView = UIView() /* ... Customize the view as you like ... */ // Use class method of SwiftEntryKit to display the view using the desired attributes SwiftEntryKit.display(entry: customView, using: attributes) ``` -------------------------------- ### Configure Window Level Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Set the window level for the entry. The default is .statusBar. ```Swift attributes.windowLevel = .normal ``` -------------------------------- ### Display Entry with Window Management Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md These methods allow displaying a view or view controller as an entry, with options to control key window status and rollback behavior. ```Swift public class func display(entry view: UIView, using attributes: EKAttributes, presentInsideKeyWindow: Bool = default, rollbackWindow: RollbackWindow = default) public class func display(entry viewController: UIViewController, using attributes: EKAttributes, presentInsideKeyWindow: Bool = default, rollbackWindow: RollbackWindow = default) ``` ```Swift public class func display(entry view: UIView, using attributes: EKAttributes, rollbackWindow: UIWindow = default) public class func display(entry viewController: UIViewController, using attributes: EKAttributes, rollbackWindow: UIWindow = default) ``` -------------------------------- ### Configure Entrance and Exit Animations Source: https://context7.com/huri000/swiftentrykit/llms.txt Define translation, scale, and fade effects for entry and exit transitions, or disable animations entirely. ```swift var attributes = EKAttributes.topFloat // Translation with spring animation attributes.entranceAnimation = .init( translate: .init( duration: 0.5, anchorPosition: .automatic, spring: .init(damping: 0.8, initialVelocity: 0) ) ) // Combined animation: translate + scale + fade attributes.entranceAnimation = .init( translate: .init(duration: 0.7, spring: .init(damping: 1, initialVelocity: 0)), scale: .init(from: 0.6, to: 1, duration: 0.5), fade: .init(from: 0, to: 1, duration: 0.3) ) // Exit animation attributes.exitAnimation = .init( translate: .init(duration: 0.3, anchorPosition: .top) ) // Pop behavior when overridden by higher priority entry attributes.popBehavior = .animated(animation: .init( translate: .init(duration: 0.2), scale: .init(from: 1, to: 0.8, duration: 0.2) )) // No animation attributes.entranceAnimation = .none ``` -------------------------------- ### Configure Background Styles Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Define the visual appearance of the entry and screen backgrounds using various styles. ```Swift attributes.entryBackground = .clear attributes.screenBackground = .clear ``` ```Swift attributes.entryBackground = .color(color: .standardContent) attributes.screenBackground = .color(color: EKColor(UIColor(white: 0.5, alpha: 0.5))) ``` ```Swift let colors: [EKColor] = ... attributes.entryBackground = .gradient(gradient: .init(colors: colors, startPoint: .zero, endPoint: CGPoint(x: 1, y: 1))) ``` ```Swift attributes.entryBackground = .visualEffect(style: .dark) ``` -------------------------------- ### Configure EKAttributes position constraints Source: https://context7.com/huri000/swiftentrykit/llms.txt Set size, position, safe area, and keyboard behavior for entry overlays. ```swift var attributes = EKAttributes.topFloat // Full width entry attributes.positionConstraints = .fullWidth // Floating entry with margins attributes.positionConstraints = .float // Custom size attributes.positionConstraints.size = .init( width: .ratio(value: 0.9), // 90% of screen width height: .intrinsic // Height determined by content ) // Fixed dimensions attributes.positionConstraints.size = .init( width: .constant(value: 300), height: .constant(value: 200) ) // Maximum size constraints attributes.positionConstraints.maxSize = .init( width: .constant(value: UIScreen.main.bounds.width), height: .ratio(value: 0.7) ) // Safe area handling attributes.positionConstraints.safeArea = .empty(fillSafeArea: true) // Fill safe area with background attributes.positionConstraints.safeArea = .empty(fillSafeArea: false) // Leave safe area empty attributes.positionConstraints.safeArea = .overridden // Ignore safe area // Vertical offset from edge attributes.positionConstraints.verticalOffset = 20 // Keyboard relation for forms let keyboardOffset = EKAttributes.PositionConstraints.KeyboardRelation.Offset( bottom: 10, screenEdgeResistance: 20 ) attributes.positionConstraints.keyboardRelation = .bind(offset: keyboardOffset) // Disable auto-rotation attributes.positionConstraints.rotation.isEnabled = false ``` -------------------------------- ### Clone SwiftEntryKit via Terminal Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Use this command to clone the repository directly from GitHub. ```bash $ git clone https://github.com/huri000/SwiftEntryKit.git ``` -------------------------------- ### Create adaptive EKColor instances Source: https://context7.com/huri000/swiftentrykit/llms.txt Define colors that support light/dark mode, custom RGB values, or preset standards. ```swift // Single color for both modes let uniformColor = EKColor(.systemBlue) // Different colors for light and dark modes let adaptiveColor = EKColor(light: .white, dark: .black) // Using RGB values let customColor = EKColor(red: 66, green: 133, blue: 244) // Using hex RGB let hexColor = EKColor(rgb: 0x4285F4) // Preset colors let background = EKColor.standardBackground // white/black let content = EKColor.standardContent // black/white // Modify alpha let semiTransparent = EKColor(.systemBlue).with(alpha: 0.5) // Invert colors let inverted = adaptiveColor.inverted ``` -------------------------------- ### Check if Any Entry is Currently Displaying Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Inquire whether any entry is currently visible on the screen. ```Swift if SwiftEntryKit.isCurrentlyDisplaying { /* Do your things */ } ``` -------------------------------- ### Integrate SwiftEntryKit with Accio Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Add this package dependency to your Package.swift manifest. ```swift .package(url: "https://github.com/huri000/SwiftEntryKit", .exact("2.0.0")) ``` -------------------------------- ### Set Display Mode Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Force the entry to use a specific user interface style. ```Swift attributes.displayMode = .dark ``` -------------------------------- ### Integrate SwiftEntryKit with Carthage Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Add this line to your Cartfile to specify the SwiftEntryKit dependency. ```ogdl github "huri000/SwiftEntryKit" == 2.0.0 ``` -------------------------------- ### Set Display Position Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Define the screen position for the entry. The default is .top. ```Swift attributes.position = .bottom ``` -------------------------------- ### Display View with Alternative Rollback Window Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Allows specifying a custom window to become key after the entry is dismissed, instead of the default application delegate window. This is useful for managing complex window hierarchies. ```Swift SwiftEntryKit.display(entry: view, using: attributes, rollbackWindow: .custom(window: alternativeWindow)) ``` -------------------------------- ### Configure Entry Border Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Add a border to the entry with specified color and thickness. ```Swift attributes.border = .value(color: .black, width: 0.5) ``` ```Swift attributes.border = .none ``` -------------------------------- ### Create Mutable EKAttributes Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Instantiate a mutable EKAttributes structure for entry configuration. ```swift var attributes = EKAttributes() ``` -------------------------------- ### Set Queueing Heuristic Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configure the global sorting strategy for the entry queue. This should be set once before displaying entries. ```Swift EKAttributes.Precedence.QueueingHeuristic.value = .priority ``` ```Swift EKAttributes.Precedence.QueueingHeuristic.value = .chronological ``` -------------------------------- ### Configure Lifecycle Events Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Inject closures to execute code at specific points during the entry's lifecycle. ```Swift attributes.lifecycleEvents.willAppear = { // Executed before the entry animates inside } attributes.lifecycleEvents.didAppear = { // Executed after the entry animates inside } attributes.lifecycleEvents.willDisappear = { // Executed before the entry animates outside } attributes.lifecycleEvents.didDisappear = { // Executed after the entry animates outside } ``` -------------------------------- ### Set Entry Width Ratio Constraint Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Defines the entry's width as a ratio of the screen's width. Use this when the entry's width should adapt to the screen size. ```Swift let widthConstraint = EKAttributes.PositionConstraints.Edge.ratio(value: 0.9) ``` -------------------------------- ### Configure Entry Max Size Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Sets maximum width and height limitations for the entry. This prevents the entry from exceeding predefined boundaries, which is particularly useful during device orientation changes. ```Swift attributes.positionConstraints.maxSize = .init(width: widthConstraint, height: heightConstraint) ``` -------------------------------- ### Define Entrance Animations Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Combine multiple animation types into a single complex entrance sequence. ```Swift attributes.entranceAnimation = .init( translate: .init(duration: 0.7, anchorPosition: .top, spring: .init(damping: 1, initialVelocity: 0)), scale: .init(from: 0.6, to: 1, duration: 0.7), fade: .init(from: 0.8, to: 1, duration: 0.3)) ``` -------------------------------- ### Display Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Call this method to display the entry using the configured attributes. ```swift SwiftEntryKit.display(entry: customView, using: attributes) ``` -------------------------------- ### Enable Entry Scroll with Jolt Animation Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Enables swipe gestures and a rubber band effect for the entry, with a 'jolt' animation upon release. This provides a dynamic scrolling experience. ```Swift attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .jolt) ``` -------------------------------- ### Control Precedence and Priority Source: https://context7.com/huri000/swiftentrykit/llms.txt Define how entries are queued or override existing entries based on priority levels. ```swift var attributes = EKAttributes() // Override current entry if priority allows attributes.precedence = .override(priority: .high, dropEnqueuedEntries: false) // Enqueue entry to display after current one attributes.precedence = .enqueue(priority: .normal) // Override and clear the queue attributes.precedence = .override(priority: .max, dropEnqueuedEntries: true) // Set global queueing heuristic (once at app start) EKAttributes.Precedence.QueueingHeuristic.value = .priority // or .chronological // Check queue status if !SwiftEntryKit.isQueueEmpty { print("Entries waiting in queue") } if SwiftEntryKit.queueContains(entryNamed: "ImportantAlert") { print("Important alert is queued") } ``` -------------------------------- ### Apply Round Corners Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configure corner radius and which corners are rounded for the entry. ```Swift attributes.roundCorners = .top(radius: 10) ``` ```Swift attributes.roundCorners = .bottom(radius: 10) ``` ```Swift attributes.roundCorners = .all(radius: 10) ``` ```Swift attributes.roundCorners = .none ``` -------------------------------- ### Manage Display Priority Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Demonstrates how higher priority entries prevent lower priority entries from being displayed. ```Swift let highPriorityAttributes = EKAttributes() highPriorityAttributes.precedence.priority = .high let normalPriorityAttributes = EKAttributes() normalPriorityAttributes.precedence.priority = .normal // Display high priority entry SwiftEntryKit.display(entry: view1, using: highPriorityAttributes) // Display normal priority entry (ignored!) SwiftEntryKit.display(entry: view2, using: normalPriorityAttributes) ``` -------------------------------- ### Configure Scroll and Swipe Behavior Source: https://context7.com/huri000/swiftentrykit/llms.txt Enable or disable swipe-to-dismiss functionality and define custom pullback animations for scrollable entries. ```swift var attributes = EKAttributes.topFloat // Enable swipe with jolt pullback animation attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .jolt) // Enable swipe with ease-out pullback attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .easeOut) // Custom pullback animation let customPullback = EKAttributes.Scroll.PullbackAnimation( duration: 0.4, damping: 0.5, initialSpringVelocity: 5 ) attributes.scroll = .enabled(swipeable: true, pullbackAnimation: customPullback) // Disable edge crossing (can't pull past screen edge) attributes.scroll = .edgeCrossingDisabled(swipeable: true) // Completely disable scrolling attributes.scroll = .disabled ``` -------------------------------- ### Present Form Message View Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Displays a form message view within the key window to allow keyboard interaction. ```Swift SwiftEntryKit.display(entry: formMessageView, using: attributes, presentInsideKeyWindow: true) ``` -------------------------------- ### Create and Display an Email/Password Form Source: https://context7.com/huri000/swiftentrykit/llms.txt Use EKFormMessageView to create a form with text fields for email and password, and a submit button. Configure attributes for display, such as position and background effects. ```swift let placeholderStyle = EKProperty.LabelStyle( font: .systemFont(ofSize: 14), color: EKColor(.placeholderText) ) let textStyle = EKProperty.LabelStyle( font: .systemFont(ofSize: 14), color: EKColor(.label) ) // Email field var emailField = EKProperty.TextFieldContent( keyboardType: .emailAddress, placeholder: EKProperty.LabelContent(text: "Email", style: placeholderStyle), textStyle: textStyle, leadingImage: UIImage(named: "email_icon"), bottomBorderColor: EKColor(.separator) ) // Password field var passwordField = EKProperty.TextFieldContent( keyboardType: .default, placeholder: EKProperty.LabelContent(text: "Password", style: placeholderStyle), textStyle: textStyle, isSecure: true, leadingImage: UIImage(named: "lock_icon"), bottomBorderColor: EKColor(.separator) ) // Submit button let submitButton = EKProperty.ButtonContent( label: EKProperty.LabelContent( text: "Sign In", style: .init(font: .boldSystemFont(ofSize: 16), color: .white) ), backgroundColor: EKColor(.systemBlue), highlightedBackgroundColor: EKColor(UIColor.systemBlue.withAlphaComponent(0.8))) { // Access entered text print("Email: \(emailField.textContent)") print("Password: \(passwordField.textContent)") SwiftEntryKit.dismiss() } // Create form let title = EKProperty.LabelContent( text: "Sign In", style: .init(font: .boldSystemFont(ofSize: 20), color: .black, alignment: .center) ) let formView = EKFormMessageView( with: title, textFieldsContent: [emailField, passwordField], buttonContent: submitButton ) // Display var attributes = EKAttributes.centerFloat attributes.screenBackground = .visualEffect(style: .dark) attributes.entryBackground = .color(color: .white) attributes.roundCorners = .all(radius: 15) attributes.positionConstraints.size = .init( width: .ratio(value: 0.9), height: .intrinsic ) SwiftEntryKit.display(entry: formView, using: attributes, presentInsideKeyWindow: true) ``` -------------------------------- ### Manage Lifecycle Events Source: https://context7.com/huri000/swiftentrykit/llms.txt Inject callbacks to execute logic during specific entry lifecycle stages such as appearance and disappearance. ```swift var attributes = EKAttributes.topFloat attributes.lifecycleEvents.willAppear = { print("Entry will appear") } attributes.lifecycleEvents.didAppear = { print("Entry appeared") // Start timer, analytics, etc. } attributes.lifecycleEvents.willDisappear = { print("Entry will disappear") } attributes.lifecycleEvents.didDisappear = { print("Entry disappeared") // Cleanup, show next entry, etc. } SwiftEntryKit.display(entry: myView, using: attributes) ``` -------------------------------- ### Create and Display a Success Pop-up Message Source: https://context7.com/huri000/swiftentrykit/llms.txt Use EKPopUpMessageView to display a success message with a theme image, title, description, and a button. Customize attributes for background, corners, and haptic feedback. ```swift let themeImage = EKPopUpMessage.ThemeImage( image: EKProperty.ImageContent( image: UIImage(named: "success_icon")!, size: CGSize(width: 60, height: 60) ), position: .topToTop(offset: 40) ) let title = EKProperty.LabelContent( text: "Success!", style: .init(font: .boldSystemFont(ofSize: 22), color: .black, alignment: .center) ) let description = EKProperty.LabelContent( text: "Your order has been placed successfully.", style: .init(font: .systemFont(ofSize: 16), color: EKColor(.darkGray), alignment: .center) ) let button = EKProperty.ButtonContent( label: EKProperty.LabelContent( text: "Continue Shopping", style: .init(font: .boldSystemFont(ofSize: 16), color: .white) ), backgroundColor: EKColor(.systemGreen), highlightedBackgroundColor: EKColor(UIColor.systemGreen.withAlphaComponent(0.8)) ) let popUpMessage = EKPopUpMessage( themeImage: themeImage, title: title, description: description, button: button ) { SwiftEntryKit.dismiss() // Navigate to shop } let popUpView = EKPopUpMessageView(with: popUpMessage) var attributes = EKAttributes.centerFloat attributes.entryBackground = .color(color: .white) attributes.screenBackground = .color(color: EKColor(UIColor.black.withAlphaComponent(0.6))) attributes.roundCorners = .all(radius: 20) attributes.hapticFeedbackType = .success SwiftEntryKit.display(entry: popUpView, using: attributes) ``` -------------------------------- ### Handle User Interactions Source: https://context7.com/huri000/swiftentrykit/llms.txt Manage how entries and the underlying screen respond to touch events, including custom tap actions. ```swift var attributes = EKAttributes.topFloat // Dismiss entry on tap attributes.entryInteraction = .dismiss // Forward screen touches to underlying window attributes.screenInteraction = .forward // Absorb touches (do nothing) attributes.entryInteraction = .absorbTouches // Delay exit by 3 seconds on interaction attributes.entryInteraction = .delayExit(by: 3) // Dismiss screen touch dismisses entry attributes.screenInteraction = .dismiss // Custom tap action attributes.entryInteraction.customTapActions.append { print("Entry was tapped!") // Navigate to detail screen, etc. } ``` -------------------------------- ### Check if Specific Entry is Currently Displaying Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Inquire whether a specific entry, identified by its name, is currently displayed. ```Swift if SwiftEntryKit.isCurrentlyDisplaying(entryNamed: "Top Note") { /* Do your things */ } ``` -------------------------------- ### Configuring EKAttributes Source: https://context7.com/huri000/swiftentrykit/llms.txt Customize the appearance and behavior of entries using the EKAttributes struct. This includes settings for positioning, backgrounds, shadows, and corner radius. ```swift var attributes = EKAttributes() // Identification attributes.name = "SuccessNotification" // Position: .top, .center, .bottom attributes.position = .top // Display duration (seconds or .infinity) attributes.displayDuration = 4 // Window level attributes.windowLevel = .statusBar // Entry and screen backgrounds attributes.entryBackground = .color(color: EKColor(.white)) attributes.screenBackground = .color(color: EKColor(UIColor.black.withAlphaComponent(0.5))) // Gradient background let gradientColors = [EKColor(.red), EKColor(.orange)] attributes.entryBackground = .gradient(gradient: .init( colors: gradientColors, startPoint: .zero, endPoint: CGPoint(x: 1, y: 1) )) // Blur background attributes.entryBackground = .visualEffect(style: .standard) // Shadow attributes.shadow = .active(with: .init(color: .black, opacity: 0.3, radius: 10, offset: .zero)) // Round corners attributes.roundCorners = .all(radius: 10) // Border attributes.border = .value(color: EKColor(.gray), width: 0.5) // Status bar style attributes.statusBar = .light SwiftEntryKit.display(entry: myView, using: attributes) ``` -------------------------------- ### Bind Entry to Keyboard with Offset Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configures the entry to dynamically adjust its position relative to the keyboard. The `Offset` struct defines the desired distance from the keyboard's top and a resistance value to keep the entry on screen. ```Swift let offset = EKAttributes.PositionConstraints.KeyboardRelation.Offset(bottom: 10, screenEdgeResistance: 20) let keyboardRelation = EKAttributes.PositionConstraints.KeyboardRelation.bind(offset: offset) attributes.positionConstraints.keyboardRelation = keyboardRelation ``` -------------------------------- ### Check Display Status by Name Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Verify if an entry with a specific name is currently being displayed. ```Swift if SwiftEntryKit.isCurrentlyDisplaying(entryNamed: "Top Note") { /* Do your things */ } ``` -------------------------------- ### Displaying Entries Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Method to display a custom view with specific attributes. ```APIDOC ## SwiftEntryKit.display ### Description Displays a custom view using the provided EKAttributes configuration. ### Parameters - **entry** (UIView) - Required - The view to display - **using** (EKAttributes) - Required - Configuration attributes for the entry ### Request Example SwiftEntryKit.display(entry: customView, using: attributes) ``` -------------------------------- ### Manage Entry Shadows Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Control the visibility and properties of the shadow surrounding the entry. ```Swift attributes.shadow = .active(with: .init(color: .black, opacity: 0.3, radius: 10, offset: .zero)) ``` ```Swift attributes.shadow = .none ``` -------------------------------- ### Set Display Duration Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Define how long an entry remains visible after its entrance animation. ```Swift attributes.displayDuration = 4 ``` ```Swift attributes.displayDuration = .infinity ``` -------------------------------- ### Displaying Content with SwiftEntryKit Source: https://context7.com/huri000/swiftentrykit/llms.txt Use these methods to present custom views or view controllers and check the current display status. These methods are thread-safe and can be called from any queue. ```swift import SwiftEntryKit // Display a custom view with attributes var attributes = EKAttributes.topFloat attributes.displayDuration = 3 attributes.entryBackground = .color(color: EKColor(.systemBlue)) let customView = UILabel() customView.text = "Hello World" customView.textAlignment = .center SwiftEntryKit.display(entry: customView, using: attributes) // Display a view controller let viewController = MyCustomViewController() SwiftEntryKit.display(entry: viewController, using: attributes, presentInsideKeyWindow: true) // Check if entry is currently displayed if SwiftEntryKit.isCurrentlyDisplaying { print("An entry is visible") } // Check for specific named entry if SwiftEntryKit.isCurrentlyDisplaying(entryNamed: "MyNotification") { print("MyNotification is currently shown") } ``` -------------------------------- ### Integrate SwiftEntryKit with CocoaPods Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Add this configuration to your Podfile to include SwiftEntryKit in your project. ```ruby source 'https://github.com/cocoapods/specs.git' platform :ios, '9.0' use_frameworks! pod 'SwiftEntryKit', '2.0.0' ``` -------------------------------- ### Apply Size Constraints to Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Assigns the defined width and height constraints to the entry's position constraints. This explicitly sets the entry's dimensions. ```Swift attributes.positionConstraints.size = .init(width: widthConstraint, height: heightConstraint) ``` -------------------------------- ### Configure Enqueue Precedence Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Set precedence to add the entry to the queue if it is not empty. ```Swift attributes.precedence = .enqueue(priority: .normal) ``` -------------------------------- ### Enable Entry Scroll with Ease-Out Animation Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Enables swipe gestures and a rubber band effect for the entry, with an 'ease-out' animation upon release. This offers a smoother scrolling dismissal. ```Swift attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .easeOut) ``` -------------------------------- ### Display EKNotificationMessageView Source: https://context7.com/huri000/swiftentrykit/llms.txt Configures and displays a notification-style message with an image, title, description, and optional auxiliary label. ```swift // Create label styles let titleStyle = EKProperty.LabelStyle( font: .boldSystemFont(ofSize: 16), color: EKColor(.white), alignment: .left ) let descStyle = EKProperty.LabelStyle( font: .systemFont(ofSize: 14), color: EKColor(UIColor.white.withAlphaComponent(0.8)), alignment: .left ) // Create content let title = EKProperty.LabelContent(text: "New Message", style: titleStyle) let description = EKProperty.LabelContent(text: "You have a new message from John", style: descStyle) let image = EKProperty.ImageContent( image: UIImage(named: "message_icon")!, size: CGSize(width: 35, height: 35) ) // Create simple message let simpleMessage = EKSimpleMessage(image: image, title: title, description: description) // Create notification message with optional auxiliary label (e.g., time) let auxStyle = EKProperty.LabelStyle(font: .systemFont(ofSize: 12), color: EKColor(.lightGray)) let auxiliary = EKProperty.LabelContent(text: "now", style: auxStyle) let notificationMessage = EKNotificationMessage(simpleMessage: simpleMessage, auxiliary: auxiliary) // Create view and display let contentView = EKNotificationMessageView(with: notificationMessage) var attributes = EKAttributes.topFloat attributes.entryBackground = .gradient(gradient: .init( colors: [EKColor(.systemBlue), EKColor(.systemPurple)], startPoint: .zero, endPoint: CGPoint(x: 1, y: 1) )) attributes.shadow = .active(with: .init(opacity: 0.5, radius: 10)) SwiftEntryKit.display(entry: contentView, using: attributes) ``` -------------------------------- ### Check if Entry Queue is Empty Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Inquire whether the queue of pending entries is empty. ```Swift if SwiftEntryKit.isQueueEmpty { /* Do your things */ } ``` -------------------------------- ### Set Status Bar to Light Style Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Sets the status bar to a light style. This is useful for entries with dark backgrounds. ```Swift attributes.statusBar = .light ``` -------------------------------- ### Configure Entry Safe Area Handling Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Specifies how the entry should interact with the device's safe area. Setting `fillSafeArea` to `false` ensures that the safe area insets are respected and not part of the entry's display area. ```Swift attributes.positionConstraints.safeArea = .empty(fillSafeArea: false) ``` -------------------------------- ### Display EKAlertMessageView Source: https://context7.com/huri000/swiftentrykit/llms.txt Configures and displays an alert dialog with custom buttons and interaction attributes. ```swift // Create button content let okButtonLabel = EKProperty.LabelContent( text: "OK", style: .init(font: .boldSystemFont(ofSize: 16), color: EKColor(.systemBlue)) ) let okButton = EKProperty.ButtonContent( label: okButtonLabel, backgroundColor: .clear, highlightedBackgroundColor: EKColor(UIColor.systemBlue.withAlphaComponent(0.1)) ) { SwiftEntryKit.dismiss() print("OK tapped") } let cancelButtonLabel = EKProperty.LabelContent( text: "Cancel", style: .init(font: .systemFont(ofSize: 16), color: EKColor(.systemRed)) ) let cancelButton = EKProperty.ButtonContent( label: cancelButtonLabel, backgroundColor: .clear, highlightedBackgroundColor: EKColor(UIColor.systemRed.withAlphaComponent(0.1)) ) { SwiftEntryKit.dismiss() } // Create button bar let buttonBarContent = EKProperty.ButtonBarContent( with: okButton, cancelButton, separatorColor: EKColor(.separator), buttonHeight: 50, expandAnimatedly: true ) // Create message let title = EKProperty.LabelContent( text: "Confirm Action", style: .init(font: .boldSystemFont(ofSize: 18), color: .black, alignment: .center) ) let description = EKProperty.LabelContent( text: "Are you sure you want to proceed?", style: .init(font: .systemFont(ofSize: 14), color: EKColor(.darkGray), alignment: .center) ) let image = EKProperty.ImageContent(image: UIImage(named: "warning_icon")!, size: CGSize(width: 50, height: 50)) let simpleMessage = EKSimpleMessage(image: image, title: title, description: description) let alertMessage = EKAlertMessage(simpleMessage: simpleMessage, buttonBarContent: buttonBarContent) // Display let alertView = EKAlertMessageView(with: alertMessage) var attributes = EKAttributes.centerFloat attributes.screenBackground = .color(color: EKColor(UIColor.black.withAlphaComponent(0.5))) attributes.entryBackground = .color(color: .white) attributes.roundCorners = .all(radius: 15) attributes.screenInteraction = .dismiss attributes.entryInteraction = .absorbTouches SwiftEntryKit.display(entry: alertView, using: attributes) ``` -------------------------------- ### Define Rotation Constraints Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Structure for managing interface orientation and autorotation settings for entries. ```Swift /** Rotation related position constraints */ public struct Rotation { /** Attributes of supported interface orientations */ public enum SupportedInterfaceOrientation { /** Uses standard supported interface orientation (target specification in general settings) */ case standard /** Supports all orinetations */ case all } /** Autorotate the entry along with the device orientation */ public var isEnabled: Bool /** The screen autorotates with accordance to this option */ public var supportedInterfaceOrientations: SwiftEntryKit.EKAttributes.PositionConstraints.Rotation.SupportedInterfaceOrientation } ``` -------------------------------- ### Dismissing Entries Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Methods to dismiss currently displayed entries or clear the entry queue. ```APIDOC ## SwiftEntryKit.dismiss ### Description Dismisses entries based on the provided dismissal mode. ### Method Static Method ### Parameters #### Parameters - **mode** (DismissMode) - Optional - The strategy for dismissal (.displayed, .all, .queue, .specific, .prioritizedLowerOrEqualTo) - **completion** (Closure) - Optional - Trailing closure executed after dismissal ### Request Example SwiftEntryKit.dismiss(.all) { // Completion logic } ``` -------------------------------- ### Define Popup Theme Image Structure Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Defines the structure for a theme image in popups, including its content and position. Used when creating image-less popups by setting themeImage to nil. ```Swift /** Popup theme image */ public struct ThemeImage { /** Position of the theme image */ public enum Position { case topToTop(offset: CGFloat) case centerToTop(offset: CGFloat) } /** The content of the image */ public var image: EKProperty.ImageContent /** The psotion of the image */ public var position: Position } public init(themeImage: ThemeImage? = default, title: EKProperty.LabelContent, description: EKProperty.LabelContent, button: EKProperty.ButtonContent, action: @escaping EKPopUpMessageAction) ``` -------------------------------- ### Display a Temporary Note Message Source: https://context7.com/huri000/swiftentrykit/llms.txt Use EKNoteMessageView for displaying temporary text or status messages. Configure background color, display duration, and haptic feedback. The note can be dismissed programmatically. ```swift let labelContent = EKProperty.LabelContent( text: "Processing your request...", style: EKProperty.LabelStyle( font: .systemFont(ofSize: 14), color: EKColor(.white), alignment: .center ) ) let noteView = EKNoteMessageView(with: labelContent) noteView.horizontalOffset = 20 noteView.verticalOffset = 10 var attributes = EKAttributes.topNote attributes.entryBackground = .color(color: EKColor(.systemOrange)) attributes.displayDuration = .infinity attributes.hapticFeedbackType = .warning SwiftEntryKit.display(entry: noteView, using: attributes) // Later, dismiss when done SwiftEntryKit.dismiss() ``` -------------------------------- ### Dismiss Entry with Completion Handler Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Dismisses the current entry and executes a trailing closure immediately after the dismissal is complete. ```Swift SwiftEntryKit.dismiss { // Executed right after the entry has been dismissed } ``` -------------------------------- ### Display Status and Queue Management Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Methods to check if an entry is currently visible or if the queue contains specific items. ```APIDOC ## SwiftEntryKit Status Checks ### Description Inquire about the current state of the entry display and the queue. ### Methods - **isCurrentlyDisplaying**: Returns true if any entry is visible. - **isCurrentlyDisplaying(entryNamed:)**: Returns true if a specific named entry is visible. - **isQueueEmpty**: Returns true if no entries are queued. - **queueContains(entryNamed:)**: Returns true if the queue contains a specific named entry. ``` -------------------------------- ### Dismiss Currently Displayed Entry with Specific Option Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Dismisses the currently displayed entry. Use `.displayed` to dismiss only the visible entry. ```Swift SwiftEntryKit.dismiss(.displayed) ``` -------------------------------- ### Add Custom Tap Actions to Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Appends custom actions to be executed when the user taps the entry. This allows for specific, user-defined responses to entry interactions. ```Swift let action = { // Do something useful } attributes.entryInteraction.customTapActions.append(action) ``` -------------------------------- ### Set Entry Name Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Assign a name to an EKAttributes instance to allow for specific identification later. ```Swift attributes.name = "Top Note" ``` -------------------------------- ### Configure Override Precedence Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Set precedence to override existing entries based on priority, with an option to drop the current queue. ```Swift attributes.precedence = .override(priority: .max, dropEnqueuedEntries: false) ``` -------------------------------- ### Set Entry and Screen Interaction to Dismiss Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configures both entry and screen interactions to immediately dismiss the entry upon a tap. This is a common behavior for simple notifications. ```Swift attributes.entryInteraction = .dismiss attributes.screenInteraction = .dismiss ``` -------------------------------- ### Dismiss All Entries and Flush Queue Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Dismisses the currently displayed entry and also clears all entries from the queue. ```Swift SwiftEntryKit.dismiss(.all) ``` -------------------------------- ### Update Entry Precedence Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Replaces the deprecated displayPriority property with the precedence configuration. ```Swift attributes.displayPriority = value ``` ```Swift attributes.precedence = .override(priority: value, dropEnqueuedEntries: false) ``` -------------------------------- ### Set Pop Behavior Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Define how the entry behaves when dismissed by another entry with higher priority. ```Swift attributes.popBehavior = .animated(animation: .init(translate: .init(duration: 0.2))) ``` ```Swift attributes.popBehavior = .overridden ``` -------------------------------- ### Dismiss Currently Displayed Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Invoke this method to dismiss the currently displayed entry with its exit animation. The window is removed upon completion. ```Swift SwiftEntryKit.dismiss() ``` -------------------------------- ### Set Entry Interaction to Delay Exit Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configures user interaction with the entry to delay its dismissal animation by a specified duration. This provides a grace period for the user to interact before the entry disappears. ```Swift attributes.entryInteraction = .delayExit(by: 3) ``` -------------------------------- ### Check Entry Display Status Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Use this method to determine if a specific entry is currently being displayed. ```Swift public class func isCurrentlyDisplaying(entryNamed name: String? = default) -> Bool ``` -------------------------------- ### Transform Entry Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Allows transforming an existing entry into a new view while maintaining the same attributes. ```Swift let view = UIView() // Customize SwiftEntryKit.transform(to: view) ``` -------------------------------- ### Dismiss Entries by Priority Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Dismisses any entry that has a display priority lower than or equal to the specified priority, such as `.normal`. ```Swift SwiftEntryKit.dismiss(.prioritizedLowerOrEqualTo(priority: .normal)) ``` -------------------------------- ### Dismiss Specific Entry by Name Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Dismisses all entries that match the provided name, whether they are currently displayed or enqueued. ```Swift SwiftEntryKit.dismiss(.specific(entryName: "Entry Name")) ``` -------------------------------- ### Set Screen Interaction to Forward Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configures screen taps to be forwarded to the underlying window or application. This is useful for non-intrusive entries where interaction should pass through to the main app. ```Swift attributes.screenInteraction = .forward ``` -------------------------------- ### Dismissing Entries in SwiftEntryKit Source: https://context7.com/huri000/swiftentrykit/llms.txt Various methods to dismiss active or queued entries, including support for completion handlers and priority-based filtering. ```swift // Dismiss currently displayed entry SwiftEntryKit.dismiss() // Dismiss with completion handler SwiftEntryKit.dismiss { print("Entry dismissed") } // Dismiss all entries including queued ones SwiftEntryKit.dismiss(.all) // Dismiss only queued entries SwiftEntryKit.dismiss(.enqueued) // Dismiss specific entry by name SwiftEntryKit.dismiss(.specific(entryName: "AlertEntry")) // Dismiss entries with priority lower or equal to normal SwiftEntryKit.dismiss(.prioritizedLowerOrEqualTo(priority: .normal)) ``` -------------------------------- ### Flush Entry Queue Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Clears all entries from the queue without affecting the currently displayed entry. ```Swift SwiftEntryKit.dismiss(.queue) ``` -------------------------------- ### EKAttributes Structure Definition Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Defines the configurable attributes for SwiftEntryKit entries, including display, user interaction, and styling options. ```Swift public struct EKAttributes // Identification public var name: String? // Display public var windowLevel: WindowLevel public var position: Position public var precedence: Precedence public var displayDuration: DisplayDuration public var positionConstraints: PositionConstraints // User Interaction public var screenInteraction: UserInteraction public var entryInteraction: UserInteraction public var scroll: Scroll public var hapticFeedbackType: NotificationHapticFeedback public var lifecycleEvents: LifecycleEvents // Theme & Style public var displayMode = DisplayMode.inferred public var entryBackground: BackgroundStyle public var screenBackground: BackgroundStyle public var shadow: Shadow public var roundCorners: RoundCorners public var border: Border public var statusBar: StatusBar // Animations public var entranceAnimation: Animation public var exitAnimation: Animation public var popBehavior: PopBehavior ``` -------------------------------- ### Set Entry Vertical Offset Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Applies an additional vertical offset to the entry's position, independent of safe area insets. This allows for fine-tuning the entry's vertical placement. ```Swift attributes.positionConstraints.verticalOffset = 10 ``` -------------------------------- ### Enable Swipe but Disable Stretch on Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Enables swipe gestures for dismissing the entry but disables the stretch or rubber band effect. This allows for swipe dismissal without the visual stretching. ```Swift attributes.scroll = .edgeCrossingDisabled(swipeable: true) ``` -------------------------------- ### Infer Status Bar Style Source: https://github.com/huri000/swiftentrykit/blob/master/README.md The status bar appearance is inferred from the previous context and will not be changed. This is the default behavior. ```Swift attributes.statusBar = .inferred ``` -------------------------------- ### Set Entry Interaction to Absorb Touches Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Configures user interaction with the entry to swallow or ignore touch events. This prevents taps on the entry from triggering actions in lower layers. ```Swift attributes.entryInteraction = .absorbTouches ``` -------------------------------- ### Hide Status Bar Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Hides the status bar completely. Use this when the entry should occupy the full screen. ```Swift attributes.statusBar = .hidden ``` -------------------------------- ### Check if Queue Contains Specific Entry Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Inquire whether the entry queue contains an entry with the specified name. ```Swift if SwiftEntryKit.queueContains(entryNamed: "Custom-Name") { /* Do your things */ } ``` -------------------------------- ### Set Entry Intrinsic Height Constraint Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Sets the entry's height to be determined by its content. This is useful for entries where the height should naturally fit the content, decided by internal vertical constraints. ```Swift let heightConstraint = EKAttributes.PositionConstraints.Edge.intrinsic ``` -------------------------------- ### Set First Responder in Lifecycle Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Triggers the first responder status for a form view when the entry appears. ```Swift attributes.lifecycleEvents.didAppear = { formMessageView.becomeFirstResponder(with: 0) } ``` -------------------------------- ### Disable Entry Autorotation Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Controls whether the entry rotates automatically with the device's orientation. Setting `isEnabled` to `false` fixes the entry's orientation. ```Swift attributes.positionConstraints.rotation.isEnabled = false ``` -------------------------------- ### Check if SwiftEntryKit is Currently Displaying an Entry Source: https://github.com/huri000/swiftentrykit/blob/master/CHANGELOG.md Inquires if SwiftEntryKit is currently displaying an entry. Use this boolean property to conditionally execute code based on whether a notification or popup is active. ```Swift if SwiftEntryKit.isCurrentlyDisplaying { /* Do Something */ } ``` -------------------------------- ### Disable Entry Scroll Gestures Source: https://github.com/huri000/swiftentrykit/blob/master/README.md Disables all pan and swipe gestures on the entry. This prevents the user from interacting with the entry through swipe or drag motions. ```Swift attributes.scroll = .disabled ```