cloud-sdk-ios-fiori icon indicating copy to clipboard operation
cloud-sdk-ios-fiori copied to clipboard

SAPFiori.FUIButton dark mode glitch when wrapped in UIViewRepresentable, SDK version 8.0.2

Open dzmitry-antonenka-sap opened this issue 1 year ago • 0 comments


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: Simulator Screen Shot - iPhone 13 Pro - 2022-09-09 at 09 21 00 Simulator Screen Shot - iPhone 13 Pro - 2022-09-09 at 09 21 06

Expected: no glitch with shifted highlighted area in top left for dark mode

dzmitry-antonenka-sap avatar Sep 09 '22 06:09 dzmitry-antonenka-sap