@Claude31 this full code
import CoreLocation
import SwiftUI
struct ContentView: View {
@ObservedObject var detector = BeaconDetector()
@EnvironmentObject var popupManager: PopupManager
@EnvironmentObject var authViewModel: AuthViewModel
@State var isNavigationBarHidden: Bool = true
@State var isShowAlert = true
@State var showDetail = false
var artworkinfo: Artworkinfo
var exhibition: Exhibition
// var artwork: Artwork
@StateObject var artwork = ArtworkViewModel()
@State private var showSecondView = false
var body: some View {
VStack {
Group {
// no logged in
if authViewModel.userSession == nil {
LoginView()
} else {
// logged in user
if detector.lastDistance == .immediate {
if showDetail == false {
Text("")
.alert(isPresented: $isShowAlert) {
Alert(
title: Text("Hi! Art Lovers"),
message: Text("We want to help you find your nearest Artwork 🖼️"),
dismissButton:
.default(Text("OK"),
action: {
self.showDetail = true
}
)
)
}
} else {
let getArtwork = artwork.artworks.filter { $0.id == "1" }.first
if getArtwork?.uuidbeacon == BeaconDetector.getBeaconID() {
NavigationLink(destination: ArtworkInfoBeacon(artwork: getArtwork!), isActive: self.$showDetail) {
ArtworkInfoBeacon(artwork: getArtwork!)
}
}
}
} else {
mainInterfaceView
}
}
} // Group
} // vStack
} // some view
// func alertDetector() -> EmptyView {
// showDetail = false
// return EmptyView()
// }
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView(artworkinfo: Artworkinfo(
id: 0,
atwName: "Anthropocene",
atwArtist: "Sirawich",
ateCate: "Painting",
atwDesc: "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal",
atwSound: "mp4",
atwImg: "AnthropoceneCover",
idExhbt: 0), exhibition: Exhibition(id: "", exhbtstate: "", exhbtname: "", exhbtstr: "", exhbtend: "", exhbtdesc: "", timestr: "", timeend: "", exhbtorgnz: "", loctname: "", loctdetail: "", ticket: "", imgcover: ""), artwork: ArtworkViewModel())
}
}
extension ContentView {
var mainInterfaceView: some View {
VStack {
MainTabView()
}
}
}
Post
Replies
Boosts
Views
Activity
I tried to do what was suggested from MarcoCarnevali (Thank you very much for your help.), But the program still doesn't work as I want.
Any feedback would be appreciated. Thanks
Edit: now i found error, Thanks for help me
ForEach<Array, String, Optional<NavigationLink<ArtworkInfoCard, ArtworkInfoView>>>: the ID 1 occurs multiple times within the collection, this will give undefined results!
ForEach<Array, String, Optional<NavigationLink<ArtworkInfoCard, ArtworkInfoView>>>: the ID 1 occurs multiple times within the collection, this will give undefined results!
ForEach<Array, String, ForEach<Array, String, Optional<NavigationLink<ArtworkInfoCard, ArtworkInfoView>>>>: the ID 2 occurs multiple times within the collection, this will give undefined results!
ForEach<Array, String, ForEach<Array, String, Optional<NavigationLink<ArtworkInfoCard, ArtworkInfoView>>>>: the ID 1 occurs multiple times within the collection, this will give undefined results!
LazyVGridLayout: the ID UniqueID(value: 4196) is used by multiple child views, this will give undefined results!
Edit: