How do I center the “😃” between the rectangles?

Where it is currently _is_ the center of the parent, but I want it to be centered between the rectangles instead. Horizontally centered is the goal; vertically centered would be a nice bonus.

Image below; code here: https://gist.github.com/cliss/df21f012bfc44d94c033756bf970f1af

Centering Question

Centering Question. GitHub Gist: instantly share code, notes, and snippets.

Gist

I should have thought of this. 🤦🏻‍♂️

@wingman_ saved the day. 🎉 🥰

The smiley is far lower than I'd want, but because I statically define the frame of the rectangles, I can .offset(y:) it, so I'm not worried about that.

https://mastodon.social/@wingman_/112298395433948771

And yes, all of this is simply in service of this very, very dumb gag. Which in turn is all @jelly's fault.
@caseyliss @jelly Dumb gag or not, this is genuinely useful functionality - so thank you!
@caseyliss @jelly If you're going to use the handshake emoji, you need to take this screenshot with Sylvester Stallone and Carl Weathers ( tho with the film knowledge you and Marco show on ATP maybe you'll need to ask John why :D )
@DrChris @jelly That's actually where this started, but it looks weird as shit (I tried)
@caseyliss @DrChris @jelly Could it work with a line art version?… Something like this, but icon-sized?
@caseyliss @jelly There needs to be a predator hand shake emoji
@DrChris I’m assuming you actually mean Arnold from Predator?
@miketaffet ha yes -hoisted on my own pedantic petard!
@caseyliss @jelly CASEY! This should have been Arnold and Carl Weathers!
@caseyliss no, I meant the actors, not the emoji. You’re crossing Predator with Bad Boys and it’s breaking my meme brain
@caseyliss @jelly You spelled “delightful” wrong. 😉
@caseyliss I just don’t get why you didn’t ask me
@caseyliss hooray! I deleted my first comment bc I thought you wanted the views to be different widths. If thats still the case, you can do something like this
Aligning views across stacks | Apple Developer Documentation

Create a custom alignment and use it to align views across multiple stacks.

Apple Developer Documentation
@caseyliss Yeah, „overlay" is often a saver in SwiftUI 😏

@caseyliss You should set the background color of your pair function to see what boundaries you are actually playing with. Otherwise, you are likely to start needing to use alignment guides for where you want one item to line up with another outside if its immediate XStack.

I often toss on Spacer() for actual centering. Does wonders.

@jeffkibuule I started down the path of AlignmentGuide, but it seems there's no alignment guide for vertical centering, which I would also need.
@caseyliss Can you color the rectangles behind? I can give better guidance afterwards.
@caseyliss A ZStack on a Spacer/EmptyView between the pairs?
@chockenberry I don't think so, because the core of the issue is that the pair is not of equal widths.

@caseyliss Well then you either need to restructure the views or use some fixed widths.

Nothing to anchor with in current layout.

@caseyliss I'm getting PTSD of trying to center DIVs in CSS as soon as I tried to do it anywhere else than just a blank canvas.
coordinateSpace(_:) | Apple Developer Documentation

Assigns a name to the view’s coordinate space, so other code can operate on dimensions like points and sizes relative to the named space.

Apple Developer Documentation
@caseyliss Seems like a job for custom Layout? I’ve not travelled that road yet though. You could do it by capturing the frames of the two black rectangles and calculating it and hard positioning it in the ZStack or overlay of the HStack. Ugly but... so is the problem? 🤷‍♂️
@marcpalmer Yeah my knowledge of that is limited to watching one WWDC video nearly a year ago 🤪
@caseyliss If you’re not totally wedded to stacks, you can use Grid{}. You can set alignment and spans for every cell. It’s how I did my credit comparison view.
@hopscotchjalopy haha, that's exactly what I'm working on
@caseyliss if you can set a width to the text, it makes this a lot easier. I did 100 here and added the emoji to the HStack

@caseyliss I’m afraid I don’t have anything useful to suggest!

But I started learning SwiftUI a few weeks ago and my early impressions were “wow I’m impressed that someone has found ✨ BRAND NEW ✨ ways to make centering as difficult as CSS”

@caseyliss
Sorry to bother you but could you tell Marco that there seems to be a problem with Overcast working with the latest watchOS 10.4. Everything works except the watch crown volume control. I think it is Overcast because Now Playing app works.
Love your podcast.
You’re help is appreciated.
Jim