feat(swift-ios): add T3 Connect to onboarding
This commit is contained in:
2 files changed
+30
-9
No files matched your search
@@ -131,17 +131,32 @@ public struct ConnectionOnboardingView: View {
|
||||
.foregroundStyle(T3Colors.textSecondary)
|
||||
.padding(.top, 12)
|
||||
|
||||
Button {
|
||||
showingScanner = true
|
||||
} label: {
|
||||
Label("Scan QR code", systemImage: "qrcode.viewfinder")
|
||||
.frame(maxWidth: .infinity)
|
||||
if let capability = model.client as? any T3ConnectCapable {
|
||||
NavigationLink {
|
||||
T3ConnectView(capability: capability) {
|
||||
await model.reload()
|
||||
onConnected()
|
||||
}
|
||||
} label: {
|
||||
Label("Continue with T3 Connect", systemImage: "cloud")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(ConnectionPrimaryButtonStyle())
|
||||
.padding(.top, 36)
|
||||
.accessibilityHint("Sign in to connect an environment linked to your T3 account")
|
||||
}
|
||||
.buttonStyle(ConnectionPrimaryButtonStyle())
|
||||
.padding(.top, 36)
|
||||
.accessibilityHint("Opens the camera")
|
||||
|
||||
VStack(spacing: 0) {
|
||||
connectionAction(
|
||||
title: "Scan QR code",
|
||||
subtitle: "Pair directly with a computer nearby",
|
||||
systemImage: "qrcode.viewfinder"
|
||||
) {
|
||||
showingScanner = true
|
||||
}
|
||||
|
||||
Divider().overlay(Color.white.opacity(0.09))
|
||||
|
||||
connectionAction(
|
||||
title: "Paste connection link",
|
||||
subtitle: "Copy it from T3 Code on your computer",
|
||||
|
||||
@@ -4,10 +4,15 @@ public struct T3ConnectView: View {
|
||||
@Bindable private var controller: T3ConnectController
|
||||
private let connectEnvironment:
|
||||
@MainActor (T3ConnectManagedEnvironmentCredential) async throws -> Void
|
||||
private let onConnected: @MainActor () async -> Void
|
||||
|
||||
public init(capability: any T3ConnectCapable) {
|
||||
public init(
|
||||
capability: any T3ConnectCapable,
|
||||
onConnected: @escaping @MainActor () async -> Void = {}
|
||||
) {
|
||||
controller = capability.t3ConnectController
|
||||
connectEnvironment = capability.connectT3Environment
|
||||
self.onConnected = onConnected
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
@@ -213,6 +218,7 @@ public struct T3ConnectView: View {
|
||||
do {
|
||||
let credential = try await controller.credential(for: environment)
|
||||
try await connectEnvironment(credential)
|
||||
await onConnected()
|
||||
} catch {
|
||||
controller.errorMessage = error.localizedDescription
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user