TeraSupportingCurrentDetail.swift (2465B)
1 import SwiftUI 2 3 /// Navigation holds identity and context, while the observed owner supplies 4 /// the current value. Mandatory invalidation removes even an open detail. 5 struct TeraSearchCurrentDetail: View { 6 let resultID: String 7 let type: TeraSearchResultType 8 @ObservedObject var store: TeraSearchStore 9 let context: TeraLocalNetwork? 10 @ObservedObject var mediaStore: TeraMediaStore 11 let publicKey: String 12 let revise: (TeraTodayCard) -> Void 13 let retract: (TeraTodayCard) -> Void 14 15 var body: some View { 16 if let result = store.currentResult(id: resultID, type: type, context: context) { 17 if let card = result.card { 18 TeraTodayDetailView( 19 card: card, context: context, mediaStore: mediaStore, 20 canRevise: card.authorPublicKey == publicKey && card.localOperationID != nil, 21 canRetract: card.authorPublicKey == publicKey, revise: revise, retract: retract 22 ) 23 } else if let profile = result.profile { 24 TeraProfileView(profile: profile, context: context, mediaStore: mediaStore) 25 } else { 26 TeraSupportingUnavailableDetail() 27 } 28 } else { 29 TeraSupportingUnavailableDetail() 30 } 31 } 32 } 33 34 struct TeraMeCurrentDetail: View { 35 let cardID: String? 36 @ObservedObject var store: TeraMeStore 37 let context: TeraLocalNetwork? 38 @ObservedObject var mediaStore: TeraMediaStore 39 let publicKey: String 40 let revise: (TeraTodayCard) -> Void 41 let retract: (TeraTodayCard) -> Void 42 43 var body: some View { 44 if let cardID { 45 if let card = store.currentCard(id: cardID, context: context) { 46 TeraTodayDetailView( 47 card: card, context: context, mediaStore: mediaStore, 48 canRevise: card.authorPublicKey == publicKey && card.localOperationID != nil, 49 canRetract: card.authorPublicKey == publicKey, revise: revise, retract: retract 50 ) 51 } else { 52 TeraSupportingUnavailableDetail() 53 } 54 } else if let profile = store.currentProfile(context: context) { 55 TeraProfileView(profile: profile, context: context, mediaStore: mediaStore) 56 } else { 57 TeraSupportingUnavailableDetail() 58 } 59 } 60 } 61 62 private struct TeraSupportingUnavailableDetail: View { 63 var body: some View { 64 ContentUnavailableView( 65 "Content unavailable", systemImage: "eye.slash", 66 description: Text("This content is no longer available in this local network.") 67 ) 68 .accessibilityIdentifier("tera.supporting.detail.unavailable") 69 } 70 }