-
-
Notifications
You must be signed in to change notification settings - Fork 15
refactor(ui): improve chat and node list row layout #236
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
base: dev
Are you sure you want to change the base?
Changes from all commits
b1db6a8
802300e
a74d965
4d468db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import SwiftUI | ||
|
|
||
| extension View { | ||
| /// Adds a trailing chevron aligned with the top row of a list item. | ||
| /// Used with hidden NavigationLink pattern to control chevron positioning. | ||
| func listChevron(offset: CGFloat = -8) -> some View { | ||
| HStack(spacing: 12) { | ||
| self | ||
| Image(systemName: "chevron.right") | ||
| .font(.caption.weight(.semibold)) | ||
| .foregroundStyle(.tertiary) | ||
| .offset(y: offset) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,24 +9,27 @@ struct ChannelConversationRow: View { | |
| var body: some View { | ||
| HStack(spacing: 12) { | ||
| ChannelAvatar(channel: channel, size: 44) | ||
| .overlay(alignment: .topTrailing) { | ||
| UnreadCountBadge(count: channel.unreadCount) | ||
| } | ||
|
|
||
| VStack(alignment: .leading, spacing: 4) { | ||
| HStack(spacing: 4) { | ||
| Text(channel.name.isEmpty ? L10n.Chats.Chats.Channel.defaultName(Int(channel.index)) : channel.name) | ||
| .font(.headline) | ||
| .lineLimit(1) | ||
|
|
||
| Spacer() | ||
|
|
||
| NotificationLevelIndicator(level: channel.notificationLevel) | ||
|
|
||
| if channel.isFavorite { | ||
| Image(systemName: "star.fill") | ||
| .foregroundStyle(.yellow) | ||
| .font(.caption) | ||
| .font(.system(size: 13.2)) | ||
| .accessibilityLabel(Strings.favorite) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| NotificationLevelIndicator(level: channel.notificationLevel) | ||
|
|
||
| if let date = channel.lastMessageDate { | ||
| ConversationTimestamp(date: date) | ||
| } | ||
|
|
@@ -39,12 +42,6 @@ struct ChannelConversationRow: View { | |
| .lineLimit(1) | ||
|
|
||
| Spacer() | ||
|
|
||
| UnreadBadges( | ||
| unreadCount: channel.unreadCount, | ||
| unreadMentionCount: channel.unreadMentionCount, | ||
| notificationLevel: channel.notificationLevel | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this will remove the ability to color the unread badge based on the set notification level |
||
| ) | ||
| } | ||
| } | ||
| .alignmentGuide(.listRowSeparatorLeading) { d in | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,27 +8,30 @@ struct ConversationRow: View { | |
| var body: some View { | ||
| HStack(spacing: 12) { | ||
| ContactAvatar(contact: contact, size: 44) | ||
| .overlay(alignment: .topTrailing) { | ||
| UnreadCountBadge(count: contact.unreadCount) | ||
| } | ||
|
|
||
| VStack(alignment: .leading, spacing: 4) { | ||
| HStack(spacing: 4) { | ||
| Text(contact.displayName) | ||
| .font(.headline) | ||
| .lineLimit(1) | ||
|
|
||
| Spacer() | ||
|
|
||
| MutedIndicator(isMuted: contact.isMuted) | ||
|
|
||
| if viewModel.togglingFavoriteID == contact.id { | ||
| ProgressView() | ||
| .controlSize(.small) | ||
| } else if contact.isFavorite { | ||
| Image(systemName: "star.fill") | ||
| .foregroundStyle(.yellow) | ||
| .font(.caption) | ||
| .font(.system(size: 13.2)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use specific font sizes, stick with dynamic. To make it a little larger than |
||
| .accessibilityLabel(L10n.Chats.Chats.Row.favorite) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| MutedIndicator(isMuted: contact.isMuted) | ||
|
|
||
| if let date = contact.lastMessageDate { | ||
| ConversationTimestamp(date: date) | ||
| } | ||
|
|
@@ -41,12 +44,6 @@ struct ConversationRow: View { | |
| .lineLimit(1) | ||
|
|
||
| Spacer() | ||
|
|
||
| UnreadBadges( | ||
| unreadCount: contact.unreadCount, | ||
| unreadMentionCount: contact.unreadMentionCount, | ||
| notificationLevel: contact.isMuted ? .muted : .all | ||
| ) | ||
| } | ||
| } | ||
| .alignmentGuide(.listRowSeparatorLeading) { d in | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,13 @@ struct ConversationTimestamp: View { | |
| if calendar.isDateInToday(date) { | ||
| return date.formatted(date: .omitted, time: .shortened) | ||
| } else if calendar.isDateInYesterday(date) { | ||
| return date.formatted(.relative(presentation: .named)) | ||
| } else { | ||
| return "Yesterday" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't hard code strings, use |
||
| } else if let daysAgo = calendar.dateComponents([.day], from: date, to: now).day, daysAgo < 7 { | ||
| return date.formatted(.dateTime.weekday(.wide)) | ||
| } else if calendar.component(.year, from: date) == calendar.component(.year, from: now) { | ||
| return date.formatted(.dateTime.month(.abbreviated).day()) | ||
| } else { | ||
| return date.formatted(.dateTime.month(.abbreviated).day().year()) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,26 +5,29 @@ struct RoomConversationRow: View { | |
| let session: RemoteNodeSessionDTO | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 12) { | ||
| HStack(alignment: .center, spacing: 12) { | ||
| NodeAvatar(publicKey: session.publicKey, role: .roomServer, size: 44) | ||
| .overlay(alignment: .topTrailing) { | ||
| UnreadCountBadge(count: session.unreadCount) | ||
| } | ||
|
|
||
| VStack(alignment: .leading, spacing: 4) { | ||
| HStack(spacing: 4) { | ||
| Text(session.name) | ||
| .font(.headline) | ||
| .lineLimit(1) | ||
|
|
||
| Spacer() | ||
|
|
||
| NotificationLevelIndicator(level: session.notificationLevel) | ||
|
|
||
| if session.isFavorite { | ||
| Image(systemName: "star.fill") | ||
| .foregroundStyle(.yellow) | ||
| .font(.caption) | ||
| .font(.system(size: 13.2)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use dynamic type |
||
| .accessibilityLabel(L10n.Chats.Chats.Row.favorite) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| NotificationLevelIndicator(level: session.notificationLevel) | ||
|
|
||
| if let date = session.lastMessageDate { | ||
| ConversationTimestamp(date: date) | ||
| } | ||
|
|
@@ -42,11 +45,6 @@ struct RoomConversationRow: View { | |
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| UnreadBadges( | ||
| unreadCount: session.unreadCount, | ||
| notificationLevel: session.notificationLevel | ||
| ) | ||
| } | ||
| } | ||
| .alignmentGuide(.listRowSeparatorLeading) { d in | ||
|
|
@@ -56,6 +54,7 @@ struct RoomConversationRow: View { | |
| Image(systemName: "chevron.right") | ||
| .font(.caption.weight(.semibold)) | ||
| .foregroundStyle(.tertiary) | ||
| .offset(y: -11) | ||
| } | ||
| .padding(.vertical, 4) | ||
| .contentShape(.rect) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import SwiftUI | ||
|
|
||
| /// Red badge with unread count, displayed as an overlay on avatars. | ||
| /// Matches iOS app icon badge style. | ||
| struct UnreadCountBadge: View { | ||
| let count: Int | ||
|
|
||
| var body: some View { | ||
| if count > 0 { | ||
| Text(count, format: .number) | ||
| .font(.caption2.bold()) | ||
| .foregroundStyle(.white) | ||
| .padding(.horizontal, 4) | ||
| .frame(minWidth: 18, minHeight: 18) | ||
| .background(.red, in: .capsule) | ||
| .offset(x: 4, y: -4) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #Preview { | ||
| VStack(spacing: 20) { | ||
| Circle() | ||
| .fill(.blue) | ||
| .frame(width: 44, height: 44) | ||
| .overlay(alignment: .topTrailing) { | ||
| UnreadCountBadge(count: 3) | ||
| } | ||
|
|
||
| Circle() | ||
| .fill(.blue) | ||
| .frame(width: 44, height: 44) | ||
| .overlay(alignment: .topTrailing) { | ||
| UnreadCountBadge(count: 42) | ||
| } | ||
|
|
||
| Circle() | ||
| .fill(.blue) | ||
| .frame(width: 44, height: 44) | ||
| .overlay(alignment: .topTrailing) { | ||
| UnreadCountBadge(count: 0) | ||
| } | ||
| } | ||
| .padding() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,18 +40,18 @@ struct ContactRowView: View { | |
| .accessibilityLabel(L10n.Contacts.Contacts.Row.blocked) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| if isTogglingFavorite { | ||
| ProgressView() | ||
| .controlSize(.small) | ||
| } else if contact.isFavorite { | ||
| Image(systemName: "star.fill") | ||
| .font(.caption) | ||
| .font(.system(size: 13.2)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, use dynamic type. |
||
| .foregroundStyle(.yellow) | ||
| .accessibilityLabel(L10n.Contacts.Contacts.Row.favorite) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| RelativeTimestampText(timestamp: contact.lastAdvertTimestamp) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this removed? This will remove the "@" badge that appears when a user was mentioned in a chat/channel.