Skip to content

Commit

Permalink
Fix Recent Books Widget's spacing error and text alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
thai-d-v committed Aug 24, 2023
1 parent 3d6f5d7 commit 7ea57b5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
11 changes: 10 additions & 1 deletion BookPlayerWidgetUI/RecentBooksWidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct BookView: View {
.foregroundColor(titleColor)
.font(.caption)
.lineLimit(2)
.multilineTextAlignment(.center)
.frame(width: nil, height: 34, alignment: .leading)
}
}
Expand Down Expand Up @@ -147,6 +148,7 @@ struct RecentBooksWidgetView: View {
HStack {
ForEach(items, id: \.relativePath) { item in
BookView(item: item, titleColor: widgetColors.primaryColor, theme: entry.theme, entry: entry)
.frame(minWidth: 0, maxWidth: .infinity)
}
}
.padding([.leading, .trailing])
Expand All @@ -161,7 +163,14 @@ struct RecentBooksWidgetView: View {
struct RecentBooksWidgetView_Previews: PreviewProvider {
static var previews: some View {
Group {
RecentBooksWidgetView(entry: LibraryEntry(date: Date(), items: [], theme: nil, timerSeconds: 300, autoplay: true))
RecentBooksWidgetView(
entry: LibraryEntry(date: Date(),
items: [.previewItem(title: "a very very very long title"),
.previewItem(title: "a short title"),
.previewItem(title: "a short title")],
theme: nil,
timerSeconds: 300,
autoplay: true))
.previewContext(WidgetPreviewContext(family: .systemMedium))
}
}
Expand Down
23 changes: 23 additions & 0 deletions Shared/CoreData/Lightweight-Models/SimpleLibraryItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,26 @@ extension SimpleLibraryItem {
}
}
}

#if DEBUG
extension SimpleLibraryItem {
static public func previewItem(title: String) -> Self {
SimpleLibraryItem(
title: title,
details: "some details",
speed: 1,
currentTime: 1,
duration: 1,
percentCompleted: 10,
isFinished: false,
relativePath: UUID().uuidString,
remoteURL: nil,
artworkURL: nil,
orderRank: 1,
parentFolder: nil,
originalFileName: "",
lastPlayDate: nil,
type: SimpleItemType.book)
}
}
#endif

0 comments on commit 7ea57b5

Please sign in to comment.