Post

Replies

Boosts

Views

Activity

Shadow being drawn overtop stroke
I'm trying to have a RoundedRectangle with a slightly different color border (stroke in this case) with a shadow behind it. The issue I'm having is that the shadow itself is being drawn overtop the stroke. I've tried using a ZStack with another RoundedRectangle in the background with a shadow, but I kept running into the same issue. Anyone have any better ideas? Section { VStack { RoundedRectangle(cornerRadius: 11) .fill(color.shadow(.drop(color: .gray, radius: 2, x: 2, y: 2))) .stroke(color.opacity(0.5), lineWidth: 5) } .frame(height: 200) .padding() } .listRowInsets(EdgeInsets()) // Remove padding inside section, but causes clipping on the RoundedRectangle stroke .listRowBackground(Color.clear) // Remove background color
1
0
102
2w
Update Widget Every Minute
Is this not possible? I have a simple text view that shows the time, but it doesn't stay in sync with the time. I've tried to use a timer like I do inside the app, but that didn't work. I tried TimelineView with it set to every minute, and that didn't work. I tried to use the dynamic date using Text(date, style: ) and that didn't work. I looked it up and apparently it's a limitation to WidgetKit, however, I don't understand how the Apple Clock widget can have a moving second hand that updates properly. Do I just need to add a bunch of entries in the TimelineProvider? Right now, it's just the default that gets loaded when you create a Widget extension. func timeline(for configuration: SingleClockIntent, in context: Context) async -> Timeline<SingleClockEntry> { var entries: [SingleClockEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. let currentDate = Date() for hourOffset in 0 ..< 5 { let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! let entry = SingleClockEntry(date: entryDate, configuration: configuration) entries.append(entry) } return Timeline(entries: entries, policy: .atEnd) } EDIT: This code below seems to be working. Can someone confirm if it will continue to work, or will it eventually stop updating? func timeline(for configuration: SingleClockIntent, in context: Context) async -> Timeline<SingleClockEntry> { var entries: [SingleClockEntry] = [] let calendar = Calendar.current let current = Date() // Get the next minute let secondEntryDate = calendar.nextDate(after: current, matching: DateComponents(second: 0), matchingPolicy: .strict, direction: .forward)! entries.append(SingleClockEntry(date: current, configuration: configuration)) // Adds current time entries.append(SingleClockEntry(date: secondEntryDate, configuration: configuration)) // Adds next minute after current time // Add an entry every min for the next 30 minutes for offset in 0..<30 { let entryDate = Calendar.current.date(byAdding: .minute, value: offset, to: secondEntryDate)! let entry = SingleClockEntry(date: entryDate, configuration: configuration) entries.append(entry) } return Timeline(entries: entries, policy: .atEnd) }
3
0
74
4w