Skip to content

Instantly share code, notes, and snippets.

@SergeiMeza
Created March 4, 2020 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeiMeza/3c460434d414f8177a44463044dee3ab to your computer and use it in GitHub Desktop.
Save SergeiMeza/3c460434d414f8177a44463044dee3ab to your computer and use it in GitHub Desktop.
//
// 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