-
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
147 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Sources/PulseUI/Features/Console/Views/ConsoleHelperViews.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.