Skip to content

Commit

Permalink
Fixed #6 + some imporvements
Browse files Browse the repository at this point in the history
  • Loading branch information
oolxg committed Jul 12, 2023
1 parent 306a46b commit c038c91
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
35 changes: 23 additions & 12 deletions Hanami/App/Core/Search/Filter/FiltersFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,29 +115,40 @@ struct FiltersFeature: ReducerProtocol {

return .none

case .mangaStatusButtonTapped(let tag):
if tag.state == .selected {
state.mangaStatuses[id: tag.id]!.state = .notSelected
case .mangaStatusButtonTapped(let tagContainer):
if tagContainer.state == .selected {
state.mangaStatuses[id: tagContainer.id]!.state = .notSelected
} else {
state.mangaStatuses[id: tag.id]!.state = .selected
state.mangaStatuses[id: tagContainer.id]!.state = .selected
}

return hapticClient.generateFeedback(.light).fireAndForget()

case .contentRatingButtonTapped(let tag):
if tag.state == .selected {
state.contentRatings[id: tag.id]!.state = .notSelected
case .contentRatingButtonTapped(let tagContainer):
if tagContainer.state == .selected {
state.contentRatings[id: tagContainer.id]!.state = .notSelected
} else {
state.contentRatings[id: tag.id]!.state = .selected
state.contentRatings[id: tagContainer.id]!.state = .selected
}

// setting all tags to notSelected when user tapped on `safe`
if tagContainer.tag == .safe && tagContainer.state != .selected {
for tagID in state.contentRatings.ids {
state.contentRatings[id: tagID]!.state = .notSelected
}
state.contentRatings[id: tagContainer.id]!.state = .selected
} else {
let safeTagID = state.contentRatings.first(where: { $0.tag == .safe })!.id
state.contentRatings[id: safeTagID]!.state = .notSelected
}

return hapticClient.generateFeedback(.light).fireAndForget()

case .publicationDemographicButtonTapped(let tag):
if tag.state == .selected {
state.publicationDemographics[id: tag.id]!.state = .notSelected
case .publicationDemographicButtonTapped(let tagContainer):
if tagContainer.state == .selected {
state.publicationDemographics[id: tagContainer.id]!.state = .notSelected
} else {
state.publicationDemographics[id: tag.id]!.state = .selected
state.publicationDemographics[id: tagContainer.id]!.state = .selected
}

return hapticClient.generateFeedback(.light).fireAndForget()
Expand Down
4 changes: 2 additions & 2 deletions Hanami/Tools/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ enum Defaults {
}

enum Feedback {
static var feedbackDomain: URL? {
static let apiURL: URL? = {
if AppUtil.appConfiguration != .debug, var urlString = Bundle.main.infoDictionary?["API_URL"] as? String {
urlString = "https://" + urlString
return URL(string: urlString)
}

return nil
}
}()
}
}

0 comments on commit c038c91

Please sign in to comment.