Skip to content

Commit

Permalink
IOS-2579 Add ability to add content to the right side of list header
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-pusya committed Apr 3, 2024
1 parent 8855d15 commit 96395c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import SwiftUI

struct ListSectionHeaderView: View {
struct ListSectionHeaderView<Content>: View where Content: View {
let title: String
let rightContent: () -> Content?

init(title: String, @ViewBuilder rightContent: @escaping () -> Content? = { EmptyView() }) {
self.title = title
self.rightContent = rightContent
}

var body: some View {
SectionHeaderView(title: title)
SectionHeaderView(title: title, rightContent: rightContent)
.divider(spacing: 0, alignment: .leading)
}
}

struct ListSectionHeaderView_Previews: PreviewProvider {
static var previews: some View {
ListSectionHeaderView(title: "title")
#Preview("SectionHeader") {
ListSectionHeaderView(title: "Title")
}

#Preview("SectionHeader with clear button") {
ListSectionHeaderView(title: "Title") {
Button(Loc.clear, action: {})
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import Foundation
import SwiftUI

struct SectionHeaderView: View {

struct SectionHeaderView<Content>: View where Content: View {
let title: String
let rightContent: () -> Content?

init(title: String, @ViewBuilder rightContent: @escaping () -> Content? = { EmptyView() }) {
self.title = title
self.rightContent = rightContent
}

var body: some View {
HStack(spacing: 0) {
AnytypeText(title, style: .caption1Regular, color: .Text.secondary)
Spacer()
rightContent()
}
.padding(.top, 26)
.padding(.bottom, 8)
Expand Down

0 comments on commit 96395c1

Please sign in to comment.