目录
目录README.md

WhatsNew

This package is a simple way of adding What’s New pages to your app. The pages are dynamically created based on the number of items passed to the WhatsNewView.

How to use:

  1. In your target’s General Settings, make sure your app Display Name is set as you want it.

  2. Create the content for each What’s New page you want displayed. You can use What’s New BulletPoint struct to add bullet points with images, bold titles and explanatory text. The compnent will use whatever accent color you set for the page.

struct WhatsNewPageView: View {
    var body: some View {
        VStack (alignment: .leading, spacing: 10){
            BulletPointView(title: "We now have SEARCH!!!",
                            imageName: "paintbrush.fill",
                            text: "Search to find books that have been on previous best seller lists.")
            BulletPointView(title: "More bugs squashed.",
                            imageName: "myTruck",
                            text: "And the hits keep coming")
                            
            Spacer()
        }
        .padding()
        .accentColor(Color.red)
    }
}

... same for each additional page
  1. Import WhatsNew into your startup file.

  2. In your @main struct, create a state variable to control display of WhatsNew pages.

  3. Instantiate a WhatsNew class. You can use the (alwaysShow: true) parameter to always display WhatsNew content for testing.

  4. Add the .onAppear modifier to check for updates in the version number of the app. Add .sheet modifier to your ContentView() call to display the What’s new compomnent.

import SwiftUI
import WhatsNew

@main
struct PackageTesterApp: App {
    let whatsNew = WhatsNew(alwaysShow: true)
    @State private var showWhatsNew = false

    var body: some Scene {
        WindowGroup {
            ContentView()
                .onAppear(perform: {
                    whatsNew.checkForUpdate(showWhatsNew: $showWhatsNew)
                })
                .sheet(isPresented: $showWhatsNew) {
                    WhatsNewView {
                        WhatsNewPageView()
                        WhatsNewPageView2()
                    }
                }
        }
    }
}

And that should do it!

关于
104.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号