Skip to content
Merged
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 @@ -38,6 +38,7 @@ struct ListPickerItemExample: View {
@State var allowSearch: Bool = false
@State var customDestination: Bool = false
@State var disableEntriesSection: Bool = false
@State var disableContentSection: Bool = false
@State var allowEmpty: Bool = false
@State var autoDismissDestination: Bool = false

Expand Down Expand Up @@ -115,6 +116,8 @@ struct ListPickerItemExample: View {

Toggle("Disable Entries Section", isOn: self.$disableEntriesSection)

Toggle("Disable Content Section", isOn: self.$disableContentSection)

Toggle("Allow Empty", isOn: self.$allowEmpty)

Toggle("Auto Dismiss Destination(Only for Single Selection and isTrackingLiveChanges is true)", isOn: self.$autoDismissDestination)
Expand All @@ -140,6 +143,7 @@ struct ListPickerItemExample: View {
func destinationViewGroup() -> some View {
self.destinationView
.disableEntriesSection(self.disableEntriesSection)
.disableContentSection(self.disableContentSection)
.autoDismissDestination(self.autoDismissDestination)
.navigationTitle("Destination Title")
.ifApply(self.customDestination) {
Expand Down
11 changes: 7 additions & 4 deletions Sources/FioriSwiftUICore/DataTypes/SortFilter+DataType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public extension SortFilterItem {
/// If searchBar in list picker is shown. Default is `false`.
public var isSearchBarHidden: Bool = false
var disableListEntriesSection: Bool = false
var disableListContentSection: Bool = false
var allowsDisplaySelectionCount: Bool = true
var resetButtonConfiguration: FilterFeedbackBarResetButtonConfiguration = .init()

Expand Down Expand Up @@ -689,10 +690,11 @@ public extension SortFilterItem {
/// - itemLayout: Options layout type when `displayMode` is `.filterFormCell`.
/// - displayMode: Options display mode.
/// - listEntriesSectionMode: List entries section mode when `displayMode` is `.list`.
/// - disableContentSection: A boolean value to control the display of the unselected area section.
/// - allowsDisplaySelectionCount: A boolean value to indicate to allow display selection count or not.
/// - resetButtonConfiguration: A configuration to customize the reset button.
public init(id: String = UUID().uuidString, name: String, title: String? = nil, value: Int, valueOptions: [String], allowsEmptySelection: Bool, barItemDisplayMode: BarItemDisplayMode = .name, isSearchBarHidden: Bool = false, icon: String? = nil, itemLayout: OptionListPickerItemLayoutType = .fixed, displayMode: DisplayMode = .automatic, listEntriesSectionMode: ListEntriesSectionMode = .default, allowsDisplaySelectionCount: Bool = true, resetButtonConfiguration: FilterFeedbackBarResetButtonConfiguration = FilterFeedbackBarResetButtonConfiguration()) {
self.init(id: id, name: name, title: title, value: [value], valueOptions: valueOptions, allowsMultipleSelection: false, allowsEmptySelection: allowsEmptySelection, barItemDisplayMode: barItemDisplayMode, isSearchBarHidden: isSearchBarHidden, icon: icon, itemLayout: itemLayout, displayMode: displayMode, listEntriesSectionMode: listEntriesSectionMode, allowsDisplaySelectionCount: allowsDisplaySelectionCount, resetButtonConfiguration: resetButtonConfiguration)
public init(id: String = UUID().uuidString, name: String, title: String? = nil, value: Int, valueOptions: [String], allowsEmptySelection: Bool, barItemDisplayMode: BarItemDisplayMode = .name, isSearchBarHidden: Bool = false, icon: String? = nil, itemLayout: OptionListPickerItemLayoutType = .fixed, displayMode: DisplayMode = .automatic, listEntriesSectionMode: ListEntriesSectionMode = .default, disableContentSection: Bool = false, allowsDisplaySelectionCount: Bool = true, resetButtonConfiguration: FilterFeedbackBarResetButtonConfiguration = FilterFeedbackBarResetButtonConfiguration()) {
self.init(id: id, name: name, title: title, value: [value], valueOptions: valueOptions, allowsMultipleSelection: false, allowsEmptySelection: allowsEmptySelection, barItemDisplayMode: barItemDisplayMode, isSearchBarHidden: isSearchBarHidden, icon: icon, itemLayout: itemLayout, displayMode: displayMode, listEntriesSectionMode: listEntriesSectionMode, disableContentSection: disableContentSection, allowsDisplaySelectionCount: allowsDisplaySelectionCount, resetButtonConfiguration: resetButtonConfiguration)
}

/// Create PickerItem for filter feedback.
Expand All @@ -712,9 +714,10 @@ public extension SortFilterItem {
/// - itemLayout: Options layout type when `displayMode` is `.filterFormCell`.
/// - displayMode: Options display mode.
/// - listEntriesSectionMode: List entries section mode when `displayMode` is `.list`.
/// - disableContentSection: A boolean value to control the display of the unselected area section.
/// - allowsDisplaySelectionCount: A boolean value to indicate to allow display selection count or not.
/// - resetButtonConfiguration: A configuration to customize the reset button.
public init(id: String = UUID().uuidString, name: String, title: String? = nil, value: [Int], valueOptions: [String], allowsMultipleSelection: Bool, allowsEmptySelection: Bool, barItemDisplayMode: BarItemDisplayMode = .name, isSearchBarHidden: Bool = false, icon: String? = nil, itemLayout: OptionListPickerItemLayoutType = .fixed, displayMode: DisplayMode = .automatic, listEntriesSectionMode: ListEntriesSectionMode = .default, allowsDisplaySelectionCount: Bool = true, resetButtonConfiguration: FilterFeedbackBarResetButtonConfiguration = FilterFeedbackBarResetButtonConfiguration()) {
public init(id: String = UUID().uuidString, name: String, title: String? = nil, value: [Int], valueOptions: [String], allowsMultipleSelection: Bool, allowsEmptySelection: Bool, barItemDisplayMode: BarItemDisplayMode = .name, isSearchBarHidden: Bool = false, icon: String? = nil, itemLayout: OptionListPickerItemLayoutType = .fixed, displayMode: DisplayMode = .automatic, listEntriesSectionMode: ListEntriesSectionMode = .default, disableContentSection: Bool = false, allowsDisplaySelectionCount: Bool = true, resetButtonConfiguration: FilterFeedbackBarResetButtonConfiguration = FilterFeedbackBarResetButtonConfiguration()) {
self.id = id
self.name = name
self.title = title
Expand Down Expand Up @@ -745,7 +748,7 @@ public extension SortFilterItem {
case .enable:
self.disableListEntriesSection = false
}

self.disableListContentSection = disableContentSection
self.allowsDisplaySelectionCount = allowsDisplaySelectionCount
self.resetButtonConfiguration = resetButtonConfiguration
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ struct PickerMenuItem: View {
}
return listPickerDestination
.disableEntriesSection(self.item.disableListEntriesSection)
.disableContentSection(self.item.disableListContentSection)
.listStyle(.plain)
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.scrollContentBackground(.hidden)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ extension SortFilterCFGItemContainer: View {
Text(e.value)
}
.disableEntriesSection(self._items[r][c].picker.disableListEntriesSection)
.disableContentSection(self._items[r][c].picker.disableListContentSection)
.listStyle(.plain)
.frame(minWidth: UIDevice.current.userInterfaceIdiom != .phone ? self.popoverWidth : nil)
.scrollContentBackground(.hidden)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ struct ListPickerDestinationContent<Data: RandomAccessCollection, ID: Hashable,
@Environment(\.dismiss) var dismiss
@Environment(\.listPickerDestinationConfiguration) var destinationConfiguration
@Environment(\.disableEntriesSection) var disableEntriesSection
@Environment(\.disableContentSection) var disableContentSection
@Environment(\.autoDismissDestination) var autoDismissDestination
@Environment(\.isFilterFeedbackBarListPickerStyle) var isFilterFeedbackBarListPickerStyle

Expand Down Expand Up @@ -741,7 +742,7 @@ struct ListPickerDestinationContent<Data: RandomAccessCollection, ID: Hashable,
Section {
self.generateSection(by: items)
} header: {
if !self.allEntriesHeaderIsEmpty(), !self.isSingleSelection {
if !self.allEntriesHeaderIsEmpty(), !self.disableContentSection, !self.isSingleSelection {
HStack {
self.destinationConfiguration?.allEntriesSectionTitle
Spacer()
Expand Down Expand Up @@ -827,7 +828,7 @@ struct ListPickerDestinationContent<Data: RandomAccessCollection, ID: Hashable,
// single section
if let items = filteredData.first?.1 {
Section {
if !self.allEntriesHeaderIsEmpty(), !self.isSingleSelection {
if !self.allEntriesHeaderIsEmpty(), !self.disableContentSection, !self.isSingleSelection {
HStack {
self.destinationConfiguration?.allEntriesSectionTitle
Spacer()
Expand Down Expand Up @@ -1161,6 +1162,10 @@ struct DisableEntriesSectionEnvironment: EnvironmentKey {
static let defaultValue: Bool = false
}

struct DisableContentSectionEnvironment: EnvironmentKey {
static let defaultValue: Bool = false
}

struct AutoDismissDestinationEnvironment: EnvironmentKey {
static let defaultValue: Bool = false
}
Expand Down Expand Up @@ -1192,6 +1197,11 @@ extension EnvironmentValues {
get { self[IsFilterFeedbackBarListPickerStyleEnvironment.self] }
set { self[IsFilterFeedbackBarListPickerStyleEnvironment.self] = newValue }
}

var disableContentSection: Bool {
get { self[DisableContentSectionEnvironment.self] }
set { self[DisableContentSectionEnvironment.self] = newValue }
}
}

public extension View {
Expand Down Expand Up @@ -1222,6 +1232,13 @@ public extension View {
func destinationRowBackgroundColor(_ color: Color) -> some View {
self.preference(key: DestinationRowBackgroundPreferenceKey.self, value: color)
}

/// Controls whether the unselected section of `ListPickerDestination` can be displayed
/// - Parameter disabled: A Boolean value where true hides the unselected section and false allows it to be displayed
/// - Returns: A configured `ListPickerDestination` view with the unselected section's visibility controlled by the parameter
func disableContentSection(_ disabled: Bool = true) -> some View {
self.environment(\.disableContentSection, disabled)
}
}

extension Notification.Name {
Expand Down
Loading