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

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

Open
dzmitry-antonenka-sap opened this issue Sep 9, 2022 · 0 comments
Assignees

Comments

@dzmitry-antonenka-sap
Copy link

dzmitry-antonenka-sap commented Sep 9, 2022


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 dzmitry-antonenka-sap changed the title SAPFiori.FUIButton dark mode glitch when wrapped in UIViewRepresentable SAPFiori.FUIButton dark mode glitch when wrapped in UIViewRepresentable, SDK version 8.0.2 Sep 9, 2022
@MarcoEidinger MarcoEidinger transferred this issue from SAP/cloud-sdk-ios Sep 19, 2022
@dyongxu dyongxu assigned dyongxu and xiaoqinggrace and unassigned dyongxu Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants