<commit_before>//
// Xcore
// Copyright © 2017 Xcore
// MIT license, see LICENSE file for details
//

import Foundation

extension UIAccessibility {
    public struct ReturnFocus {
        private var element: Any?

        public var isEmpty: Bool {
            element == nil
        }

        public mutating func focus() {
            UIAccessibility.post(notification: .layoutChanged, argument: element)
            element = nil
        }

        /// A method to store the last focused element, so later we can ask voice-over
        /// to return focus to it.
        ///
        /// - Parameter tappedElement: An element to store as the last focused element.
        ///             If `element` value is `nil`, then element that is currently
        ///             focused by the specified assistive technology is used instead.
        public mutating func update(_ tappedElement: Any? = nil) {
            guard let tappedElement = tappedElement else {
                self.element = UIAccessibility.focusedElement(using: .notificationVoiceOver)
                return
            }

            self.element = tappedElement
        }

        public mutating func reset() {
            UIAccessibility.post(notification: .screenChanged, argument: nil)
            element = nil
        }
    }
}

extension UIAccessibility {
    /// A variable indicating the last focused accessibility element.<commit_msg>Moved the methods next to focus.<commit_after>//
// Xcore
// Copyright © 2017 Xcore
// MIT license, see LICENSE file for details
//

import Foundation

extension UIAccessibility {
    public struct ReturnFocus {
        private var element: Any?

        public var isEmpty: Bool {
            element == nil
        }

        /// A method to store the last focused element, so later we can ask voice-over
        /// to return focus to it.
        ///
        /// - Parameter tappedElement: An element to store as the last focused element.
        ///             If `element` value is `nil`, then element that is currently
        ///             focused by the specified assistive technology is used instead.
        public mutating func update(_ tappedElement: Any? = nil) {
            guard let tappedElement = tappedElement else {
                self.element = UIAccessibility.focusedElement(using: .notificationVoiceOver)
                return
            }

            self.element = tappedElement
        }

        public mutating func focus() {
            UIAccessibility.post(notification: .layoutChanged, argument: element)
            element = nil
        }

        public mutating func reset() {
            UIAccessibility.post(notification: .screenChanged, argument: nil)
            element = nil
        }
    }
}

extension UIAccessibility {
    /// A variable indicating the last focused accessibility element.
{'fraction_non_alphanumeric': 0.07310248338579924, 'fraction_numerical': 0.0027981811822315496, 'mean_word_length': 1.8571428571428572, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1789050', 'n_tokens_mistral': 680, 'n_tokens_neox': 649, 'n_words': 258}