From 8cfb37411e6c6380524253a4ccc168b5fafc2176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Fari=C3=B1a?= Date: Thu, 23 May 2024 17:20:32 +0200 Subject: [PATCH] Add tutorial for enabling Safari web extension (#77) feat: add tutorial for enabling Safari web extension closes #76 --- .../View Models/SettingsViewModel.swift | 13 ++++++++---- .../Screens/Views/SettingsView.swift | 14 +++++++------ Hax/Resources/Localizable.xcstrings | 20 +++++++++++++++++++ .../Screens/SettingsViewModelTests.swift | 11 ++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Hax/Presentation/Screens/View Models/SettingsViewModel.swift b/Hax/Presentation/Screens/View Models/SettingsViewModel.swift index f03aaa0..f3253ec 100644 --- a/Hax/Presentation/Screens/View Models/SettingsViewModel.swift +++ b/Hax/Presentation/Screens/View Models/SettingsViewModel.swift @@ -26,7 +26,10 @@ protocol SettingsViewModelProtocol: ObservableObject { // MARK: Methods - /// Called when the privacy policy button is triggered. + /// Called when the "Safari Extension" button is triggered. + func onSafariExtensionButtonTrigger() + + /// Called when the "Privacy Policy" button is triggered. func onPrivacyPolicyButtonTrigger() } @@ -47,9 +50,11 @@ final class SettingsViewModel: SettingsViewModelProtocol { // MARK: Methods + func onSafariExtensionButtonTrigger() { + url = IdentifiableURL(URL(string: "https://luisfl.me/hax/help/safari-extension")) + } + func onPrivacyPolicyButtonTrigger() { - url = IdentifiableURL( - URL(string: "https://luisfl.me/hax/privacy-policy") - ) + url = IdentifiableURL(URL(string: "https://luisfl.me/hax/privacy-policy")) } } diff --git a/Hax/Presentation/Screens/Views/SettingsView.swift b/Hax/Presentation/Screens/Views/SettingsView.swift index 0fa6b6b..c1e369b 100644 --- a/Hax/Presentation/Screens/Views/SettingsView.swift +++ b/Hax/Presentation/Screens/Views/SettingsView.swift @@ -34,6 +34,11 @@ struct SettingsView: View { Label("Filters", systemImage: "eye.slash") } } + Section("Help") { + Button("Safari Extension") { + model.onSafariExtensionButtonTrigger() + } + } Section("About") { Button("Privacy Policy") { model.onPrivacyPolicyButtonTrigger() @@ -56,11 +61,8 @@ struct SettingsView: View { // MARK: - Previews -struct SettingsView_Previews: PreviewProvider { - - static var previews: some View { - NavigationStack { - SettingsView(model: SettingsViewModel()) - } +#Preview { + NavigationStack { + SettingsView(model: SettingsViewModel()) } } diff --git a/Hax/Resources/Localizable.xcstrings b/Hax/Resources/Localizable.xcstrings index 45a99e1..1c307b1 100644 --- a/Hax/Resources/Localizable.xcstrings +++ b/Hax/Resources/Localizable.xcstrings @@ -231,6 +231,16 @@ } } }, + "Help" : { + "localizations" : { + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ayuda" + } + } + } + }, "Input a valid Hacker News link into the text field." : { "localizations" : { "es" : { @@ -351,6 +361,16 @@ } } }, + "Safari Extension" : { + "localizations" : { + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Extensión de Safari" + } + } + } + }, "Select Feed" : { "localizations" : { "es" : { diff --git a/HaxTests/Tests/Presentation/Screens/SettingsViewModelTests.swift b/HaxTests/Tests/Presentation/Screens/SettingsViewModelTests.swift index e9c5ab8..f1429de 100644 --- a/HaxTests/Tests/Presentation/Screens/SettingsViewModelTests.swift +++ b/HaxTests/Tests/Presentation/Screens/SettingsViewModelTests.swift @@ -45,6 +45,17 @@ final class SettingsViewModelTests: XCTestCase { XCTAssertEqual(appVersionServiceMock.appVersionCallCount, 1) } + func testOnSafariExtensionButtonTrigger() { + // When + sut.onSafariExtensionButtonTrigger() + + // Then + XCTAssertEqual( + sut.url?.url.absoluteString, + "https://luisfl.me/hax/help/safari-extension" + ) + } + func testOnPrivacyPolicyButtonTrigger() { // When sut.onPrivacyPolicyButtonTrigger()