mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Knock Requests List Screen (#3533)
* created the basic navigation and files * updated the logic so that the buttons that do not have permissions won't show * added the empty state * progress in making the list UI * update tests * UI improvements * fixed an issue with media provider * update button style * fixed a navigation bug * pr suggestions * pr suggestions
This commit is contained in:
@@ -18,7 +18,7 @@ struct KnockRequestInfo {
|
||||
struct KnockRequestsBannerView: View {
|
||||
let requests: [KnockRequestInfo]
|
||||
let onDismiss: () -> Void
|
||||
let onAccept: (String) -> Void
|
||||
let onAccept: ((String) -> Void)?
|
||||
let onViewAll: () -> Void
|
||||
var mediaProvider: MediaProviderProtocol?
|
||||
|
||||
@@ -34,9 +34,16 @@ struct KnockRequestsBannerView: View {
|
||||
@ViewBuilder
|
||||
private var mainContent: some View {
|
||||
if requests.count == 1 {
|
||||
SingleKnockRequestBannerContent(request: requests[0], onDismiss: onDismiss, onAccept: onAccept, onViewAll: onViewAll)
|
||||
SingleKnockRequestBannerContent(request: requests[0],
|
||||
onDismiss: onDismiss,
|
||||
onAccept: onAccept,
|
||||
onViewAll: onViewAll,
|
||||
mediaProvider: mediaProvider)
|
||||
} else if requests.count > 1 {
|
||||
MultipleKnockRequestsBannerContent(requests: requests, onDismiss: onDismiss, onViewAll: onViewAll)
|
||||
MultipleKnockRequestsBannerContent(requests: requests,
|
||||
onDismiss: onDismiss,
|
||||
onViewAll: onViewAll,
|
||||
mediaProvider: mediaProvider)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
@@ -46,7 +53,7 @@ struct KnockRequestsBannerView: View {
|
||||
private struct SingleKnockRequestBannerContent: View {
|
||||
let request: KnockRequestInfo
|
||||
let onDismiss: () -> Void
|
||||
let onAccept: (String) -> Void
|
||||
let onAccept: ((String) -> Void)?
|
||||
let onViewAll: () -> Void
|
||||
var mediaProvider: MediaProviderProtocol?
|
||||
|
||||
@@ -93,11 +100,13 @@ private struct SingleKnockRequestBannerContent: View {
|
||||
private var actions: some View {
|
||||
HStack(spacing: 12) {
|
||||
Button(L10n.screenRoomSingleKnockRequestViewButtonTitle, action: onViewAll)
|
||||
.buttonStyle(.compound(.secondary))
|
||||
Button(L10n.screenRoomSingleKnockRequestAcceptButtonTitle, action: {
|
||||
onAccept(request.userID)
|
||||
})
|
||||
.buttonStyle(.compound(.primary))
|
||||
.buttonStyle(.compound(.secondary, size: .medium))
|
||||
if let onAccept {
|
||||
Button(L10n.screenRoomSingleKnockRequestAcceptButtonTitle, action: {
|
||||
onAccept(request.userID)
|
||||
})
|
||||
.buttonStyle(.compound(.primary, size: .medium))
|
||||
}
|
||||
}
|
||||
.padding(.top, request.reason == nil ? 0 : 2)
|
||||
.frame(maxWidth: .infinity)
|
||||
@@ -142,7 +151,7 @@ private struct MultipleKnockRequestsBannerContent: View {
|
||||
Button(L10n.screenRoomMultipleKnockRequestsViewAllButtonTitle) {
|
||||
onViewAll()
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.buttonStyle(.compound(.primary, size: .medium))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,6 +190,8 @@ struct KnockRequestsBannerView_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
KnockRequestsBannerView(requests: singleRequest, onDismiss: { }, onAccept: { _ in }, onViewAll: { })
|
||||
.previewDisplayName("Single Request")
|
||||
KnockRequestsBannerView(requests: singleRequest, onDismiss: { }, onAccept: nil, onViewAll: { })
|
||||
.previewDisplayName("Single Request, no accept action")
|
||||
KnockRequestsBannerView(requests: singleRequestWithReason, onDismiss: { }, onAccept: { _ in }, onViewAll: { })
|
||||
.previewDisplayName("Single Request with reason")
|
||||
KnockRequestsBannerView(requests: singleRequestNoDisplayName, onDismiss: { }, onAccept: { _ in }, onViewAll: { })
|
||||
|
||||
Reference in New Issue
Block a user