Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public struct DataTableConfiguration: Equatable {
public var heightForSectionFooter: CGFloat = 44
public var heightForSectionHeader: CGFloat = 44
public var heightForSearchView: CGFloat = 60
public var rightOffsetForSearchView: CGFloat = 0
public var heightOfInterRowSpacing: CGFloat = 1

public var shouldShowFooter: Bool = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public protocol SwiftDataTableDataSource: class {
/// - Returns: the height of the search view
@objc optional func heightForSearchView(in dataTable: SwiftDataTable) -> CGFloat

/// The right offset of the search view from the right. Defaults to 0.
///
/// - Parameter dataTable: SwiftDataTable
/// - Returns: the right offset of the search view from the right
@objc optional func rightOffsetForSearchView(in dataTable: SwiftDataTable) -> CGFloat

/// Height of the inter row spacing. Defaults to 1.
///
Expand Down
9 changes: 8 additions & 1 deletion SwiftDataTables/Classes/SwiftDataTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public class SwiftDataTable: UIView {
public override func layoutSubviews() {
super.layoutSubviews()
let searchBarHeight = self.heightForSearchView()
self.searchBar.frame = CGRect(x: 0, y: 0, width: self.bounds.width, height: searchBarHeight)
self.searchBar.frame = CGRect(x: 0, y: 0, width: self.bounds.width - self.rightOffsetForSearchView(), height: searchBarHeight)
self.collectionView.frame = CGRect(x: 0, y: searchBarHeight, width: self.bounds.width, height: self.bounds.height-searchBarHeight)
}

Expand Down Expand Up @@ -648,6 +648,13 @@ extension SwiftDataTable {
return self.delegate?.heightForSearchView?(in: self) ?? self.options.heightForSearchView
}

func rightOffsetForSearchView() -> CGFloat {
guard self.shouldShowSearchSection() else {
return 0
}
return self.delegate?.rightOffsetForSearchView?(in: self) ?? self.options.rightOffsetForSearchView
}

func showVerticalScrollBars() -> Bool {
return self.delegate?.shouldShowVerticalScrollBars?(in: self) ?? self.options.shouldShowVerticalScrollBars
}
Expand Down