11import SwiftUI
2+ import Combine
23
34struct OnboardingView : View {
45 @Environment ( AppState . self) private var appState
56 @State private var step = 0
7+ @State private var micGranted = PermissionService . isMicrophoneAuthorized ( )
8+ @State private var accessibilityGranted = PermissionService . isAccessibilityGranted ( )
69
710 var body : some View {
811 VStack ( spacing: 0 ) {
@@ -64,15 +67,15 @@ struct OnboardingView: View {
6467 . multilineTextAlignment ( . center)
6568 . foregroundStyle ( . secondary)
6669 HStack ( spacing: 12 ) {
67- if PermissionService . isMicrophoneAuthorized ( ) {
70+ if micGranted {
6871 Label ( " Granted " , systemImage: " checkmark.circle.fill " )
6972 . foregroundStyle ( . green)
7073 Button ( " Next " ) { step = 2 }
7174 . buttonStyle ( . borderedProminent)
7275 } else {
7376 Button ( " Grant Access " ) {
7477 Task {
75- _ = await PermissionService . requestMicrophoneAccess ( )
78+ micGranted = await PermissionService . requestMicrophoneAccess ( )
7679 }
7780 }
7881 . buttonStyle ( . borderedProminent)
@@ -95,7 +98,7 @@ struct OnboardingView: View {
9598 . multilineTextAlignment ( . center)
9699 . foregroundStyle ( . secondary)
97100 HStack ( spacing: 12 ) {
98- if PermissionService . isAccessibilityGranted ( ) {
101+ if accessibilityGranted {
99102 Label ( " Granted " , systemImage: " checkmark.circle.fill " )
100103 . foregroundStyle ( . green)
101104 Button ( " Next " ) { step = 3 }
@@ -110,6 +113,9 @@ struct OnboardingView: View {
110113 }
111114 }
112115 . controlSize ( . large)
116+ . onReceive ( Timer . publish ( every: 1 , on: . main, in: . common) . autoconnect ( ) ) { _ in
117+ accessibilityGranted = PermissionService . isAccessibilityGranted ( )
118+ }
113119 }
114120 }
115121
0 commit comments