Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
John O'Reilly edited this pageOct 21, 2022 ·3 revisions

Welcome to the Confetti wiki!

Using Swift Package

The shared code is published as a Swift Package (using theKMMBridge tool). To use just go to File/Add Package in XCode and enterhttps://github.com/joreilly/Confetti (as shown below)

Screenshot 2022-10-21 at 16 27 05

Note that this useshttps://github.com/rickclephas/KMP-NativeCoroutines library and right now Swift Package for this needs to be also manually added in XCode.

Example SwiftUI code

import SwiftUIimport ConfettiKitimport KMPNativeCoroutinesAsyncstructContentView:View{letrepository=ConfettiRepository()@Statevarsessions:[SessionDetails]=[]varbody:someView{List(sessions, id: \.id){ sessioninVStack(alignment:.leading){Text(session.title).bold()Text(session.room?.name??"")}}.task{awaitobserveSessions()}}func observeSessions()async{        repository.setConference(conference:"droidconlondon2022")do{letstream=asyncStream(for: repository.sessionsNative)fortryawaitdatain stream{self.sessions= data}}catch{print("Failed with error:\(error)")}}}

Note that it's also necessary to initialise Koin (like following for example)

import SwiftUIimport ConfettiKit@mainstructYourApp:App{init(){KoinKt.doInitKoin()}varbody:someScene{WindowGroup{ContentView()}}}

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp