Skip to content

Instantly share code, notes, and snippets.

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 MarcoEidinger/103abc247eb166a92661da8094ce888b to your computer and use it in GitHub Desktop.
Save MarcoEidinger/103abc247eb166a92661da8094ce888b to your computer and use it in GitHub Desktop.
Using Xcode Previews with SAP Cloud Platform SDK for iOS
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