I want to make an application where the user can add as many Widgets as they want. So I need to define dynamic widgets in WidgetBundle.
I tried this code the below but error appears:
@WidgetBundleBuilder
var body: some Widget {
List {
ForEach(0..<2) { _ in
CalendarWidget()
}
}
}
Is there any way to do dynamic widgets?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I want widget my app's users to create their own widgets, but I couldn't set up a dynamic structure in the WidgetBundle. Can I do this with INIntentConfiguration?
I don't understand how my username is defined. Is there any way to change this?
I wrote my new app entirely with SwiftUI. When I test my app with VoiceOver in a language other than English, VoiceOver reads the texts of the app in English.
Probably an issue with SwiftUI itself. Has this issue been resolved with the updates from WWDC21?
I'm developing a widget app that coins multiple functional widgets. The problem is fetching data. I want to fetch data from HealthKit to display step counts and fetch weather data.
I'm using just one Widget object. I show different widgets by changing the View objects in them according to the widget type which is a String property.
I can fetch data from EventKit for calendar events, but reminders, health information, and internet fetching is not working on my code. So where am I doing wrong?
My widget provider is looking like that:
func getTimeline(for configuration: WidgetConfigurationIntentIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {
if let widget = lookUpWidget(for: configuration) {
let currentDate = Date()
let midnight = Calendar.current.startOfDay(for: currentDate)
let nextMinute = Calendar.current.date(byAdding: .minute, value: 1, to: midnight)!
let type = widget.type
switch type {
case "Quotes":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName, text: widget.text)
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Daily Forecast":
let entry = MainEntry(date: Date(), type: widget.type!, weatherInfo: loadWeatherInfo(), backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName)
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Calendar":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName, calendarEventTitles: loadCalendarEventTitles())
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Countdown":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName, text: widget.text, countdownDate: widget.countdownDate)
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Reminders":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName, reminderTitles: loadReminderTitles())
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Battery":
let entry = MainEntry(date: Date(), type: widget.type!, batteryLevel: Int(loadBatteryLevel()), backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName)
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Clock":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName)
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Steps":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, themeHexColor: widget.themeHexColor, fontName: widget.fontName, stepCount: loadStepCount())
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
case "Photos":
let entry = MainEntry(date: Date(), type: widget.type!, backgroundImageData: widget.backgroundImage, backgroundHexColor: widget.backgroundHexColor, fontName: widget.fontName)
let timeline = Timeline(entries: [entry], policy: .after(nextMinute))
completion(timeline)
default:
let entry = MainEntry(date: Date(), type: "Nothing")
let timeline = Timeline(entries: [entry], policy: .atEnd)
completion(timeline)
}
} else {
let entry = MainEntry(date: Date(), type: "Nothing")
let timeline = Timeline(entries: [entry], policy: .atEnd)
completion(timeline)
}
}
Hi everyone. I want to download some JSON files to localize my app.
What format should this JSON file be in and how can I use these files after downloading them?
I found that this is possible on Apple Watch and iPhone devices from Apple's resources, but I haven't seen anything about AirPods and AirTags.
I'm wondering is it possible or not.