How to use the xiblint.xibutils.view_accessibility_label function in xiblint

To help you get started, we’ve selected a few xiblint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lyft / xiblint / xiblint / rules / accessibility_labels_for_images.py View on Github external
def check(self, context):  # type: (XibContext) -> None
        for image_view in context.tree.findall(".//imageView"):
            if (
                    view_is_accessibility_element(image_view) is True and
                    not view_accessibility_label(image_view) and
                    not get_view_user_defined_attr(image_view, 'accessibilityFormat')
            ):
                context.error(image_view, "Image is accessible but has no accessibility label")
github lyft / xiblint / xiblint / rules / accessibility_labels_for_image_buttons.py View on Github external
def check(self, context):  # type: (XibContext) -> None
        for button in context.tree.findall(".//button"):
            state_normal = button.find("./state[@key='normal']")
            if (
                    state_normal is None or
                    'title' in state_normal.attrib or
                    view_is_accessibility_element(button) is False or
                    view_accessibility_label(button) or
                    get_view_user_defined_attr(button, 'accessibilityFormat')
            ):
                continue

            if 'image' in state_normal.attrib:
                context.error(
                    button,
                    "Button with image '{}' and no title; "
                    "should either have an accessibility label or 'Accessibility Enabled' unchecked",
                    state_normal.attrib['image'])

            if 'backgroundImage' in state_normal.attrib:
                context.error(
                    button,
                    "Button with background image '{}' and no title "
                    "should either have an accessibility label or 'Accessibility Enabled' unchecked",