SwiftUI seems to ignore Spacer on WatchOS

Viewed 551

I've started playing around with SwiftUI by making a standalone WatchOS app. Currently, I'm working on a login screen, and I'm having a discrepancy between what I see in the simulator and what I see in the preview:

Preview (what I'm looking for) Preview (what I'm looking for)

Simulator Simulator

Appears to be a minor issue, I know, but I have text that appears to indicate that a code is being sent, and when that appears, text gets cut off in the simulator:

Preview (what I'm looking for) Preview (what I'm looking for)

Simulator Simulator

Here's the code for the view:

struct PhoneView: View {
    @State private var phone = ""
    @State private var sending = true

    @Binding private(set) var error: TError?
    @Binding private(set) var auth: TPhoneAuth?

    var body: some View {
        VStack {
            Text("Let's get started!")
                .font(.largeTitle)
                .lineLimit(nil)
                .multilineTextAlignment(.center)
            Spacer()
            if sending {
                Text("Sending code...")
                    .multilineTextAlignment(.center)
            }
            TextField($phone, placeholder: Text("Enter Phone"), onCommit: {
                let phone = self.phone.filter { $0.isNumber }
                let auth = TPhoneAuth(phone: phone)
                self.sending = true
                auth.sendCode { error in
                    self.sending = false
                    if let error = error {
                        print(error)
                        self.error = error
                    } else {
                        print(auth.phone)
                        self.auth = auth
                    }
                }
            })
                .textContentType(.telephoneNumber)
                .multilineTextAlignment(.center)
        }
    }
}

So essentially, it's a VStack of Text, Spacer, conditional Text, and TextField. As for how the view is presented, both in the preview and in the app, the view is the entirety of the body (i.e. no VStacks, HStacks, Groups, or anything of the like wrapping it).

Also, I tried to replicate the issue on iOS, but it behaves as expected there, and the preview and simulator give the same result. If anyone has run into a similar issue or has an idea as to what is going on (I may just be missing something obvious), it would be much appreciated :)

0 Answers
Related