mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -117,8 +117,8 @@ struct TimelineViewState: BindableState {
|
||||
|
||||
let hasPredecessor: Bool
|
||||
|
||||
// The `pinnedEventIDs` are used only to determine if an item is already pinned or not.
|
||||
// It's updated from the room info, so it's faster than using the timeline
|
||||
/// The `pinnedEventIDs` are used only to determine if an item is already pinned or not.
|
||||
/// It's updated from the room info, so it's faster than using the timeline
|
||||
var pinnedEventIDs: Set<String> = []
|
||||
|
||||
/// A closure providing the associated audio player state for an item in the timeline.
|
||||
@@ -234,7 +234,7 @@ struct TimelineState {
|
||||
/// A focussed event that was navigated to via a permalink.
|
||||
var focussedEvent: FocussedEvent?
|
||||
|
||||
// These can be removed when we have full swiftUI and moved as @State values in the view
|
||||
/// These can be removed when we have full swiftUI and moved as @State values in the view
|
||||
var scrollToBottomPublisher = PassthroughSubject<Void, Never>()
|
||||
|
||||
var itemsDictionary = OrderedDictionary<TimelineItemIdentifier.UniqueID, RoomTimelineItemViewState>()
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
import Combine
|
||||
import Compound
|
||||
import MatrixRustSDK
|
||||
import SwiftUI
|
||||
|
||||
import OrderedCollections
|
||||
import SwiftUI
|
||||
|
||||
/// A table view cell that displays a timeline item in a room. The cell is intended
|
||||
/// to be configured to display a SwiftUI view and not use any UIKit.
|
||||
@@ -238,7 +237,9 @@ class TimelineTableViewController: UIViewController {
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) is not available.") }
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) is not available.")
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
@@ -48,8 +48,8 @@ struct TimelineItemMenuReaction: Hashable {
|
||||
let key: String
|
||||
let symbol: SFSymbol
|
||||
|
||||
// Frequently used emojis on the all use the same .heart SFSymbol.
|
||||
// Override equatable so we can remove duplicates.
|
||||
/// Frequently used emojis on the all use the same .heart SFSymbol.
|
||||
/// Override equatable so we can remove duplicates.
|
||||
static func == (lhs: TimelineItemMenuReaction, rhs: TimelineItemMenuReaction) -> Bool {
|
||||
lhs.key == rhs.key
|
||||
}
|
||||
@@ -80,7 +80,9 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
case share
|
||||
case save
|
||||
|
||||
var id: Self { self }
|
||||
var id: Self {
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether the item should cancel a reply/edit occurring in the composer.
|
||||
var switchToDefaultComposer: Bool {
|
||||
|
||||
@@ -62,9 +62,10 @@ struct PollView: View {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private var senderString: String { poll.createdByAccountOwner ? L10n.commonYou : sender.disambiguatedDisplayName ?? sender.id }
|
||||
private var senderString: String {
|
||||
poll.createdByAccountOwner ? L10n.commonYou : sender.disambiguatedDisplayName ?? sender.id
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var accessibleQuestionView: some View {
|
||||
questionView
|
||||
.accessibilityRepresentation {
|
||||
|
||||
@@ -44,18 +44,17 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview {
|
||||
.mockDan
|
||||
]
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members))
|
||||
let mock = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
return mock
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
static let orderedReadReceipts: [ReadReceipt] = [
|
||||
|
||||
@@ -31,8 +31,8 @@ struct LongPressWithFeedback: ViewModifier {
|
||||
})
|
||||
}
|
||||
|
||||
// The gesture's minimum duration doesn't actually invoke the perform block when elapsed (thus
|
||||
// the implementation below) but it does cancel other system gestures e.g. swipe to reply
|
||||
/// The gesture's minimum duration doesn't actually invoke the perform block when elapsed (thus
|
||||
/// the implementation below) but it does cancel other system gestures e.g. swipe to reply
|
||||
private func handleLongPress(isPressing: Bool) {
|
||||
isLongPressing = isPressing
|
||||
|
||||
@@ -56,7 +56,6 @@ struct LongPressWithFeedback: ViewModifier {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func mainContent(content: Content) -> some View {
|
||||
content
|
||||
.compositingGroup() // Apply the shadow to the view as a whole.
|
||||
@@ -76,7 +75,9 @@ extension View {
|
||||
}
|
||||
|
||||
struct LongPressWithFeedback_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View { Preview() }
|
||||
static var previews: some View {
|
||||
Preview()
|
||||
}
|
||||
|
||||
struct Preview: View {
|
||||
private let viewModel = TimelineViewModel.mock
|
||||
@@ -123,12 +124,14 @@ struct LongPressWithFeedback_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
}
|
||||
|
||||
// Fixes the issue on iOS 18 where LongPress conflicts with the scroll view
|
||||
// https://github.com/feedback-assistant/reports/issues/542#issuecomment-2581322968
|
||||
/// Fixes the issue on iOS 18 where LongPress conflicts with the scroll view
|
||||
/// https://github.com/feedback-assistant/reports/issues/542#issuecomment-2581322968
|
||||
private struct LongPressGestureRepresentable: UIGestureRecognizerRepresentable {
|
||||
var handle: (UILongPressGestureRecognizer) -> Void
|
||||
|
||||
func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { .init() }
|
||||
func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator {
|
||||
.init()
|
||||
}
|
||||
|
||||
func makeUIGestureRecognizer(context: Context) -> UILongPressGestureRecognizer {
|
||||
let gesture = UILongPressGestureRecognizer()
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct ThreadDecorator: View {
|
||||
var body: some View {
|
||||
|
||||
@@ -12,7 +12,6 @@ private struct TimelineItemAccessibilityModifier: ViewModifier {
|
||||
let timelineItem: RoomTimelineItemProtocol
|
||||
let action: () -> Void
|
||||
|
||||
@ViewBuilder
|
||||
func body(content: Content) -> some View {
|
||||
switch timelineItem {
|
||||
case is PollRoomTimelineItem:
|
||||
|
||||
@@ -18,8 +18,14 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
||||
let adjustedDeliveryStatus: TimelineItemDeliveryStatus?
|
||||
@ViewBuilder let content: () -> Content
|
||||
|
||||
private var isDirectOneToOneRoom: Bool { context.viewState.isDirectOneToOneRoom }
|
||||
private var isFocussed: Bool { focussedEventID != nil && timelineItem.id.eventID == focussedEventID }
|
||||
private var isDirectOneToOneRoom: Bool {
|
||||
context.viewState.isDirectOneToOneRoom
|
||||
}
|
||||
|
||||
private var isFocussed: Bool {
|
||||
focussedEventID != nil && timelineItem.id.eventID == focussedEventID
|
||||
}
|
||||
|
||||
private var isPinned: Bool {
|
||||
guard context.viewState.timelineKind != .pinned,
|
||||
let eventID = timelineItem.id.eventID else {
|
||||
@@ -179,7 +185,6 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
||||
color: timelineItem.bubbleBackgroundColor)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var contentWithReply: some View {
|
||||
TimelineBubbleLayout(spacing: 8) {
|
||||
if !context.viewState.timelineKind.isThread, timelineItem.properties.isThreaded {
|
||||
|
||||
@@ -96,7 +96,6 @@ private struct TimelineItemSendInfoLabel: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var content: some View {
|
||||
HStack(spacing: 4) {
|
||||
Text(sendInfo.localizedString)
|
||||
|
||||
@@ -49,7 +49,6 @@ struct TimelineStyler<Content: View>: View {
|
||||
.animation(.elementDefault, value: adjustedDeliveryStatus)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var mainContent: some View {
|
||||
TimelineItemBubbledStylerView(timelineItem: timelineItem, adjustedDeliveryStatus: adjustedDeliveryStatus, content: content)
|
||||
}
|
||||
@@ -99,14 +98,13 @@ struct TimelineItemStyler_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
static let sentLast: TextRoomTimelineItem = {
|
||||
let id = viewModel.state.timelineState.uniqueIDs.last ?? .init(UUID().uuidString)
|
||||
let result = TextRoomTimelineItem(id: .event(uniqueID: id, eventOrTransactionID: .eventID(UUID().uuidString)),
|
||||
timestamp: .mock,
|
||||
isOutgoing: true,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
sender: .test,
|
||||
content: .init(body: "Test"))
|
||||
return result
|
||||
return TextRoomTimelineItem(id: .event(uniqueID: id, eventOrTransactionID: .eventID(UUID().uuidString)),
|
||||
timestamp: .mock,
|
||||
isOutgoing: true,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
sender: .test,
|
||||
content: .init(body: "Test"))
|
||||
}()
|
||||
|
||||
static let ltrString = TextRoomTimelineItem(id: .randomEvent,
|
||||
|
||||
@@ -67,7 +67,6 @@ struct TimelineItemDebugView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var disclosureGroupContent: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Divider()
|
||||
|
||||
+2
-4
@@ -45,10 +45,8 @@ struct CallNotificationRoomTimelineView: View {
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
.padding(12)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.stroke(.compound.borderInteractiveSecondary, lineWidth: 1)
|
||||
)
|
||||
.overlay(RoundedRectangle(cornerRadius: 8)
|
||||
.stroke(.compound.borderInteractiveSecondary, lineWidth: 1))
|
||||
.padding(16)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ struct FormattedBodyText: View {
|
||||
boostFontSize: boostFontSize)
|
||||
}
|
||||
|
||||
// These is needed to create the slightly off inlined timestamp effect
|
||||
/// These is needed to create the slightly off inlined timestamp effect
|
||||
private var additionalWhitespacesSuffix: String {
|
||||
.generateBreakableWhitespaceEnd(whitespaceCount: additionalWhitespacesCount, layoutDirection: layoutDirection)
|
||||
}
|
||||
@@ -68,7 +68,6 @@ struct FormattedBodyText: View {
|
||||
.accessibilityLabel(Text(attributedString))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var mainContent: some View {
|
||||
layout
|
||||
.tint(.compound.textLinkExternal)
|
||||
|
||||
+3
-1
@@ -13,7 +13,9 @@ struct ImageRoomTimelineView: View {
|
||||
@Environment(\.timelineContext) private var context
|
||||
let timelineItem: ImageRoomTimelineItem
|
||||
|
||||
var hasMediaCaption: Bool { timelineItem.content.caption != nil }
|
||||
var hasMediaCaption: Bool {
|
||||
timelineItem.content.caption != nil
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
TimelineStyler(timelineItem: timelineItem) {
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
import OrderedCollections
|
||||
import SwiftUI
|
||||
|
||||
struct TextRoomTimelineView: View, TextBasedRoomTimelineViewProtocol {
|
||||
static let maxLinkPreviewsToRender = 2
|
||||
|
||||
+3
-1
@@ -13,7 +13,9 @@ struct VideoRoomTimelineView: View {
|
||||
@Environment(\.timelineContext) private var context
|
||||
let timelineItem: VideoRoomTimelineItem
|
||||
|
||||
private var hasMediaCaption: Bool { timelineItem.content.caption != nil }
|
||||
private var hasMediaCaption: Bool {
|
||||
timelineItem.content.caption != nil
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
TimelineStyler(timelineItem: timelineItem) {
|
||||
|
||||
@@ -81,10 +81,9 @@ struct TimelineViewRepresentable: UIViewControllerRepresentable {
|
||||
@EnvironmentObject private var viewModelContext: TimelineViewModel.Context
|
||||
|
||||
func makeUIViewController(context: Context) -> TimelineTableViewController {
|
||||
let tableViewController = TimelineTableViewController(coordinator: context.coordinator,
|
||||
isScrolledToBottom: $viewModelContext.isScrolledToBottom,
|
||||
scrollToBottomPublisher: viewModelContext.viewState.timelineState.scrollToBottomPublisher)
|
||||
return tableViewController
|
||||
TimelineTableViewController(coordinator: context.coordinator,
|
||||
isScrolledToBottom: $viewModelContext.isScrolledToBottom,
|
||||
scrollToBottomPublisher: viewModelContext.viewState.timelineState.scrollToBottomPublisher)
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: TimelineTableViewController, context: Context) {
|
||||
|
||||
Reference in New Issue
Block a user