TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: WeSplit - Duplicated "Done" button on keyboard

Forums > 100 Days of SwiftUI

I just finished the WeSplit project and everything works great. However I noticed that my keyboard now has two "Done" buttons, one of which is a little larger/darker. See link below for photo of my keyboard.

Here is the code I used. If I remove the .toolbar code then there is no Done button, but as soon as I put it back in there are two. Any ideas??

@FocusState private var amountIsFocused: Bool

@FocusState private var amountIsFocused: Bool

.toolbar {
                ToolbarItemGroup(placement: .keyboard) {
                    Spacer()
                    Button("Done") {
                        amountIsFocused = false
                    }
                }
            }

View keyboard here: https://drive.google.com/file/d/1jdydlDNKP9TtNhwv7ZgnjSsvzDRHgKYF/view?usp=sharing

Thanks!

3      

What happens if you change the button text to dragonfly? (You know, because it's a "bug" .... )

Do you get two copies of dragonfly ?

2      

Yes, it shows "dragonfly" twice, one of which (on the right) is all capital letters.

2      

The only thing i can suggest ic do Clean Build Folder (Shift+Cmd+K).

if that does not work put a Link to GitHub so we can look at it. The code you show looks correct.

2      

I cleaned my build folder and deleted derived data. Same error.

I am not very familiar with Github but did my best to upload everything here: https://github.com/expeditiondocs/WeSplit

I followed the tutorial so I don't think the code is wrong but maybe a bug with my Xcode? I just have no idea what that may be. Running ver 13.0.

2      

I just updated my macOS and Xcode to latest versions, no change. The other weird thing is that the two buttons on first launch are on opposite sides of the toolbar. But after dismissing the keyboard once then the spacer kicks in and they are both on the right side of the keyboard. Also weird that one stays in lowecase while the other is all uppercased.

I have NO idea what is happening.

2      

I looked at the your code on GitHub, could it be that the .toolbar is after a section closing braket not after the form closing braket?

2      

Yes @MalbonaGenio is correct move the .toolbar to closing brace of Form

NavigationView {
  Form { 
  // ..... Rest of code
  }
  .navigationTitle("WeSplit")
  .toolbar {
    ToolbarItemGroup(placement: .keyboard) {
        Spacer()
        Button("dragonfly") {
            amountIsFocused = false
        }
    }
  }
}

And it work fine

7      

Yes, thank you!!!

3      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.