* handling the history visibility flag * better logic to handle visibility * better handling of the visibility options state * added some copies, and the public room directory visibility state * completed the UI added also the preview tests * improved the handling of the directory visibility * added the space users case and improved handling of the access -> vsibility reaction. Also added a simple error handling for the public directory toggle * added the edit room address view but is missing its full implementation * implement the UI for the edit room address screen * implemented error checking when editing the address * updated preview tests and improved code * typo fix * Fix various issues after rebasing. * Fix build errors and broken snapshot tests * Adopt latest room privacy and canonical alias setting APIs * Add support for creating and editing the room's alias. * Add support for saving room privacy setting changes. * Fix room alias screen snapshot tests following recent changes. --------- Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
86 lines
2.2 KiB
Swift
86 lines
2.2 KiB
Swift
//
|
|
// Copyright 2022-2024 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
|
|
|
|
enum CreateRoomScreenErrorType: Error {
|
|
case failedCreatingRoom
|
|
case failedUploadingMedia
|
|
case fileTooLarge
|
|
case mediaFileError
|
|
case unknown
|
|
}
|
|
|
|
enum CreateRoomViewModelAction {
|
|
case openRoom(withIdentifier: String)
|
|
case deselectUser(UserProfileProxy)
|
|
case updateDetails(CreateRoomFlowParameters)
|
|
case displayMediaPicker
|
|
case displayCameraPicker
|
|
case removeImage
|
|
}
|
|
|
|
struct CreateRoomViewState: BindableState {
|
|
var roomName: String
|
|
let serverName: String
|
|
let isKnockingFeatureEnabled: Bool
|
|
var selectedUsers: [UserProfileProxy]
|
|
var aliasLocalPart: String
|
|
var bindings: CreateRoomViewStateBindings
|
|
var avatarURL: URL?
|
|
var canCreateRoom: Bool {
|
|
!roomName.isEmpty && aliasErrors.isEmpty
|
|
}
|
|
|
|
var aliasErrors: Set<CreateRoomAliasErrorState> = []
|
|
var aliasErrorDescription: String? {
|
|
if aliasErrors.contains(.alreadyExists) {
|
|
L10n.errorRoomAddressAlreadyExists
|
|
} else if aliasErrors.contains(.invalidSymbols) {
|
|
L10n.errorRoomAddressInvalidSymbols
|
|
} else {
|
|
nil
|
|
}
|
|
}
|
|
}
|
|
|
|
struct CreateRoomViewStateBindings {
|
|
var roomTopic: String
|
|
var isRoomPrivate: Bool
|
|
var isKnockingOnly: Bool
|
|
var showAttachmentConfirmationDialog = false
|
|
|
|
/// Information describing the currently displayed alert.
|
|
var alertInfo: AlertInfo<CreateRoomScreenErrorType>?
|
|
}
|
|
|
|
enum CreateRoomViewAction {
|
|
case createRoom
|
|
case deselectUser(UserProfileProxy)
|
|
case displayCameraPicker
|
|
case displayMediaPicker
|
|
case removeImage
|
|
case updateRoomName(String)
|
|
case updateAliasLocalPart(String)
|
|
}
|
|
|
|
enum CreateRoomAliasErrorState {
|
|
case alreadyExists
|
|
case invalidSymbols
|
|
}
|
|
|
|
extension Set<CreateRoomAliasErrorState> {
|
|
var errorDescription: String? {
|
|
if contains(.alreadyExists) {
|
|
return L10n.errorRoomAddressAlreadyExists
|
|
} else if contains(.invalidSymbols) {
|
|
return L10n.errorRoomAddressInvalidSymbols
|
|
}
|
|
return nil
|
|
}
|
|
}
|