Skip to content

Commit ede614a

Browse files
committed
Minor design improvements
1 parent ea09a55 commit ede614a

11 files changed

+147
-355
lines changed

Sources/PulseUI/Features/Console/List/ConsoleListContentView.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct ConsoleListContentView: View {
2323
Text("Empty")
2424
.font(.subheadline)
2525
.foregroundColor(.secondary)
26+
.listRowInsets(EdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 16))
2627
} else {
2728
ForEach(viewModel.visibleEntities, id: \.objectID) { entity in
2829
let objectID = entity.objectID
@@ -33,11 +34,12 @@ struct ConsoleListContentView: View {
3334
.onDisappear { viewModel.onDisappearCell(with: objectID) }
3435
#endif
3536
#if os(iOS)
36-
.listRowInsets(EdgeInsets(top: 10, leading: 20, bottom: 10, trailing: 16))
37+
.listRowInsets(EdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 16))
3738
#endif
3839
}
3940
}
4041
footerView
42+
.listRowInsets(EdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 16))
4143
}
4244

4345
@ViewBuilder

Sources/PulseUI/Features/Console/List/ConsoleListView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private struct _ConsoleListView: View {
6969
ConsoleSearchListContentView()
7070
} else {
7171
ConsoleToolbarView()
72-
.listRowSeparator(.hidden, edges: .top)
72+
.listRowSeparator(.hidden, edges: .all)
73+
.listRowInsets(EdgeInsets(top: 4, leading: 16, bottom: 8, trailing: 16))
7374
ConsoleListContentView()
7475
}
7576
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean).
4+
5+
import SwiftUI
6+
import Pulse
7+
8+
struct ConsoleTimestampView: View {
9+
let date: Date
10+
11+
var body: some View {
12+
Text(ConsoleMessageCell.timeFormatter.string(from: date))
13+
#if os(tvOS)
14+
.font(.system(size: 21))
15+
#else
16+
.font(.caption)
17+
#endif
18+
.monospacedDigit()
19+
.tracking(-0.5)
20+
.lineLimit(1)
21+
.foregroundStyle(.secondary)
22+
}
23+
}
24+
25+
@available(iOS 15, visionOS 1, *)
26+
struct MockBadgeView: View {
27+
var body: some View {
28+
Text("MOCK")
29+
.foregroundStyle(.background)
30+
.font(.caption2.weight(.semibold))
31+
.padding(EdgeInsets(top: 2, leading: 5, bottom: 1, trailing: 5))
32+
.background(Color.secondary.opacity(0.66))
33+
.clipShape(Capsule())
34+
}
35+
}
36+
37+
struct StatusIndicatorView: View {
38+
let state: NetworkTaskEntity.State?
39+
40+
var body: some View {
41+
Image(systemName: "circle.fill")
42+
.foregroundStyle(color)
43+
#if os(tvOS)
44+
.font(.system(size: 12))
45+
#else
46+
.font(.system(size: 10))
47+
#endif
48+
.clipShape(RoundedRectangle(cornerRadius: 3))
49+
}
50+
51+
private var color: Color {
52+
guard let state else {
53+
return .secondary
54+
}
55+
switch state {
56+
case .pending: return .orange
57+
case .success: return .green
58+
case .failure: return .red
59+
}
60+
}
61+
}

Sources/PulseUI/Features/Console/Views/ConsoleMessageCell.swift

+10-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Pulse
77
import CoreData
88
import Combine
99

10-
@available(iOS 15, visionOS 1.0, *)
10+
@available(iOS 15, visionOS 1, *)
1111
struct ConsoleMessageCell: View {
1212
let message: LoggerMessageEntity
1313
var isDisclosureNeeded = false
@@ -38,15 +38,16 @@ struct ConsoleMessageCell: View {
3838
.font(.footnote)
3939
.foregroundColor(titleColor)
4040
Spacer()
41+
#if !os(watchOS)
4142
Components.makePinView(for: message)
42-
HStack(spacing: 3) {
43-
ConsoleTimestampView(date: message.createdAt)
44-
.overlay(alignment: .trailing) {
45-
if isDisclosureNeeded {
46-
ListDisclosureIndicator()
47-
.offset(x: 11, y: 0)
48-
}
49-
}
43+
ConsoleTimestampView(date: message.createdAt)
44+
.padding(.trailing, 3)
45+
#endif
46+
}
47+
.overlay(alignment: .trailing) {
48+
if isDisclosureNeeded {
49+
ListDisclosureIndicator()
50+
.offset(x: 8, y: 0)
5051
}
5152
}
5253
}
@@ -125,15 +126,3 @@ struct ConsoleMessageCell_Previews: PreviewProvider {
125126
}
126127
}
127128
#endif
128-
129-
struct ConsoleConstants {
130-
#if os(watchOS)
131-
static let fontTitle = Font.system(size: 14)
132-
#elseif os(macOS)
133-
static let fontTitle = Font.subheadline
134-
#elseif os(iOS) || os(visionOS)
135-
static let fontTitle = Font.subheadline.monospacedDigit()
136-
#else
137-
static let fontTitle = Font.caption
138-
#endif
139-
}

0 commit comments

Comments
 (0)