Simplify code embedding privacy policy and tos

This commit is contained in:
Jackson Harper
2023-11-02 13:35:03 +08:00
parent afe25c34fe
commit 6d7cbc45e3
2 changed files with 44 additions and 38 deletions

View File

@ -157,17 +157,23 @@ struct ProfileView: View {
)
#endif
NavigationLink(
destination: BasicWebAppView.privacyPolicyWebView(baseURL: dataService.appEnvironment.webAppBaseURL)
) {
Text(LocalText.privacyPolicyGeneric)
}
Button(
action: {
if let url = URL(string: "https://omnivore.app/privacy") {
openURL(url)
}
},
label: { Text(LocalText.privacyPolicyGeneric) }
)
NavigationLink(
destination: BasicWebAppView.termsConditionsWebView(baseURL: dataService.appEnvironment.webAppBaseURL)
) {
Text(LocalText.termsAndConditionsGeneric)
}
Button(
action: {
if let url = URL(string: "https://omnivore.app/terms") {
openURL(url)
}
},
label: { Text(LocalText.termsAndConditionsGeneric) }
)
}
Section(footer: Text(viewModel.appVersionString)) {
@ -200,11 +206,11 @@ struct ProfileView: View {
extension BasicWebAppView {
static func privacyPolicyWebView(baseURL: URL) -> BasicWebAppView {
omnivoreWebView(path: "/app/privacy", baseURL: baseURL)
omnivoreWebView(path: "/privacy", baseURL: baseURL)
}
static func termsConditionsWebView(baseURL: URL) -> BasicWebAppView {
omnivoreWebView(path: "/app/terms", baseURL: baseURL)
omnivoreWebView(path: "/terms", baseURL: baseURL)
}
private static func omnivoreWebView(path: String, baseURL: URL) -> BasicWebAppView {

View File

@ -87,37 +87,37 @@ struct WelcomeView: View {
Spacer()
}
.sheet(isPresented: $showPrivacyModal) {
VStack {
HStack {
Spacer()
Button(
action: {
showPrivacyModal = false
},
label: {
Image(systemName: "xmark.circle").foregroundColor(.appGrayTextContrast)
}
)
}
.padding()
NavigationView {
BasicWebAppView.privacyPolicyWebView(baseURL: dataService.appEnvironment.webAppBaseURL)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(
action: {
showPrivacyModal = false
},
label: {
Text(LocalText.genericClose)
}
)
}
}
}
}
.sheet(isPresented: $showTermsModal) {
VStack {
HStack {
Spacer()
Button(
action: {
showTermsModal = false
},
label: {
Image(systemName: "xmark.circle").foregroundColor(.appGrayTextContrast)
}
)
}
.padding()
NavigationView {
BasicWebAppView.termsConditionsWebView(baseURL: dataService.appEnvironment.webAppBaseURL)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(
action: {
showTermsModal = false
},
label: {
Text(LocalText.genericClose)
}
)
}
}
}
}
.sheet(isPresented: $showAboutPage) {