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

Programmatic toggling of toolbar not working consistently #16

Open
t14-consulting opened this issue Sep 21, 2024 · 2 comments
Open

Programmatic toggling of toolbar not working consistently #16

t14-consulting opened this issue Sep 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@t14-consulting
Copy link

t14-consulting commented Sep 21, 2024

I have experienced that programmatic toggling works only intermittently.

I can illustrate the problem by using the demo app (v8.7 and Keyboardkit Pro 8.8.6) and trying to toggle the toolbar every second using a timer. I would expect the toolbar to toggle every second, but nothing happens even though the toggle variable is changing.

To reproduce the issue, change the demo app as follows:
Change KeyboardViewController by adding: model and timer:
class Model: ObservableObject { @Published var isToolbarToggled: Bool = true } class KeyboardViewController: KeyboardInputViewController { @ObservedObject var model = Model() var timer: Timer?

setup the time
override func viewDidLoad() { ... timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in print("DEBUG: \(Date()) scheduledTime toggled=\(self!.model.isToolbarToggled)") self!.model.isToolbarToggled.toggle() } }

Pass the isToolbarToggled to DemoToolbarView
setupPro( withLicenseKey: KeyboardApp.demoApp.licenseKey ?? "", licenseConfiguration: setupServices, // Specified below view: { controller in DemoKeyboardView(controller: controller, isToolbarToggled: self.$model.isToolbarToggled) } )

Change DemoToolbarView to accept the parameter:
struct DemoKeyboardView: View { ... @Binding var isToolbarToggled: Bool ... var body: some View { KeyboardView( state: controller.state, services: keyboardServices, buttonContent: { $0.view }, buttonView: { $0.view }, emojiKeyboard: { $0.view }, toolbar: { params in // <- All view builders has parameters with more information DemoToolbar( controller: controller, toolbar: params.view, theme: $theme, isToggled: $isToolbarToggled ) } ) } }

Change DemoToolbar to accept the parameter:
struct DemoToolbar<Toolbar: View>: View { ... @Binding var isToggled: Bool ... var body: some View { try? Keyboard.ToggleToolbar( isToggled: $isToggled, toolbar: autocompleteToolbar, toggledToolbar: menuToolbar ) .tint(.primary) } }

image

@danielsaidi
Copy link
Contributor

Hi @t14-consulting

Thank you for the bug report - I'll look into this in a 8.9.x patch update.

@danielsaidi danielsaidi added the bug Something isn't working label Sep 22, 2024
@danielsaidi
Copy link
Contributor

Hi @t14-consulting

Can you try if this works better in the 9.0 release? I use these bindings in the updated demo app and haven't noticed any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants