@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.

dimillian, to random
@dimillian@mastodon.social avatar

He already has his iPhone

alpennec,
@alpennec@iosdev.space avatar

@dimillian will iPhone still exist when he’ll be aged enough to have one?

simonbs, to random
@simonbs@mastodon.social avatar

Did anyone manage to show icons in search tokens using the .searchable(…) SwiftUI modifier? I thought I could use Label(_:systemName:) or one of its other overloads, but no matter what I do, the icon doesn't show up in the token.

Code snippet showing my usage of the .searchable view modifier.

alpennec,
@alpennec@iosdev.space avatar

@simonbs what OS version are you using? It was a regression that is now fixed in iOS 17.5 (at least when I tested again with the beta 1).

See my other post for more info: https://iosdev.space/@alpennec/112217496535895332

alpennec,
@alpennec@iosdev.space avatar

@simonbs unfortunately it's not possible in SwiftUI. I filed FB13225142 in October 2023 so we can have the tokenBackgroundColor from UIKit.

https://developer.apple.com/documentation/uikit/uisearchtextfield/3175442-tokenbackgroundcolor

alpennec,
@alpennec@iosdev.space avatar

@simonbs I'm not aware how to swizzle, can you share how you've achieved that please?

Thanks!

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?

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle @adam thanks! This is helpful. What about the other types of precipitation like hail, sleet, mixed? Should we treat them as snow?

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle @bardi @adam

Thanks.

I was under the impression that this is actually the case: only rain and snow. I haven't been able to see a forecast in Apple Weather with sleet or mixed. So I'll not take other precipitation types into account for now.

By the way, have you tried to access the snowfallAmount from the Weather returned by WeatherKit? It seems to be the real value, that could be used in charts for example.

https://forums.developer.apple.com/forums/thread/722108?answerId=783540022#783540022

alpennec,
@alpennec@iosdev.space avatar

@MuseumShuffle @bardi @adam this is expected to obtain something different from Apple Weather app if you use precipitationAmount in your charts: this is the liquid equivalent, so for snow it more or less means melted. And using a 10x of this amount provides an approximate for the snowfall amount.

But I would rather use the snowfallAmount that can be decoded from the Weather structure provided. This is probably what Apple uses.

I hope Apple will make it easier to access!

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 :/

#SwiftUI

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!

#SwiftUI

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 #SwiftUI 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 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 🫤

_Davidsmith, to apple
@_Davidsmith@mastodon.social avatar

For the next step in my design journey I wanted to tackle a slightly more complicated UI, so I have rebuilt Widgetsmith's weather app into a design which fits on visionOS. This process was actually simpler than I had originally feared.

It seems like if you have built an iOS SwiftUI app using good general conventions then it is mostly just the colors and navigation chrome which needs to be revamped.

I broke down my process here: https://www.david-smith.org/blog/2023/07/12/design-notes-40/

alpennec,
@alpennec@iosdev.space avatar

@_Davidsmith

Hey David 👋.

Thanks for this blog post.

I tried to reproduce the blend(.destinationOut) thing you explained without success. I have a Swift Charts Line as a background View of an HStack of VStack Views (probably more or less what you have). I want the Line to be cut where it's below a View from the HStack.

Could you share a little bit more how to achieve what you've done please?

Thanks!

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