optonaut/ActiveLabel.swift

handleCustomTap not working

Opened this issue · 0 comments

private func setupPolicyTermOfUse() {
        let termOfUseType = ActiveType.custom(pattern: "\\sTerms of use\\b")
        let policyType = ActiveType.custom(pattern: "\\sPrivacy policy\\b")

        policyAndTermOfUseLb.enabledTypes = [termOfUseType, policyType]
        policyAndTermOfUseLb.isUserInteractionEnabled = true

        policyAndTermOfUseLb.customize { [weak self] label in
            guard let self = self else { return }
            label.text = "We secure your data inline with our Terms of use and Privacy policy"

            label.customSelectedColor[termOfUseType] = UIColor.green
            label.customSelectedColor[policyType] = UIColor.green

            label.handleCustomTap(for: termOfUseType) { element in
                self.openTermOfUse()
            }
            label.handleCustomTap(for: policyType) { element in
                self.openPolicy()
            }
            label.handleCustomTap(for: ActiveType.custom(pattern: "\\sTerms of use\\b")) { _ in
                print("Custom type tapped policyType")
            }
        }
    }

    private func openTermOfUse() {
        print("Custom type tapped termOfUseType")
    }

    private func openPolicy() {
        print("Custom type tapped termOfUseType")
    }

handleCustomTap not excute handle tap