Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI toolbar does not appear above keyboard. #66

Closed
oscbyspro opened this issue Mar 24, 2022 · 5 comments
Closed

SwiftUI toolbar does not appear above keyboard. #66

oscbyspro opened this issue Mar 24, 2022 · 5 comments

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Mar 24, 2022

SwiftUI.TextField can add a toolbar above the keyboard as shown below.

view.toolbar {
    ToolbarItemGroup(placement: .keyboard) {
        Spacer()
        Button("Done") { /* action */ }
    }
}

This does not work on DiffableTextField, however. It should be fixed, if possible, otherwise an alternative should be offered.

@oscbyspro oscbyspro added bug sum ting broke enhancement improvements n' stuff labels Mar 24, 2022
@oscbyspro
Copy link
Owner Author

This is one many properties that are not exposed by SwiftUI, so I'll have to make an inputAccessoryView alternative.

@oscbyspro
Copy link
Owner Author

oscbyspro commented Mar 24, 2022

The view.toolbar modifier has a rather peculiar behavior. On each update its closure is called, but its views are only made on setup. A conditional view will only appear if its condition is true on setup, for example. But, if the toolbar contains a view like Text(String(describing: state)) and the state changes, the Text view will update its description. Hm.

@oscbyspro oscbyspro changed the title SwiftUI toolbar does appear above keyboard. SwiftUI toolbar does not appear above keyboard. Mar 24, 2022
@oscbyspro oscbyspro added this to the v3.2.0 milestone Mar 24, 2022
@oscbyspro
Copy link
Owner Author

oscbyspro commented Mar 24, 2022

If found some rough documentation on how it works.

https://developer.apple.com/documentation/swiftui/toolbaritemgroup/init(placement:content:)

But how to extract views is not public. Also, ToolbarContentBuilder

https://developer.apple.com/documentation/swiftui/toolbarcontentbuilder

This is the stupidest rabbit hole for something that “should just work”.

@oscbyspro
Copy link
Owner Author

Every option besides “pray that Apple exposes \.toolbar” seems bad. The least bad alternative besides that would probably be: something, something, UIHostingController.

@oscbyspro oscbyspro removed the bug sum ting broke label Mar 24, 2022
@oscbyspro
Copy link
Owner Author

Will wait on this one. I haven't yet thought of an idea that is not-so-bad enough to implement.

@oscbyspro oscbyspro removed the enhancement improvements n' stuff label Mar 24, 2022
@oscbyspro oscbyspro removed this from the v3.2.0 milestone Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant