Skip to content

Commit

Permalink
feat: 🎸 HCPSDKFIORIUIKIT-2783 SwiftUI FilterFeedbackBar (#810)
Browse files Browse the repository at this point in the history
Not show selected value on the bar title for single selected

Co-authored-by: I824136 <xiaoqing.he@sap.com>
  • Loading branch information
xiaoqinggrace and xiaoqinggracehe authored Oct 3, 2024
1 parent 277d5bc commit 03b51cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ struct SortFilterExample: View {
[
.switch(item: .init(name: "Favorite", value: true, icon: "heart.fill"), showsOnFilterFeedbackBar: true),
.switch(item: .init(name: "Tagged", value: nil, icon: "tag"), showsOnFilterFeedbackBar: false),
.picker(item: .init(name: "JIRA Status", value: [0], valueOptions: ["Received", "Started", "Hold", "Transfer", "Completed", "Pending Review Pending Pending Pending Pending Pending", "Accepted Medium", "Rejected"], allowsMultipleSelection: true, allowsEmptySelection: true, icon: "clock", itemLayout: .flexible), showsOnFilterFeedbackBar: true)
.picker(item: .init(name: "JIRA Status", value: [0], valueOptions: ["Received", "Started", "Hold", "Transfer", "Completed", "Pending Review Pending Pending Pending Pending Pending", "Accepted Medium", "Rejected"], allowsMultipleSelection: true, allowsEmptySelection: true, showsValueForSingleSelected: false, icon: "clock", itemLayout: .flexible), showsOnFilterFeedbackBar: true)
],
[
.picker(item: .init(name: "Priority", value: [0], valueOptions: ["High", "Medium", "Low"], allowsMultipleSelection: true, allowsEmptySelection: true, icon: "filemenu.and.cursorarrow"), showsOnFilterFeedbackBar: true),
.picker(item: .init(name: "Priority", value: [0], valueOptions: ["High", "Medium", "Low"], allowsMultipleSelection: true, allowsEmptySelection: true, showsValueForSingleSelected: false, icon: "filemenu.and.cursorarrow"), showsOnFilterFeedbackBar: true),
.filterfeedback(item: .init(name: "Sort Order", value: [0], valueOptions: ["Ascending", "Descending"], allowsMultipleSelection: false, allowsEmptySelection: false, icon: "checkmark"))
],
[
Expand Down
6 changes: 4 additions & 2 deletions Sources/FioriSwiftUICore/DataTypes/SortFilter+DataType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,11 @@ public extension SortFilterItem {
var valueOptions: [String]
public let allowsMultipleSelection: Bool
public let allowsEmptySelection: Bool
public var showsValueForSingleSelected: Bool = true
public let icon: String?
public var itemLayout: OptionListPickerItemLayoutType = .fixed

public init(id: String = UUID().uuidString, name: String, value: [Int], valueOptions: [String], allowsMultipleSelection: Bool, allowsEmptySelection: Bool, icon: String? = nil, itemLayout: OptionListPickerItemLayoutType = .fixed) {
public init(id: String = UUID().uuidString, name: String, value: [Int], valueOptions: [String], allowsMultipleSelection: Bool, allowsEmptySelection: Bool, showsValueForSingleSelected: Bool = true, icon: String? = nil, itemLayout: OptionListPickerItemLayoutType = .fixed) {
self.id = id
self.name = name
self.value = value
Expand All @@ -321,6 +322,7 @@ public extension SortFilterItem {
self.valueOptions = valueOptions
self.allowsMultipleSelection = allowsMultipleSelection
self.allowsEmptySelection = allowsEmptySelection
self.showsValueForSingleSelected = showsValueForSingleSelected
self.icon = icon
self.itemLayout = itemLayout
}
Expand Down Expand Up @@ -393,7 +395,7 @@ public extension SortFilterItem {

var label: String {
if self.allowsMultipleSelection, self.value.count >= 1 {
if self.value.count == 1 {
if self.value.count == 1, self.showsValueForSingleSelected {
return self.valueOptions[self.value[0]]
} else {
return "\(self.name) (\(self.value.count))"
Expand Down

0 comments on commit 03b51cc

Please sign in to comment.