mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Pinned events banner loading state (#3118)
This commit is contained in:
+32
-21
@@ -18,7 +18,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct PinnedItemsBannerView: View {
|
||||
let pinnedEventsState: PinnedEventsState
|
||||
let state: PinnedEventsBannerState
|
||||
|
||||
let onMainButtonTap: () -> Void
|
||||
let onViewAllButtonTap: () -> Void
|
||||
@@ -38,7 +38,7 @@ struct PinnedItemsBannerView: View {
|
||||
Button { onMainButtonTap() } label: {
|
||||
HStack(spacing: 0) {
|
||||
HStack(spacing: 10) {
|
||||
PinnedItemsIndicatorView(pinIndex: pinnedEventsState.selectedPinIndex, pinsCount: pinnedEventsState.pinnedEventContents.count)
|
||||
PinnedItemsIndicatorView(pinIndex: state.selectedPinIndex, pinsCount: state.count)
|
||||
.accessibilityHidden(true)
|
||||
CompoundIcon(\.pinSolid, size: .small, relativeTo: .compound.bodyMD)
|
||||
.foregroundColor(Color.compound.iconSecondaryAlpha)
|
||||
@@ -48,26 +48,34 @@ struct PinnedItemsBannerView: View {
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.disabled(state.isLoading)
|
||||
.accessibilityElement(children: .contain)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var viewAllButton: some View {
|
||||
Button { onViewAllButtonTap() } label: {
|
||||
Text(L10n.screenRoomPinnedBannerViewAllButtonTitle)
|
||||
.font(.compound.bodyMDSemibold)
|
||||
.foregroundStyle(Color.compound.textPrimary)
|
||||
switch state {
|
||||
case .loaded:
|
||||
Button { onViewAllButtonTap() } label: {
|
||||
Text(L10n.screenRoomPinnedBannerViewAllButtonTitle)
|
||||
.font(.compound.bodyMDSemibold)
|
||||
.foregroundStyle(Color.compound.textPrimary)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 5)
|
||||
}
|
||||
case .loading:
|
||||
ProgressView()
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 5)
|
||||
}
|
||||
}
|
||||
|
||||
private var content: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(pinnedEventsState.bannerIndicatorDescription)
|
||||
Text(state.bannerIndicatorDescription)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textActionAccent)
|
||||
.lineLimit(1)
|
||||
Text(pinnedEventsState.selectedPinContent)
|
||||
Text(state.displayedMessage)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.lineLimit(1)
|
||||
@@ -79,27 +87,30 @@ struct PinnedItemsBannerView_Previews: PreviewProvider, TestablePreview {
|
||||
static var attributedContent: AttributedString {
|
||||
var boldPart = AttributedString("Image:")
|
||||
boldPart.bold()
|
||||
var final = boldPart + " content.png"
|
||||
var finalString = boldPart + " content.png"
|
||||
// This should be ignored when presented
|
||||
final.font = .headline
|
||||
return final
|
||||
finalString.font = .headline
|
||||
return finalString
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
VStack(spacing: 20) {
|
||||
PinnedItemsBannerView(pinnedEventsState: .init(pinnedEventContents: ["1": "Content",
|
||||
"2": "2",
|
||||
"3": "3"],
|
||||
selectedPinEventID: "1"),
|
||||
PinnedItemsBannerView(state: .loaded(state: .init(pinnedEventContents: ["1": "Content",
|
||||
"2": "2",
|
||||
"3": "3"],
|
||||
selectedPinEventID: "1")),
|
||||
onMainButtonTap: { },
|
||||
onViewAllButtonTap: { })
|
||||
PinnedItemsBannerView(pinnedEventsState: .init(pinnedEventContents: ["1": "Very very very very long content here",
|
||||
"2": "2"],
|
||||
selectedPinEventID: "1"),
|
||||
PinnedItemsBannerView(state: .loaded(state: .init(pinnedEventContents: ["1": "Very very very very long content here",
|
||||
"2": "2"],
|
||||
selectedPinEventID: "1")),
|
||||
onMainButtonTap: { },
|
||||
onViewAllButtonTap: { })
|
||||
PinnedItemsBannerView(pinnedEventsState: .init(pinnedEventContents: ["1": attributedContent],
|
||||
selectedPinEventID: "1"),
|
||||
PinnedItemsBannerView(state: .loaded(state: .init(pinnedEventContents: ["1": attributedContent],
|
||||
selectedPinEventID: "1")),
|
||||
onMainButtonTap: { },
|
||||
onViewAllButtonTap: { })
|
||||
PinnedItemsBannerView(state: .loading(numbersOfEvents: 5),
|
||||
onMainButtonTap: { },
|
||||
onViewAllButtonTap: { })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user