diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift index 030e97886a..31646a8fcb 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/ListSectionHeaderView.swift @@ -1,16 +1,26 @@ import SwiftUI -struct ListSectionHeaderView: View { +struct ListSectionHeaderView: 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: {}) } } diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift index 5fd3157a0b..58df0ca690 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/List/SectionHeaderView.swift @@ -1,14 +1,20 @@ import Foundation import SwiftUI -struct SectionHeaderView: View { - +struct SectionHeaderView: 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)