-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display event log in metrics debugging view (#942)
- Loading branch information
Showing
6 changed files
with
140 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,9 @@ | |
}, | ||
"Enabled" : { | ||
|
||
}, | ||
"Event log" : { | ||
|
||
}, | ||
"Examples" : { | ||
|
||
|
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 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
import CoreMedia | ||
import PillarboxPlayer | ||
import SwiftUI | ||
|
||
struct MetricEventCell: View { | ||
private static let dateFormatter: DateFormatter = { | ||
let formatter = DateFormatter() | ||
formatter.dateStyle = .short | ||
formatter.timeStyle = .short | ||
return formatter | ||
}() | ||
|
||
private static let durationFormatter: DateComponentsFormatter = { | ||
let formatter = DateComponentsFormatter() | ||
formatter.allowedUnits = [.hour, .minute, .second] | ||
formatter.zeroFormattingBehavior = .pad | ||
return formatter | ||
}() | ||
|
||
let event: MetricEvent | ||
|
||
private var time: String { | ||
if let duration = Self.duration(from: event.time) { | ||
return "[\(duration)] \(formattedDate)" | ||
} | ||
else { | ||
return formattedDate | ||
} | ||
} | ||
|
||
private var description: String { | ||
event.kind.description | ||
} | ||
|
||
private var formattedDate: String { | ||
Self.dateFormatter.string(from: event.date) | ||
} | ||
|
||
var body: some View { | ||
VStack(alignment: .leading) { | ||
Text(time) | ||
.font(.subheadline) | ||
.foregroundColor(.secondary) | ||
.lineLimit(1) | ||
Text(description) | ||
.lineLimit(3) | ||
.multilineTextAlignment(.leading) | ||
} | ||
} | ||
|
||
private static func duration(from time: CMTime) -> String? { | ||
guard time.isValid else { return nil } | ||
return durationFormatter.string(from: time.seconds) | ||
} | ||
} |
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
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