11import SwiftUI
22
33struct MainNavView : View {
4+ @AppStorage ( PaykitFeatureFlags . uiEnabledKey) private var isPaykitUIEnabled = false
5+
46 @EnvironmentObject private var app : AppViewModel
57 @Environment ( CameraManager . self) private var cameraManager
68 @EnvironmentObject private var contactsManager : ContactsManager
@@ -16,6 +18,10 @@ struct MainNavView: View {
1618 @State private var showClipboardAlert = false
1719 @State private var clipboardUri : String ?
1820
21+ private var isPaykitUIActive : Bool {
22+ PaykitFeatureFlags . isUIAvailable && isPaykitUIEnabled
23+ }
24+
1925 // Delay constants for clipboard processing
2026 private static let nodeReadyDelayNanoseconds : UInt64 = 500_000_000 // 0.5 seconds
2127 private static let statePropagationDelayNanoseconds : UInt64 = 500_000_000 // 0.5 seconds
@@ -247,6 +253,15 @@ struct MainNavView: View {
247253 Logger . info ( " Received deeplink: \( url. absoluteString) " )
248254
249255 if let callback = PubkyRingAuthCallback . parse ( url: url) {
256+ guard isPaykitUIActive else {
257+ app. toast (
258+ type: . error,
259+ title: t ( " profile__auth_error_title " ) ,
260+ description: t ( " other__qr_error_text " )
261+ )
262+ return
263+ }
264+
250265 let handlingResult = await pubkyProfile. handleAuthCallback ( callback)
251266
252267 switch handlingResult {
@@ -368,7 +383,9 @@ struct MainNavView: View {
368383
369384 // Profile & Contacts
370385 case . contacts:
371- if let initializationErrorMessage = pubkyProfile. initializationErrorMessage {
386+ if !isPaykitUIActive {
387+ ComingSoonScreen ( )
388+ } else if let initializationErrorMessage = pubkyProfile. initializationErrorMessage {
372389 pubkyInitializationErrorView ( message: initializationErrorMessage)
373390 } else if app. hasSeenContactsIntro || !contactsManager. contacts. isEmpty {
374391 if !pubkyProfile. isInitialized {
@@ -383,12 +400,18 @@ struct MainNavView: View {
383400 } else {
384401 ContactsIntroView ( )
385402 }
386- case . contactsIntro: ContactsIntroView ( )
387- case let . contactDetail( publicKey) : ContactDetailView ( publicKey: publicKey)
388- case let . contactActivity( publicKey) : ContactActivityView ( publicKey: publicKey)
389- case let . assignActivityContact( activityId) : AssignActivityContactView ( activityId: activityId)
403+ case . contactsIntro:
404+ if isPaykitUIActive { ContactsIntroView ( ) } else { ComingSoonScreen ( ) }
405+ case let . contactDetail( publicKey) :
406+ if isPaykitUIActive { ContactDetailView ( publicKey: publicKey) } else { paykitDisabledRedirectView }
407+ case let . contactActivity( publicKey) :
408+ if isPaykitUIActive { ContactActivityView ( publicKey: publicKey) } else { paykitDisabledRedirectView }
409+ case let . assignActivityContact( activityId) :
410+ if isPaykitUIActive { AssignActivityContactView ( activityId: activityId) } else { paykitDisabledRedirectView }
390411 case . contactImportOverview:
391- if let fallbackRoute = fallbackRouteForMissingPendingImport ( hasPendingImport: contactsManager. hasPendingImport) {
412+ if !isPaykitUIActive {
413+ paykitDisabledRedirectView
414+ } else if let fallbackRoute = fallbackRouteForMissingPendingImport ( hasPendingImport: contactsManager. hasPendingImport) {
392415 missingPendingImportView ( fallbackRoute: fallbackRoute)
393416 } else if let profile = contactsManager. pendingImportProfile {
394417 ContactImportOverviewView (
@@ -399,15 +422,21 @@ struct MainNavView: View {
399422 missingPendingImportView ( fallbackRoute: . payContacts)
400423 }
401424 case . contactImportSelect:
402- if let fallbackRoute = fallbackRouteForMissingPendingImport ( hasPendingImport: contactsManager. hasPendingImport) {
425+ if !isPaykitUIActive {
426+ paykitDisabledRedirectView
427+ } else if let fallbackRoute = fallbackRouteForMissingPendingImport ( hasPendingImport: contactsManager. hasPendingImport) {
403428 missingPendingImportView ( fallbackRoute: fallbackRoute)
404429 } else {
405430 ContactImportSelectView ( contacts: contactsManager. pendingImportContacts)
406431 }
407- case let . addContact( publicKey) : AddContactView ( publicKey: publicKey)
408- case let . editContact( publicKey) : EditContactView ( publicKey: publicKey)
432+ case let . addContact( publicKey) :
433+ if isPaykitUIActive { AddContactView ( publicKey: publicKey) } else { paykitDisabledRedirectView }
434+ case let . editContact( publicKey) :
435+ if isPaykitUIActive { EditContactView ( publicKey: publicKey) } else { paykitDisabledRedirectView }
409436 case . profile:
410- if let initializationErrorMessage = pubkyProfile. initializationErrorMessage {
437+ if !isPaykitUIActive {
438+ ComingSoonScreen ( )
439+ } else if let initializationErrorMessage = pubkyProfile. initializationErrorMessage {
411440 pubkyInitializationErrorView ( message: initializationErrorMessage)
412441 } else if !pubkyProfile. isInitialized {
413442 pubkyLoadingView
@@ -418,11 +447,16 @@ struct MainNavView: View {
418447 } else {
419448 ProfileIntroView ( )
420449 }
421- case . profileIntro: ProfileIntroView ( )
422- case . pubkyChoice: PubkyChoiceView ( )
423- case . createProfile: CreateProfileView ( )
424- case . editProfile: EditProfileView ( )
425- case . payContacts: PayContactsView ( )
450+ case . profileIntro:
451+ if isPaykitUIActive { ProfileIntroView ( ) } else { ComingSoonScreen ( ) }
452+ case . pubkyChoice:
453+ if isPaykitUIActive { PubkyChoiceView ( ) } else { paykitDisabledRedirectView }
454+ case . createProfile:
455+ if isPaykitUIActive { CreateProfileView ( ) } else { paykitDisabledRedirectView }
456+ case . editProfile:
457+ if isPaykitUIActive { EditProfileView ( ) } else { paykitDisabledRedirectView }
458+ case . payContacts:
459+ if isPaykitUIActive { PayContactsView ( ) } else { paykitDisabledRedirectView }
426460
427461 // Shop
428462 case . shopIntro: ShopIntro ( )
@@ -451,7 +485,8 @@ struct MainNavView: View {
451485 case . widgetsSettings: WidgetsSettingsScreen ( )
452486 case . notifications: NotificationsSettings ( )
453487 case . notificationsIntro: NotificationsIntro ( )
454- case . paymentPreference: PaymentPreferenceView ( )
488+ case . paymentPreference:
489+ if isPaykitUIActive { PaymentPreferenceView ( ) } else { paykitDisabledRedirectView }
455490
456491 // Security settings
457492 case . changePin: ChangePinScreen ( )
@@ -499,6 +534,13 @@ struct MainNavView: View {
499534 }
500535 }
501536
537+ private var paykitDisabledRedirectView : some View {
538+ Color . customBlack
539+ . task {
540+ navigation. reset ( )
541+ }
542+ }
543+
502544 private func handleClipboard( ) {
503545 Task { @MainActor in
504546 guard let uri = UIPasteboard . general. string else {
0 commit comments