Some Post-demo Cleanups (#200)

* Remove redundant string

* Use placeholder avatar on home screen

* Add initial home screen ui test

* Fix settings screen PR remarks

* Remove UIKit alert from home screen sign out

* Remove UIKit alert from soft logout clear all data

* Add reference screenshots for home screen UI tests

* Formatting fixes

* Add clearing room method to client proxy

* Clear room proxies on screen dismiss

* Fix retain cycle in room view model

* Do not go into authentication state immediately

* Define sizes for user and room avatars on different screens

* Use defined avatar sizes everywhere

* Disable image disk caching

* Rename rounded corner shape

* Fix text color of placeholder avatars

* Fix PR reviews on formatted body text

* Fix merge conflict

* Remove shouldShowSenderDetails everywhere and just use it from inGroupState

* Remove redundant linter disablings

* Fix PR remarks

* Rename media provider size parameter
This commit is contained in:
ismailgulek
2022-09-23 12:21:41 +03:00
committed by GitHub
parent b9f8fb0b6f
commit bdc83dac27
54 changed files with 307 additions and 204 deletions
@@ -42,7 +42,7 @@ struct RoomHeaderView: View {
.accessibilityIdentifier("encryptionBadgeIcon")
}
}
.frame(width: 32.0, height: 32.0)
.frame(width: AvatarSize.room(on: .timeline).value, height: AvatarSize.room(on: .timeline).value)
}
@ViewBuilder private var roomAvatarImage: some View {
@@ -41,6 +41,9 @@ struct RoomScreen: View {
}
}
.alert(item: $context.alertInfo) { $0.alert }
.onDisappear {
context.send(viewAction: .viewDisappeared)
}
}
private func sendMessage() {
@@ -144,7 +144,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
.background(Color.element.systemGray6) // Demo time!
.cornerRadius(12, inGroupState: timelineItem.inGroupState) // Demo time!
// .overlay(
// RoundedCorner(radius: 18, inGroupState: timelineItem.inGroupState)
// RoundedCornerShape(radius: 18, inGroupState: timelineItem.inGroupState)
// .stroke(Color.element.systemGray5)
// )
}
@@ -58,7 +58,6 @@ struct EmoteRoomTimelineView_Previews: PreviewProvider {
EmoteRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
shouldShowSenderDetails: true,
inGroupState: .single,
isOutgoing: false,
senderId: senderId)
@@ -26,25 +26,13 @@ struct FormattedBodyText: View {
VStack(alignment: .leading, spacing: 8.0) {
ForEach(attributedComponents, id: \.self) { component in
if component.isBlockquote {
if isOutgoing {
Text(component.attributedString)
.fixedSize(horizontal: false, vertical: true)
.foregroundColor(.element.primaryContent)
.padding(EdgeInsets(top: 6, leading: 12, bottom: 6, trailing: 12))
.clipped()
.background(Color.element.systemGray4)
.cornerRadius(13)
} else {
Text(component.attributedString)
.fixedSize(horizontal: false, vertical: true)
.foregroundColor(.element.primaryContent)
.padding(EdgeInsets(top: 8, leading: 12, bottom: 8, trailing: 12))
.clipped()
.overlay(
RoundedRectangle(cornerRadius: 13)
.stroke(Color.element.systemGray5)
)
}
Text(component.attributedString.mergingAttributes(blockquoteAttributes))
.fixedSize(horizontal: false, vertical: true)
.foregroundColor(.element.primaryContent)
.padding(EdgeInsets(top: 6, leading: 12, bottom: 6, trailing: 12))
.clipped()
.background(Color.element.systemGray4)
.cornerRadius(13)
} else {
Text(component.attributedString)
.fixedSize(horizontal: false, vertical: true)
@@ -54,6 +42,12 @@ struct FormattedBodyText: View {
}
.tint(.element.accent)
}
private var blockquoteAttributes: AttributeContainer {
var container = AttributeContainer()
container.font = .element.caption1
return container
}
}
extension FormattedBodyText {
@@ -62,7 +62,6 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
text: "Some image",
timestamp: "Now",
shouldShowSenderDetails: false,
inGroupState: .single,
isOutgoing: false,
senderId: "Bob",
@@ -72,7 +71,6 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
text: "Some other image",
timestamp: "Now",
shouldShowSenderDetails: false,
inGroupState: .single,
isOutgoing: false,
senderId: "Bob",
@@ -82,7 +80,6 @@ struct ImageRoomTimelineView_Previews: PreviewProvider {
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: UUID().uuidString,
text: "Blurhashed image",
timestamp: "Now",
shouldShowSenderDetails: false,
inGroupState: .single,
isOutgoing: false,
senderId: "Bob",
@@ -59,7 +59,6 @@ struct NoticeRoomTimelineView_Previews: PreviewProvider {
NoticeRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
shouldShowSenderDetails: true,
inGroupState: .single,
isOutgoing: false,
senderId: senderId)
@@ -25,7 +25,7 @@ struct PlaceholderAvatarImage: View {
bgColor
Text(textForImage)
.padding(4)
.foregroundColor(.element.background)
.foregroundColor(.white)
.font(.title2.bold())
}
.aspectRatio(1, contentMode: .fill)
@@ -51,7 +51,6 @@ struct RedactedRoomTimelineView_Previews: PreviewProvider {
RedactedRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
shouldShowSenderDetails: true,
inGroupState: .single,
isOutgoing: false,
senderId: senderId)
@@ -43,26 +43,22 @@ struct TextRoomTimelineView_Previews: PreviewProvider {
VStack(alignment: .leading, spacing: 20.0) {
TextRoomTimelineView(timelineItem: itemWith(text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
timestamp: "Now",
shouldShowSenderDetails: true,
isOutgoing: false,
senderId: "Bob"))
TextRoomTimelineView(timelineItem: itemWith(text: "Some other text",
timestamp: "Later",
shouldShowSenderDetails: true,
isOutgoing: true,
senderId: "Anne"))
TextRoomTimelineView(timelineItem: itemWith(text: "Short loin ground round tongue hamburger, fatback salami shoulder. Beef turkey sausage kielbasa strip steak. Alcatra capicola pig tail pancetta chislic.",
timestamp: "Now",
shouldShowSenderDetails: true,
isOutgoing: false,
senderId: "Bob"))
.timelineStyle(.plain)
TextRoomTimelineView(timelineItem: itemWith(text: "Some other text",
timestamp: "Later",
shouldShowSenderDetails: true,
isOutgoing: true,
senderId: "Anne"))
.timelineStyle(.plain)
@@ -70,11 +66,10 @@ struct TextRoomTimelineView_Previews: PreviewProvider {
.padding(.horizontal, 8)
}
private static func itemWith(text: String, timestamp: String, shouldShowSenderDetails: Bool, isOutgoing: Bool, senderId: String) -> TextRoomTimelineItem {
private static func itemWith(text: String, timestamp: String, isOutgoing: Bool, senderId: String) -> TextRoomTimelineItem {
TextRoomTimelineItem(id: UUID().uuidString,
text: text,
timestamp: timestamp,
shouldShowSenderDetails: shouldShowSenderDetails,
inGroupState: .single,
isOutgoing: isOutgoing,
senderId: senderId)
@@ -20,7 +20,7 @@ import SwiftUI
struct TimelineSenderAvatarView: View {
let timelineItem: EventBasedTimelineItemProtocol
@ScaledMetric private var avatarSize = 32
@ScaledMetric private var avatarSize = AvatarSize.user(on: .timeline).value
var body: some View {
ZStack(alignment: .center) {