<commit_before>//
//  TouchableRenderer.swift
//  PortalView
//
//  Created by <NAME> on 4/3/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

internal struct TouchableRenderer<MessageType>: UIKitRenderer {
    
    let child: Component<MessageType>
    let gesture: Gesture<MessageType>
    
    func render(with layoutEngine: LayoutEngine, isDebugModeEnabled: Bool) -> Render<MessageType> {
        var result = child.render(with: layoutEngine, isDebugModeEnabled: isDebugModeEnabled)
        switch gesture {
            
        case .tap(let message):
            let dispatcher: MessageDispatcher<MessageType>
            if let mailbox = result.mailbox {
                dispatcher = MessageDispatcher(message: message, mailbox: mailbox)
            } else {
                dispatcher = MessageDispatcher(message: message)
                result = Render(view: result.view, mailbox: dispatcher.mailbox, executeAfterLayout: result.afterLayout)
            }
            result.view.register(dispatcher: dispatcher)
            let recognizer = UITapGestureRecognizer(target: dispatcher, action: #selector(MessageDispatcher<MessageType>.dispatch))
            result.view.addGestureRecognizer(recognizer)
            
        }
        return result<commit_msg>Fix bug for touchable when using non interactives view<commit_after>//
//  TouchableRenderer.swift
//  PortalView
//
//  Created by <NAME> on 4/3/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

internal struct TouchableRenderer<MessageType>: UIKitRenderer {
    
    let child: Component<MessageType>
    let gesture: Gesture<MessageType>
    
    func render(with layoutEngine: LayoutEngine, isDebugModeEnabled: Bool) -> Render<MessageType> {
        var result = child.render(with: layoutEngine, isDebugModeEnabled: isDebugModeEnabled)
        
        result.view.isUserInteractionEnabled = true
        
        switch gesture {
            
        case .tap(let message):
            let dispatcher: MessageDispatcher<MessageType>
            if let mailbox = result.mailbox {
                dispatcher = MessageDispatcher(message: message, mailbox: mailbox)
            } else {
                dispatcher = MessageDispatcher(message: message)
                result = Render(view: result.view, mailbox: dispatcher.mailbox, executeAfterLayout: result.afterLayout)
            }
            result.view.register(dispatcher: dispatcher)
            let recognizer = UITapGestureRecognizer(target: dispatcher, action: #selector(MessageDispatcher<MessageType>.dispatch))
            result.view.addGestureRecognizer(recognizer)
            
        }
        return result
{'fraction_non_alphanumeric': 0.08441799925622909, 'fraction_numerical': 0.005950167348456675, 'mean_word_length': 2.5676392572944295, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '2265986', 'n_tokens_mistral': 722, 'n_tokens_neox': 685, 'n_words': 167}