mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:31:27 +00:00
Add encryption history banner and update session verification banner strings. (#1250)
* Add a hard wall on back-pagination in encrypted rooms. Until the app supports key backup, the history will never be decryptable. * Fix initial display of the timeline table view. * Update session verification banner strings.
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// The item shown when all previous items are un-decryptable due to
|
||||
/// key backup not yet being supported in the app.
|
||||
struct EncryptedHistoryRoomTimelineView: View {
|
||||
let timelineItem: EncryptedHistoryRoomTimelineItem
|
||||
|
||||
var body: some View {
|
||||
Label {
|
||||
Text(L10n.screenRoomEncryptedHistoryBanner)
|
||||
.font(.compound.bodyMDSemibold)
|
||||
.foregroundColor(.compound.textInfoPrimary)
|
||||
} icon: {
|
||||
Image(systemName: "info.circle.fill")
|
||||
.foregroundColor(.compound.iconInfoPrimary)
|
||||
}
|
||||
.labelStyle(EncryptedHistoryLabelStyle())
|
||||
.padding(16)
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.fill(Color.compound.bgInfoSubtle)
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.stroke(Color.compound.borderInfoSubtle)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 16)
|
||||
}
|
||||
}
|
||||
|
||||
private struct EncryptedHistoryLabelStyle: LabelStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 16) {
|
||||
configuration.icon
|
||||
configuration.title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EncryptedHistoryRoomTimelineView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let item = EncryptedHistoryRoomTimelineItem(id: UUID().uuidString)
|
||||
EncryptedHistoryRoomTimelineView(timelineItem: item)
|
||||
}
|
||||
}
|
||||
@@ -119,6 +119,13 @@ class TimelineTableViewController: UIViewController {
|
||||
// for each possible cell, causing layout issues
|
||||
tableView.accessibilityElementsHidden = Tests.shouldDisableTimelineAccessibility
|
||||
|
||||
tableView.publisher(for: \.contentSize)
|
||||
.removeDuplicates()
|
||||
.sink { [weak self] _ in
|
||||
self?.updateTopPadding()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
scrollToBottomPublisher
|
||||
.sink { [weak self] _ in
|
||||
self?.scrollToBottom(animated: true)
|
||||
@@ -242,9 +249,11 @@ class TimelineTableViewController: UIViewController {
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems(timelineItemsIDs)
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
|
||||
|
||||
// Probably redundant now we observe content size changes…
|
||||
// Leaving in place for the release and will reassess after.
|
||||
updateTopPadding()
|
||||
|
||||
|
||||
if previousLayout.isBottomVisible {
|
||||
scrollToBottom(animated: false)
|
||||
} else if let pinnedItem = previousLayout.pinnedItem {
|
||||
@@ -283,7 +292,8 @@ class TimelineTableViewController: UIViewController {
|
||||
let contentHeight = tableView.contentSize.height - headerHeight
|
||||
let newHeight = max(0, tableView.visibleSize.height - contentHeight)
|
||||
|
||||
guard newHeight != headerHeight else { return }
|
||||
// Round the check to account floating point accuracy during keyboard appearance.
|
||||
guard newHeight.rounded() != headerHeight.rounded() else { return }
|
||||
|
||||
if newHeight > 0 {
|
||||
let frame = CGRect(origin: .zero, size: CGSize(width: tableView.contentSize.width, height: newHeight))
|
||||
|
||||
Reference in New Issue
Block a user