Skip to content

1998code/SwiftNEWKit

Repository files navigation

SNK

SwiftNEW

Stable Beta Validate JSON Files Swift Version

Platforms License

image

Features

Description Version
Mesh Gradient and Linear Gradient Background 5.3.0
Apple visionOS & Vision Pro 4.1.0
Auto trigger/pop-up .sheet when Version / Build changes 4.0.0
Version Number in x.y.z and/or x.y 4.0.0
Remote Drop Notification 3.5.0
Firebase Real-Time Database 3.0.0
Remote JSON File 3.0.0
Versioning + View History 2.0.0

Preview

CleanShot 2022-06-11 at 22 54 15@2x

Gallery

IMG_3472 IMG_3471
Light Native Dark Native
Simulator Screen Shot - iPhone 13 Pro Max CleanShot 2022-12-11 at 12 46 30@2x CleanShot 2022-12-11 at 12 49 12@2x
History View (2.0.0) App Icon (3.9.6) [Vertical / Horizontal]
CleanShot 2023-06-22 at 14 24 07@2x Screenshot 2024-07-01 at 10 18 33 PM
Support VisionOS (4.1.0 or above) Mesh Gradient Background (5.3.0 or above)

Example

Path: ./Demo (Xcode Project)

Version

GitHub release (latest by date) GitHub release (latest by date including pre-releases)

swiftui-128x128_2x

Tested Platforms and Environment

Local

Tested on Latest Compatible
iOS 18.5 > 15.0
iPadOS 18.5 > 15.0
macOS 15.5 > 14.0
visionOS 2 > 1
tvOS 18.5 > 17.0

Cloud

Tested on Compatible
Xcode > 13.4 (13F17a)
macOS > 12.3.1 (21E258)

Setup

Steps Description Screenshot
1 Navigate to root project CleanShot 2022-06-11 at 17 39 39@2x
2 Select Project CleanShot 2022-06-11 at 17 39 48@2x
3 Select Package Dependencies CleanShot 2022-06-11 at 17 39 53@2x
4 Click + and paste https://github.com/1998code/SwiftNEWKit to the searchbox CleanShot 2022-06-11 at 17 39 32@2x
5L Create a new local file called data.json You may copy this JSON sample.
5R You can use remote JSON / firebase realtime database too. Sample: https://testground-a937f-default-rtdb.firebaseio.com/0.json?print=pretty

Major Usage

  1. Import Package.
import SwiftNEW
  1. Add States before body or any some View.

States

var Suggested Options Type
showNew * false false, true Bool
align .center .leading, .center, .trailing HorizontalAlignment
color .accentColor All Colors Supported Color
size "simple" "invisible", "mini", "simple" String
labelColor UIColor.systemBackground or NSColor.windowBackgroundColor All Colors Supported Color
label "Show Release Note" All Strings String
labelImage "arrow.up.circle.fill" All SF Symbols String
history true true, false Bool
data "data" or "https://.../{}.json" "{LOCAL_JSON_FILE}" or Remote String
showDrop false false, true Bool
mesh true false, true Bool
Samples:
// Required
@State var showNew: Bool = false

// Optional (5.2.0 or above)
@State var align: HorizontalAlignment = .center
@State var color: Color = .accentColor
@State var size: String = "normal"
#if os(iOS)
@State var labelColor: Color = Color(UIColor.systemBackground)
#elseif os(macOS)
@State var labelColor: Color = Color(NSColor.windowBackgroundColor)
#endif
@State var label: String = "Show Release Note"
@State var labelImage: String = "arrow.up.circle.fill"
@State var history: Bool = true
@State var data: String = "data"
@State var showDrop: Bool = false
@State var mesh: Bool = false
  1. Then, paste this code inside body or any some View.
// Simplified with default options in 5.2.0 or above
SwiftNEW(show: $showNew)

// 5.1.0 or below
SwiftNEW(show: $showNew, align: $align, color: $color, size: $size, labelColor: $labelColor, label: $label, labelImage: $labelImage, history: $history, data: $data, showDrop: $showDrop)

Instead of using separate states, inline states work too. (No longer required after 5.2.0)

*Show Bool cannot be inline.

SwiftNEW(show: $showNew, align: .constant(.center), color: .constant(.accentColor), size: .constant("normal"), labelColor: .constant(Color(UIColor.systemBackground)), label: .constant("Show Release Note"), labelImage: .constant("arrow.up.circle.fill"), history: .constant(true), data: .constant("data"), showDrop: .constant(false))
  1. Your code should look similar to the following, including the minimum features and default styles.
struct ContentView: View {
    @State var showNew: Bool = false
    var body: some View {
        SwiftNEW(show: $showNew)
    }
}

JSON

Structure / Model (REF)

  • The below code is just for reference only. You don't need to copy the structure or model.
public struct Vmodel: Codable, Hashable {
    var version: String
    var new: [Model]
}
public struct Model: Codable, Hashable {
    var icon: String
    var title: String
    var subtitle: String
    var body: String
}

Sample

Copy the JSON sample to data.json file (If you don't have it, create a new file.)

68747470733a2f2f76616c696461746f722e737761676765722e696f2f76616c696461746f723f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f4f41492f4f70656e4150492d53706563696669636174696f6e2f6d61737465722f6578616d706c65732f76

[
  {
    "version": "1.2",
    "new": [
      {
        "body": "Available for iOS 16, iPadOS 16, macOS 13",
        "icon": "hammer.fill",
        "subtitle": "Broken UI",
        "title": "Bug fixes"
      },
      {
        "body": "Direct load via remote storage. Easy!",
        "icon": "square.and.arrow.down.fill",
        "subtitle": "Supported",
        "title": "Firebase Remote"
      },
      {
        "body": "Free and open source! Created by Ming with ❤️‍🔥",
        "icon": "macpro.gen3.server",
        "subtitle": "Design",
        "title": "Serverless"
      },
      {
        "body": "Pull requests and make it better for everyone!",
        "icon": "arrow.triangle.pull",
        "subtitle": "Together",
        "title": "Contribute"
      }
    ]
  },
  {
   "version": "1.1",
    "new": [
      {
        "body": "Available for iOS 16, iPadOS 16, macOS 13",
        "icon": "hammer.fill",
        "subtitle": "Broken UI",
        "title": "Bug fixes"
      },
      {
        "body": "Direct load via local storage. Super fast!",
        "icon": "square.and.arrow.down.fill",
        "subtitle": "Supported",
        "title": "Local File"
      },
      {
        "body": "Free and open source! Created by Ming with ❤️‍🔥",
        "icon": "macpro.gen3.server",
        "subtitle": "Design",
        "title": "Serverless"
      },
      {
        "body": "Pull requests and make it better for everyone!",
        "icon": "arrow.triangle.pull",
        "subtitle": "Together",
        "title": "Contribute"
      }
    ]
  }
]

Contributing

Contributions to SwiftNEW are welcome!

  • To report bugs or request features, please open an issue on GitHub
  • When submitting a pull request, please follow the coding style of the project

License

MIT. Read the LICENSE file for details.

Translation

This doc is also available in:

English | 繁中 / 简中 / 粵語 | 日本語 | 한국어

Please feel free to open a pull request and add new language(s) or fix any typos/mistakes.

Supported By

Digital Ocean Logo

Ask DeepWiki

About

Show "Release Note" on SwiftUI [ AI Assistant available below ]

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages