cloud-sdk-ios-fiori
cloud-sdk-ios-fiori copied to clipboard
SAPFiori.FUIButton dark mode glitch when wrapped in UIViewRepresentable, SDK version 8.0.2
import SwiftUI
import SAPFiori
// https://github.com/SAP/cloud-sdk-ios.git
// exact 8.0.2
struct FUIButtonWrapper: UIViewRepresentable {
let title: String
let foregroundColor: Color
let action: () -> Void
func makeCoordinator() -> Coordinator { Coordinator(self) }
class Coordinator: NSObject {
var parent: FUIButtonWrapper
init(_ actionButton: FUIButtonWrapper) {
self.parent = actionButton
super.init()
}
@objc
func action(_ sender: Any) {
self.parent.action()
}
}
func makeUIView(context: Context) -> UIButton {
let button = SAPFiori.FUIButton(style: .secondary)
button.setTitle(self.title, for: .normal)
button.setBackgroundColor(UIColor.preferredFioriColor(forStyle: .primaryFill), for: .normal)
button.setBackgroundColor(UIColor.preferredFioriColor(forStyle: .primaryFill).withAlphaComponent(0.4), for: .highlighted)
button.setTitleColor(UIColor(foregroundColor), for: .normal)
button.setTitleColor(UIColor(foregroundColor).withAlphaComponent(0.4), for: .highlighted)
button.isPersistentSelection = false
button.isAccessibilityElement = true
button.addTarget(context.coordinator, action: #selector(Coordinator.action(_ :)), for: .touchUpInside)
return button
}
func updateUIView(_ uiView: UIButton, context: Context) {}
}
struct ContentView: View {
var body: some View {
VStack {
FUIButtonWrapper(title: "title 1", foregroundColor: .red, action: {})
FUIButtonWrapper(title: "title 2", foregroundColor: .blue, action: {})
}
.padding()
}
}
Observed: glitch with shifted highlighted area in top left for dark mode:
Expected: no glitch with shifted highlighted area in top left for dark mode