SP3.1: Update room settings for Spaces #5231

- Update after review
This commit is contained in:
Gil Eluard
2022-02-28 16:07:09 +01:00
parent 3a9b6b248b
commit bca69bb7c8
52 changed files with 878 additions and 519 deletions
@@ -32,8 +32,8 @@ struct AddRoomSelector: View {
var body: some View {
MatrixItemChooser(viewModel: viewModel, listBottomPadding: nil)
.background(theme.colors.background)
.navigationBarItems(leading: cancelButton,
trailing: doneButton)
.navigationBarItems(leading: cancelButton, trailing: doneButton)
.accentColor(theme.colors.accent)
}
// MARK: Private
@@ -43,7 +43,6 @@ struct AddRoomSelector: View {
viewModel.send(viewAction: .cancel)
})
.font(theme.fonts.body)
.foregroundColor(theme.colors.accent)
}
private var doneButton: some View {
@@ -51,7 +50,6 @@ struct AddRoomSelector: View {
viewModel.send(viewAction: .done)
})
.font(theme.fonts.body)
.foregroundColor(viewModel.viewState.selectedItemIds.isEmpty ? theme.colors.quarterlyContent : theme.colors.accent)
.opacity(viewModel.viewState.selectedItemIds.isEmpty ? 0.7 : 1)
.disabled(viewModel.viewState.selectedItemIds.isEmpty)
}
@@ -26,10 +26,10 @@ class MatrixItemChooserRoomAncestorsDataSource: MatrixItemChooserDataSource {
}
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
let ancestorsId = session.spaceService.ancestorsPerRoomId[roomId] ?? []
let ancestorsIds = session.spaceService.ancestorsPerRoomId[roomId] ?? []
completion(Result(catching: {
return [
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsId.compactMap { spaceId in
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsIds.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
}
@@ -34,7 +34,7 @@ class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource
}
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
let ancestorsId = session.spaceService.directParentIds(ofRoomWithId: roomId)
let ancestorsIds = session.spaceService.directParentIds(ofRoomWithId: roomId)
switch preselectionMode {
case .none:
@@ -45,7 +45,7 @@ class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource
completion(Result(catching: {
return [
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsId.compactMap { spaceId in
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsIds.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
}
@@ -37,7 +37,7 @@ class MatrixItemChooserRoomRestrictedAllowedParentsDataSource: MatrixItemChooser
guard let self = self else { return }
let joinRuleEvent = state?.stateEvents(with: .roomJoinRules)?.last
let allowContent: [[String:String]] = joinRuleEvent?.wireContent["allow"] as? [[String:String]] ?? []
let allowContent: [[String: String]] = joinRuleEvent?.wireContent["allow"] as? [[String: String]] ?? []
self.allowedParentIds = allowContent.compactMap { allowDictionnary in
guard let type = allowDictionnary["type"], type == "m.room_membership" else {
return nil
@@ -23,13 +23,13 @@ extension MatrixListItemData {
}
init(mxRoom: MXRoom, spaceService: MXSpaceService) {
let parentSapceIds = mxRoom.summary.parentSpaceIds ?? Set()
let parentSpaceIds = mxRoom.summary.parentSpaceIds ?? Set()
let detailText: String?
if parentSapceIds.isEmpty {
if parentSpaceIds.isEmpty {
detailText = nil
} else {
if let spaceName = spaceService.getSpace(withId: parentSapceIds.first ?? "")?.summary?.displayname {
let count = parentSapceIds.count - 1
if let spaceName = spaceService.getSpace(withId: parentSpaceIds.first ?? "")?.summary?.displayname {
let count = parentSpaceIds.count - 1
switch count {
case 0:
detailText = VectorL10n.spacesCreationInSpacename(spaceName)
@@ -39,8 +39,8 @@ extension MatrixListItemData {
detailText = VectorL10n.spacesCreationInSpacenamePlusMany(spaceName, "\(count)")
}
} else {
if parentSapceIds.count > 1 {
detailText = VectorL10n.spacesCreationInManySpaces("\(parentSapceIds.count)")
if parentSpaceIds.count > 1 {
detailText = VectorL10n.spacesCreationInManySpaces("\(parentSpaceIds.count)")
} else {
detailText = VectorL10n.spacesCreationInOneSpace
}
@@ -44,7 +44,7 @@ struct MatrixItemChooser: View {
var body: some View {
listContent
.background(Color.clear)
.modifier(WaitOverlay(isLoading: .constant(viewModel.viewState.loading)))
.waitOverlay(show: viewModel.viewState.loading)
.alert(isPresented: .constant(viewModel.viewState.error != nil)) {
Alert(title: Text(VectorL10n.error), message: Text(viewModel.viewState.error ?? ""), dismissButton: .cancel(Text(VectorL10n.ok)))
}
@@ -38,36 +38,10 @@ class RoomAncestorSelectorItemsProcessor: MatrixItemChooserProcessorProtocol {
}
func computeSelection(withIds itemsIds: [String], completion: @escaping (Result<Void, Error>) -> Void) {
// addChild(from: itemsIds, at: 0, completion: completion)
completion(Result.success(()))
}
func isItemIncluded(_ item: (MatrixListItemData)) -> Bool {
return true
}
// MARK: Private
// func addChild(from roomIds: [String], at index: Int, completion: @escaping (Result<Void, Error>) -> Void) {
// guard index < roomIds.count else {
// completion(Result.success(()))
// return
// }
//
// let roomId = roomIds[index]
//
// guard !parentSpace.isRoomAChild(roomId: roomId) else {
// addChild(from: roomIds, at: index + 1, completion: completion)
// return
// }
//
// parentSpace.addChild(roomId: roomIds[index]) { [weak self] response in
// switch response {
// case .success:
// self?.addChild(from: roomIds, at: index + 1, completion: completion)
// case .failure(let error):
// completion(Result.failure(error))
// }
// }
// }
}
@@ -41,7 +41,7 @@ struct SpaceCreationEmailInvites: View {
}
mainView
.animation(.easeInOut(duration: 0.2), value: viewModel.viewState.loading)
.modifier(WaitOverlay(isLoading: .constant(viewModel.viewState.loading)))
.waitOverlay(show: viewModel.viewState.loading)
}
.background(theme.colors.background)
.navigationBarHidden(true)