How huri000/swiftentrykit works
Project Type and Purpose
• SwiftEntryKit is an iOS UI library used to present customizable notification entries. It is designed to offer a wide array of display options (positioning, styling, animations, haptics, lifecycle events, etc.) by creating separate windows that display entries without interfering with the main app’s navigation.
Analyzing the File Structure
• There is a clear separation between the example project (in the “Example” directory), the source code (in the “Source” directory), and tests (in the “Tests” directory).
• Within “Source” you see further subdivisions:
• Extensions: Contains helper utilities and UI layout extensions.
• Infra: Contains classes related to window and view management (e.g., EKWindow, EKRootViewController, and various content view wrappers) that create and manage the separate UIWindow instances.
• MessageViews: Contains pre-built UI components like banners, alerts, pop-ups, and different message views (with subdirectories for notes, alerts, etc.).
• Model: Defines data models such as EKAlertMessage, EKNotificationMessage, and the EKAttributes structure that drives the configuration for all entries.
• Utils: Contains utility components (e.g., gradient views, haptic feedback generators, responder extensions) that support the presentation logic.
• Other files like the podspec and Package.swift indicate how the library is packaged and distributed.
a. Main Components:
• SwiftEntryKit API Layer – the public API (i.e. SwiftEntryKit.display, dismiss, and related functions).
• Entry Attributes & Configuration – the EKAttributes struct (found in the Model folder) that contains all configurable parameters: display duration, animations, user interactions, background style, and more.
• UI Presentation Layer – the various MessageViews (like EKNotificationMessageView and others) that define the view appearance.
• Window Management – components in the Infra folder (EKWindow, EKWindowProvider, EKRootViewController, etc.) that manage the creation and life cycle of the UIWindow used for entry presentation.
• Utility & Extensions – modules from the Extensions and Utils folder that help support layout, custom animations, haptic feedback, and overall UI adjustments.
• Example/Demo – the example project providing practical usage, demonstrating how an application integrates and uses SwiftEntryKit.
b. Relationships and Interactions:
• The public API (SwiftEntryKit) accepts a custom view or view controller along with an EKAttributes configuration.
• The attributes (model/data) inform the UI Presentation Layer on how to animate, display, and interact with the entry.
• The UI Presentation Layer constructs and organizes the content view (using components from MessageViews) based on these attributes.
• The Infra layer then creates a dedicated UIWindow that hosts the entry view. This window is managed (shown/dismissed) with lifecycle events and animations per configuration.
• The dependency direction flows from the API invocation down to the infra (window creation), with back-and-forth interactions such as user-interaction events (e.g., swipe to dismiss) invoking callbacks.
c. Important Architectural Patterns and Design Principles:
• Modular Design: Separation into discrete modules such as Model, Infra, MessageViews, and Utils.
• Configuration-Driven Behavior: The EKAttributes configuration object enables a high degree of customization by decoupling the presentation behavior from the underlying view logic.
• Lifecycle Management: Use of event callbacks (willAppear, didAppear, etc.) to keep the UI responsive.
• Reusability and Extensibility: The extensive use of extensions, presets, and customization hooks signifies a design built for reuse across different UI patterns (toasts, alerts, pop-ups).
• Dependency Inversion: The library offers a clear public API (via SwiftEntryKit.display and related methods) decoupled from the internal components.
d. Relevant Technologies, Frameworks, or Libraries:
• iOS/Swift: Mention that the library heavily leverages UIKit components and iOS-specific UI window management.
• CocoaPods/Carthage/Accio: These build and dependency managers are used to integrate SwiftEntryKit in user projects.
• Animation, Haptic, and Layout Utilities: Internal use of custom animations, haptic feedback generators, and Auto Layout helpers.