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) { VStack(alignment: .leading, spacing: 8) {
ZStack(alignment: .bottomTrailing) { ZStack(alignment: .bottomTrailing) {
CachedAsyncImage(url: imageURL) CachedAsyncImage(url: imageURL)
.aspectRatio(contentMode: .fit) .aspectRatio(contentMode: .fill)
.frame(minHeight: 180) .frame(width: UIScreen.main.bounds.width - 32)
.clipped()
.clipShape(RoundedRectangle(cornerRadius: 8)) .clipShape(RoundedRectangle(cornerRadius: 8))
if bookmark.readProgress > 0 && bookmark.isArchived == false && bookmark.isMarked == false { if bookmark.readProgress > 0 && bookmark.isArchived == false && bookmark.isMarked == false {

View File

@ -7,6 +7,7 @@ struct SearchBookmarksView: View {
@Binding var selectedBookmark: Bookmark? @Binding var selectedBookmark: Bookmark?
@Namespace private var namespace @Namespace private var namespace
@State private var isFirstAppearance = true @State private var isFirstAppearance = true
@State private var cardLayoutStyle: CardLayoutStyle = .magazine
var body: some View { var body: some View {
VStack(spacing: 0) { 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()) .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) .listRowSeparator(.hidden)
.listRowBackground(Color(R.color.bookmark_list_bg)) .listRowBackground(Color(R.color.bookmark_list_bg))
} }
@ -98,6 +111,22 @@ struct SearchBookmarksView: View {
searchFieldIsFocused = true searchFieldIsFocused = true
isFirstAppearance = false 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
}
} }
} }
} }