From 2582293c06364c05a2ea9bc392252b043f28d5b7 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 7 May 2026 12:53:46 +0200 Subject: [PATCH] call: Only group voice/video call if threads developer option is on --- .../Other/AccessibilityIdentifiers.swift | 3 + .../View/RoomCallControlsToolbar.swift | 58 ++++++++++++++----- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/ElementX/Sources/Other/AccessibilityIdentifiers.swift b/ElementX/Sources/Other/AccessibilityIdentifiers.swift index 58ae5ae30..cec73edd1 100644 --- a/ElementX/Sources/Other/AccessibilityIdentifiers.swift +++ b/ElementX/Sources/Other/AccessibilityIdentifiers.swift @@ -159,6 +159,9 @@ enum A11yIdentifiers { let joinCall = "room-join_call" let scrollToBottom = "room-scroll_to_bottom" + let startVoiceCall = "room-start_voice_call" + let startVideoCall = "room-start_video_call" + let messageComposer = "room-message_composer" let sendButton = "room-send_button" diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomCallControlsToolbar.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomCallControlsToolbar.swift index d4aa91bd8..1e4cef40a 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomCallControlsToolbar.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomCallControlsToolbar.swift @@ -23,24 +23,45 @@ struct RoomCallControlsToolbar: ToolbarContent { } } else { if viewState.isDirectOneToOneRoom { - ToolbarItem(placement: .primaryAction) { - Menu { - Button { - onCallTap(true) + if viewState.roomThreadListEnabled { + // If the developer mode room thread list option is enabled there + // is not enough place for 2 calls buttons + ToolbarItem(placement: .primaryAction) { + Menu { + Button { + onCallTap(true) + } label: { + Label(L10n.a11yStartVoiceCall, icon: \.voiceCallSolid) + } + + Button { + onCallTap(false) + } label: { + Label(L10n.a11yStartVideoCall, icon: \.videoCallSolid) + } } label: { - Label(L10n.a11yStartVoiceCall, icon: \.voiceCallSolid) + CompoundIcon(\.voiceCallSolid) } - - Button { - onCallTap(false) - } label: { - Label(L10n.a11yStartVideoCall, icon: \.videoCallSolid) - } - } label: { - CompoundIcon(\.voiceCallSolid) + .accessibilityLabel(L10n.a11yStartCall) + .disabled(!viewState.canJoinCall) + } + } else { + ToolbarItem(placement: .primaryAction) { + Button { onCallTap(true) } label: { + CompoundIcon(\.voiceCallSolid) + } + .accessibilityLabel(L10n.a11yStartVoiceCall) + .accessibilityIdentifier(A11yIdentifiers.roomScreen.startVoiceCall) + .disabled(!viewState.canJoinCall) + } + ToolbarItem(placement: .primaryAction) { + Button { onCallTap(false) } label: { + CompoundIcon(\.videoCallSolid) + } + .accessibilityLabel(L10n.a11yStartVideoCall) + .accessibilityIdentifier(A11yIdentifiers.roomScreen.startVideoCall) + .disabled(!viewState.canJoinCall) } - .accessibilityLabel(L10n.a11yStartCall) - .disabled(!viewState.canJoinCall) } } else { ToolbarItem(placement: .primaryAction) { @@ -66,6 +87,10 @@ struct RoomCallControlsToolbar_Previews: PreviewProvider { ElementNavigationStack { Color.clear.toolbar { RoomCallControlsToolbar(viewState: .mock(hasOngoingCall: false, isDirectOneToOneRoom: true)) { _ in } } } + + ElementNavigationStack { + Color.clear.toolbar { RoomCallControlsToolbar(viewState: .mock(hasOngoingCall: false, isDirectOneToOneRoom: true, roomThreadListEnabled: true)) { _ in } } + } ElementNavigationStack { Color.clear.toolbar { RoomCallControlsToolbar(viewState: .mock(hasOngoingCall: false)) { _ in } } } @@ -81,12 +106,13 @@ struct RoomCallControlsToolbar_Previews: PreviewProvider { } private extension RoomScreenViewState { - static func mock(hasOngoingCall: Bool, isDirectOneToOneRoom: Bool = false, canJoinCall: Bool = true, activeRoomCallIntent: CallIntent? = nil) -> RoomScreenViewState { + static func mock(hasOngoingCall: Bool, isDirectOneToOneRoom: Bool = false, canJoinCall: Bool = true, activeRoomCallIntent: CallIntent? = nil, roomThreadListEnabled: Bool = false) -> RoomScreenViewState { RoomScreenViewState(roomAvatar: .room(id: "mock", name: "Mock Room", avatarURL: nil), canJoinCall: canJoinCall, hasOngoingCall: hasOngoingCall, activeRoomCallIntent: activeRoomCallIntent, isDirectOneToOneRoom: isDirectOneToOneRoom, + roomThreadListEnabled: roomThreadListEnabled, hasSuccessor: false) } }