Skip to content

Commit

Permalink
Add tutorial for enabling Safari web extension (#77)
Browse files Browse the repository at this point in the history
feat: add tutorial for enabling Safari web extension

closes #76
  • Loading branch information
lui5fl authored May 23, 2024
1 parent 5ebd298 commit 8cfb374
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Hax/Presentation/Screens/View Models/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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"))
}
}
14 changes: 8 additions & 6 deletions Hax/Presentation/Screens/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ struct SettingsView<Model: SettingsViewModelProtocol>: View {
Label("Filters", systemImage: "eye.slash")
}
}
Section("Help") {
Button("Safari Extension") {
model.onSafariExtensionButtonTrigger()
}
}
Section("About") {
Button("Privacy Policy") {
model.onPrivacyPolicyButtonTrigger()
Expand All @@ -56,11 +61,8 @@ struct SettingsView<Model: SettingsViewModelProtocol>: View {

// MARK: - Previews

struct SettingsView_Previews: PreviewProvider {

static var previews: some View {
NavigationStack {
SettingsView(model: SettingsViewModel())
}
#Preview {
NavigationStack {
SettingsView(model: SettingsViewModel())
}
}
20 changes: 20 additions & 0 deletions Hax/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@
}
}
},
"Help" : {
"localizations" : {
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ayuda"
}
}
}
},
"Input a valid Hacker News link into the text field." : {
"localizations" : {
"es" : {
Expand Down Expand Up @@ -351,6 +361,16 @@
}
}
},
"Safari Extension" : {
"localizations" : {
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Extensión de Safari"
}
}
}
},
"Select Feed" : {
"localizations" : {
"es" : {
Expand Down
11 changes: 11 additions & 0 deletions HaxTests/Tests/Presentation/Screens/SettingsViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8cfb374

Please sign in to comment.