mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
tombstoned and upgraded rooms implementation
added tests tombstoned room avatar
This commit is contained in:
+43
-6
@@ -5,20 +5,50 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct TimelineStartRoomTimelineView: View {
|
||||
let timelineItem: TimelineStartRoomTimelineItem
|
||||
@Environment(\.timelineContext) private var context
|
||||
|
||||
var body: some View {
|
||||
Text(title)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.padding(.vertical, 24)
|
||||
.frame(maxWidth: .infinity)
|
||||
VStack(spacing: 14) {
|
||||
if context?.viewState.hasPredecessor == true {
|
||||
upgrade
|
||||
}
|
||||
if context?.viewState.isDirectOneToOneRoom != true {
|
||||
Text(title)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.padding(.bottom, 24)
|
||||
.padding(.top, context?.viewState.hasPredecessor == true ? 0 : 24)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var title: String {
|
||||
private var upgrade: some View {
|
||||
VStack(spacing: 16) {
|
||||
Text(L10n.screenRoomTimelineUpgradedRoomMessage)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
Button {
|
||||
context?.send(viewAction: .seePredecessorTapped)
|
||||
} label: {
|
||||
Text(L10n.screenRoomTimelineUpgradedRoomAction)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.compound(.primary, size: .medium))
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.padding(.top, 16)
|
||||
.padding(.bottom, 8)
|
||||
.padding(.horizontal, 16)
|
||||
.highlight(borderColor: .compound.borderInfoSubtle, primaryColor: .compound.bgInfoSubtle, secondaryColor: Color.clear)
|
||||
}
|
||||
|
||||
private var title: String {
|
||||
var text = L10n.screenRoomTimelineBeginningOfRoomNoName
|
||||
if let name = timelineItem.name {
|
||||
text = L10n.screenRoomTimelineBeginningOfRoom(name)
|
||||
@@ -28,8 +58,15 @@ struct TimelineStartRoomTimelineView: View {
|
||||
}
|
||||
|
||||
struct TimelineStartRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = TimelineViewModel.mock(hasPredecessor: true)
|
||||
|
||||
static var previews: some View {
|
||||
let item = TimelineStartRoomTimelineItem(name: "Alice and Bob")
|
||||
TimelineStartRoomTimelineView(timelineItem: item)
|
||||
.previewLayout(.sizeThatFits)
|
||||
TimelineStartRoomTimelineView(timelineItem: item)
|
||||
.environment(\.timelineContext, viewModel.context)
|
||||
.previewLayout(.sizeThatFits)
|
||||
.previewDisplayName("with predecessor")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user