Rename screens (#826)

* Rename: AnalyticsPrompt -> AnalyticsPromptScreen

* Rename: AnalyticsSettings -> AnalyticsSettingsScreen

* Rename: Settings -> SettingsScreen

* Rename: SessionVerification -> SessionVerificationScreen

* Rename: BugReport -> BugReportScreen

* Rename: FilePreview -> FilePreviewScreen

* Rename: AnalyticsPrompt -> AnalyticsPromptScreen

* Rename: Invites -> InvitesScreen

* Rename: InviteUsers -> InviteUsersScreen

* Rename: MediaPicker -> MediaPickerScreen

* Delete unused UIActivityViewControllerWrapper

* Rename: ReportContent -> ReportContentScreen

* Rename: RoomDetails -> RoomDetailsScreen

* Rename: RoomMemberDetails -> RoomMemberDetailsScreen

* Rename: RoomMemberList -> RoomMemberListScreen

* Rename: Cleanup

* Renaming missed items

* Low effort attempt at fixing the flakey unit tests
This commit is contained in:
Stefan Ceriu
2023-04-24 18:48:07 +03:00
committed by GitHub
parent 9911ad2b9b
commit 24572c6582
88 changed files with 492 additions and 520 deletions
@@ -0,0 +1,64 @@
//
// Copyright 2022 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
struct RoomMembersListScreenCoordinatorParameters {
let navigationStackCoordinator: NavigationStackCoordinator
let mediaProvider: MediaProviderProtocol
let members: [RoomMemberProxyProtocol]
}
enum RoomMembersListScreenCoordinatorAction { }
final class RoomMembersListScreenCoordinator: CoordinatorProtocol {
private let parameters: RoomMembersListScreenCoordinatorParameters
private var viewModel: RoomMembersListScreenViewModelProtocol
private var navigationStackCoordinator: NavigationStackCoordinator { parameters.navigationStackCoordinator }
var callback: ((RoomMembersListScreenCoordinatorAction) -> Void)?
init(parameters: RoomMembersListScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = RoomMembersListScreenViewModel(mediaProvider: parameters.mediaProvider,
members: parameters.members)
}
func start() {
viewModel.callback = { [weak self] action in
guard let self else { return }
switch action {
case let .selectMember(member):
self.selectMember(member)
}
}
}
func toPresentable() -> AnyView {
AnyView(RoomMembersListScreen(context: viewModel.context))
}
// MARK: - Private
private func selectMember(_ member: RoomMemberProxyProtocol) {
let parameters = RoomMemberDetailsScreenCoordinatorParameters(roomMemberProxy: member, mediaProvider: parameters.mediaProvider)
let coordinator = RoomMemberDetailsScreenCoordinator(parameters: parameters)
navigationStackCoordinator.push(coordinator)
}
}
@@ -0,0 +1,49 @@
//
// Copyright 2022 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 Foundation
enum RoomMembersListScreenViewModelAction {
case selectMember(_ member: RoomMemberProxyProtocol)
}
struct RoomMembersListScreenViewState: BindableState {
var members: [RoomMemberDetails]
var bindings: RoomMembersListScreenViewStateBindings
var visibleMembers: [RoomMemberDetails] {
if bindings.searchQuery.isEmpty {
return members
}
return members.lazy.filter { member in
member.id.localizedCaseInsensitiveContains(bindings.searchQuery) ||
member.name?.localizedCaseInsensitiveContains(bindings.searchQuery) ?? false
}
}
}
struct RoomMembersListScreenViewStateBindings {
var searchQuery = ""
/// Information describing the currently displayed alert.
var alertInfo: AlertInfo<RoomDetailsScreenErrorType>?
}
enum RoomMembersListScreenViewAction {
case selectMember(id: String)
}
@@ -0,0 +1,48 @@
//
// Copyright 2022 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
typealias RoomMembersListScreenViewModelType = StateStoreViewModel<RoomMembersListScreenViewState, RoomMembersListScreenViewAction>
class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMembersListScreenViewModelProtocol {
private let mediaProvider: MediaProviderProtocol
private let members: [RoomMemberProxyProtocol]
var callback: ((RoomMembersListScreenViewModelAction) -> Void)?
init(mediaProvider: MediaProviderProtocol,
members: [RoomMemberProxyProtocol]) {
self.mediaProvider = mediaProvider
self.members = members
super.init(initialViewState: .init(members: members.map { RoomMemberDetails(withProxy: $0) },
bindings: .init()),
imageProvider: mediaProvider)
}
// MARK: - Public
override func process(viewAction: RoomMembersListScreenViewAction) {
switch viewAction {
case .selectMember(let id):
guard let member = members.first(where: { $0.userID == id }) else {
MXLog.error("Selected member \(id) not found")
return
}
callback?(.selectMember(member))
}
}
}
@@ -0,0 +1,23 @@
//
// Copyright 2022 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 Foundation
@MainActor
protocol RoomMembersListScreenViewModelProtocol {
var callback: ((RoomMembersListScreenViewModelAction) -> Void)? { get set }
var context: RoomMembersListScreenViewModelType.Context { get }
}
@@ -0,0 +1,67 @@
//
// Copyright 2022 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
struct RoomMembersListScreen: View {
@Environment(\.colorScheme) private var colorScheme
@ObservedObject var context: RoomMembersListScreenViewModel.Context
var body: some View {
ScrollView {
LazyVStack(alignment: .leading) {
Section {
ForEach(context.viewState.visibleMembers) { member in
RoomMembersListScreenMemberCell(member: member, context: context)
.id(member.id)
}
} header: {
Text(L10n.commonMemberCount(context.viewState.members.count))
.foregroundColor(.element.secondaryContent)
.font(.element.body)
.padding(.vertical, 12)
}
.padding(.horizontal)
}
}
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer(displayMode: .always))
.searchableStyle(.list)
.background(Color.element.background.ignoresSafeArea())
.navigationTitle(L10n.commonPeople)
.alert(item: $context.alertInfo) { $0.alert }
}
}
// MARK: - Previews
struct RoomMembersListScreen_Previews: PreviewProvider {
static let viewModel = {
let members: [RoomMemberProxyMock] = [
.mockAlice,
.mockBob,
.mockCharlie
]
return RoomMembersListScreenViewModel(mediaProvider: MockMediaProvider(),
members: members)
}()
static var previews: some View {
NavigationStack {
RoomMembersListScreen(context: viewModel.context)
}
}
}
@@ -0,0 +1,65 @@
//
// Copyright 2022 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
struct RoomMembersListScreenMemberCell: View {
@ScaledMetric private var avatarSize = AvatarSize.user(on: .roomDetails).value
let member: RoomMemberDetails
let context: RoomMembersListScreenViewModel.Context
var body: some View {
Button {
context.send(viewAction: .selectMember(id: member.id))
} label: {
HStack {
LoadableAvatarImage(url: member.avatarURL,
name: member.name ?? "",
contentID: member.id,
avatarSize: .user(on: .roomDetails),
imageProvider: context.imageProvider)
.accessibilityHidden(true)
Text(member.name ?? "")
.font(.element.calloutBold)
.foregroundColor(.element.primaryContent)
.lineLimit(1)
Spacer()
}
.accessibilityElement(children: .combine)
}
}
}
struct RoomMembersListMemberCell_Previews: PreviewProvider {
static var previews: some View {
let members: [RoomMemberProxyMock] = [
.mockAlice,
.mockBob,
.mockCharlie
]
let viewModel = RoomMembersListScreenViewModel(mediaProvider: MockMediaProvider(),
members: members)
return VStack {
ForEach(members, id: \.userID) { member in
RoomMembersListScreenMemberCell(member: .init(withProxy: member), context: viewModel.context)
}
}
}
}