From ee39d815100c893da828a5c5ad14763f67f888a3 Mon Sep 17 00:00:00 2001 From: Stephen Byatt <47413006+stephenb10@users.noreply.github.com> Date: Tue, 22 Jun 2021 11:35:28 +1000 Subject: [PATCH] UI Changes: Change time format for better readability with titles over 1hr Add padding between title and media information Change watched status image to circle check system image --- JellyfinPlayer/EpisodeItemView.swift | 11 +++++++---- JellyfinPlayer/MovieItemView.swift | 10 ++++++---- Shared/Extensions/APIExtensions.swift | 18 ++++++++++-------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/JellyfinPlayer/EpisodeItemView.swift b/JellyfinPlayer/EpisodeItemView.swift index c686286e..91e07c4b 100644 --- a/JellyfinPlayer/EpisodeItemView.swift +++ b/JellyfinPlayer/EpisodeItemView.swift @@ -52,6 +52,7 @@ struct EpisodeItemView: View { .stroke(Color.secondary, lineWidth: 1)) } } + .padding(.top, 1) } .padding(.bottom, UIDevice.current.userInterfaceIdiom == .pad ? 98 : 30) } @@ -89,10 +90,10 @@ struct EpisodeItemView: View { viewModel.updateWatchState() } label: { if viewModel.isWatched { - Image(systemName: "checkmark.rectangle.fill").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle.fill").foregroundColor(Color.primary) .font(.system(size: 20)) } else { - Image(systemName: "xmark.rectangle").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle").foregroundColor(Color.primary) .font(.system(size: 20)) } } @@ -254,6 +255,8 @@ struct EpisodeItemView: View { Spacer() }.frame(maxWidth: .infinity, alignment: .leading) .offset(x: 14) + .padding(.top, 1) + }.frame(maxWidth: .infinity, alignment: .leading) Spacer() HStack { @@ -273,10 +276,10 @@ struct EpisodeItemView: View { viewModel.updateWatchState() } label: { if viewModel.isWatched { - Image(systemName: "checkmark.rectangle.fill").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle.fill").foregroundColor(Color.primary) .font(.system(size: 20)) } else { - Image(systemName: "xmark.rectangle").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle").foregroundColor(Color.primary) .font(.system(size: 20)) } } diff --git a/JellyfinPlayer/MovieItemView.swift b/JellyfinPlayer/MovieItemView.swift index b62b1ba6..f866392a 100644 --- a/JellyfinPlayer/MovieItemView.swift +++ b/JellyfinPlayer/MovieItemView.swift @@ -58,6 +58,7 @@ struct MovieItemView: View { .stroke(Color.secondary, lineWidth: 1)) } } + .padding(.top, 1) } .padding(.bottom, UIDevice.current.userInterfaceIdiom == .pad ? 98 : 30) } @@ -95,10 +96,10 @@ struct MovieItemView: View { viewModel.updateWatchState() } label: { if viewModel.isWatched { - Image(systemName: "checkmark.rectangle.fill").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle.fill").foregroundColor(Color.primary) .font(.system(size: 20)) } else { - Image(systemName: "xmark.rectangle").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle").foregroundColor(Color.primary) .font(.system(size: 20)) } } @@ -270,6 +271,7 @@ struct MovieItemView: View { Spacer() }.frame(maxWidth: .infinity, alignment: .leading) .offset(x: 14) + .padding(.top, 1) }.frame(maxWidth: .infinity, alignment: .leading) Spacer() HStack { @@ -289,10 +291,10 @@ struct MovieItemView: View { viewModel.updateWatchState() } label: { if viewModel.isWatched { - Image(systemName: "checkmark.rectangle.fill").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle.fill").foregroundColor(Color.primary) .font(.system(size: 20)) } else { - Image(systemName: "xmark.rectangle").foregroundColor(Color.primary) + Image(systemName: "checkmark.circle").foregroundColor(Color.primary) .font(.system(size: 20)) } } diff --git a/Shared/Extensions/APIExtensions.swift b/Shared/Extensions/APIExtensions.swift index ce357d08..03d865e5 100644 --- a/Shared/Extensions/APIExtensions.swift +++ b/Shared/Extensions/APIExtensions.swift @@ -104,14 +104,16 @@ extension BaseItemDto { // MARK: Calculations func getItemRuntime() -> String { - let seconds = (self.runTimeTicks ?? 0) / 10_000_000 - let hours = (seconds / 3600) - let minutes = ((seconds - (hours * 3600)) / 60) - if hours != 0 { - return "\(hours):\(String(minutes).leftPad(toWidth: 2, withString: "0"))" - } else { - return "\(String(minutes))m" - } + let timeHMSFormatter: DateComponentsFormatter = { + let formatter = DateComponentsFormatter() + formatter.unitsStyle = .brief + formatter.allowedUnits = [.hour, .minute] + return formatter + }() + + let text = timeHMSFormatter.string(from: Double(self.runTimeTicks! / 10_000_000)) ?? "" + + return text } func getItemProgressString() -> String {