Revamp EpisodeIconView + format item.overview properly

Some metadata sources use '<br>' instead of '\n' for newlines.
This fixes that for the most part.
This commit is contained in:
Shav Kinderlehrer 2024-02-22 14:13:53 -05:00
parent 1ce620567c
commit 33b07566cb
7 changed files with 32 additions and 24 deletions

View File

@ -39,7 +39,7 @@
3D91FDCB2B28CA2500919017 /* SignInToServerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D91FDCA2B28CA2500919017 /* SignInToServerView.swift */; };
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */; };
3DAFA8E82B38AFED00D71AD1 /* ItemInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E72B38AFED00D71AD1 /* ItemInfoView.swift */; };
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */; };
3DAFA8EA2B39039900D71AD1 /* BaseItemDtoExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8E92B39039900D71AD1 /* BaseItemDtoExtensions.swift */; };
3DAFA8EC2B394F9F00D71AD1 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8EB2B394F9F00D71AD1 /* ViewExtensions.swift */; };
3DAFA8EF2B3B707B00D71AD1 /* ItemMovieView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAFA8EE2B3B707B00D71AD1 /* ItemMovieView.swift */; };
3DBAC9E22B4C31BE005F8764 /* ItemPeopleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DBAC9E12B4C31BE005F8764 /* ItemPeopleView.swift */; };
@ -99,7 +99,7 @@
3D91FDCA2B28CA2500919017 /* SignInToServerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInToServerView.swift; sourceTree = "<group>"; };
3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinDateFormatter.swift; sourceTree = "<group>"; };
3DAFA8E72B38AFED00D71AD1 /* ItemInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemInfoView.swift; sourceTree = "<group>"; };
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinKitExtensions.swift; sourceTree = "<group>"; };
3DAFA8E92B39039900D71AD1 /* BaseItemDtoExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemDtoExtensions.swift; sourceTree = "<group>"; };
3DAFA8EB2B394F9F00D71AD1 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; };
3DAFA8EE2B3B707B00D71AD1 /* ItemMovieView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemMovieView.swift; sourceTree = "<group>"; };
3DBAC9E12B4C31BE005F8764 /* ItemPeopleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemPeopleView.swift; sourceTree = "<group>"; };
@ -279,7 +279,7 @@
3DBAC9E32B4C7404005F8764 /* UIScreenCurrent.swift */,
3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */,
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */,
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */,
3DAFA8E92B39039900D71AD1 /* BaseItemDtoExtensions.swift */,
3DAFA8EB2B394F9F00D71AD1 /* ViewExtensions.swift */,
3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */,
3DD6850B2B85A6A8002FAA1A /* BindingNot.swift */,
@ -395,7 +395,7 @@
3DF1ED3E2B282836000AD8EA /* JellyfinClientController.swift in Sources */,
3D1015D92B27F57400F5C29A /* AddServerView.swift in Sources */,
3DDF35D52B7D384000423923 /* ItemSeriesEpisodesView.swift in Sources */,
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */,
3DAFA8EA2B39039900D71AD1 /* BaseItemDtoExtensions.swift in Sources */,
3D13F9652B37EC7A00E91913 /* ItemHeaderView.swift in Sources */,
3D3816C92B4B5648006414D7 /* ItemGenresView.swift in Sources */,
3DAFA8EC2B394F9F00D71AD1 /* ViewExtensions.swift in Sources */,
@ -668,8 +668,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/n3d1117/ExpandableText?tab=readme-ov-file";
requirement = {
branch = main;
kind = branch;
kind = exactVersion;
version = 1.0.0;
};
};
3D7709372B29139700199889 /* XCRemoteSwiftPackageReference "Pulse" */ = {

View File

@ -5,9 +5,9 @@
"package": "ExpandableText",
"repositoryURL": "https://github.com/n3d1117/ExpandableText?tab=readme-ov-file",
"state": {
"branch": "main",
"revision": "2b0dd2f3d2870fe933ffe5c2ee057d2e9fa647e2",
"version": null
"branch": null,
"revision": "3707127edfb075d26f6f14c940702974ed887f33",
"version": "1.0.0"
}
},
{

View File

@ -26,3 +26,11 @@ extension BaseItemDto {
return nil
}
}
extension BaseItemDto {
var overviewNL: String? {
get {
self.overview?.replacingOccurrences(of: "<br>", with: "\n")
}
}
}

View File

@ -19,7 +19,7 @@ struct ItemMediaView: View {
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
ExpandableText((item.overview ?? "").replacingOccurrences(of: "<br>", with: ""))
ExpandableText((item.overviewNL ?? "").replacingOccurrences(of: "<br>", with: ""))
.lineLimit(8)
}
}

View File

@ -14,30 +14,30 @@ struct ItemSeriesEpisodeIconView: View {
@EnvironmentObject var size: ScreenSize
var iconWidthMultiplier: CGFloat = 0.35
var iconWidthMultiplier: CGFloat = 0.5
var body: some View {
VStack(alignment: .leading) {
HStack(alignment: .top) {
ItemIconView(item: item, width: (size.size.width * iconWidthMultiplier), height: (size.size.width * iconWidthMultiplier) / 1.7)
HStack {
ItemIconView(item: item,
width: (size.size.width * iconWidthMultiplier),
height: (size.size.width * iconWidthMultiplier) / 1.7,
contentMode: .fill)
VStack(alignment: .leading) {
Text("Episode \(item.indexNumber ?? 0)")
.foregroundStyle(Color.secondary)
.font(.caption)
Text(item.name ?? "---")
.bold()
.lineLimit(nil)
Text(item.overview ?? "")
.foregroundStyle(Color.secondary)
.foregroundStyle(.secondary)
.font(.callout)
Spacer()
Text(item.name ?? "---")
.bold()
}
.frame(height: (size.size.width * iconWidthMultiplier) / 1.7)
}
ExpandableText((item.overviewNL ?? "").replacingOccurrences(of: "<br>", with: "\n"))
.foregroundColor(.secondary)
}
.padding(.vertical)
}
}

View File

@ -44,7 +44,7 @@ struct ItemPersonView: View {
.font(.title)
.padding([.horizontal, .top])
if let overview = item.overview {
if let overview = item.overviewNL {
ExpandableText(overview)
.lineLimit(8)
.padding([.horizontal, .bottom])

View File

@ -13,7 +13,7 @@ struct ItemSeasonView: View {
var body: some View {
VStack {
if item.overview != nil {
if item.overviewNL != nil {
ItemMediaView(item: item)
.padding([.horizontal, .bottom])
}