Created
June 6, 2020 15:07
-
-
Save MarcoEidinger/103abc247eb166a92661da8094ce888b to your computer and use it in GitHub Desktop.
Using Xcode Previews with SAP Cloud Platform SDK for iOS
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
import SAPFiori | |
class ProductObjectTableViewCell: FUIObjectTableViewCell { | |
required init() { | |
super.init() | |
self.detailImage = UIImage(named: "laptop") | |
self.headlineText = "Notebook Basic 15" | |
self.subheadlineText = "Notebooks" | |
self.footnoteText = "In Stock" | |
self.accessoryType = .detailDisclosureButton | |
} | |
@objc required dynamic init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} | |
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
@available(iOS 13.0, *) | |
struct ProductObjectTableViewCellPreview: PreviewProvider { | |
static let productCell = ProductObjectTableViewCell() | |
static var previews: some View { | |
Group { | |
TableViewCellRepresentable(for: productCell) | |
.frame(width: 500, height: 100, alignment: .center) | |
.previewLayout(PreviewLayout.sizeThatFits) | |
.padding() | |
.previewDisplayName("Default") | |
TableViewCellRepresentable(for: productCell) | |
.frame(width: 500, height: 100, alignment: .center) | |
.previewLayout(PreviewLayout.sizeThatFits) | |
.padding() | |
.environment(\.colorScheme, .dark) | |
.previewDisplayName("Dark Mode") | |
} | |
} | |
} | |
struct TableViewCellRepresentable: UIViewRepresentable { | |
private let cell: UITableViewCell | |
init(for cell: UITableViewCell) { | |
self.cell = cell | |
} | |
func makeUIView(context: UIViewRepresentableContext<TableViewCellRepresentable>) -> UITableViewCell { | |
return self.cell | |
} | |
func updateUIView(_ uiView: UITableViewCell, context: UIViewRepresentableContext<TableViewCellRepresentable>) { | |
} | |
typealias UIViewType = UITableViewCell | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment