From 243cbcbc41e782f58c5012dbf8701cf2f932498a Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 29 Jan 2023 16:06:46 +0100 Subject: [PATCH] Notifications: Swap container for a List + make mentions more prominent --- .../Notifications/NotificationRowView.swift | 3 ++ .../Notifications/NotificationsListView.swift | 48 +++++++++++-------- .../Status/Row/StatusActionsView.swift | 1 + 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift index cc263912..429177a9 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift @@ -32,6 +32,9 @@ struct NotificationRowView: View { } } } + .alignmentGuide(.listRowSeparatorLeading) { viewDimensions in + return -100 + } } private func makeAvatarView(type: Models.Notification.NotificationType) -> some View { diff --git a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift index 21cb1244..268797f8 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift @@ -19,14 +19,12 @@ public struct NotificationsListView: View { } public var body: some View { - ScrollView { - LazyVStack { - notificationsView - .frame(maxWidth: .maxColumnWidth) - } - .padding(.top, .layoutPadding + 16) - .background(theme.primaryBackgroundColor) + List { + topPaddingView + notificationsView } + .environment(\.defaultMinListRowHeight, 1) + .listStyle(.plain) .navigationTitle(lockedType?.menuTitle() ?? viewModel.selectedType?.menuTitle() ?? "notifications.navigation-title") .navigationBarTitleDisplayMode(.inline) .toolbar { @@ -84,13 +82,12 @@ public struct NotificationsListView: View { ForEach(ConsolidatedNotification.placeholders()) { notification in NotificationRowView(notification: notification) .redacted(reason: .placeholder) - .padding(.leading, .layoutPadding + 4) - .padding(.trailing, .layoutPadding) - .padding(.top, 6) - .padding(.bottom, 2) + .listRowInsets(.init(top: 12, + leading: .layoutPadding + 4, + bottom: 12, + trailing: .layoutPadding)) + .listRowBackground(theme.primaryBackgroundColor) .shimmering() - Divider() - .padding(.vertical, .dividerPadding) } case let .display(notifications, nextPageState): @@ -101,12 +98,12 @@ public struct NotificationsListView: View { } else { ForEach(notifications) { notification in NotificationRowView(notification: notification) - .padding(.leading, .layoutPadding + 4) - .padding(.trailing, .layoutPadding) - .padding(.top, 6) - .padding(.bottom, 2) - Divider() - .padding(.vertical, .dividerPadding) + .listRowInsets(.init(top: 12, + leading: .layoutPadding + 4, + bottom: 12, + trailing: .layoutPadding)) + .listRowBackground(notification.type == .mention && lockedType != .mention ? + theme.secondaryBackgroundColor : theme.primaryBackgroundColor) } } @@ -141,5 +138,18 @@ public struct NotificationsListView: View { ProgressView() Spacer() } + .listRowInsets(.init(top: .layoutPadding, + leading: .layoutPadding + 4, + bottom: .layoutPadding, + trailing: .layoutPadding)) + .listRowBackground(theme.primaryBackgroundColor) + } + + private var topPaddingView: some View { + HStack { } + .listRowBackground(Color.clear) + .listRowSeparator(.hidden) + .listRowInsets(.init()) + .frame(height: .layoutPadding) } } diff --git a/Packages/Status/Sources/Status/Row/StatusActionsView.swift b/Packages/Status/Sources/Status/Row/StatusActionsView.swift index 5bced84b..1ba2a49f 100644 --- a/Packages/Status/Sources/Status/Row/StatusActionsView.swift +++ b/Packages/Status/Sources/Status/Row/StatusActionsView.swift @@ -70,6 +70,7 @@ struct StatusActionsView: View { ShareLink(item: url) { Image(systemName: action.iconName(viewModel: viewModel)) } + .buttonStyle(.borderless) } } else { Button {