capacitor-community / privacy-screen

⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.
MIT License
87 stars 23 forks source link

bug: contentMode switch not working because of .lowercased() #100

Closed nomadminded closed 3 months ago

nomadminded commented 3 months ago

Plugin version: 5.1.1

Platform(s): iOS

Current behavior: contentMode in config is not working because of the error in the following switch:

private static func getContentModeFromString(_ contentMode: String?) -> UIView.ContentMode? {
        switch contentMode?.lowercased() {
        case "center": return .center
        case "scaleAspectFill": return .scaleAspectFill
        case "scaleAspectFit": return .scaleAspectFit
        case "scaleToFill": return .scaleToFill
        default: return nil
        }
    }

Expected behavior:

cases should be all lowercased

private static func getContentModeFromString(_ contentMode: String?) -> UIView.ContentMode? {
        switch contentMode?.lowercased() {
        case "center": return .center
        case "scaleaspectfill": return .scaleAspectFill
        case "scaleaspectfit": return .scaleAspectFit
        case "scaletofill": return .scaleToFill
        default: return nil
        }
    }

Steps to reproduce: set contentMode to scaleAspectFill / scaleAspectFit / scaleToFill

Related code: PrivacyScreen.swift

nomadminded commented 3 months ago

the pr that was made to integrate contentMode already contained correct lowercased code version, so probably this unintentional bug was created during merge?

robingenz commented 3 months ago

Feel free to create a PR.

nomadminded commented 3 months ago

created pr #101

nomadminded commented 3 months ago

is it ok to merge? can you finish the merge please? thank you