mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Keyboard is kept dismissed when dismissing the actions or the attachments menu (#1141)
* keyboard is kept dismissed * no need for dispatch queue
This commit is contained in:
@@ -107,6 +107,11 @@ struct RoomScreenViewStateBindings {
|
|||||||
var composerFocused: Bool
|
var composerFocused: Bool
|
||||||
|
|
||||||
var scrollToBottomButtonVisible = false
|
var scrollToBottomButtonVisible = false
|
||||||
|
var showAttachmentPopover = false {
|
||||||
|
didSet {
|
||||||
|
composerFocused = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Information describing the currently displayed alert.
|
/// Information describing the currently displayed alert.
|
||||||
var alertInfo: AlertInfo<RoomScreenErrorType>?
|
var alertInfo: AlertInfo<RoomScreenErrorType>?
|
||||||
@@ -118,7 +123,11 @@ struct RoomScreenViewStateBindings {
|
|||||||
var sendFailedConfirmationDialogInfo: SendFailedConfirmationDialogInfo?
|
var sendFailedConfirmationDialogInfo: SendFailedConfirmationDialogInfo?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TimelineItemActionMenuInfo: Identifiable {
|
struct TimelineItemActionMenuInfo: Identifiable, Equatable {
|
||||||
|
static func == (lhs: TimelineItemActionMenuInfo, rhs: TimelineItemActionMenuInfo) -> Bool {
|
||||||
|
lhs.id == rhs.id
|
||||||
|
}
|
||||||
|
|
||||||
let item: EventBasedTimelineItemProtocol
|
let item: EventBasedTimelineItemProtocol
|
||||||
|
|
||||||
var id: String {
|
var id: String {
|
||||||
|
|||||||
@@ -111,12 +111,12 @@ private struct UITextViewWrapper: UIViewRepresentable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async { // Avoid cycle detected through attribute warnings
|
if !focused, textView.isFirstResponder {
|
||||||
if focused, textView.window != nil, !textView.isFirstResponder {
|
textView.resignFirstResponder()
|
||||||
|
} else if focused, textView.window != nil, !textView.isFirstResponder {
|
||||||
textView.becomeFirstResponder()
|
textView.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func makeCoordinator() -> Coordinator {
|
func makeCoordinator() -> Coordinator {
|
||||||
Coordinator(text: $text,
|
Coordinator(text: $text,
|
||||||
|
|||||||
@@ -19,36 +19,35 @@ import SwiftUI
|
|||||||
struct RoomAttachmentPicker: View {
|
struct RoomAttachmentPicker: View {
|
||||||
@ObservedObject var context: RoomScreenViewModel.Context
|
@ObservedObject var context: RoomScreenViewModel.Context
|
||||||
|
|
||||||
@State private var showAttachmentPopover = false
|
|
||||||
@State private var sheetContentHeight = CGFloat(0)
|
@State private var sheetContentHeight = CGFloat(0)
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button {
|
Button {
|
||||||
showAttachmentPopover = true
|
context.showAttachmentPopover = true
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "plus.circle.fill")
|
Image(systemName: "plus.circle.fill")
|
||||||
.font(.compound.headingLG)
|
.font(.compound.headingLG)
|
||||||
.foregroundColor(.compound.textActionPrimary)
|
.foregroundColor(.compound.textActionPrimary)
|
||||||
}
|
}
|
||||||
.accessibilityIdentifier(A11yIdentifiers.roomScreen.attachmentPicker)
|
.accessibilityIdentifier(A11yIdentifiers.roomScreen.attachmentPicker)
|
||||||
.popover(isPresented: $showAttachmentPopover) {
|
.popover(isPresented: $context.showAttachmentPopover) {
|
||||||
VStack(alignment: .leading, spacing: 0.0) {
|
VStack(alignment: .leading, spacing: 0.0) {
|
||||||
Button {
|
Button {
|
||||||
showAttachmentPopover = false
|
context.showAttachmentPopover = false
|
||||||
context.send(viewAction: .displayMediaPicker)
|
context.send(viewAction: .displayMediaPicker)
|
||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceGallery, systemImageName: "photo.fill")
|
PickerLabel(title: L10n.screenRoomAttachmentSourceGallery, systemImageName: "photo.fill")
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
showAttachmentPopover = false
|
context.showAttachmentPopover = false
|
||||||
context.send(viewAction: .displayDocumentPicker)
|
context.send(viewAction: .displayDocumentPicker)
|
||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceFiles, systemImageName: "paperclip")
|
PickerLabel(title: L10n.screenRoomAttachmentSourceFiles, systemImageName: "paperclip")
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
showAttachmentPopover = false
|
context.showAttachmentPopover = false
|
||||||
context.send(viewAction: .displayCameraPicker)
|
context.send(viewAction: .displayCameraPicker)
|
||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceCamera, systemImageName: "camera.fill")
|
PickerLabel(title: L10n.screenRoomAttachmentSourceCamera, systemImageName: "camera.fill")
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ struct RoomScreen: View {
|
|||||||
} editCancellationAction: {
|
} editCancellationAction: {
|
||||||
context.send(viewAction: .cancelEdit)
|
context.send(viewAction: .cancelEdit)
|
||||||
}
|
}
|
||||||
|
.onChange(of: context.actionMenuInfo) { _ in
|
||||||
|
context.composerFocused = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var scrollToBottomButton: some View {
|
private var scrollToBottomButton: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user