added setting to change anime per row in landscape and portrait modes + fixed stretched images 2

This commit is contained in:
Ibrahim Sulejmenov 2025-03-15 22:04:49 +01:00
parent bbebf14837
commit 6d6bc33dfe
3 changed files with 18 additions and 7 deletions

View file

@ -76,6 +76,10 @@ struct LibraryView: View {
.frame(maxWidth: .infinity)
} else {
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 12), count: columnsCount), spacing: 12) {
let totalSpacing: CGFloat = 16 * CGFloat(columnsCount + 1) // Spacing between items
let availableWidth = UIScreen.main.bounds.width - totalSpacing
let cellWidth = availableWidth / CGFloat(columnsCount)
ForEach(libraryManager.bookmarks) { item in
if let module = moduleManager.modules.first(where: { $0.id.uuidString == item.moduleId }) {
NavigationLink(destination: MediaInfoView(title: item.title, imageUrl: item.imageUrl, href: item.href, module: module)) {
@ -89,9 +93,9 @@ struct LibraryView: View {
.shimmering()
}
.resizable()
.aspectRatio(2/3, contentMode: .fill)
// Allow the image to expand to fill the available width of its grid cell.
.frame(maxWidth: .infinity)
.aspectRatio(contentMode: .fill)
.frame(height: cellWidth * 3 / 2)
.frame(maxWidth: cellWidth)
.cornerRadius(10)
.clipped()
.overlay(

View file

@ -65,9 +65,10 @@ struct MediaInfoView: View {
.shimmering()
}
.resizable()
.aspectRatio(2/3, contentMode: .fit)
.cornerRadius(10)
.aspectRatio(contentMode: .fill)
.frame(width: 150, height: 225)
.clipped()
.cornerRadius(10)
VStack(alignment: .leading, spacing: 4) {
Text(title)

View file

@ -112,15 +112,21 @@ struct SearchView: View {
.frame(maxWidth: .infinity)
.padding(.top)
} else {
let totalSpacing: CGFloat = 16 * CGFloat(columnsCount + 1) // Spacing between items
let availableWidth = UIScreen.main.bounds.width - totalSpacing
let cellWidth = availableWidth / CGFloat(columnsCount)
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 16), count: columnsCount), spacing: 16) {
ForEach(searchItems) { item in
NavigationLink(destination: MediaInfoView(title: item.title, imageUrl: item.imageUrl, href: item.href, module: selectedModule!)) {
VStack {
KFImage(URL(string: item.imageUrl))
.resizable()
.aspectRatio(2/3, contentMode: .fit)
.aspectRatio(contentMode: .fill)
.frame(height: cellWidth * 3 / 2)
.frame(maxWidth: cellWidth)
.cornerRadius(10)
.frame(maxWidth: .infinity)
.clipped()
Text(item.title)
.font(.subheadline)
.foregroundColor(Color.primary)