@alpennec@iosdev.space avatar

alpennec

@alpennec@iosdev.space

👨🏻‍💻 Swift/SwiftUI. Making http://indieapps.space/@Tizipizi. Angel Investor. Sea Lover ⛵️

This profile is from a federated server and may be incomplete. Browse more on the original instance.

alpennec, to random
@alpennec@iosdev.space avatar

@MuseumShuffle

Hey Chris. How's everything going?

I've a question regarding WeatherKit: what's the way to handle the precipitationAmount + unit. WeatherKit provides the amount in liquid equivalent of all precipitation amounts. So we should format them using ft/mm (and not use cm for solid precipitations like snow/sleet/hail, thus never use the snowfall MeasurementFormatUnitUsage ( https://developer.apple.com/documentation/foundation/measurementformatunitusage/3931463-snowfall)?

What about the "mixed" type?

christianselig, to random
@christianselig@mastodon.social avatar

Is it a visionOS bug or a me bug that if you disable a button in a navigation bar it gains a weird hover state? If me, how do you fix it?

Code: https://gist.github.com/christianselig/7f79bf92e71550f3d3f0749b312e8969

alpennec,
@alpennec@iosdev.space avatar

@christianselig even if you specify the button border shape?

https://developer.apple.com/documentation/swiftui/view/buttonbordershape(_:)

Or buttonStyle(.plain) maybe?

christianselig, to random
@christianselig@mastodon.social avatar

SwiftUI noob question: I understand why my ViewModel is being initialized twice, but why is it not being deinitialized?

It's created, then a second later when appState.show is changed, the view is recomputed, and view, and its ViewModel, are created anew. Cool! But why is the old one not deinitialized? What's holding onto it?

Sample code: https://gist.github.com/christianselig/d88b1a4d1989b973689ae62d4691162f

alpennec,
@alpennec@iosdev.space avatar
alpennec,
@alpennec@iosdev.space avatar

@rockbart @shadowfacts @christianselig @harshil this behaviour is documented in the official State documentation if I'm interpreting correctly and my understanding is right: https://developer.apple.com/documentation/swiftui/state#Store-observable-objects

I'm personally not a big fan of this behaviour 🫤

alpennec,
@alpennec@iosdev.space avatar

@rockbart @shadowfacts @christianselig @harshil let’s see if things change at dub dub!

davidbures, to SwiftUI
@davidbures@mstdn.social avatar

I need some design help, I’m not good at iOS development 😅

I have this screen. Originally, it was called “Dictionary”. This is where you look up words.

Then, due to SwiftUI being annoying, I had to add another title to that bottom sheet. Because that technically is also a part of the dictionary, I also gave it the title “Dictionary”. See pic no2 for what inside that bottom sheet.

But now I have the same title on the same screen twice, which is bad.

How would you solve it?

#swiftui #iOSDev

alpennec,
@alpennec@iosdev.space avatar

@davidbures you don’t need the sheet, do you? Why don’t you put the searchable in the View directly?

alpennec,
@alpennec@iosdev.space avatar

@davidbures I’m using an XS Max and I don’t found it that annoying. In the rare occasions, I do that 👇🏻.

But still, you can put the search at the bottom like in Safari and display the results above.

davidbures, to SwiftUI
@davidbures@mstdn.social avatar

It’s a shame that there isn’t a standard search field in SwiftUI. I can’t use .searchable for this use case, so I have to build my own search field, and I just can’t get the animation right :/

video/mp4

alpennec,
@alpennec@iosdev.space avatar

@davidbures why can’t you use searchable here?

alpennec,
@alpennec@iosdev.space avatar

@davidbures if you use a NavigationStack, you can specify to always show the search field with ‘always’ here: https://developer.apple.com/documentation/swiftui/searchfieldplacement/navigationbardrawerdisplaymode

  1. How have you done it? It’s seems very fast to make the keyboard appear. Is that UIKit?
  2. How can you have a sheet below the TabView? Looks nice!
alpennec,
@alpennec@iosdev.space avatar

@davidbures @glacials you can’t remove it. But you can toggle the search when the view appears.

alpennec,
@alpennec@iosdev.space avatar

@davidbures @glacials that’s iOS. You can’t remove it. But you can programmatically enable the search if this is the expected behavior for your app: pass a binding to the is presented variable.

https://developer.apple.com/documentation/SwiftUI/View/searchable(text:isPresented:placement:prompt:)-1hn4y

alpennec,
@alpennec@iosdev.space avatar

@glacials @davidbures you can’t place the search field wherever you want when you use the searchable ViewModifier. It’s positioned by the NavigationStack.

You can put a custom search field in the navigation bar with the principal ToolbarItemPlacement if you want: https://developer.apple.com/documentation/swiftui/toolbaritemplacement/principal. But you lose the benefits of the searchable ViewModifier and I’m not sure how it would look like with other items in the toolbar.

mzarra, to SwiftUI
@mzarra@mastodon.social avatar

SwiftUI question: I have a state var that is a BOOL. Another view reacts when that BOOL changes.

Is there any way to get SwiftUI to only react when the var is both touched AND changed?

As in, if I set the BOOL to false and it was already false, nothing fires?

Thanks!

alpennec,
@alpennec@iosdev.space avatar

@mzarra you mean when you use onChange?

alpennec, to SwiftUI
@alpennec@iosdev.space avatar

It seems iOS 17.4/17.5 introduces a regression when using sheets with both presentationBackground + presentationDetents.

The same code works fine on a sim running iOS 17.2 but not on a sim running iOS 17.5 where CPU + memory usage 🚀💣

Hopefully fixed before RC: FB13774180!

@Reutter filed a feedback too regarding this issue: FB13500564

cc @ricketson @curtclifton @lucabernardi

video/mp4

marcel, to random
@marcel@mastodon.social avatar

I mean... just look at this. None of this was rocket science. So cool.

video/mp4

alpennec,
@alpennec@iosdev.space avatar

@marcel your mood faces are fun. How is the animation done?

MuseumShuffle, to random
@MuseumShuffle@mastodon.social avatar

I've noticed something odd with WeatherKit the last few days.

I ask for the weather from the start of today to 9 days from that. The day that is 9 days away has limited data (no hourly data but some limited data about the day). That’s fine.

The last few days I’ve noticed my app not showing info for the day 9 days away sometimes.

I decided to do some logging and record what the first and last hours and days returned are before I use the data from WeatherKit.

🧵 1/2

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle @malin @kaidombrowski @joehribar interesting. Thanks for sharing.

Do you have a sample app that reproduces this issue please? Maybe the one you used to file the feedback. Thanks.

MuseumShuffle, to random
@MuseumShuffle@mastodon.social avatar

@alpennec this is the feedback I opened last year when I discovered that the hourly forecast data is incorrect if the GMT offset is not in one hour increments. 😃

I was using Nepal as an example.

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle ok thanks! I guess I’ll file a feedback too! Thanks

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle oh ok. Cool to know they listen to feedback.

I guess I’ll use the time as if it was 0 minutes for now. And for time zone where it’s 45 minutes, I’ll take the hour after.

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle here is my feedback number: FB13730109

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle thanks. I hope it will be fixed with iOS 18. But I guess it’s something that can be fixed server side. So it could be used for previous OS versions. I’ve not tried the REST API, maybe it works as expected.

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle here is an answer to my feedback. It seems we don’t see any changes to how the API returns hourly forecast for these places where the local hours are not hours but _:30 or _:45 🫤

marcel, to SwiftUI
@marcel@mastodon.social avatar

Originally I didn't want to ship the app with a light mode but I feel like it would be one of the first things people would ask for, so here we go. I'm not completely happy with it yet, but it's a good start.

video/mp4

alpennec,
@alpennec@iosdev.space avatar

@marcel If I understand how it works, the day is split in 3, I can answer once for a split, and I have the choice between 5 moods?

alpennec,
@alpennec@iosdev.space avatar

@marcel I like that you limit us and have opinions for us. I've been thinking about an app like that but it ended in my idea list because I can't decide what to limit and want to offer everything.

alpennec,
@alpennec@iosdev.space avatar

@marcel things like

  • unlimited moments in a day
  • customising the mood scale (number of levels, theme)
  • preloading a list of activities and categories/groups (editable)
  • offering activities analysis and insights (count/frequency/charts/relationships between them to highlight influences)

With that in mind, I would have ended with something very different from your design (calendar for example).

MuseumShuffle, (edited ) to SwiftUI
@MuseumShuffle@mastodon.social avatar

Threw my hands up today and opened a TSI to try and get SwiftUI previews working again with Please Don't Rain.

A few releases of Xcode ago they stopped working completely and I have no idea why. Running on device or simulator is fine.

I've tried removing derived data and deleting my simulators via xcrun. No luck.

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle even if you just preview a Text in your main app content view?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • kavyap
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • osvaldo12
  • everett
  • Youngstown
  • khanakhh
  • slotface
  • rosin
  • thenastyranch
  • ngwrru68w68
  • Durango
  • JUstTest
  • normalnudes
  • ethstaker
  • GTA5RPClips
  • modclub
  • cisconetworking
  • mdbf
  • tacticalgear
  • cubers
  • provamag3
  • tester
  • anitta
  • Leos
  • lostlight
  • All magazines