SP3.1: Update room settings for Spaces element-ios#5231

- Changed the Room Settings screen according to the new design
- Implemented the room access flow
- Added room upgrade support
- Implemented the room suggestion screen
This commit is contained in:
Gil Eluard
2022-01-13 15:53:45 +01:00
parent 085fc7d5b0
commit ce226cff8a
78 changed files with 3755 additions and 196 deletions
@@ -36,7 +36,7 @@ struct MatrixItemChooser: View {
var body: some View {
listContent
.background(Color.clear)
.modifier(WaitOverlay(isLoading: .constant(viewModel.viewState.loading)))
.modifier(WaitOverlay(allowUserInteraction: false, message: .constant(viewModel.viewState.loadingText), isLoading: .constant(viewModel.viewState.loading)))
.alert(isPresented: .constant(viewModel.viewState.error != nil), content: {
Alert(title: Text(MatrixKitL10n.error), message: Text(viewModel.viewState.error ?? ""), dismissButton: .cancel(Text(MatrixKitL10n.ok)))
})
@@ -48,30 +48,36 @@ struct MatrixItemChooser: View {
private var listContent: some View {
ScrollView{
headerView
if viewModel.viewState.items.isEmpty {
Text(viewModel.viewState.emptyListMessage)
.font(theme.fonts.body)
.foregroundColor(theme.colors.secondaryContent)
.accessibility(identifier: "emptyListMessage")
Spacer()
} else {
LazyVStack(spacing: 0) {
ForEach(viewModel.viewState.items) { item in
MatrixItemChooserListRow(
avatar: item.avatar,
displayName: item.displayName,
detailText: item.detailText,
isSelected: viewModel.viewState.selectedItemIds.contains(item.id)
)
.onTapGesture {
viewModel.send(viewAction: .itemTapped(item.id))
LazyVStack(spacing: 0) {
ForEach(viewModel.viewState.sections) { section in
if section.title != nil || section.infoText != nil {
MatrixItemChooserSectionHeader(title: section.title, infoText: section.infoText)
}
if section.items.isEmpty {
Text(viewModel.viewState.emptyListMessage)
.font(theme.fonts.body)
.foregroundColor(theme.colors.secondaryContent)
.accessibility(identifier: "emptyListMessage")
} else {
ForEach(section.items) { item in
MatrixItemChooserListRow(
avatar: item.avatar,
type: item.type,
displayName: item.displayName,
detailText: item.detailText,
isSelected: viewModel.viewState.selectedItemIds.contains(item.id)
)
.onTapGesture {
viewModel.send(viewAction: .itemTapped(item.id))
}
}
}
}
.accessibility(identifier: "itemsList")
.frame(maxHeight: .infinity, alignment: .top)
.animation(nil)
}
.accessibility(identifier: "sectionsList")
.frame(maxHeight: .infinity, alignment: .top)
.animation(nil)
}
}
@@ -28,6 +28,7 @@ struct MatrixItemChooserListRow: View {
// MARK: Public
let avatar: AvatarInputProtocol
let type: MatrixListItemDataType
let displayName: String?
let detailText: String?
let isSelected: Bool
@@ -35,7 +36,11 @@ struct MatrixItemChooserListRow: View {
@ViewBuilder
var body: some View {
HStack{
AvatarImage(avatarData: avatar, size: .small)
if type == .space {
SpaceAvatarImage(avatarData: avatar, size: .small)
} else {
AvatarImage(avatarData: avatar, size: .small)
}
VStack(alignment: .leading) {
Text(displayName ?? "")
.foregroundColor(theme.colors.primaryContent)
@@ -0,0 +1,82 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
@available(iOS 14.0, *)
struct MatrixItemChooserSectionHeader: View {
// MARK: - Properties
// MARK: Private
@Environment(\.theme) private var theme: ThemeSwiftUI
// MARK: Public
let title: String?
let infoText: String?
@ViewBuilder
var body: some View {
VStack(alignment: .leading, spacing: 16) {
if let titleText = title {
Text(titleText)
.foregroundColor(theme.colors.secondaryContent)
.font(theme.fonts.footnoteSB)
.frame(maxWidth: .infinity, alignment: .leading)
.accessibility(identifier: "headerTitleText")
}
if let infoText = infoText {
HStack(spacing: 16) {
Image(uiImage: Asset.Images.roomAccessInfoHeaderIcon.image)
.renderingMode(.template)
.foregroundColor(theme.colors.secondaryContent)
Text(infoText)
.foregroundColor(theme.colors.secondaryContent)
.font(theme.fonts.footnote)
.accessibility(identifier: "headerInfoText")
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.vertical, 8)
.padding(.horizontal)
.background(theme.colors.navigation)
.cornerRadius(8)
}
}
.padding()
}
}
// MARK: - Previews
@available(iOS 14.0, *)
struct MatrixItemChooserSectionHeader_Previews: PreviewProvider {
static var previews: some View {
Group {
VStack(spacing: 16) {
MatrixItemChooserSectionHeader(title: nil, infoText: nil)
MatrixItemChooserSectionHeader(title: "Some Title", infoText: nil)
MatrixItemChooserSectionHeader(title: "Some Title", infoText: "A very long info text in order to see if it's well handled by the UI")
}.theme(.light).preferredColorScheme(.light)
VStack(spacing: 16) {
MatrixItemChooserSectionHeader(title: nil, infoText: nil)
MatrixItemChooserSectionHeader(title: "Some Title", infoText: nil)
MatrixItemChooserSectionHeader(title: "Some Title", infoText: "A very long info text in order to see if it's well handled by the UI")
}.theme(.dark).preferredColorScheme(.dark)
}
}
}