Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add displayValueForFirstRow and displayValueForSecondRow closure in DoublePickerInlineRow #2246

Merged
merged 1 commit into from May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Source/Rows/PickerInlineRow.swift
Expand Up @@ -102,6 +102,12 @@ open class _DoublePickerInlineRow<A, B> : Row<PickerInlineCell<Tuple<A, B>>>, No

/// Options for second component given the selected value from the first component. Will be called often so should be O(1)
public var secondOptions: ((A) -> [B]) = { _ in [] }

/// Modify the displayed values for the first picker row.
public var displayValueForFirstRow: ((A) -> (String)) = { a in return String(describing: a) }

/// Modify the displayed values for the second picker row.
public var displayValueForSecondRow: ((B) -> (String)) = { b in return String(describing: b) }

public var noValueDisplayText: String?

Expand Down Expand Up @@ -140,6 +146,8 @@ public final class DoublePickerInlineRow<A, B> : _DoublePickerInlineRow<A, B>, R
public func setupInlineRow(_ inlineRow: InlineRow) {
inlineRow.firstOptions = firstOptions
inlineRow.secondOptions = secondOptions
inlineRow.displayValueForFirstRow = displayValueForFirstRow
inlineRow.displayValueForSecondRow = displayValueForSecondRow
inlineRow.displayValueFor = self.displayValueFor
inlineRow.cell.height = { UITableView.automaticDimension }
}
Expand Down