fix: Card width consistency and layout loading in search

- Fixed natural layout width using screen bounds instead of infinity
- Added card layout settings loading in SearchBookmarksView
- Consistent card width across all views prevents overflow
This commit is contained in:
Ilyas Hallak 2025-09-05 21:58:24 +02:00
parent f40c5597f3
commit c13fc107b1
2 changed files with 34 additions and 4 deletions

View File

@ -275,8 +275,9 @@ struct BookmarkCardView: View {
VStack(alignment: .leading, spacing: 8) {
ZStack(alignment: .bottomTrailing) {
CachedAsyncImage(url: imageURL)
.aspectRatio(contentMode: .fit)
.frame(minHeight: 180)
.aspectRatio(contentMode: .fill)
.frame(width: UIScreen.main.bounds.width - 32)
.clipped()
.clipShape(RoundedRectangle(cornerRadius: 8))
if bookmark.readProgress > 0 && bookmark.isArchived == false && bookmark.isMarked == false {

View File

@ -7,6 +7,7 @@ struct SearchBookmarksView: View {
@Binding var selectedBookmark: Bookmark?
@Namespace private var namespace
@State private var isFirstAppearance = true
@State private var cardLayoutStyle: CardLayoutStyle = .magazine
var body: some View {
VStack(spacing: 0) {
@ -61,10 +62,22 @@ struct SearchBookmarksView: View {
}
}
}) {
BookmarkCardView(bookmark: bookmark, currentState: .all, onArchive: {_ in }, onDelete: {_ in }, onToggleFavorite: {_ in })
BookmarkCardView(
bookmark: bookmark,
currentState: .all,
layout: cardLayoutStyle,
onArchive: {_ in },
onDelete: {_ in },
onToggleFavorite: {_ in }
)
}
.buttonStyle(PlainButtonStyle())
.listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
.listRowInsets(EdgeInsets(
top: cardLayoutStyle == .compact ? 8 : 12,
leading: 16,
bottom: cardLayoutStyle == .compact ? 8 : 12,
trailing: 16
))
.listRowSeparator(.hidden)
.listRowBackground(Color(R.color.bookmark_list_bg))
}
@ -98,6 +111,22 @@ struct SearchBookmarksView: View {
searchFieldIsFocused = true
isFirstAppearance = false
}
loadCardLayoutStyle()
}
.onReceive(NotificationCenter.default.publisher(for: .cardLayoutChanged)) { notification in
if let layout = notification.object as? CardLayoutStyle {
cardLayoutStyle = layout
}
}
}
private func loadCardLayoutStyle() {
Task {
let loadCardLayoutUseCase = DefaultUseCaseFactory.shared.makeLoadCardLayoutUseCase()
let layout = await loadCardLayoutUseCase.execute()
await MainActor.run {
cardLayoutStyle = layout
}
}
}
}