Created
March 4, 2020 14:43
-
-
Save SergeiMeza/3c460434d414f8177a44463044dee3ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Jeany Meza on 2020/03/04. | |
// Copyright © 2020 pestalozzitech. All rights reserved. | |
// | |
import UIKit | |
import UIComponents | |
public class TemplateCollectionViewCell: UICollectionViewCell { | |
public override init(frame: CGRect) { | |
super.init(frame: frame) | |
setupLayout() | |
} | |
/// Storyboard/Nib files not supported | |
public required init?(coder: NSCoder) { fatalError("Storyboard/Nib files not supported") } | |
private func setupLayout() { | |
contentView | |
.backgroundColor(.systemBackground) | |
UILabel() | |
.text("Hello World") | |
.addTo(contentView) | |
.makeConstraints { make in | |
make.edges.equalToSuperview() | |
} | |
} | |
} | |
#if DEBUG | |
import SwiftUI | |
struct TemplateCollectionViewCellWrapper: UIViewRepresentable { | |
typealias UIViewType = TemplateCollectionViewCell | |
func makeUIView(context: UIViewRepresentableContext<TemplateCollectionViewCellWrapper>) -> TemplateCollectionViewCell { | |
return TemplateCollectionViewCell() | |
} | |
func updateUIView(_ uiView: TemplateCollectionViewCell, context: UIViewRepresentableContext<TemplateCollectionViewCellWrapper>) { } | |
} | |
struct TemplateCollectionViewCellWrapper_Providers: PreviewProvider { | |
static var previews: some View { | |
Group { | |
TemplateCollectionViewCellWrapper() | |
.previewLayout(.fixed(width: 375, height: 200)) | |
.environment(\.colorScheme, .light) | |
.edgesIgnoringSafeArea(.all) | |
.previewDisplayName("Template Cell - Light") | |
TemplateCollectionViewCellWrapper() | |
.previewLayout(.fixed(width: 375, height: 200)) | |
.environment(\.colorScheme, .dark) | |
.edgesIgnoringSafeArea(.all) | |
.previewDisplayName("Template Cell - Dark") | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment