Swiftpack.co - 1998code/SwiftNEWKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by 1998code.
1998code/SwiftNEWKit 3.9.1
Show "What's New" with SwiftUI.
⭐️ 40
πŸ•“ 8 weeks ago
iOS macOS watchOS
.package(url: "https://github.com/1998code/SwiftNEWKit.git", from: "3.9.1")

SwiftNEWKit

Accelerated by Apple SwiftUI

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

Aims

Provide an easy way for Apple Developers to Show "What's New" to the end users.

Features

  • Auto trigger the .sheet from Version and/or Build increase
  • One-line Coding
  • JSON Compatible
  • Data Versioning
  • View History (2.0.0 or above)
  • Fast Loading from local storage
  • Simple Binding and pass data
  • Simple Model, easy to modify
  • Open Source for all developers
  • Support Remote JSON File (3.0.0 or above)
  • Support Firebase Real Time Database (3.0.0 or above)
  • Support Remote Drop Notification (3.5.0 or above)

Version

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

swiftui-128x128_2x

Environment

Xcode Local

Tested on Latest Compatible
iOS 16 > 14
iPadOS 16 > 14
macOS 13 > 11

Xcode Cloud

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

Guide

English | δΈ­ζ–‡ | Feel free to add/update new language(s) via pull requests

Get Started

Full Tutorial: https://bit.ly/3NOvJB8

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 first.
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 "normal" "invisible", "mini", "normal" String
labelColor Color(UIColor.systemBackground) or Color(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
Samples:
@State var showNew: Bool = false
@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
  1. Then, paste this code inside body or any some View.
SwiftNEW(show: $showNew, align: $align, color: $color, size: $size, labelColor: $labelColor, label: $label, labelImage: $labelImage, history: $history, data: $data, showDrop: $showDrop)

Instead of using seperate states, inline states works too. *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))

JSON

Structure / Model

  • 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, simply create a new one.)

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"
      }
    ]
  }
]

Developer Note

  • Please report bugs in Issues section.
  • If you want to discuss future roadmap or contribution, please find on Discussions.

Preview

IMG_3472 IMG_3471
Light Native Dark Native
Simulator Screen Shot - iPhone 13 Pro Max - 2022-07-10 at 11 19 40
History View (2.0.0)

Demo

Path: ./Demo

License

MIT

GitHub

link
Stars: 40
Last commit: 8 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics