Skip to content

Commit

Permalink
Fix minor issue with view presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Mar 10, 2024
1 parent 486f9df commit c2ff0fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,7 @@
CBF14FC627970C8A001D94D0 /* HomeMessageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeMessageCollectionViewCell.swift; sourceTree = "<group>"; };
CBFCB30D2B2CD47800253E9E /* ConfigurationURLDebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationURLDebugViewController.swift; sourceTree = "<group>"; };
D63657182A7BAE7C001AF19D /* EmailManagerRequestDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailManagerRequestDelegate.swift; sourceTree = "<group>"; };
D63C2E552B9E31D70012E514 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../BrowserServicesKit; sourceTree = "<group>"; };
D64648AC2B59936B0033090B /* SubscriptionEmailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionEmailView.swift; sourceTree = "<group>"; };
D64648AE2B5993890033090B /* SubscriptionEmailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionEmailViewModel.swift; sourceTree = "<group>"; };
D652498D2B515A6A0056B0DE /* SubscriptionSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionSettingsViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3712,6 +3713,7 @@
84E341891E2F7EFB00BDBA6F = {
isa = PBXGroup;
children = (
D63C2E552B9E31D70012E514 /* BrowserServicesKit */,
EE3B98EB2A963515002F63A0 /* WidgetsExtensionAlpha.entitlements */,
6FB030C7234331B400A10DB9 /* Configuration.xcconfig */,
EEB8FDB92A990AEE00EBEDCF /* Configuration-Alpha.xcconfig */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@
"version" : "3.0.0"
}
},
{
"identity" : "browserserviceskit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"branch" : "daniel/subscription.cache",
"revision" : "1befaa6678b4a63be01342bfc47aa51390805c41"
}
},
{
"identity" : "cocoaasyncsocket",
"kind" : "remoteSourceControl",
Expand Down
32 changes: 13 additions & 19 deletions DuckDuckGo/SettingsSubscriptionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct SettingsSubscriptionView: View {

@EnvironmentObject var viewModel: SettingsViewModel
@StateObject var subscriptionFlowViewModel = SubscriptionFlowViewModel()
@State var isShowingsubScriptionFlow = false
@State var isShowingDBP = false
@State var isShowingITP = false

Expand Down Expand Up @@ -91,12 +90,12 @@ struct SettingsSubscriptionView: View {
Group {
SettingsCustomCell(content: { subscriptionDescriptionView })
SettingsCustomCell(content: { learnMoreView },
action: { isShowingsubScriptionFlow = true },
action: { viewModel.shouldNavigateToSubscriptionFlow = true },
isButton: true )

SettingsCustomCell(content: { iHaveASubscriptionView },
action: {
isShowingsubScriptionFlow = true
viewModel.shouldNavigateToSubscriptionFlow = true
subscriptionFlowViewModel.activateSubscriptionOnLoad = true
},
isButton: true )
Expand Down Expand Up @@ -180,24 +179,23 @@ struct SettingsSubscriptionView: View {

}
// Subscription Restore
.sheet(isPresented: $isShowingsubScriptionFlow) {
SubscriptionFlowView(viewModel: subscriptionFlowViewModel).interactiveDismissDisabled()
}
.sheet(isPresented: $viewModel.shouldNavigateToSubscriptionFlow,
onDismiss: {
Task { viewModel.onAppear() }
},
content: {
SubscriptionFlowView(viewModel: subscriptionFlowViewModel).interactiveDismissDisabled()
})


// Refresh subscription when dismissing the Subscription Flow
.onChange(of: isShowingsubScriptionFlow, perform: { value in
if !value {
Task { viewModel.onAppear() }
}
})

.onChange(of: viewModel.shouldNavigateToDBP, perform: { value in
if value {
// Allow the sheet to dismiss before presenting a new one
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Constants.navigationDelay) {
isShowingDBP = true
}
} else {
isShowingDBP = false
}
})

Expand All @@ -207,12 +205,8 @@ struct SettingsSubscriptionView: View {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Constants.navigationDelay) {
isShowingITP = true
}
}
})

.onChange(of: viewModel.shouldNavigateToSubscriptionFlow, perform: { value in
if value {
isShowingsubScriptionFlow = true
} else {
isShowingITP = false
}
})

Expand Down

0 comments on commit c2ff0fd

Please sign in to comment.