mirror of
https://github.com/luxfhe/example-ios-demo.git
synced 2026-10-30 18:13:24 +00:00
This app is ZAMA's BSD 3-Clause Clear demo. The license requires its notices to survive redistribution, and a rebrand had replaced every one of them with ours: the LICENSE text, 66 source headers and the app's copyright string. They are back, each with our line beside it for our changes. Co-authored-by: Hanzo Dev <[email protected]>
38 lines
994 B
Swift
38 lines
994 B
Swift
// Copyright © 2025 Zama. All rights reserved.
|
|
// Copyright © 2025 Lux Industries Inc.
|
|
|
|
import SwiftUI
|
|
struct PreviewContent: View {
|
|
@ObservedObject var viewModel: ViewModel
|
|
|
|
var body: some View {
|
|
if let ad = ViewModel.allAds.first(where: { $0.id == viewModel.adID }) {
|
|
AdView(ad: ad)
|
|
} else {
|
|
Text("No Ad OMG")
|
|
}
|
|
}
|
|
}
|
|
|
|
final class ViewModel: ObservableObject {
|
|
static let allAds: [AdModel] = {
|
|
do {
|
|
print("Load JSON. This runs only once for all instances.")
|
|
|
|
if let url = Bundle.main.url(forResource: "allAds", withExtension: "json"),
|
|
let data = FileManager.default.contents(atPath: url.path) {
|
|
return try AdModel.allAds(from: data)
|
|
}
|
|
} catch {
|
|
print("Decoding error: \(error)")
|
|
}
|
|
return []
|
|
}()
|
|
|
|
@Published var adID: Int?
|
|
|
|
init(adID: Int? = nil) {
|
|
self.adID = adID
|
|
}
|
|
}
|