mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Reverting to TableView but with SwiftUI compatibility (#1407)
* revert but also allows us to keep the existing SwiftUI implementation if we need it * code improvement * pr review * FF is volatile * message that communicates that is volatile
This commit is contained in:
@@ -17,10 +17,12 @@ import SwiftUI
|
||||
|
||||
struct RoomTimelineItemView: View {
|
||||
@EnvironmentObject private var context: RoomScreenViewModel.Context
|
||||
let viewState: RoomTimelineItemViewState
|
||||
@ObservedObject var viewState: RoomTimelineItemViewState
|
||||
|
||||
var body: some View {
|
||||
timelineView
|
||||
.animation(.elementDefault, value: viewState.groupStyle)
|
||||
.animation(.elementDefault, value: viewState.type)
|
||||
.environmentObject(context)
|
||||
.environment(\.timelineGroupStyle, viewState.groupStyle)
|
||||
.onAppear {
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct RoomTimelineItemViewState: Identifiable, Equatable {
|
||||
let type: RoomTimelineItemType
|
||||
let groupStyle: TimelineGroupStyle
|
||||
final class RoomTimelineItemViewState: Identifiable, Equatable, ObservableObject {
|
||||
static func == (lhs: RoomTimelineItemViewState, rhs: RoomTimelineItemViewState) -> Bool {
|
||||
lhs.type == rhs.type && lhs.groupStyle == rhs.groupStyle
|
||||
}
|
||||
|
||||
@Published var type: RoomTimelineItemType
|
||||
@Published var groupStyle: TimelineGroupStyle
|
||||
|
||||
/// Contains all the identification info of the item, `timelineID`, `eventID` and `transactionID`
|
||||
var identifier: TimelineItemIdentifier {
|
||||
@@ -33,10 +37,13 @@ struct RoomTimelineItemViewState: Identifiable, Equatable {
|
||||
var isReactable: Bool {
|
||||
type.isReactable
|
||||
}
|
||||
}
|
||||
|
||||
extension RoomTimelineItemViewState {
|
||||
init(item: RoomTimelineItemProtocol, groupStyle: TimelineGroupStyle) {
|
||||
init(type: RoomTimelineItemType, groupStyle: TimelineGroupStyle) {
|
||||
self.type = type
|
||||
self.groupStyle = groupStyle
|
||||
}
|
||||
|
||||
convenience init(item: RoomTimelineItemProtocol, groupStyle: TimelineGroupStyle) {
|
||||
self.init(type: .init(item: item), groupStyle: groupStyle)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user