DecaneDocs
PlatformSwiftUI
Platform

SwiftUI

DecaneKitUI wraps the wallet in an @Observable model for iOS 17 and macOS 14. Its state updates on the main actor from the wallet’s events, and its actions catch errors into lastError instead of throwing.

swiftSignInView.swift
import SwiftUI
import DecaneKitUI

struct SignInView: View {
    @State var model = try! DecaneObservable(config: config)
    @State var email = ""
    @State var code = ""

    var body: some View {
        if let addresses = model.addresses {
            Text(addresses.evm)
        } else {
            TextField("Email", text: $email)
            Button("Send code") { Task { await model.sendEmailCode(to: email) } }
            TextField("Code", text: $code)
            Button("Sign in") { Task { await model.verifyEmailCode(email: email, code: code) } }
                .disabled(model.isBusy)
        }
        if let error = model.lastError { Text(error.localizedDescription) }
    }
}
StateType
addressesAddresses?
isUnlocked, needsReconnect, isBusyBool
sessionExpiresAtDate?
profileAuthProfile?
lastErrorDecaneError?
lastEventDecaneEvent?

Actions: restore(), sendEmailCode(to:), verifyEmailCode(email:code:), signMessage(chain:text:), disconnect(), and perform for any other wallet call. The underlying DecaneWallet is available for everything else.