Skip to content

Latest commit

 

History

History
172 lines (132 loc) · 5.34 KB

File metadata and controls

172 lines (132 loc) · 5.34 KB

← Back to README

⚙️ Configuration

Available Parameters

Parameter Type Default Description
show * Binding<Bool> false Controls the presentation state
align Binding<HorizontalAlignment> .center Content alignment (.leading, .center, .trailing)
color Binding<Color> .accentColor Primary theme color
size Binding<String> "simple" Button size: "invisible", "mini", "simple", "normal"
label Binding<String> "Show Release Note" Button display text
labelImage Binding<String> "arrow.up.circle.fill" SF Symbol icon name
history Binding<Bool> true Enable version history navigation
data Binding<String> "data" Local JSON filename or remote URL
showDrop Binding<Bool> false Use iOS drop notification style
mesh Binding<Bool> true Enable mesh gradient backgrounds
specialEffect Binding<SwiftNEWSpecialEffect> .none Special effects: .none, .christmas, .particles
glass Binding<Bool> true Enable glass morphism effects
presentation Binding<SwiftNEWPresentation> .sheet Presentation style: .sheet, .fullScreenCover, .embed
showBuild Binding<Bool> true Show build number alongside the version in the header
headingStyle Binding<SwiftNEWHeadingStyle> .version Subtitle line style: .version (Version 6.3 (18)), .versionOnly (6.3), .appName (app's display name)
iconStyle Binding<SwiftNEWIconStyle> .filled Row icon style: .filled (colored backdrop, white glyph) or .plain (no backdrop, glyph in theme color)

* Required parameter

Examples

Minimal

SwiftNEW(show: $showNew)

Custom Styling

SwiftNEW(
    show: $showNew,
    color: .purple,
    size: "normal",
    mesh: true,
    glass: true
)

Hide Build Number

SwiftNEW(
    show: $showNew,
    showBuild: false
)

Heading Style

SwiftNEW(show: $showNew)                                  // "What's New in / Version 6.3 (18)"
SwiftNEW(show: $showNew, headingStyle: .versionOnly)      // "What's New in / 6.3"
SwiftNEW(show: $showNew, headingStyle: .appName)          // "What's New in / {App Name}"

Icon Style

SwiftNEW(show: $showNew)                              // .filled — colored backdrop, white glyph (default)
SwiftNEW(show: $showNew, iconStyle: .plain)           // no backdrop, glyph uses theme color

Special Effects

SwiftNEW(show: $showNew, specialEffect: .christmas)   // Snowfall
SwiftNEW(show: $showNew, specialEffect: .particles)   // Floating rainbow particles

Drop Notification (iOS only)

SwiftNEW(
    show: $showNew,
    label: "New Update",
    labelImage: "bell.badge",
    showDrop: true
)

🔧 Data Sources

SwiftNEW reads release notes from a JSON source. The same parameter (data) is used for both local and remote inputs — if it starts with http, it is fetched over the network; otherwise it is loaded as a bundled resource by name.

If loading fails, SwiftNEW shows an inline error state with a retry button. Successful data loads are cached for the current view lifetime, so repeated appearances do not re-fetch the same source unnecessarily.

Local JSON

Add a JSON file (typically data.json) to your app bundle:

[
  {
    "version": "1.2.0",
    "new": [
      {
        "icon": "hammer.fill",
        "title": "Bug Fixes",
        "subtitle": "Stability Improvements",
        "body": "Resolved critical issues and improved overall app performance."
      },
      {
        "icon": "sparkles",
        "title": "New Features",
        "subtitle": "Enhanced Experience",
        "body": "Improved animations and modern UI components."
      }
    ]
  }
]

Remote JSON

Pass any reachable JSON URL:

SwiftNEW(show: $showNew, data: "https://api.example.com/releases.json")

Firebase Realtime Database

Firebase exposes data over plain HTTPS, so the remote form works directly:

SwiftNEW(show: $showNew, data: "https://your-project.firebaseio.com/releases.json")

Data Model Reference

public struct Vmodel: Codable, Hashable, Identifiable, Sendable {
    public var id: String       // derived from version + subVersion
    public var version: String  // e.g., "1.2.0"
    public var subVersion: String?
    public var new: [Model]
}

public struct Model: Codable, Hashable, Identifiable, Sendable {
    public var id: String       // derived from icon + title + subtitle + body
    public var icon: String     // SF Symbol name
    public var title: String
    public var subtitle: String
    public var body: String
}

Auto-Trigger Storage

SwiftNEW remembers the last displayed app version/build in @AppStorage using namespaced keys:

Key Value
swiftnew.version Last displayed CFBundleShortVersionString
swiftnew.build Last displayed CFBundleVersion

Version/build comparison is string-safe, so non-numeric bundle values such as 1.0-beta or 1.0b3 will not crash.

Tips

  • Keep title short; put detail in body.
  • Use semantic versioning (1.2.3) for clearer history.
  • For frequently changing release notes, prefer remote/Firebase over rebuilding the app.