Skip to content

Instantly share code, notes, and snippets.

@SergeiMeza
Created March 4, 2020 14:42
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/0f8736ca381fbd71e9f7c326249d20a7 to your computer and use it in GitHub Desktop.
Save SergeiMeza/0f8736ca381fbd71e9f7c326249d20a7 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 TemplateView: UIView {
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() {
self
.backgroundColor(.systemBackground)
UILabel()
.text("Hello World")
.addTo(self)
.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}
#if DEBUG
import SwiftUI
struct TemplateViewWrapper: UIViewRepresentable {
typealias UIViewType = TemplateView
func makeUIView(context: UIViewRepresentableContext<TemplateViewWrapper>) -> TemplateView {
return TemplateView()
}
func updateUIView(_ uiView: TemplateView, context: UIViewRepresentableContext<TemplateViewWrapper>) { }
}
struct TemplateViewWrapper_Providers: PreviewProvider {
static var previews: some View {
Group {
TemplateViewWrapper()
.previewLayout(.fixed(width: 375, height: 200))
.environment(\.colorScheme, .light)
.edgesIgnoringSafeArea(.all)
.previewDisplayName("Template View - Light")
TemplateViewWrapper()
.previewLayout(.fixed(width: 375, height: 200))
.environment(\.colorScheme, .dark)
.edgesIgnoringSafeArea(.all)
.previewDisplayName("Template View - Dark")
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment