Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New timeline items #424

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

"settings_appearance" = "Appearance";
"settings_timeline_style" = "Timeline Style";

"room_timeline_style_plain_long_description" = "Plain Timeline";
"room_timeline_style_bubbled_long_description" = "Bubbled Timeline";

Expand All @@ -21,6 +22,8 @@

"room_timeline_context_menu_retry_decryption" = "Retry decryption";

"room_timeline_item_unsupported" = "Unsupported event";

"session_verification_banner_title" = "Help keep your messages secure";
"session_verification_banner_message" = "Looks like you’re using a new device. Verify its you.";

Expand Down
2 changes: 2 additions & 0 deletions ElementX/Sources/Generated/Strings+Untranslated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ extension ElementL10n {
public static let roomTimelineContextMenuRetryDecryption = ElementL10n.tr("Untranslated", "room_timeline_context_menu_retry_decryption")
/// Editing
public static let roomTimelineEditing = ElementL10n.tr("Untranslated", "room_timeline_editing")
/// Unsupported event
public static let roomTimelineItemUnsupported = ElementL10n.tr("Untranslated", "room_timeline_item_unsupported")
/// Failed creating the permalink
public static let roomTimelinePermalinkCreationFailure = ElementL10n.tr("Untranslated", "room_timeline_permalink_creation_failure")
/// Replying to %@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ struct BugReportScreen: View {
Toggle(ElementL10n.sendBugReportIncludeLogs, isOn: $context.sendingLogsEnabled)
.toggleStyle(ElementToggleStyle())
.accessibilityIdentifier("sendLogsToggle")
Text(ElementL10n.sendBugReportIncludeLogs).accessibilityIdentifier("sendLogsText")
Text(ElementL10n.sendBugReportIncludeLogs)
.accessibilityIdentifier("sendLogsText")
}
.onTapGesture {
context.send(viewAction: .toggleSendLogs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ typealias RoomScreenViewModelType = StateStoreViewModel<RoomScreenViewState, Roo

class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol {
private enum Constants {
static let backPaginationEventLimit: UInt = 20
static let backPaginationPageSize: UInt = 50
}

Expand Down Expand Up @@ -121,7 +122,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
// MARK: - Private

private func paginateBackwards() async {
switch await timelineController.paginateBackwards(Constants.backPaginationPageSize) {
switch await timelineController.paginateBackwards(requestSize: Constants.backPaginationEventLimit, untilNumberOfItems: Constants.backPaginationPageSize) {
case .failure:
displayError(.alert(ElementL10n.roomTimelineBackpaginationFailure))
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {

@ViewBuilder
var styledContentOutgoing: some View {
let topPadding: CGFloat? = timelineItem.inGroupState == .single || timelineItem.inGroupState == .beginning ? 8 : 0
let topPadding: CGFloat? = timelineItem.groupState == .single || timelineItem.groupState == .beginning ? 8 : 0

if shouldAvoidBubbling {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import SwiftUI
struct TimelineDeliveryStatusView: View {
let deliveryStatus: MessageTimelineItemDeliveryStatus
let deliveryStatus: TimelineItemDeliveryStatus

@State var showDeliveryStatus: Bool

Expand All @@ -29,7 +29,7 @@ struct TimelineDeliveryStatusView: View {
}
}

init(deliveryStatus: MessageTimelineItemDeliveryStatus) {
init(deliveryStatus: TimelineItemDeliveryStatus) {
self.deliveryStatus = deliveryStatus

switch deliveryStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ struct EmoteRoomTimelineView: View {
}
}
}
.id(timelineItem.id)
}
}

Expand All @@ -57,7 +56,7 @@ struct EmoteRoomTimelineView_Previews: PreviewProvider {
EmoteRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: senderId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@ struct EncryptedRoomTimelineView: View {
Button {
showEncryptionInfo = !showEncryptionInfo
} label: {
HStack(alignment: .top) {
Image(systemName: "lock.shield")
.foregroundColor(.red)
.padding(.top, 1.0)
Label {
if showEncryptionInfo {
FormattedBodyText(text: encryptionDetails)
} else {
FormattedBodyText(text: timelineItem.text)
}
} icon: {
Image(systemName: "lock.shield")
.foregroundColor(.red)
}
.animation(nil, value: showEncryptionInfo)
}
}
.id(timelineItem.id)
}

private var encryptionDetails: String {
Expand Down Expand Up @@ -79,7 +78,7 @@ struct EncryptedRoomTimelineView_Previews: PreviewProvider {
text: text,
encryptionType: .unknown,
timestamp: timestamp,
inGroupState: .single,
groupState: .single,
isOutgoing: isOutgoing,
isEditable: false,
senderId: senderId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ struct FileRoomTimelineView: View {
.padding(.vertical, 12)
.padding(.horizontal, 6)
}
.id(timelineItem.id)
}
}

Expand All @@ -45,7 +44,7 @@ struct FileRoomTimelineView_Previews: PreviewProvider {
FileRoomTimelineView(timelineItem: FileRoomTimelineItem(id: UUID().uuidString,
text: "document.pdf",
timestamp: "Now",
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: "Bob",
Expand All @@ -55,7 +54,7 @@ struct FileRoomTimelineView_Previews: PreviewProvider {
FileRoomTimelineView(timelineItem: FileRoomTimelineItem(id: UUID().uuidString,
text: "document.docx",
timestamp: "Now",
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: "Bob",
Expand All @@ -65,7 +64,7 @@ struct FileRoomTimelineView_Previews: PreviewProvider {
FileRoomTimelineView(timelineItem: FileRoomTimelineItem(id: UUID().uuidString,
text: "document.txt",
timestamp: "Now",
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: "Bob",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ struct ImageRoomTimelineView: View {
.aspectRatio(timelineItem.aspectRatio, contentMode: .fit)
}
}
.id(timelineItem.id)
.animation(.elementDefault, value: timelineItem.image)
}
}
Expand All @@ -60,7 +59,7 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
text: "Some image",
timestamp: "Now",
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: "Bob",
Expand All @@ -70,7 +69,7 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
text: "Some other image",
timestamp: "Now",
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: "Bob",
Expand All @@ -80,7 +79,7 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
text: "Blurhashed image",
timestamp: "Now",
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: "Bob",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ struct NoticeRoomTimelineView: View {
}
}
}
.id(timelineItem.id)
}
}

Expand All @@ -57,7 +56,7 @@ struct NoticeRoomTimelineView_Previews: PreviewProvider {
NoticeRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: senderId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright 2022 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

struct PaginationIndicatorRoomTimelineView: View {
let timelineItem: PaginationIndicatorRoomTimelineItem

var body: some View {
ProgressView()
.frame(maxWidth: .infinity)
}
}

struct PaginationIndicatorRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
let item = PaginationIndicatorRoomTimelineItem()
PaginationIndicatorRoomTimelineView(timelineItem: item)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct ReadMarkerRoomTimelineView: View {
VStack {
Spacer(minLength: 4.0)
Divider()
.id(timelineItem.id)
.frame(maxWidth: .infinity)
.overlay(Color.element.accent)
}
Expand All @@ -33,7 +32,7 @@ struct ReadMarkerRoomTimelineView: View {

struct ReadMarkerRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
let item = ReadMarkerRoomTimelineItem(id: UUID().uuidString)
let item = ReadMarkerRoomTimelineItem()
ReadMarkerRoomTimelineView(timelineItem: item)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct RedactedRoomTimelineView: View {
FormattedBodyText(text: timelineItem.text)
}
}
.id(timelineItem.id)
}
}

Expand All @@ -44,7 +43,7 @@ struct RedactedRoomTimelineView_Previews: PreviewProvider {
RedactedRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
inGroupState: .single,
groupState: .single,
isOutgoing: false,
isEditable: false,
senderId: senderId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//

import Foundation
import SwiftUI

struct SeparatorRoomTimelineView: View {
Expand All @@ -24,15 +23,14 @@ struct SeparatorRoomTimelineView: View {
Text(timelineItem.text)
.font(.element.footnote)
.foregroundColor(.element.secondaryContent)
.id(timelineItem.id)
.padding(.vertical, 24)
.frame(maxWidth: .infinity)
}
}

struct SeparatorRoomTimelineView_Previews: PreviewProvider {
static var previews: some View {
let item = SeparatorRoomTimelineItem(id: UUID().uuidString, text: "This is a separator")
let item = SeparatorRoomTimelineItem(text: "This is a separator")
SeparatorRoomTimelineView(timelineItem: item)
}
}
Loading