mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
Search tab (#5754)
* Add a developer flag for the search tab Introduces a globalSearchEnabled user preference (off by default) with a toggle in Developer Options, used to gate the new search experience. * Support search role tabs in the tab coordinator Migrates the NavigationTabCoordinator to SwiftUI's value-based Tab API and adds an isSearch option so a tab can adopt the iOS 26 .search role, which detaches it into the trailing search button in the tab bar. * Moves room search to a new screen Adds a new screen that filters the alternate room summary provider as you type, shows an empty state, and lists matching rooms with their matrix identifier. Supports hardware keyboard selection (arrow keys to move through results, return to open) by reaching into the system search field. * Present search in a dedicated tab Adds the search tab to the chats flow on iOS 26 when the flag is enabled, rendered as the detached .search role button. The Cmd+K shortcut now selects this tab, and the home screen's inline search is hidden while the tab is available. * Remove the old global search screen The dedicated search tab replaces the Cmd+K floating window, so the GlobalSearchScreen, its window plumbing in the WindowManager, and its presentation in the chats flow are all removed.
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// Copyright 2025 Element Creations Ltd.
|
||||
// Copyright 2022-2025 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Combine
|
||||
@testable import ElementX
|
||||
import Testing
|
||||
|
||||
@MainActor
|
||||
struct GlobalSearchScreenViewModelTests {
|
||||
var viewModel: GlobalSearchScreenViewModelProtocol!
|
||||
var context: GlobalSearchScreenViewModelType.Context!
|
||||
|
||||
init() {
|
||||
viewModel = GlobalSearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||
mediaProvider: MediaProviderMock(.init()))
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
@Test
|
||||
mutating func searching() async throws {
|
||||
let deferred = deferFulfillment(context.$viewState) { state in
|
||||
state.rooms.count == 1
|
||||
}
|
||||
|
||||
context.searchQuery = "Second"
|
||||
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
@Test
|
||||
func roomSelection() async throws {
|
||||
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||
switch action {
|
||||
case .select(let roomID):
|
||||
return roomID == "2"
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
context.send(viewAction: .select(roomID: "2"))
|
||||
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
@testable import ElementX
|
||||
import Testing
|
||||
|
||||
@MainActor
|
||||
struct SearchScreenViewModelTests {
|
||||
let viewModel: SearchScreenViewModelProtocol
|
||||
var context: SearchScreenViewModelType.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
init() {
|
||||
viewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||
mediaProvider: MediaProviderMock(.init()))
|
||||
}
|
||||
|
||||
@Test
|
||||
func searching() async throws {
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.rooms)) { $0.count == 1 }
|
||||
context.searchQuery = "Second"
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
@Test
|
||||
func roomSelection() async throws {
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||
switch action {
|
||||
case .presentRoom(let roomID):
|
||||
roomID == "2"
|
||||
}
|
||||
}
|
||||
|
||||
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user