<commit_before>//
//  PXTermsAndConditionView.swift
//  MercadoPagoSDK
//
//  Created by <NAME> on 5/3/18.
//  Copyright © 2018 MercadoPago. All rights reserved.
//

import Foundation

protocol PXTermsAndConditionViewDelegate: NSObjectProtocol {
    func shouldOpenTermsCondition(_ title: String, url: URL)
}

class PXTermsAndConditionView: PXComponentView {

    var SCREEN_TITLE = "Términos y Condiciones"
    internal let DEFAULT_CREDITS_HEIGHT = CGFloat(80)

    fileprivate let termsAndConditionsText: MPTextView = MPTextView()
    var termsAndConditionsDto: PXTermsDto?

    weak var delegate: PXTermsAndConditionViewDelegate?

    init(shouldAddMargins: Bool = true, termsDto: PXTermsDto? = nil, delegate: PXTermsAndConditionViewDelegate? = nil) {
        super.init()

        self.delegate = delegate
        self.termsAndConditionsDto = termsDto
        self.termsAndConditionsText.backgroundColor = .clear
        translatesAutoresizingMaskIntoConstraints = false

        termsAndConditionsText.isUserInteractionEnabled = true
        termsAndConditionsText.isEditable = false
        termsAndConditionsText.delegate = self
        termsAndConditionsText.translatesAutoresizingMaskIntoConstraints = false
        termsAndConditionsText.attributedText = getTyCText()
        termsAndConditionsText.backgroundColor = .clear

        if termsAndConditionsDto != nil {
            let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
            tap.delegate = self
            self.addGestureRecognizer(tap)
        }

        addSubview(termsAndConditionsText)
            

        let URLAttribute: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: UIFont(name: ResourceManager.shared.DEFAULT_FONT_NAME, size: 12) ?? UIFont.systemFont(ofSize: 12), NSAttributedString.Key.foregroundColor: ThemeManager.shared.secondaryColor()]

        termsAndConditionsText.linkTextAttributes = URLAttribute

        let PERCENT_WIDTH: CGFloat = 90.0
        PXLayout.matchWidth(ofView: termsAndConditionsText, toView: self, withPercentage: PERCENT_WIDTH).isActive = true
        PXLayout.centerHorizontally(view: termsAndConditionsText).isActive = true

        var topAndBottomMargins = PXLayout.S_MARGIN
        if !shouldAddMargins {
            topAndBottomMargins = PXLayout.ZERO_MARGIN
        }<commit_msg>Se corrige condicion para que se agregue el tapGesture solo cuando no se eligio mercadoCreditos<commit_after>//
//  PXTermsAndConditionView.swift
//  MercadoPagoSDK
//
//  Created by <NAME> on 5/3/18.
//  Copyright © 2018 MercadoPago. All rights reserved.
//

import Foundation

protocol PXTermsAndConditionViewDelegate: NSObjectProtocol {
    func shouldOpenTermsCondition(_ title: String, url: URL)
}

class PXTermsAndConditionView: PXComponentView {

    var SCREEN_TITLE = "Términos y Condiciones"
    internal let DEFAULT_CREDITS_HEIGHT = CGFloat(80)

    private let termsAndConditionsText: MPTextView = MPTextView()
    var termsAndConditionsDto: PXTermsDto?

    weak var delegate: PXTermsAndConditionViewDelegate?

    init(shouldAddMargins: Bool = true, termsDto: PXTermsDto? = nil, delegate: PXTermsAndConditionViewDelegate? = nil) {
        super.init()

        self.delegate = delegate
        self.termsAndConditionsDto = termsDto
        self.termsAndConditionsText.backgroundColor = .clear
        translatesAutoresizingMaskIntoConstraints = false

        termsAndConditionsText.isUserInteractionEnabled = true
        termsAndConditionsText.isEditable = false
        termsAndConditionsText.delegate = self
        termsAndConditionsText.translatesAutoresizingMaskIntoConstraints = false
        termsAndConditionsText.attributedText = getTyCText()
        termsAndConditionsText.backgroundColor = .clear

        if termsAndConditionsDto == nil {
            let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
            tap.delegate = self
            self.addGestureRecognizer(tap)
        }

        addSubview(termsAndConditionsText)
            

        let URLAttribute: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: UIFont(name: ResourceManager.shared.DEFAULT_FONT_NAME, size: 12) ?? UIFont.systemFont(ofSize: 12), NSAttributedString.Key.foregroundColor: ThemeManager.shared.secondaryColor()]

        termsAndConditionsText.linkTextAttributes = URLAttribute

        let PERCENT_WIDTH: CGFloat = 90.0
        PXLayout.matchWidth(ofView: termsAndConditionsText, toView: self, withPercentage: PERCENT_WIDTH).isActive = true
        PXLayout.centerHorizontally(view: termsAndConditionsText).isActive = true

        var topAndBottomMargins = PXLayout.S_MARGIN
        if !shouldAddMargins {
            topAndBottomMargins = PXLayout.ZERO_MARGIN
        }
{'fraction_non_alphanumeric': 0.07241523650062788, 'fraction_numerical': 0.007115948095437421, 'mean_word_length': 3.653359298928919, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1566575', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1399, 'n_words': 272}