Texts

Monday Hero can automatically understand the texts, and convert design to Swift/Kotlin code.

Texts are automatically detected and their code is generated by Monday Hero. With texts, you can describe an interface element or provide messages. Texts display static text with no editing features.

Monday Hero names texts on the design as Labels. However, it's also possible to convert label into components like buttons or create Custom Labels to reuse elements on the page like HeaderLabel below:

Automatically Detected Texts

In the image above, there is a Welcome to Travel App label. It's code is autogenerated like below.

Label

Texts are called as Label in the Swift language. Let's see the generated code and its attributes.

//Signup Page, Welcome Label
import UIKit

class SignUpViewController: UIViewController {

	// MARK: - Properties
	@IBOutlet private weak var welcomeLabel: UILabel!

	override func viewDidLoad() {
		super.viewDidLoad()
		setupViews()
		setupLayout()
	}

}

extension SignUpViewController {
	private func setupViews() {

		welcomeLabel.textColor = UIColor.black
		welcomeLabel.numberOfLines = 0
		welcomeLabel.font = UIFont.textStyle7
		welcomeLabel.textAlignment = .center
		welcomeLabel.text = NSLocalizedString("welcome.to.travel.app", comment: "")

	}

	private func setupLayout() {
		//Constraints are defined in Storyboard file.
	}

}

Custom Texts

In order to reuse the same styled labels like header1, header2, create custom texts. Here is how to do it:

The code will be generated like below for custom texts:

//HeaderLabel.swift

import UIKit

class HeaderLabel: UILabel {

	// MARK: - Initializers
	override init(frame: CGRect) {
		super.init(frame: frame)
		initialize()
	}

	required init?(coder aDecoder: NSCoder) {
		super.init(coder: aDecoder)
		initialize()
	}

	func initialize() {
		applyDefaultStyle()
	}

	// MARK: - Styling
	func applyDefaultStyle() {
		self.textColor = UIColor.pebble
		self.numberOfLines = 0
		self.font = UIFont.textStyle18
		self.textAlignment = .left
	}

	func set(text: String){
		self.text = text
	}

}

Last updated