Skip to content

Commit

Permalink
Minor design improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 12, 2024
1 parent ea09a55 commit ede614a
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct ConsoleListContentView: View {
Text("Empty")
.font(.subheadline)
.foregroundColor(.secondary)
.listRowInsets(EdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 16))
} else {
ForEach(viewModel.visibleEntities, id: \.objectID) { entity in
let objectID = entity.objectID
Expand All @@ -33,11 +34,12 @@ struct ConsoleListContentView: View {
.onDisappear { viewModel.onDisappearCell(with: objectID) }
#endif
#if os(iOS)
.listRowInsets(EdgeInsets(top: 10, leading: 20, bottom: 10, trailing: 16))
.listRowInsets(EdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 16))
#endif
}
}
footerView
.listRowInsets(EdgeInsets(top: 12, leading: 20, bottom: 12, trailing: 16))
}

@ViewBuilder
Expand Down
3 changes: 2 additions & 1 deletion Sources/PulseUI/Features/Console/List/ConsoleListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ private struct _ConsoleListView: View {
ConsoleSearchListContentView()
} else {
ConsoleToolbarView()
.listRowSeparator(.hidden, edges: .top)
.listRowSeparator(.hidden, edges: .all)
.listRowInsets(EdgeInsets(top: 4, leading: 16, bottom: 8, trailing: 16))
ConsoleListContentView()
}
}
Expand Down
61 changes: 61 additions & 0 deletions Sources/PulseUI/Features/Console/Views/ConsoleHelperViews.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// The MIT License (MIT)
//
// Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean).

import SwiftUI
import Pulse

struct ConsoleTimestampView: View {
let date: Date

var body: some View {
Text(ConsoleMessageCell.timeFormatter.string(from: date))
#if os(tvOS)
.font(.system(size: 21))
#else
.font(.caption)
#endif
.monospacedDigit()
.tracking(-0.5)
.lineLimit(1)
.foregroundStyle(.secondary)
}
}

@available(iOS 15, visionOS 1, *)
struct MockBadgeView: View {
var body: some View {
Text("MOCK")
.foregroundStyle(.background)
.font(.caption2.weight(.semibold))
.padding(EdgeInsets(top: 2, leading: 5, bottom: 1, trailing: 5))
.background(Color.secondary.opacity(0.66))
.clipShape(Capsule())
}
}

struct StatusIndicatorView: View {
let state: NetworkTaskEntity.State?

var body: some View {
Image(systemName: "circle.fill")
.foregroundStyle(color)
#if os(tvOS)
.font(.system(size: 12))
#else
.font(.system(size: 10))
#endif
.clipShape(RoundedRectangle(cornerRadius: 3))
}

private var color: Color {
guard let state else {
return .secondary
}
switch state {
case .pending: return .orange
case .success: return .green
case .failure: return .red
}
}
}
31 changes: 10 additions & 21 deletions Sources/PulseUI/Features/Console/Views/ConsoleMessageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Pulse
import CoreData
import Combine

@available(iOS 15, visionOS 1.0, *)
@available(iOS 15, visionOS 1, *)
struct ConsoleMessageCell: View {
let message: LoggerMessageEntity
var isDisclosureNeeded = false
Expand Down Expand Up @@ -38,15 +38,16 @@ struct ConsoleMessageCell: View {
.font(.footnote)
.foregroundColor(titleColor)
Spacer()
#if !os(watchOS)
Components.makePinView(for: message)
HStack(spacing: 3) {
ConsoleTimestampView(date: message.createdAt)
.overlay(alignment: .trailing) {
if isDisclosureNeeded {
ListDisclosureIndicator()
.offset(x: 11, y: 0)
}
}
ConsoleTimestampView(date: message.createdAt)
.padding(.trailing, 3)
#endif
}
.overlay(alignment: .trailing) {
if isDisclosureNeeded {
ListDisclosureIndicator()
.offset(x: 8, y: 0)
}
}
}
Expand Down Expand Up @@ -125,15 +126,3 @@ struct ConsoleMessageCell_Previews: PreviewProvider {
}
}
#endif

struct ConsoleConstants {
#if os(watchOS)
static let fontTitle = Font.system(size: 14)
#elseif os(macOS)
static let fontTitle = Font.subheadline
#elseif os(iOS) || os(visionOS)
static let fontTitle = Font.subheadline.monospacedDigit()
#else
static let fontTitle = Font.caption
#endif
}
Loading

0 comments on commit ede614a

Please sign in to comment.