Files
letro-ios/ElementX/Sources/Screens/BlockedUsersScreen/View/BlockedUsersScreen.swift
Doug 84ff9ee2e2 Adopt StateStoreViewModelV2 in more screens. (#4275)
* Use StateStoreViewModelV2 in AnalyticsPromptScreen.

* Use StateStoreViewModelV2 in UserProfileScreen.

* Use StateStoreViewModelV2 in MediaUploadPreviewScreen.

* Use StateStoreViewModelV2 in the Roles & Permissions screens.

* Add the asyncStream variant of deferFailure.

* Use StateStoreViewModelV2 in BlockedUsersScreen.

* Use StateStoreViewModelV2 in ManageRoomMemberSheet.

* Use StateStoreViewModelV2 in ResolveVerifiedUserSendFailureScreen.

* Use StateStoreViewModelV2 in ReportContentScreen.

* Use StateStoreViewModelV2 in ReportRoomScreen.

* Use StateStoreViewModelV2 in StaticLocationScreen.

* Use StateStoreViewModelV2 in EmojiPickerScreen.

* Use StateStoreViewModelV2 in PollFormScreen.

* Use StateStoreViewModelV2 in DeclineAndBlockScreen.

* Use StateStoreViewModelV2 in RoomDetailsScreen.

* Fix a random compilation error that just popped up 🤷‍♂️

* Fix expectation message.
2025-07-02 15:13:42 +01:00

69 lines
2.6 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 Compound
import SwiftUI
struct BlockedUsersScreen: View {
@Bindable var context: BlockedUsersScreenViewModel.Context
var body: some View {
content
.compoundList()
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(L10n.commonBlockedUsers)
.alert(item: $context.alertInfo)
.disabled(context.viewState.processingUserID != nil)
}
// MARK: - Private
@ViewBuilder
private var content: some View {
if context.viewState.blockedUsers.isEmpty {
Text(L10n.screenBlockedUsersEmpty)
.font(.compound.bodyMD)
.foregroundColor(.compound.textSecondary)
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
Form {
ForEach(context.viewState.blockedUsers, id: \.self) { user in
ListRow(label: .avatar(title: user.displayName ?? user.userID,
description: user.displayName != nil ? user.userID : nil,
icon: avatar(for: user)),
details: .isWaiting(context.viewState.processingUserID == user.userID),
kind: .button { context.send(viewAction: .unblockUser(user)) })
}
}
}
}
private func avatar(for user: UserProfileProxy) -> some View {
LoadableAvatarImage(url: user.avatarURL,
name: user.displayName,
contentID: user.userID,
avatarSize: .user(on: .blockedUsers),
mediaProvider: context.mediaProvider)
.accessibilityHidden(true)
}
}
// MARK: - Previews
struct BlockedUsersScreen_Previews: PreviewProvider, TestablePreview {
static let viewModel = BlockedUsersScreenViewModel(hideProfiles: true,
clientProxy: ClientProxyMock(.init(userID: RoomMemberProxyMock.mockMe.userID)),
mediaProvider: MediaProviderMock(configuration: .init()),
userIndicatorController: UserIndicatorControllerMock())
static var previews: some View {
NavigationStack {
BlockedUsersScreen(context: viewModel.context)
}
}
}