SettingTableViewCell.swift 1.7 KB
//
//  settingTableViewCell.swift
//  browser
//
//  Created by Artem Talko on 26.09.2023.
//

import UIKit

final class SettingTableViewCell: UITableViewCell {
    let settingTableViewLabel: UILabel = {
        let obj = UILabel()
        obj.font = FontConstants.semiboldFont_17
        obj.textColor = ColorConstants.lightGray
        obj.textAlignment = .center
        obj.backgroundColor = ColorConstants.buttonsBackgroundColor
        obj.layer.cornerRadius = 10
        obj.layer.masksToBounds = true
        return obj
    }()

    let gradientLayer = CAGradientLayer()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setup()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setup() {
        contentView.addSubview(settingTableViewLabel)
        setupConstraints()
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        gradientLayer.frame = self.bounds
    }
    
    private func setupConstraints() {
        settingTableViewLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().inset(10)
            make.bottom.equalToSuperview().inset(10)
            make.leading.trailing.equalToSuperview().inset(10)
        }
    }
}

//MARK: Gradient
extension SettingTableViewCell {
    private func gradientSetup() {
        self.layer.insertSublayer(gradientLayer, at: 0)
        gradientLayer.colors = [UIColor(red: 0.349, green: 0.565, blue: 1, alpha: 1).cgColor, UIColor(red: 0.349, green: 0.565, blue: 1, alpha: 0.7).cgColor]
        gradientLayer.locations = [0.0, 1.0]
    }
}