UI update for room details (#2831)

This commit is contained in:
Mauro
2024-05-10 17:58:35 +02:00
committed by GitHub
parent 446854e1c3
commit ae06226cbc
49 changed files with 282 additions and 113 deletions
@@ -35,6 +35,7 @@ enum RoomDetailsScreenCoordinatorAction {
case presentInviteUsersScreen
case presentPollsHistory
case presentRolesAndPermissionsScreen
case presentCall
}
final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
@@ -79,6 +80,8 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.presentPollsHistory)
case .requestRolesAndPermissionsPresentation:
actionsSubject.send(.presentRolesAndPermissionsScreen)
case .startCall:
actionsSubject.send(.presentCall)
}
}
.store(in: &cancellables)
@@ -29,6 +29,7 @@ enum RoomDetailsScreenViewModelAction {
case requestEditDetailsPresentation
case requestPollsHistoryPresentation
case requestRolesAndPermissionsPresentation
case startCall
}
// MARK: View
@@ -50,6 +51,7 @@ struct RoomDetailsScreenViewState: BindableState {
var canEditRoomAvatar = false
var canEditRolesOrPermissions = false
var notificationSettingsState: RoomDetailsNotificationSettingsState = .loading
var canJoinCall = false
var canEdit: Bool {
!isDirect && (canEditRoomName || canEditRoomTopic || canEditRoomAvatar)
@@ -65,6 +67,12 @@ struct RoomDetailsScreenViewState: BindableState {
var shortcuts: [RoomDetailsScreenViewShortcut] {
var shortcuts: [RoomDetailsScreenViewShortcut] = [.mute]
if !ProcessInfo.processInfo.isiOSAppOnMac, canJoinCall {
shortcuts.append(.call)
}
if dmRecipient == nil, canInviteUsers {
shortcuts.append(.invite)
}
if let permalink = dmRecipient?.permalink {
shortcuts.append(.share(link: permalink))
} else if let permalink {
@@ -184,11 +192,14 @@ enum RoomDetailsScreenViewAction {
case processTapPolls
case toggleFavourite(isFavourite: Bool)
case processTapRolesAndPermissions
case processTapCall
}
enum RoomDetailsScreenViewShortcut {
case share(link: URL)
case mute
case call
case invite
}
extension RoomDetailsScreenViewShortcut: Hashable { }
@@ -63,6 +63,13 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
bindings: .init()),
imageProvider: mediaProvider)
Task {
let userID = roomProxy.ownUserID
if case let .success(permission) = await roomProxy.canUserJoinCall(userID: userID) {
state.canJoinCall = permission
}
}
Task {
if case let .success(permalinkURL) = await roomProxy.matrixToPermalink() {
state.permalink = permalinkURL
@@ -126,6 +133,8 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
Task { await toggleFavourite(isFavourite) }
case .processTapRolesAndPermissions:
actionsSubject.send(.requestRolesAndPermissionsPresentation)
case .processTapCall:
actionsSubject.send(.startCall)
}
}
@@ -107,6 +107,20 @@ struct RoomDetailsScreen: View {
CompoundIcon(\.shareIos)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionShare))
case .call:
Button {
context.send(viewAction: .processTapCall)
} label: {
CompoundIcon(\.videoCall)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionCall))
case .invite:
Button {
context.send(viewAction: .processTapInvite)
} label: {
CompoundIcon(\.userAdd)
}
.buttonStyle(FormActionButtonStyle(title: L10n.actionInvite))
}
}
}
@@ -152,15 +166,6 @@ struct RoomDetailsScreen: View {
context.send(viewAction: .processTapPeople)
})
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.people)
if context.viewState.canInviteUsers {
ListRow(label: .default(title: L10n.screenRoomDetailsInvitePeopleTitle,
icon: \.userAdd),
kind: .navigationLink {
context.send(viewAction: .processTapInvite)
})
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.invite)
}
}
ListRow(label: .default(title: L10n.screenPollsHistoryTitle,
icon: \.polls),