christianselig,
@christianselig@mastodon.social avatar

SwiftUI (and maybe visionOS specific?) question: how do you show a search bar in the middle of the navigation bar, like Apple does in a bunch of apps?

christianselig,
@christianselig@mastodon.social avatar

Also interesting fact you won't be able to unsee, different Apple visionOS apps use different search bar corner radii:

Apple TV, Mail: Rounded rectangle
Music, Safari: Capsule/circle

daneharrigan,
@daneharrigan@mastodon.social avatar

@christianselig seems like Apple devs are well rounded

jkrahn,
@jkrahn@mastodon.social avatar

@christianselig I don’t even have a Vision Pro and this makes me twitch a bit

pixelscience,
@pixelscience@mastodon.social avatar

@christianselig Is one of these a ToolbarItem ?

covercash,
@covercash@mastodon.social avatar

@christianselig this should be at the tippy top of the DOJ’s case file

petergam,
@petergam@mastodon.social avatar

@christianselig I've looked into this. I was only able to archive this using UISearchBar (wrapped with UIViewRepresentable) and a ToolbarItem with .principal placement.

petergam,
@petergam@mastodon.social avatar
christianselig,
@christianselig@mastodon.social avatar

@petergam Ooo, okay we arrived at a similar solution, I ended up just overlaying it though since I could not seem to get it to work nicely with principal (it kept just shoving it left) https://christianselig.com/2024/03/recreating-visionos-search-bar/

petergam,
@petergam@mastodon.social avatar

@christianselig Cool, thanks for sharing. I might snap your solution for getting the corner radius right.
I think you can get around the problem of it being shoved to the left when you principal by wrapping it in a HStack with Spacers, but your overlay solution also works.

kylebshr,
@kylebshr@mastodon.social avatar

@christianselig does putting it in the toolbar with principal location work?

christianselig,
@christianselig@mastodon.social avatar

@kylebshr No, principal location on visionOS is on the left :(

kylebshr,
@kylebshr@mastodon.social avatar

@christianselig my guess is UIKit

christianselig,
@christianselig@mastodon.social avatar

@kylebshr I'm not even sure how it'd be done in UIKit short of manually placing views in a UIToolbar or something, since there doesn't seem to be an easy way to center things there

kylebshr,
@kylebshr@mastodon.social avatar
brandon,
@brandon@fosstodon.org avatar
christianselig,
@christianselig@mastodon.social avatar

@brandon Hmm I don't think anything there pertains to positioning unfortunately

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