mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
Swift
50 lines
1.5 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import DifferenceKit
|
|
import SessionUIKit
|
|
|
|
protocol SessionTableSection: Differentiable {
|
|
var title: String? { get }
|
|
var style: SessionTableSectionStyle { get }
|
|
}
|
|
|
|
extension SessionTableSection {
|
|
var title: String? { nil }
|
|
var style: SessionTableSectionStyle { .none }
|
|
}
|
|
|
|
public enum SessionTableSectionStyle: Equatable, Hashable, Differentiable {
|
|
case none
|
|
case titleRoundedContent
|
|
case titleEdgeToEdgeContent
|
|
case titleNoBackgroundContent
|
|
case titleSeparator
|
|
case padding
|
|
case loadMore
|
|
|
|
var height: CGFloat {
|
|
switch self {
|
|
case .none: return 0
|
|
case .titleRoundedContent, .titleEdgeToEdgeContent, .titleNoBackgroundContent:
|
|
return UITableView.automaticDimension
|
|
|
|
case .titleSeparator: return Separator.height
|
|
case .padding: return Values.smallSpacing
|
|
case .loadMore: return 40
|
|
}
|
|
}
|
|
|
|
/// These values should always be consistent with the padding in `SessionCell` to ensure the text lines up
|
|
var edgePadding: CGFloat {
|
|
switch self {
|
|
case .titleRoundedContent, .titleNoBackgroundContent:
|
|
// Align to the start of the text in the cell
|
|
return (Values.largeSpacing + Values.mediumSpacing)
|
|
|
|
case .titleEdgeToEdgeContent, .titleSeparator: return Values.largeSpacing
|
|
case .none, .padding, .loadMore: return 0
|
|
}
|
|
}
|
|
}
|