// // {{class_name}}.swift // // Created by <# Developer Name #> on {{date}}. // //
import UIKit {{#options.protocol}}
protocol {{class_name}}Delegate: class {
}
protocol {{class_name}}DataSouce: class {
} {{/options.protocol}}
class {{class_name}}: UIView {
{{#options.protocol}} weak private var delegate: {{class_name}}Delegate? weak private var datasource: {{class_name}}DataSource? {{/options.protocol}} {{#properties.ui_label}} private let {{name}} = UILabel() {{/properties.ui_label}} {{#properties.ui_view}} private let {{name}} = UIView() {{/properties.ui_view}} {{#properties.unknow_type}} private let {{name}} = {{type}}() {{/properties.unknow_type}} override init(frame: CGRect) { super.init(frame: frame) setupView() setupConstraints() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented for {{class_name}}.swift") } // MARK: - Setup private func setupView() { {{#properties.ui_label}} setup{{capitalized_name}}() {{/properties.ui_label}} {{#properties.ui_view}} setup{{capitalized_name}}() {{/properties.ui_view}} {{#properties.unknow_type}} setup{{capitalized_name}}() {{/properties.unknow_type}} } {{#properties.ui_label}} private func setup{{capitalized_name}}() { {{name}}.textColor = <# UIColor #> {{name}}.font = <# UIFont #> addSubview({{name}}) } {{/properties.ui_label}} {{#properties.ui_view}} private func setup{{capitalized_name}}() { {{name}}.backgroundColor = <# UIColor #> {{name}}.clipBounds = <# true or false #> addSubview({{name}}) } {{/properties.ui_view}} {{#properties.unknow_type}} private func setup{{capitalized_name}}() { addSubview({{name}}) } {{/properties.unknow_type}} // MARK: - Constraints private func setupConstraints() { {{#properties.ui_label}} setupConstraintsFor{{capitalized_name}}() {{/properties.ui_label}} {{#properties.ui_view}} setupConstraintsFor{{capitalized_name}}() {{/properties.ui_view}} {{#properties.unknow_type}} setupConstraintsFor{{capitalized_name}}() {{/properties.unknow_type}} } {{#properties.ui_label}} private func setupConstraintsFor{{capitalized_name}}() { {{name}}.translatesAutoresizingMaskIntoConstraints = false {{name}}.topAnchor.constraint(equalTo: <# topAnchor #>, constant: <# constant #>).isActive = true {{name}}.leftAnchor.constraint(equalTo: <# leftAnchor #>, constant: <# constant #>).isActive = true {{name}}.rightAnchor.constraint(equalTo: <# rightAnchor #>, constant: <# constant #>).isActive = true {{name}}.bottomAnchor.constraint(equalTo: <# bottomAnchor #>, constant: <# constant #>).isActive = true } {{/properties.ui_label}} {{#properties.ui_view}} private func setupConstraintsFor{{capitalized_name}}() { {{name}}.translatesAutoresizingMaskIntoConstraints = false {{name}}.topAnchor.constraint(equalTo: <# topAnchor #>, constant: <# constant #>).isActive = true {{name}}.leftAnchor.constraint(equalTo: <# leftAnchor #>, constant: <# constant #>).isActive = true {{name}}.rightAnchor.constraint(equalTo: <# rightAnchor #>, constant: <# constant #>).isActive = true {{name}}.bottomAnchor.constraint(equalTo: <# bottomAnchor #>, constant: <# constant #>).isActive = true } {{/properties.ui_view}} {{#properties.unknow_type}} private func setupConstraintsFor{{capitalized_name}}() { {{name}}.translatesAutoresizingMaskIntoConstraints = false {{name}}.topAnchor.constraint(equalTo: <# topAnchor #>, constant: <# constant #>).isActive = true {{name}}.leftAnchor.constraint(equalTo: <# leftAnchor #>, constant: <# constant #>).isActive = true {{name}}.rightAnchor.constraint(equalTo: <# rightAnchor #>, constant: <# constant #>).isActive = true {{name}}.bottomAnchor.constraint(equalTo: <# bottomAnchor #>, constant: <# constant #>).isActive = true } {{/properties.unknow_type}}
}