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

fix: 🐛 [HCPSDKFIORIUIKIT-2766]FilterFeedBackBar config in bar #947

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 @@ -26,12 +26,15 @@ struct SwitchExample: View {

var body: some View {
VStack {
SwitchView(title: "Switch", isOn: self.$v1)
SwitchView(title: "Disabled Switch", isOn: self.$v2).disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/)
SwitchView(title: "Custom Style", isOn: self.$v3)
.titleStyle(CustomTitleStyle())
.switchStyle(CustomSwitchStyle())
SwitchView(title: "Very long title, layout depend on title width. long long long long long long long long long long long long long long long long long long long long long long long", isOn: self.$v4)
Group {
SwitchView(title: "Switch", isOn: self.$v1)
SwitchView(title: "Disabled Switch", isOn: self.$v2).disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/)
SwitchView(title: "Custom Style", isOn: self.$v3)
.titleStyle(CustomTitleStyle())
.switchStyle(CustomSwitchStyle())
SwitchView(title: "Very long title, layout depend on title width. long long long long long long long long long long long long long long long long long long long long long long long", isOn: self.$v4)
}
.padding(EdgeInsets(top: 9, leading: 20, bottom: 9, trailing: 20))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct SortFilterExample: View {
// .leadingFullConfigurationMenuItem(name: "All")
} else {
FilterFeedbackBar(items: self.$items, onUpdate: self.performSortAndFilter)
.leadingFullConfigurationMenuItem(name: "All Configuration")
}

List {
Expand All @@ -68,27 +69,6 @@ struct SortFilterExample: View {
}
}
.navigationTitle("Sort & Filter")
.toolbar {
Button(self.sortFilterButtonLabel) {
self.isShowingFullCFG.toggle()
}
.popover(isPresented: self.$isShowingFullCFG, arrowEdge: .leading) {
if self.isCustomStyle {
SortFilterView(
title: "Configuration",
items: self.$items,
onUpdate: self.performSortAndFilter
)
.optionListPickerStyle(font: .footnote, foregroundColorUnselected: .green, strokeColorSelected: .black)
} else {
SortFilterView(
title: "Configuration",
items: self.$items,
onUpdate: self.performSortAndFilter
)
}
}
}
.onAppear {
self.performSortAndFilter()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,23 +500,12 @@ struct PickerMenuItem: View {
#else
height += 75
#endif
if height > Screen.bounds.size.height - self.getSafeAreaInsets().top - 60 {
if height > Screen.bounds.size.height - UIEdgeInsets.getSafeAreaInsets().top - 60 {
return Screen.bounds.size.height / 2
}
return height
}

private func getSafeAreaInsets() -> UIEdgeInsets {
guard let keyWindow = UIApplication.shared.connectedScenes
.first(where: { $0.activationState == .foregroundActive })
.flatMap({ $0 as? UIWindowScene })?.windows
.first(where: \.isKeyWindow)
else {
return .zero
}
return keyWindow.safeAreaInsets
}

private func resetButtonDisable() -> Bool {
if self.item.resetButtonConfiguration.type == .reset {
return self.item.isOriginal
Expand Down Expand Up @@ -889,6 +878,9 @@ struct FullCFGMenuItem: View {
@Binding var items: [[SortFilterItem]]

@State var isSheetVisible = false
@State var barItemFrame: CGRect = .zero
@State var detentHeight: CGFloat = 0
let popoverWidth = 393.0

var onUpdate: () -> Void

Expand All @@ -904,49 +896,73 @@ struct FullCFGMenuItem: View {
.onTapGesture {
self.isSheetVisible.toggle()
}
.popover(isPresented: self.$isSheetVisible) {
SortFilterView(
title: {
if let title = fullCFGButton.name {
Text(title)
} else {
EmptyView()
.ifApply(UIDevice.current.userInterfaceIdiom != .phone, content: { v in
v.modifier(PopoverSizeModifier(isPresented: self.$isSheetVisible, arrowEdge: self.barItemFrame.arrowDirection(), popoverSize: CGSize(width: self.popoverWidth, height: self.detentHeight), popoverContent: {
self.sortConfigurationView()
}))
.background(GeometryReader { geometry in
Color.clear
.onAppear {
self.barItemFrame = geometry.frame(in: .global)
}
},
items: {
_SortFilterCFGItemContainer(items: self.$items)
},
cancelAction: {
_Action(actionText: NSLocalizedString("Cancel", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: ""), didSelectAction: {
self.isSheetVisible = false
})
.buttonStyle(CancelButtonStyle())
},
resetAction: {
_Action(actionText: NSLocalizedString("Reset", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: ""), didSelectAction: {
for r in 0 ..< self.items.count {
for c in 0 ..< self.items[r].count {
self.items[r][c].reset()
}
}
})
.buttonStyle(ResetButtonStyle())
},
applyAction: {
_Action(actionText: NSLocalizedString("Apply", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: ""), didSelectAction: {
for r in 0 ..< self.items.count {
for c in 0 ..< self.items[r].count {
self.items[r][c].apply()
}
}
self.onUpdate()
self.isSheetVisible = false
})
.buttonStyle(ApplyButtonStyle())
},
onUpdate: {}
)
}
.setOnChange(of: geometry.frame(in: .global), action1: { newValue in
self.barItemFrame = newValue
}) { _, newValue in
self.barItemFrame = newValue
}
})
})
}

private func sortConfigurationView() -> some View {
SortFilterView(
title: {
if let title = fullCFGButton.name {
Text(title)
} else {
EmptyView()
}
},
items: {
_SortFilterCFGItemContainer(items: self.$items, btnFrame: self.barItemFrame)
},
cancelAction: {
_Action(actionText: NSLocalizedString("Cancel", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: ""), didSelectAction: {
self.isSheetVisible = false
})
.buttonStyle(CancelButtonStyle())
},
resetAction: {
_Action(actionText: NSLocalizedString("Reset", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: ""), didSelectAction: {
for r in 0 ..< self.items.count {
for c in 0 ..< self.items[r].count {
self.items[r][c].reset()
}
}
})
.buttonStyle(ResetButtonStyle())
},
applyAction: {
_Action(actionText: NSLocalizedString("Apply", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: ""), didSelectAction: {
for r in 0 ..< self.items.count {
for c in 0 ..< self.items[r].count {
self.items[r][c].apply()
}
}
self.onUpdate()
self.isSheetVisible = false
})
.buttonStyle(ApplyButtonStyle())
},
onUpdate: {}
)
.sizeReader(size: { s in
self.detentHeight = s.height
})
.ifApply(UIDevice.current.userInterfaceIdiom != .phone, content: { v in
v.frame(width: self.popoverWidth)
.frame(minHeight: self.detentHeight)
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class SortFilterContext: Equatable, ObservableObject {
@Published public var isResetButtonEnabled: Bool = false
@Published public var isApplyButtonEnabled: Bool = false

@Published public var isPickerListShown: Bool = false
@Published public var isSearchBarHidden: Bool = true

@Published public var handleCancel: (() -> Void)?
@Published public var handleReset: (() -> Void)?
@Published public var handleApply: (() -> Void)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ extension SortFilterView: View {
.frame(minWidth: 480.0)
.background(Color.clear)
#endif
.frame(height: UIDevice.current.userInterfaceIdiom != .phone ? size.height + 150 : nil)
.frame(height: UIDevice.current.userInterfaceIdiom != .phone ? size.height + self.additionHeight() : nil)
.presentationDetents([.large])
}

func additionHeight() -> CGFloat {
context.isPickerListShown ? (context.isSearchBarHidden ? 68 : 120) : 120
}
}

/*
Expand Down
Loading
Loading