added label inline link sample

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-24 14:20:25 -05:00
parent ab16fb4642
commit a528dc291b

View File

@ -104,7 +104,29 @@ class LabelViewController: BaseViewController<Label> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
let fullText = "Here is a sample of text that has an inline text link that you can click on!"
let linkText = "inline text link"
let sampleLabel = Label()
sampleLabel.textStyle = .titleLarge
sampleLabel.text = fullText
if let link = ActionLabelAttribute(text: fullText, linkText: linkText) {
link.action.sink { [weak self] in
print("Clicked \(linkText)")
self?.present(UIAlertController(title: "TextLink", message: "Clicked \(linkText)", preferredStyle: .alert).with{ $0.addAction(.init(title: "OK", style: .default)) }, animated: true)
}.store(in: &subscribers)
sampleLabel.attributes = [link]
}
let stack = UIStackView(arrangedSubviews: [component, sampleLabel])
stack.spacing = 10
stack.axis = .vertical
addContentTopView(view: stack)
setupPicker()
setupModel()
}
@ -136,6 +158,7 @@ class LabelViewController: BaseViewController<Label> {
addFormRow(label: "Text Size", view: textSizePickerSelectorView)
addFormRow(label: "Text", view: textField)
disabledSwitch.onChange = { [weak self] sender in
self?.component.disabled = sender.isOn
}
@ -235,6 +258,7 @@ class LabelViewController: BaseViewController<Label> {
self?.calculatedLabel.text = "Actual height (* LineHeight x Text Lines): \(rect.height)"
}.store(in: &subscribers)
//------------------------------------
}