mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Implement Knock Logic (#3573)
* WIP RequestToJoin struct * implemented the logic to display the cells * knock request banner accept flow * mark all knocks as seen implemented * details logic * implemented accept, decline and ban in the list * added a loader and modified the stacked view of the banner * pr suggestions * updated naming and loading strings * added the initial loading state improved code and the tests * updated a string that has changed * code improvement * tests for the room screen view model * room details tests and improved the knock requests tests for the room screen * knock requests list tests * added error state alerts with retry * struct has been renamed on the sdk so I renamed it also on the app side * update SDK
This commit is contained in:
@@ -8,11 +8,12 @@
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct KnockRequestInfo {
|
||||
struct KnockRequestInfo: Equatable {
|
||||
let displayName: String?
|
||||
let avatarURL: URL?
|
||||
let userID: String
|
||||
let reason: String?
|
||||
let eventID: String
|
||||
}
|
||||
|
||||
struct KnockRequestsBannerView: View {
|
||||
@@ -102,10 +103,8 @@ private struct SingleKnockRequestBannerContent: View {
|
||||
Button(L10n.screenRoomSingleKnockRequestViewButtonTitle, action: onViewAll)
|
||||
.buttonStyle(.compound(.secondary, size: .medium))
|
||||
if let onAccept {
|
||||
Button(L10n.screenRoomSingleKnockRequestAcceptButtonTitle) {
|
||||
onAccept(request.userID)
|
||||
}
|
||||
.buttonStyle(.compound(.primary, size: .medium))
|
||||
Button(L10n.screenRoomSingleKnockRequestAcceptButtonTitle) { onAccept(request.eventID) }
|
||||
.buttonStyle(.compound(.primary, size: .medium))
|
||||
}
|
||||
}
|
||||
.padding(.top, request.reason == nil ? 0 : 2)
|
||||
@@ -123,7 +122,6 @@ private struct MultipleKnockRequestsBannerContent: View {
|
||||
requests
|
||||
.prefix(3)
|
||||
.map { .init(url: $0.avatarURL, name: $0.displayName, contentID: $0.userID) }
|
||||
.reversed()
|
||||
}
|
||||
|
||||
private var multipleKnockRequestsTitle: String {
|
||||
@@ -138,7 +136,7 @@ private struct MultipleKnockRequestsBannerContent: View {
|
||||
var body: some View {
|
||||
VStack(spacing: 14) {
|
||||
HStack(spacing: 10) {
|
||||
StackedAvatarsView(overlap: 16, lineWidth: 2, shouldStackFromLast: true, avatars: avatars, avatarSize: .user(on: .knockingUsersBannerStack), mediaProvider: mediaProvider)
|
||||
StackedAvatarsView(overlap: 16, lineWidth: 2, avatars: avatars, avatarSize: .user(on: .knockingUsersBannerStack), mediaProvider: mediaProvider)
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
Text(multipleKnockRequestsTitle)
|
||||
.lineLimit(2)
|
||||
@@ -173,18 +171,22 @@ private struct KnockRequestsBannerDismissButton: View {
|
||||
}
|
||||
|
||||
struct KnockRequestsBannerView_Previews: PreviewProvider, TestablePreview {
|
||||
static let singleRequest: [KnockRequestInfo] = [.init(displayName: "Alice", avatarURL: nil, userID: "@alice:matrix.org", reason: nil)]
|
||||
static let singleRequest: [KnockRequestInfo] = [.init(displayName: "Alice", avatarURL: nil, userID: "@alice:matrix.org", reason: nil, eventID: "1")]
|
||||
|
||||
static let singleRequestWithReason: [KnockRequestInfo] = [.init(displayName: "Alice", avatarURL: nil, userID: "@alice:matrix.org", reason: "Hey, I’d like to join this room because of xyz topic and I’d like to participate in the room.")]
|
||||
static let singleRequestWithReason: [KnockRequestInfo] = [.init(displayName: "Alice",
|
||||
avatarURL: nil,
|
||||
userID: "@alice:matrix.org",
|
||||
reason: "Hey, I’d like to join this room because of xyz topic and I’d like to participate in the room.",
|
||||
eventID: "1")]
|
||||
|
||||
static let singleRequestNoDisplayName: [KnockRequestInfo] = [.init(displayName: nil, avatarURL: nil, userID: "@alice:matrix.org", reason: nil)]
|
||||
static let singleRequestNoDisplayName: [KnockRequestInfo] = [.init(displayName: nil, avatarURL: nil, userID: "@alice:matrix.org", reason: nil, eventID: "1")]
|
||||
|
||||
static let multipleRequests: [KnockRequestInfo] = [
|
||||
.init(displayName: "Alice", avatarURL: nil, userID: "@alice:matrix.org", reason: nil),
|
||||
.init(displayName: "Bob", avatarURL: nil, userID: "@bob:matrix.org", reason: nil),
|
||||
.init(displayName: "Charlie", avatarURL: nil, userID: "@charlie:matrix.org", reason: nil),
|
||||
.init(displayName: "Dan", avatarURL: nil, userID: "@dan:matrix.org", reason: nil),
|
||||
.init(displayName: "Test", avatarURL: nil, userID: "@dan:matrix.org", reason: nil)
|
||||
.init(displayName: "Alice", avatarURL: nil, userID: "@alice:matrix.org", reason: nil, eventID: "1"),
|
||||
.init(displayName: "Bob", avatarURL: nil, userID: "@bob:matrix.org", reason: nil, eventID: "2"),
|
||||
.init(displayName: "Charlie", avatarURL: nil, userID: "@charlie:matrix.org", reason: nil, eventID: "3"),
|
||||
.init(displayName: "Dan", avatarURL: nil, userID: "@dan:matrix.org", reason: nil, eventID: "4"),
|
||||
.init(displayName: "Test", avatarURL: nil, userID: "@dan:matrix.org", reason: nil, eventID: "5")
|
||||
]
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
Reference in New Issue
Block a user