SP2: Adding Rooms to Spaces element-ios#5230

- Implemented designs with new & existing tabs in a bottom sheet
- Replaced rough edge warnings from space panel overflow with working journeys
This commit is contained in:
Gil Eluard
2021-12-23 14:08:00 +01:00
parent 9bf1c994cc
commit cfd00fea40
55 changed files with 1621 additions and 613 deletions
@@ -1,6 +1,4 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationMatrixItemChooser SpaceCreationMatrixItemChooser
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,17 +19,16 @@ import SwiftUI
@available(iOS 14.0, *)
struct SpaceCreationMatrixItemChooser: View {
// MARK: - Properties
// MARK: Properties
@ObservedObject var viewModel: SpaceCreationMatrixItemChooserViewModel.Context
@State var searchText: String = ""
@ObservedObject var viewModel: MatrixItemChooserViewModel.Context
// MARK: Private
@Environment(\.theme) private var theme: ThemeSwiftUI
// MARK: Public
@ViewBuilder
var body: some View {
VStack {
@@ -46,67 +43,16 @@ struct SpaceCreationMatrixItemChooser: View {
.navigationBarHidden(true)
}
// MARK: Private
@ViewBuilder
private var mainView: some View {
ZStack(alignment: .bottom) {
listContent
MatrixItemChooser(viewModel: viewModel)
footerView
}
}
@ViewBuilder
private var headerView: some View {
VStack {
Text(viewModel.viewState.title)
.font(theme.fonts.bodySB)
.foregroundColor(theme.colors.primaryContent)
.padding(.horizontal)
.padding(.vertical, 8)
.accessibility(identifier: "titleText")
Text(viewModel.viewState.message)
.font(theme.fonts.callout)
.foregroundColor(theme.colors.secondaryContent)
.multilineTextAlignment(.center)
.padding(.horizontal)
.accessibility(identifier: "messageText")
Spacer().frame(height: 24)
SearchBar(placeholder: VectorL10n.searchDefaultPlaceholder, text: $searchText)
.onChange(of: searchText, perform: { value in
viewModel.send(viewAction: .searchTextChanged(searchText))
})
}
}
@ViewBuilder
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
SpaceCreationMatrixItemChooserListRow(
avatar: item.avatar,
displayName: item.displayName,
detailText: item.detailText,
isSelected: viewModel.viewState.selectedItemIds.contains(item.id)
)
.onTapGesture {
viewModel.send(viewAction: .itemTapped(item.id))
}
}
}
.padding(.bottom, 76)
.accessibility(identifier: "itemsList")
.frame(maxHeight: .infinity, alignment: .top)
}
}
}
@ViewBuilder
private var footerView: some View {
@@ -118,17 +64,3 @@ struct SpaceCreationMatrixItemChooser: View {
.padding(.bottom)
}
}
// MARK: - Previews
@available(iOS 14.0, *)
struct SpaceCreationMatrixItemChooser_Previews: PreviewProvider {
static let stateRenderer = MockSpaceCreationMatrixItemChooserScreenState.stateRenderer
static var previews: some View {
stateRenderer.screenGroup(addNavigation: true)
.theme(.light).preferredColorScheme(.light)
stateRenderer.screenGroup(addNavigation: true)
.theme(.dark).preferredColorScheme(.dark)
}
}
@@ -1,73 +0,0 @@
//
// 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 SpaceCreationMatrixItemChooserListRow: View {
// MARK: - Properties
// MARK: Private
@Environment(\.theme) private var theme: ThemeSwiftUI
// MARK: Public
let avatar: AvatarInputProtocol
let displayName: String?
let detailText: String?
let isSelected: Bool
@ViewBuilder
var body: some View {
HStack{
AvatarImage(avatarData: avatar, size: .small)
VStack(alignment: .leading) {
Text(displayName ?? "")
.foregroundColor(theme.colors.primaryContent)
.font(theme.fonts.callout)
.accessibility(identifier: "itemNameText")
if let detailText = self.detailText {
Text(detailText)
.foregroundColor(theme.colors.secondaryContent)
.font(theme.fonts.footnote)
.accessibility(identifier: "itemDetailText")
}
}
Spacer()
if isSelected {
Image(systemName: "checkmark.circle.fill").renderingMode(.template).foregroundColor(theme.colors.accent)
} else {
Image(systemName: "circle").renderingMode(.template).foregroundColor(theme.colors.tertiaryContent)
}
}
.contentShape(Rectangle())
.padding(.horizontal)
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
}
}
// MARK: - Previews
@available(iOS 14.0, *)
struct SpaceCreationMatrixItemChooserListRow_Previews: PreviewProvider {
static var previews: some View {
TemplateRoomListRow(avatar: MockAvatarInput.example, displayName: "Alice")
.addDependency(MockAvatarService.example)
}
}