mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Use the same UI as Android when tapping a link to a private room. (#3044)
* Use the same UI as Android when tapping a link to a private room. * Fix preview of knocking. * Fix snapshots.
This commit is contained in:
@@ -43,6 +43,14 @@ struct JoinRoomScreenViewState: BindableState {
|
||||
roomDetails?.name ?? L10n.screenJoinRoomTitleNoPreview
|
||||
}
|
||||
|
||||
var subtitle: String? {
|
||||
switch mode {
|
||||
case .loading: nil
|
||||
case .unknown: L10n.screenJoinRoomSubtitleNoPreview
|
||||
case .invited, .join, .knock: roomDetails?.canonicalAlias
|
||||
}
|
||||
}
|
||||
|
||||
var avatar: RoomAvatar {
|
||||
.room(id: roomID, name: title, avatarURL: roomDetails?.avatarURL)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ typealias JoinRoomScreenViewModelType = StateStoreViewModel<JoinRoomScreenViewSt
|
||||
class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewModelProtocol {
|
||||
private let roomID: String
|
||||
private let via: [String]
|
||||
private let allowKnocking: Bool // For preview tests only, actions aren't sent.
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -32,11 +33,13 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
|
||||
init(roomID: String,
|
||||
via: [String],
|
||||
allowKnocking: Bool = false,
|
||||
clientProxy: ClientProxyProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.roomID = roomID
|
||||
self.via = via
|
||||
self.allowKnocking = allowKnocking
|
||||
self.clientProxy = clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -81,6 +84,8 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
switch await clientProxy.roomPreviewForIdentifier(roomID, via: via) {
|
||||
case .success(let roomDetails):
|
||||
state.roomDetails = roomDetails
|
||||
case .failure(.roomPreviewIsPrivate):
|
||||
break // Handled by the mode, we don't need an error indicator.
|
||||
case .failure:
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.errorUnknown))
|
||||
}
|
||||
@@ -96,8 +101,8 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
state.mode = .join
|
||||
} else if roomDetails.isInvited {
|
||||
state.mode = .invited
|
||||
} else if roomDetails.canKnock { // Knocking is not supported yet, treat it as .unknown
|
||||
state.mode = .unknown
|
||||
} else if roomDetails.canKnock, allowKnocking { // Knocking is not supported yet, the flag is purely for preview tests.
|
||||
state.mode = .knock
|
||||
} else {
|
||||
state.mode = .unknown
|
||||
}
|
||||
|
||||
@@ -51,10 +51,11 @@ struct JoinRoomScreen: View {
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
if let alias = context.viewState.roomDetails?.canonicalAlias {
|
||||
Text(alias)
|
||||
if let subtitle = context.viewState.subtitle {
|
||||
Text(subtitle)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
if let memberCount = context.viewState.roomDetails?.memberCount {
|
||||
@@ -168,6 +169,7 @@ struct JoinRoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return JoinRoomScreenViewModel(roomID: "1",
|
||||
via: [],
|
||||
allowKnocking: true,
|
||||
clientProxy: clientProxy,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
Reference in New Issue
Block a user