MuseumShuffle, Oh gross. My app has a sheet that can display a .confirmationDialog. In full screen mode the confirmation dialog is showing some weird behavior.
The worst is this variation where there's no message and only one of the buttons is partially visible.
The simulator for an 11" shows similar, but less weird behavior.
StewartLynch,
jonduenas, @StewartLynch I’m no expert, but I think this still runs the risk of losing MyObject state by getting reinitialized when the view reinitializes. I think your example just doesn’t run into that happening? Unless you’re asking about Observation in general, which doesn’t need any property wrappers for the view to be able to observe and update.
toddthomas, @StewartLynch already answered by actual experts in the time I took to make my example 😅, but yeah, the Observable macro does all the wiring of the property to SwiftUI’s observation mechanism. The State property wrapper saves the value to the heap so it can be preserved across view initializations where the view's identity is unchanged. Embedding the counter in a parent view whose identity changes demonstrates this.
MuseumShuffle, I just realized that if you're formatting to an abbreviated weekday then VoiceOver (at least Ava and Zoe Premium) will only fully pronounce some of the days.
I guess it's because the ones that aren't pronounced are actual words with other meanings? 🤔
Text(oneShowDay.formatted(.dateTime.weekday(.abbreviated)))#SwiftUI #accessibility #a11y #VoiceOver
A simple app progressing through the abbreviated weekdays backwards starting with Friday.
ryanlintott, @MuseumShuffle I guess “brightness higher” is technically true as well…
MuseumShuffle, @ryanlintott I flip flop on that because sun.max is classified as "Weather" in the SF Symbols app and all of the other weather symbols have weather appropriate VO descriptions. But it does need to mean brightness higher in some scenarios.
bardi, Why am I made to jump through excess hoops to simply set the caret position to the very beginning of text in a
TextEditor
😭 #swiftui
bardi, @davidbures mate, forget about formatting. I want the caret to start at 0. Not even that 😭 We have become beggars.
davidbures, @bardi Man, for sure 😭 There are so many basic things missing
rafa, Is it possible to have an item take up all the available space in a toolbar using #SwiftUI, like Safari here? Am I dumb?
rafa, @ansel that was a good guess, but no dice 🫥
dzamir, @rafa I don't know about the specific problem, but my experience with SwiftUI is that when you try to use Apple’s "official” views, you will find many roadblocks and limitations; Still, you can build nearly everything pixel-perfect when you create your views from scratch.
So, my advice would be to not use a Toolbar but just a regular, custom SwiftUI view.
ctietze, Does "flexibleSpace" in #SwiftUI for macOS not work correctly?
Anything besides a Spacer() that's required in the item?
ctietze, @Cykelero @stroughtonsmith So that's the culprit!
Ugh, of course we only get .inline and .inlineLarge, probably equivalent to .unified and .unifiedCompact, and need to resort to AppKit fiddling.
Starting with Windows in AppKit are still the best approach anyway. SwiftUI as the main app's driver is usually a disappointment.
lvalenta,
gallaugher, Back from sabbatical! More #CircuitPython and #SwiftUI content coming soon. Also info on how you can hire me to teach a bootcamp on these concepts or teach to faculty, leaving course material for use in their own classes. Feel free to share if you know educators who may be interested. https://youtu.be/DM8DUx1LkVg
kevinissac, Track My Domains is nearing completion! ✨ What are your thoughts? Any suggestions or ideas are welcome. #swiftui
MuseumShuffle, @kevinissac it looks nice!
See @rafa , you don’t get to use this.
rafa, @MuseumShuffle @kevinissac haha, oh don't worry, I still own way too many 🙈
rafa, My Safari window 10 minutes into #SwiftUI development
bardi, @rafa @davidbures from memory that would make it work like a HStack, so yeah centered if you place it between two Spacers. Wait, you want a single button to fill the entire width of the Toolbar?
rafa, @bardi @davidbures like Safari's address bar
davidbures,
chrismarquardt, @davidbures swiftui native breadcrumbs view is diy unfortunately
davidbures, @chrismarquardt Thanks! That’s sad though, I’m really hoping for some SwiftUI on Mac improvements soon, but I’m not holding my breath 🥲
marcel, I'm not sure whether I love or hate this micro toggle. #SwiftUI #BuildInPublic
marcel, @PhilipTrauner Yes! Thank you!
marcel, Do you know that feeling when you finally arrive at "OF COURSE it should be like that"? I'm there now. This here is the right solution. #SwiftUI
nwale, #swiftui has been going well, but it always feels like there are little bits missing
teissler, WWDC24 is right around the corner. Before the excitement and rush of what's to come, I want to share some navigation fun facts and tips. None of this is new, having been discussed previously in sessions, etc. From talking with developers, these are parts of the system that are often overlooked, or forgotten about #21DaysOfSwiftUINavigation #SwiftUI This is all running on macOS Sonoma 14.4, Xcode 15.3
teissler,
- List selection can drive navigation pushes. You can populate the selection binding with a value-destination NavigationLink, or, any other way you would normally populate it. #21DaysOfSwiftUINavigation #SwiftUI
A video showing a compact NavigationSplitView on iPhone Previews next to a code sample. The preview shows a list of with 4 elements, 3 navigation links, and 1 Text row. All 4 rows get a grey highlight when active. The non-navigation link row, the simple tagged Text, has no chevron, but still highlights gray in sync with the push progress. Code: import SwiftUI enum Sports: String, Hashable { case pickleball case dance case archery case volleyball } struct Day1: View { @State private var selection: Sports? var body: some View { NavigationSplitView { VStack { List(selection: $selection) { NavigationLink("Pickleball", value: Sports.pickleball) NavigationLink("Dance", value: Sports.dance) NavigationLink("Archery", value: Sports.archery) Text("Volleyball").tag(Sports.volleyball) } } } detail: { if let selection { VStack { Text(selection.rawValue.capitalized(with: .current)) Image(systemName: "figure.(selection.rawValue)") } } else { ContentUnavailableView( "Make a selection", systemImage: "volleyball") } } } } #Preview { Day1() }
teissler,
- NavigationStack and NavigationSplitView are intended to be used statically — establish the structure of your scene and generally don't move them around (there are some exceptions). Don't push a NavigationStack as part of a navigation destination. SwiftUI tries to warn in logs when it detects this.
At the risk of teaching ChatGPT anti-patterns, here is an anti-pattern! Don't try this at home, or anywhere else you take your MacBooks.
#21DaysOfSwiftUINavigation #SwiftUI
gabtheodor,
ctietze, @gabtheodor Can you share what this looks like, i.e. what's the consequence of that, and what would a misuse or forgetting this do?
dlx, Turned my favorite Winamp Skin into a #SwiftUI component kit because… I don’t know why?
gernot, German Checking and formatting phone numbers for app signup in #swiftUI. How hard can it be?
(Turns out: Hard. And I suspected that… Still sucks though.)
gernot, German @ctietze @uliwitness There are other super crazy design decisions. PartialFormatter class that doesn’t conform to the Formatter protocol. The fact that their actual PhoneNumberFormatter does, but needs a „generatedPhoneNumber = true“, because its default mode is NOT doing formatting to PhoneNumber (and it silently fails in SwiftUI Textfields). And there is a Class called „Formatter“ in the framework that is not Foundations’ Formatter. (1/2)
gernot, German And yeah, you can format using an instance of the
PhoneNumberKit
class.It’s a madhouse. (2/2)
davidbures, Rizzference is now out on the App Store!
https://apps.apple.com/cz/app/rizzference/id6474303013
It’s an app for looking up modern slang. What’s the niche? You can define an entire sentence at a time, not just individual words. Give it a go!
For the techies, it’s built 100% in SwiftUI. Feel free to ask any questions 😊
I’d like to thank all the testers and @chrismarquardt, @mattiem and @ctietze for their help and support.
dachary, @davidbures Nice! Congrats on the release! 🎉
davidbures, @dachary Thank you! I really appreciate it 😊 You can give the app a try, maybe it will help in your career 😂
iamkev, I love coffee, so I got a nice machine a while ago. Trying new beans means dialing in everything and considering all the nuances. I got tired of taking notes all the time, so I started building a small app that ideally replaces this little notebook.
Inspired by @marcel I want to #buildinpublic and document my #SwiftUI learnings along the way.
Let's call it 'Cofi' for now since it's the project's name in XCode.
hishnash, Reacting to network status changes in SwiftUI doesn't have to be complicated. By converting NWPathMonitor into an AsyncSequence, you can handle updates efficiently and cleanly within your views. Discover how in my latest post:
https://nilcoalescing.com/blog/ReactToNetworkStatusUpdatesInSwiftUI/
michaelsteeber, I’m working on a project with an important launch animation that only plays on the first launch. Unfortunately, when people install the app via TestFlight, the “what to test" sheet obscures the animation. Has anyone found a way to detect when the sheet is dismissed? #SwiftUI
clarko, @michaelsteeber I haven’t verified this yet, but I’d check Environment .scenePhase and restart the animation when transitioning to ScenePhase.active.
Even if it doesn’t solve your specific TestFlight sheet issue, it’d be a nice addition in the case where someone launched the app and got interrupted by something else/locked their phone/whatever.
michaelsteeber, @clarko great tip! Thanks!
gabtheodor,
RosaCtrl, Am I the only one that thinks deprecating this modifier was a mistake? Any available alternative requires to keep the state in two properties, one for the data, another for its visibility, super annoying, so what I’m missing? #swiftUi https://developer.apple.com/documentation/swiftui/view/alert%28item:content:%29
RosaCtrl, @bde dang! I see no issue with it, seems to work flawlessly as SwiftUI only sets the presenting value to false. Now I wanna do some refactoring! (I still use the deprecated method as the annotation is wrong and Xcode doesn’t show the warning)
bde, @RosaCtrl Glad it was helpful 🙂
kern, I got most of the way through this ambient sound app last summer, and I may finish it once my current collaboration is in the App Store. I really like the icon for this one!
phranck, German
phranck, German @dasdom Don't know. I do not have any UIKit projects.
dasdom, @phranck That’s a problem by its own.
gernot, German #swiftUI Question: I am using AnchorPreferences. Is there any way to use multiple AnchorPreferences at once? Like, use an array of points and communicating it up the hierarchy, but using a collection of
[Anchor<CGPoint>]
instead of the singleAnchor<CGPoint>
that the .anchorPreference modifier hands over?
gernot, German @ctietze This is what I am doing. Essentially the whole „Anchor“ thing is just a fancy way of bubbling up geometry values in the „global“ CoordinateSpace, and it’s converted back at the point of use. I can do the whole ting myself by „convention“ thtat the points I use are global, but I’d rather do it with Apples wrapper that makes it explicit – if I can.
ctietze, German @gernot https://developer.apple.com/documentation/swiftui/preferences# The Preference API looks just like anchorPreference(...) -- but without the "anchor" in the name. You could create your overloads where
Value
isArray<Anchor<CGPoint>>