Skip to content

Commit

Permalink
Merge pull request #1118 from planetary-social/feature/discover-categ…
Browse files Browse the repository at this point in the history
…ories-center

Center categories on iPad/Mac
  • Loading branch information
joshuatbrown authored May 9, 2024
2 parents ba6168f + 2e86623 commit 5a499cd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- On the Discover tab, center the category buttons.

## [0.1.12] - 2024-05-07Z

- Open Profiles when tapping on a NIP-05 username reference in a note.
Expand Down
61 changes: 36 additions & 25 deletions Nos/Views/Discover/FeaturedAuthorsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,46 @@ struct FeaturedAuthorsView: View {
}

var categoryPicker: some View {
ScrollView(.horizontal) {
HStack(spacing: 2) {
ForEach(FeaturedAuthorCategory.allCases, id: \.self) { category in
Button(action: {
selectedCategory = category
}, label: {
Text(category.text)
.font(.callout)
.padding(.vertical, 4)
.padding(.horizontal, 8)
.background(
selectedCategory == category ?
Color.pickerBackgroundSelected :
ViewThatFits {
categoriesStack

ScrollView(.horizontal) {
categoriesStack
}
.scrollIndicators(.never)
}
.background(Color.profileBgTop)
}

var categoriesStack: some View {
HStack(spacing: 2) {
Spacer()
ForEach(FeaturedAuthorCategory.allCases, id: \.self) { category in
Button(action: {
selectedCategory = category
}, label: {
Text(category.text)
.font(.callout)
.padding(.vertical, 4)
.padding(.horizontal, 8)
.background(
selectedCategory == category ?
Color.pickerBackgroundSelected :
Color.clear
)
.foregroundColor(
selectedCategory == category ?
Color.primaryTxt :
)
.foregroundColor(
selectedCategory == category ?
Color.primaryTxt :
Color.secondaryTxt
)
.cornerRadius(20)
.padding(4)
.frame(minWidth: 44, minHeight: 44)
})
}
)
.cornerRadius(20)
.padding(4)
.frame(minWidth: 44, minHeight: 44)
})
}
.padding(.leading, 10)
Spacer()
}
.background(Color.profileBgTop)
.padding(.leading, 10)
}

private func findOrCreateAuthors() {
Expand Down

0 comments on commit 5a499cd

Please sign in to comment.