Firstly, I'm new at SwiftUI so apologies if I don't know the exact structure or best practice. Secondly, I have been out of program for a number of years but require to better understand the Swift language.
System:
OSX: 11.3.1
XCode 12.5
iPhone: 14.5.1
I'm currently struggling to have a consistent outcome with my code. I am using WidgetKit/WidgetBundle to do some pretty basic stuff like display text. Thats it.
However, I'm being faced with redacted views on the device even though in the simulator it works fine(unredacted). Below is a very basic VStack with Text. I have added unredacted() function which I thought forces the text to be shown.
VStack {
Text("TRANSPONDER")
.kerning(3.0)
.font(.system(size: 20, weight: .light, design: .rounded))
.unredacted()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.clipped()
.padding(.all, 0)
.foregroundColor(Color.white)
.background(Color(.displayP3, red: 49.1/255, green: 70.97/255, blue: 85/255))
Spacer()
}
In my TimelineProvider() the below code
struct TransponderGA_TimelineProvider: TimelineProvider {
typealias Entry = TransponderGA_Entry
func placeholder(in context: Context) - TransponderGA_Entry {
let entry = TransponderGA_Entry(date: Date(),transpondergacode: TransponderCodeGA.init(transponderGACode: "123", transponderGAText: "dswer"))
return entry
}
func getSnapshot(in context: Context, completion: @escaping (TransponderGA_Entry) - Void) {
let entry = TransponderGA_Entry(date: Date(), transpondergacode: TransponderCodeGA.init(transponderGACode: "1200", transponderGAText: "GA Airspace"))
completion(entry)
}
func getTimeline(in context: Context, completion: @escaping (TimelineTransponderGA_Entry) - Void) {
let currentDate = Date()
let refreshDate = Calendar.current.date(byAdding: .second, value: 10, to: currentDate)!
TransponderGA_Manager.getGATransponder() { (transgacode) in
guard let tcga = transgacode else { return }
let entry = TransponderGA_Entry(date: currentDate, transpondergacode: tcga)
let timeline = Timeline(entries: [entry], policy: .after(refreshDate))
completion(timeline)
}
}
The below result occurs. However, If I use the EXACT same code with another Widget within the widget family it works perfectly.
You can see the images on stack overflow ... exactly the same question.
I'm at a complete loss to why it would work within 1 widget but the other completely hides the content on the device.
As anyone experienced anything like this before?