mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-01 01:03:01 +00:00
0bc832f8a6
* Present members of a space * present the members modally from the space * Implemented a room members flow coordinator to make such flow more modular and reusable this is required since we will need to reuse this module also in the space settings, and later we could also replace it in the RoomFlowCoordinator. * the implementation to support at least the SpaceFlowCoordinator is done a follow UP should do the refactor. * remove modal usage from the flow, we want to always be a navigation flow * Improved and implemented the room navigation in the members flow coordinator * pr suggestions and refactored the start chat flow and the invite screen * updated copies for managing room members * Update ElementX/Sources/Screens/Spaces/SpaceScreen/SpaceScreenViewModel.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
83 lines
2.2 KiB
Swift
83 lines
2.2 KiB
Swift
//
|
|
// 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 Foundation
|
|
import MatrixRustSDK
|
|
|
|
// periphery:ignore - for generic conformance
|
|
enum InviteUsersScreenErrorType: Error {
|
|
case unknown
|
|
}
|
|
|
|
enum InviteUsersScreenViewModelAction {
|
|
case dismiss
|
|
case proceed(selectedUsers: [UserProfileProxy])
|
|
}
|
|
|
|
enum InviteUsersScreenRoomType {
|
|
case draft
|
|
case room(roomProxy: JoinedRoomProxyProtocol)
|
|
}
|
|
|
|
struct InviteUsersScreenViewState: BindableState {
|
|
var bindings = InviteUsersScreenViewStateBindings()
|
|
|
|
var usersSection: UserDiscoverySection = .init(type: .suggestions, users: [])
|
|
|
|
var selectedUsers: [UserProfileProxy] = []
|
|
var membershipState: [String: MembershipState] = .init()
|
|
|
|
var isSearching = false
|
|
|
|
var hasEmptySearchResults: Bool {
|
|
!isSearching && usersSection.type == .searchResult && usersSection.users.isEmpty
|
|
}
|
|
|
|
var scrollToLastID: String?
|
|
|
|
func isUserSelected(_ user: UserProfileProxy) -> Bool {
|
|
isUserDisabled(user) || selectedUsers.contains { $0.userID == user.userID }
|
|
}
|
|
|
|
func isUserDisabled(_ user: UserProfileProxy) -> Bool {
|
|
let membershipState = membershipState(user)
|
|
return membershipState == .invite || membershipState == .join
|
|
}
|
|
|
|
func membershipState(_ user: UserProfileProxy) -> MembershipState? {
|
|
membershipState[user.userID]
|
|
}
|
|
|
|
let isCreatingRoom: Bool
|
|
|
|
var actionText: String {
|
|
if isCreatingRoom {
|
|
return selectedUsers.isEmpty ? L10n.actionSkip : L10n.actionNext
|
|
} else {
|
|
return L10n.actionInvite
|
|
}
|
|
}
|
|
|
|
var isActionDisabled: Bool {
|
|
isCreatingRoom ? false : selectedUsers.isEmpty
|
|
}
|
|
}
|
|
|
|
struct InviteUsersScreenViewStateBindings {
|
|
var searchQuery = ""
|
|
|
|
/// Information describing the currently displayed alert.
|
|
var alertInfo: AlertInfo<InviteUsersScreenErrorType>?
|
|
}
|
|
|
|
enum InviteUsersScreenViewAction {
|
|
case cancel
|
|
case proceed
|
|
case toggleUser(UserProfileProxy)
|
|
}
|