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

refactor: 💡 [HCPSDKFIORIUIKIT-2891]FilterFeedbackBar refactor #986

Merged
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 @@ -49,7 +49,9 @@ struct SortFilterExample: View {
VStack {
if self.isCustomStyle {
FilterFeedbackBar(items: self.$items, onUpdate: self.performSortAndFilter)
.filterFeedbackBarStyle(font: .subheadline, foregroundColorSelected: .red, strokeColorSelected: .red, cornerRadius: 25, maxWidth: 200)
.filterFeedbackBarItemCornerRadius(0)
.filterFeedbackBarItemBackgroundSelectedStrokeColor(.red)
.filterFeedbackBarItemSelectedForegroundColor(.red)
.filterFeedbackBarButtonStyle { c in
FilterFeedbackBarButton(c)
.titleStyle(content: { titleC in
Expand All @@ -66,12 +68,9 @@ struct SortFilterExample: View {
}
}
}
// .trailingFullConfigurationMenuItem(icon: "command")
// .leadingFullConfigurationMenuItem(icon: "command")
// .leadingFullConfigurationMenuItem(name: "All")
} else {
FilterFeedbackBar(items: self.$items, onUpdate: self.performSortAndFilter)
.leadingFullConfigurationMenuItem(name: "All Configuration")
.fullConfigurationItem(itemContent: .name("All Configuration"), position: .leading)
}

List {
Expand Down
15 changes: 9 additions & 6 deletions Sources/FioriSwiftUICore/Models/ModelDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public protocol _StepProgressIndicatorModel: AnyObject {
public protocol StepProgressIndicatorModel {}

// sourcery: generated_component_composite
public protocol FilterFeedbackBarModel: AnyObject {
public protocol _FilterFeedbackBarModel: AnyObject {
// sourcery: bindingProperty
// sourcery: backingComponent=_SortFilterMenuItemContainer
var items: [[SortFilterItem]] { get set }
Expand All @@ -526,6 +526,9 @@ public protocol FilterFeedbackBarModel: AnyObject {
var onUpdate: (() -> Void)? { get set }
}

@available(*, unavailable, renamed: "_FilterFeedbackBarModel", message: "Will be removed in the future release. Please use FilterFeedbackBar instead.")
public protocol FilterFeedbackBarModel {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Docs Violation: public declarations should be documented. (missing_docs)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Docs Violation: public declarations should be documented. (missing_docs)


// sourcery: virtualPropActionHelper = "@StateObject var context: SortFilterContext = SortFilterContext()"
// sourcery: add_env_props = "dismiss"
// sourcery: generated_component_composite
Expand Down Expand Up @@ -556,7 +559,7 @@ public protocol _SortFilterViewModel: AnyObject, TitleComponent {
@available(*, unavailable, renamed: "_SortFilterViewModel", message: "Will be removed in the future release. Please use SortFilterView instead.")
public protocol SortFilterViewModel {}

// sourcery: add_env_props = "filterFeedbackBarStyle"
// sourcery: add_env_props = "_filterFeedbackBarStyle"
// sourcery: virtualPropActionHelper = "@StateObject var context: SortFilterContext = SortFilterContext()"
// sourcery: generated_component_composite
public protocol _FilterFeedbackBarItemModel: LeftIconComponent, TitleComponent, RightIconComponent {
Expand All @@ -577,7 +580,7 @@ public protocol _FilterFeedbackBarButtonModel: LeftIconComponent, TitleComponent
@available(*, unavailable, renamed: "_FilterFeedbackBarButtonModel", message: "Will be removed in the future release. Please use FilterFeedbackBarButton instead.")
public protocol FilterFeedbackBarButtonModel {}

// sourcery: add_env_props = "filterFeedbackBarStyle"
// sourcery: add_env_props = "_filterFeedbackBarStyle"
// sourcery: generated_component_not_configurable
// sourcery: virtualPropHeight = "@State var _height: CGFloat = 0"
// sourcery: virtualPropUpdateSearchListPickerHeight = "var updateSearchListPickerHeight: ((CGFloat) -> ())? = nil"
Expand All @@ -592,7 +595,7 @@ public protocol OptionListPickerItemModel: OptionListPickerComponent {
var onTap: ((_ index: Int) -> Void)? { get }
}

// sourcery: add_env_props = "filterFeedbackBarStyle"
// sourcery: add_env_props = "_filterFeedbackBarStyle"
// sourcery: generated_component_not_configurable
// sourcery: virtualPropHeight = "@State var _height: CGFloat = 44"
// sourcery: virtualPropSearchText = "@State var _searchText: String = """
Expand All @@ -614,14 +617,14 @@ public protocol SearchListPickerItemModel: OptionListPickerComponent {
var onTap: ((_ index: Int) -> Void)? { get }
}

// sourcery: add_env_props = "filterFeedbackBarStyle"
// sourcery: add_env_props = "_filterFeedbackBarStyle"
// sourcery: generated_component_not_configurable
// sourcery: add_env_props = "fioriToggleStyle"
public protocol _SwitchPickerItemModel: SwitchPickerComponent {}

@available(*, unavailable, renamed: "_SwitchPickerItemModel", message: "Will be removed in the future release. Please create SwitchView with other initializers instead.")
public protocol SwitchPickerItemModel {}

// sourcery: add_env_props = "filterFeedbackBarStyle"
// sourcery: add_env_props = "_filterFeedbackBarStyle"
// sourcery: generated_component_not_configurable
public protocol SliderPickerItemModel: SliderPickerComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ extension OptionListPickerItem: View {
title: AttributedString(_valueOptions[rowIndex * 2]),
isSelected: _value.wrappedValue.contains(rowIndex * 2)
)
.filterFeedbackBarStyle()
.onTapGesture {
_onTap?(rowIndex * 2)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

extension Fiori {
enum FilterFeedbackBar {
enum _FilterFeedbackBar {
typealias Items = EmptyModifier
typealias ItemsCumulative = EmptyModifier

Expand All @@ -10,7 +10,7 @@ extension Fiori {
}
}

extension FilterFeedbackBar: View {
extension _FilterFeedbackBar: View {
public var body: some View {
items
.onModelUpdateAppCallback(_onUpdate ?? {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct FilterFeedbackBarStyleConfiguration {
}

/// Protocol for sort and filer menu item styling
public protocol FilterFeedbackBarStyle {
public protocol _FilterFeedbackBarStyle {
typealias Configuration = FilterFeedbackBarStyleConfiguration

/// Build view according to configuration and style
Expand All @@ -33,7 +33,7 @@ public protocol FilterFeedbackBarStyle {
#endif

/// Default style for sort and filer menu item
public struct DefaultFilterFeedbackBarStyle: FilterFeedbackBarStyle {
public struct _DefaultFilterFeedbackBarStyle: _FilterFeedbackBarStyle {
let font: Font
let foregroundColorSelected: Color
let foregroundColorUnselected: Color
Expand Down Expand Up @@ -89,31 +89,31 @@ public struct DefaultFilterFeedbackBarStyle: FilterFeedbackBarStyle {
}
}

struct FilterFeedbackBarStyleKey: EnvironmentKey {
static var defaultValue: any FilterFeedbackBarStyle = DefaultFilterFeedbackBarStyle()
struct _FilterFeedbackBarStyleKey: EnvironmentKey {
static var defaultValue: any _FilterFeedbackBarStyle = _DefaultFilterFeedbackBarStyle()
}

extension EnvironmentValues {
var filterFeedbackBarStyle: any FilterFeedbackBarStyle {
var _filterFeedbackBarStyle: any _FilterFeedbackBarStyle {
get {
self[FilterFeedbackBarStyleKey.self]
self[_FilterFeedbackBarStyleKey.self]
}
set {
self[FilterFeedbackBarStyleKey.self] = newValue
self[_FilterFeedbackBarStyleKey.self] = newValue
}
}
}

/// Experimental filter feedback bar styling
public extension View {
/// Experimental filter feedback bar styling
func filterFeedbackBarStyle(_ style: some FilterFeedbackBarStyle) -> some View {
self.environment(\.filterFeedbackBarStyle, style)
func _filterFeedbackBarStyle(_ style: some _FilterFeedbackBarStyle) -> some View {
self.environment(\._filterFeedbackBarStyle, style)
}

/// Experimental filter feedback bar styling
func filterFeedbackBarStyle(font: Font = .system(.body), foregroundColorSelected: Color = .preferredColor(.tintColor), foregroundColorUnselected: Color = .preferredColor(.tertiaryLabel), fillColorSelected: Color = Color.clear, fillColorUnselected: Color = .preferredColor(.tertiaryFill), strokeColorSelected: Color = .preferredColor(.tintColor), strokeColorUnselected: Color = .preferredColor(.separator), cornerRadius: CGFloat = 10, spacing: CGFloat = 6, padding: CGFloat = 8, borderWidth: CGFloat = 1, minHeight: CGFloat = 38, maxWidth: CGFloat = 0) -> some View {
self.environment(\.filterFeedbackBarStyle,
DefaultFilterFeedbackBarStyle(font: font, foregroundColorSelected: foregroundColorSelected, foregroundColorUnselected: foregroundColorUnselected, fillColorSelected: fillColorSelected, fillColorUnselected: fillColorUnselected, strokeColorSelected: strokeColorSelected, strokeColorUnselected: strokeColorUnselected, cornerRadius: cornerRadius, spacing: spacing, padding: padding, borderWidth: borderWidth, minHeight: minHeight, maxWidth: maxWidth))
func _filterFeedbackBarStyle(font: Font = .system(.body), foregroundColorSelected: Color = .preferredColor(.tintColor), foregroundColorUnselected: Color = .preferredColor(.tertiaryLabel), fillColorSelected: Color = Color.clear, fillColorUnselected: Color = .preferredColor(.tertiaryFill), strokeColorSelected: Color = .preferredColor(.tintColor), strokeColorUnselected: Color = .preferredColor(.separator), cornerRadius: CGFloat = 10, spacing: CGFloat = 6, padding: CGFloat = 8, borderWidth: CGFloat = 1, minHeight: CGFloat = 38, maxWidth: CGFloat = 0) -> some View {
self.environment(\._filterFeedbackBarStyle,
_DefaultFilterFeedbackBarStyle(font: font, foregroundColorSelected: foregroundColorSelected, foregroundColorUnselected: foregroundColorUnselected, fillColorSelected: fillColorSelected, fillColorUnselected: fillColorUnselected, strokeColorSelected: strokeColorSelected, strokeColorUnselected: strokeColorUnselected, cornerRadius: cornerRadius, spacing: spacing, padding: padding, borderWidth: borderWidth, minHeight: minHeight, maxWidth: maxWidth))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public struct FilterFeedbackBarItemContainer {

/// Create FilterFeedbackBarItemContainer with items.
/// - Parameter items: Data of filter feedback bar items.
public init(items: Binding<[[SortFilterItem]]>) {
public init(_ items: Binding<[[SortFilterItem]]>) {
self.__items = items
}
}
Expand Down
Loading
Loading