Skip to content

Commit

Permalink
Communication: Fix keyboard toolbar not working with iPad hardware …
Browse files Browse the repository at this point in the history
…keyboard (#248)
  • Loading branch information
anian03 authored Dec 2, 2024
1 parent 3d87d0e commit b94a624
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ extension SendMessageViewModel {
}

func performOnDisappear() {
keyboardVisible = false
do {
if let host = userSession.institution?.baseURL?.host() {
switch configuration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ struct SendMessageView: View {
}
textField
.padding(isFocused ? [.horizontal, .bottom] : .all, .l)
if isFocused {
if isFocused || viewModel.keyboardVisible {
keyboardToolbarContent
.padding(.horizontal, .l)
.padding(.vertical, .m)
.background(.bar)
}
}
.onChange(of: isFocused, initial: true) {
viewModel.keyboardVisible = isFocused
// Don't set keyboardVisible to false automatically on iPad
// Focus with hardware keyboard is messed up, this is a workaround
if UIDevice.current.userInterfaceIdiom != .pad || isFocused {
viewModel.keyboardVisible = isFocused
}
}
.onAppear {
viewModel.performOnAppear()
Expand All @@ -58,6 +62,7 @@ struct SendMessageView: View {
if value.translation.height > 0 {
// down
isFocused = false
viewModel.keyboardVisible = false
let impactMed = UIImpactFeedbackGenerator(style: .medium)
impactMed.impactOccurred()
}
Expand Down

0 comments on commit b94a624

Please sign in to comment.