Created
March 4, 2020 14:42
-
-
Save SergeiMeza/0f8736ca381fbd71e9f7c326249d20a7 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 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