//
//  BannerCell.swift
//  Shop
//
//  Created by josh on 2020/07/01.
//  Copyright © 2020 yhkaplan. All rights reserved.
//

import UIKit

final class BannerCell: UICollectionViewCell, ConfigurableCell {
    static let reuseID = "BannerCell"
    private let imageView = UIImageView()

    override init(frame: CGRect) {
        super.init(frame: frame)

        imageView.contentMode = .scaleAspectFit
        imageView.backgroundColor = .systemGray6

        contentView.addSubview(imageView)
        imageView.layout(on: contentView) { imageView, contentView in
            imageView.leading == contentView.leading
            imageView.trailing == contentView.trailing
            imageView.top == contentView.top
            imageView.bottom == contentView.bottom
        }
    }

    @available(*, unavailable)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func configure(with data: Banner) {
        imageView.image = UIImage(systemName: data.imageURL)?
            .withTintColor(.systemGray, renderingMode: .alwaysOriginal)
    }
}
