Improve displaying information in the toolbar

This commit is contained in:
Arkadiusz Fal 2021-06-16 21:30:50 +02:00
parent c4a3dab5fb
commit 850f4e6a02
2 changed files with 13 additions and 5 deletions

View File

@ -42,9 +42,11 @@ struct VideoThumbnailView: View {
Image(systemName: "calendar") Image(systemName: "calendar")
Text(video.published) Text(video.published)
if video.views != 0 {
Image(systemName: "eye") Image(systemName: "eye")
Text(video.viewsCount) Text(video.viewsCount)
} }
}
.foregroundColor(.secondary) .foregroundColor(.secondary)
.padding(.top) .padding(.top)
} }
@ -53,11 +55,13 @@ struct VideoThumbnailView: View {
Spacer() Spacer()
HStack(spacing: 8) { HStack(spacing: 8) {
if let time = video.playTime {
Image(systemName: "clock") Image(systemName: "clock")
Text(video.playTime ?? "-") Text(time)
.fontWeight(.bold) .fontWeight(.bold)
} }
}
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
.frame(minHeight: 180) .frame(minHeight: 180)

View File

@ -50,6 +50,10 @@ final class Video: Identifiable, ObservableObject {
} }
var playTime: String? { var playTime: String? {
guard !length.isZero else {
return nil
}
let formatter = DateComponentsFormatter() let formatter = DateComponentsFormatter()
formatter.unitsStyle = .positional formatter.unitsStyle = .positional