Revert decryption banner & try fix context menu crash. (#525)

This commit is contained in:
Doug
2023-02-03 16:24:28 +00:00
committed by GitHub
parent 3015896d46
commit dae8f93b40
9 changed files with 23 additions and 85 deletions
@@ -24,8 +24,6 @@ struct RoomScreen: View {
var body: some View {
timeline
.background(Color.element.background.ignoresSafeArea()) // Kills the toolbar translucency.
.overlay(alignment: .top) { encryptionBanner } // Overlay for now, safeAreaInset breaks timeline scroll offset.
.animation(.spring(), value: context.viewState.showEncryptionBanner)
.safeAreaInset(edge: .bottom, spacing: 0) { messageComposer }
.navigationBarTitleDisplayMode(.inline)
.toolbar { toolbar }
@@ -51,44 +49,6 @@ struct RoomScreen: View {
.overlay(alignment: .bottomTrailing) { scrollToBottomButton }
}
@ViewBuilder
var encryptionBanner: some View {
if context.viewState.showEncryptionBanner {
VStack(alignment: .leading, spacing: 4) {
Label {
Text("Unable to decrypt all messages")
.foregroundColor(.element.primaryContent)
} icon: {
Image(systemName: "lock.shield")
.foregroundColor(.element.background)
.padding(4)
.background(Color.element.tertiaryContent)
.cornerRadius(5)
}
.font(.element.bodyBold)
Text("Accessing your encrypted message history is not fully supported yet.")
.font(.element.subheadline)
.foregroundColor(.element.secondaryContent)
.padding(.bottom, 8)
Button(ElementL10n.globalRetry) {
context.send(viewAction: .retryDecryption)
}
.buttonStyle(.elementCapsuleProminent)
}
.padding(.horizontal, 16)
.padding(.vertical, 12)
.background {
RoundedRectangle(cornerRadius: 8)
.fill(Color.element.system)
}
.padding([.horizontal, .top], 16)
.background(Color.element.background)
.transition(.move(edge: .top).combined(with: .opacity))
}
}
var messageComposer: some View {
MessageComposer(text: $context.composerText,
focused: $context.composerFocused,
@@ -150,8 +110,7 @@ struct RoomScreen_Previews: PreviewProvider {
roomName: "Preview room")
NavigationView {
RoomScreen(context: viewModel.context).encryptionBanner
.padding()
RoomScreen(context: viewModel.context)
}
}
}
@@ -91,8 +91,8 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
var messageBubble: some View {
styledContent
.contentShape(.contextMenuPreview, RoundedCornerShape(radius: cornerRadius, corners: timelineItem.roundedCorners)) // Rounded corners for the context menu animation.
.contextMenu { [weak context] in
context?.viewState.contextMenuActionProvider?(timelineItem.id).map { actions in
.contextMenu {
context.viewState.contextMenuActionProvider?(timelineItem.id).map { actions in
TimelineItemContextMenu(itemID: timelineItem.id, contextMenuActions: actions)
}
}
@@ -39,6 +39,7 @@ enum TimelineItemContextMenuAction: Identifiable, Hashable {
case redact
case reply
case viewSource
case retryDecryption(sessionID: String)
var id: Self { self }
@@ -102,6 +103,10 @@ public struct TimelineItemContextMenu: View {
Button { send(action) } label: {
Label(ElementL10n.viewSource, systemImage: "doc.text.below.ecg")
}
case .retryDecryption:
Button { send(action) } label: {
Label(ElementL10n.roomTimelineContextMenuRetryDecryption, systemImage: "arrow.down.message")
}
}
}
}