<commit_before>//
//  UIView+AccessFocus.swift
//  Access
//
//  Created by <NAME> on 3/13/16.
//  Copyright © 2016 org. All rights reserved.
//

import UIKit
import ObjectiveC

private var AssociatedOnFocus: UInt8 = 0
private var AssociatedDidLoseFocus: UInt8 = 0

public extension UIView {
    
    public typealias AccessibilityFocusAction = (() -> Void)
    
    fileprivate class OnFocusWrapper {
        var onFocus: AccessibilityFocusAction
        init(onFocus: @escaping AccessibilityFocusAction) { self.onFocus = onFocus }
    }
    
    public var onAccessibilityFocus: AccessibilityFocusAction? {
        get {
            guard UIAccessibilityIsVoiceOverRunning() else { return nil }
            let wrapper = objc_getAssociatedObject(self, &AssociatedOnFocus) as? OnFocusWrapper
            return wrapper?.onFocus
        }
        set {
            guard UIAccessibilityIsVoiceOverRunning() else { return }
            guard let value = newValue else { return }
            objc_setAssociatedObject(self,
                                     &AssociatedOnFocus,
                                     OnFocusWrapper(onFocus: value),
                                     objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
    
    public var onAccessibilityDidLoseFocus: AccessibilityFocusAction? {
        get {
            guard UIAccessibilityIsVoiceOverRunning() else { return nil }
            let wrapper = objc_getAssociatedObject(self, &AssociatedDidLoseFocus) as? OnFocusWrapper
            return wrapper?.onFocus
        }
        set {
            guard UIAccessibilityIsVoiceOverRunning() else { return }
            guard let value = newValue else { return }
            objc_setAssociatedObject(self,
                                     &AssociatedDidLoseFocus,
                                     OnFocusWrapper(onFocus: value),
                                     objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
    
    override public func accessibilityElementDidBecomeFocused() {
        self.onAccessibilityFocus?()
    }
    
    override public func accessibilityElementDidLoseFocus() {
        self.onAccessibilityDidLoseFocus?()
    }
    <commit_msg>Fix access controll issues<commit_after>//
//  UIView+AccessFocus.swift
//  Access
//
//  Created by <NAME> on 3/13/16.
//  Copyright © 2016 org. All rights reserved.
//

import UIKit
import ObjectiveC

private var AssociatedOnFocus: UInt8 = 0
private var AssociatedDidLoseFocus: UInt8 = 0

extension UIView {
    
    public typealias AccessibilityFocusAction = (() -> Void)
    
    fileprivate class OnFocusWrapper {
        var onFocus: AccessibilityFocusAction
        init(onFocus: @escaping AccessibilityFocusAction) { self.onFocus = onFocus }
    }
    
    public var onAccessibilityFocus: AccessibilityFocusAction? {
        get {
            guard UIAccessibilityIsVoiceOverRunning() else { return nil }
            let wrapper = objc_getAssociatedObject(self, &AssociatedOnFocus) as? OnFocusWrapper
            return wrapper?.onFocus
        }
        set {
            guard UIAccessibilityIsVoiceOverRunning() else { return }
            guard let value = newValue else { return }
            objc_setAssociatedObject(self,
                                     &AssociatedOnFocus,
                                     OnFocusWrapper(onFocus: value),
                                     objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
    
    public var onAccessibilityDidLoseFocus: AccessibilityFocusAction? {
        get {
            guard UIAccessibilityIsVoiceOverRunning() else { return nil }
            let wrapper = objc_getAssociatedObject(self, &AssociatedDidLoseFocus) as? OnFocusWrapper
            return wrapper?.onFocus
        }
        set {
            guard UIAccessibilityIsVoiceOverRunning() else { return }
            guard let value = newValue else { return }
            objc_setAssociatedObject(self,
                                     &AssociatedDidLoseFocus,
                                     OnFocusWrapper(onFocus: value),
                                     objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
    
    override open func accessibilityElementDidBecomeFocused() {
        self.onAccessibilityFocus?()
    }
    
    override open func accessibilityElementDidLoseFocus() {
        self.onAccessibilityDidLoseFocus?()
    }
    
{'fraction_non_alphanumeric': 0.06244424620874219, 'fraction_numerical': 0.005798394290811775, 'mean_word_length': 1.9880079946702198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2111733', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1146, 'n_words': 252}