mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-11 12:01:18 +00:00
fixed search result grid
This commit is contained in:
parent
9feabeaa41
commit
bd37eb9db4
5 changed files with 32 additions and 35 deletions
|
|
@ -18,19 +18,19 @@ struct SearchItem: Identifiable {
|
|||
struct SearchHistorySection<Content: View>: View {
|
||||
let title: String
|
||||
let content: Content
|
||||
|
||||
|
||||
init(title: String, @ViewBuilder content: () -> Content) {
|
||||
self.title = title
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(title.uppercased())
|
||||
.font(.footnote)
|
||||
.foregroundStyle(Color.secondary)
|
||||
.padding(.horizontal, 20)
|
||||
|
||||
|
||||
VStack(spacing: 0) {
|
||||
content
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ struct SearchResultsGrid: View {
|
|||
let items: [SearchItem]
|
||||
let columns: [GridItem]
|
||||
let selectedModule: ScrapingModule
|
||||
let cellWidth: CGFloat
|
||||
|
||||
var body: some View {
|
||||
LazyVGrid(columns: columns, spacing: 16) {
|
||||
|
|
@ -21,33 +22,33 @@ struct SearchResultsGrid: View {
|
|||
KFImage(URL(string: item.imageUrl))
|
||||
.resizable()
|
||||
.aspectRatio(0.72, contentMode: .fill)
|
||||
.frame(width: 162, height: 243)
|
||||
.frame(width: cellWidth, height: cellWidth * 1.5)
|
||||
.cornerRadius(12)
|
||||
.clipped()
|
||||
|
||||
VStack {
|
||||
Spacer()
|
||||
HStack {
|
||||
Text(item.title)
|
||||
.lineLimit(2)
|
||||
.foregroundColor(.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
Spacer()
|
||||
HStack {
|
||||
Text(item.title)
|
||||
.lineLimit(2)
|
||||
.foregroundColor(.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
Spacer()
|
||||
}
|
||||
.padding(12)
|
||||
.background(
|
||||
LinearGradient(
|
||||
colors: [
|
||||
.black.opacity(0.7),
|
||||
.black.opacity(0.0)
|
||||
],
|
||||
startPoint: .bottom,
|
||||
endPoint: .top
|
||||
)
|
||||
.shadow(color: .black, radius: 4, x: 0, y: 2)
|
||||
)
|
||||
}
|
||||
.frame(width: 162)
|
||||
.padding(12)
|
||||
.background(
|
||||
LinearGradient(
|
||||
colors: [
|
||||
.black.opacity(0.7),
|
||||
.black.opacity(0.0)
|
||||
],
|
||||
startPoint: .bottom,
|
||||
endPoint: .top
|
||||
)
|
||||
.shadow(color: .black, radius: 4, x: 0, y: 2)
|
||||
)
|
||||
}
|
||||
.frame(width: cellWidth)
|
||||
}
|
||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||
.padding(4)
|
||||
|
|
@ -57,4 +58,4 @@ struct SearchResultsGrid: View {
|
|||
.padding(.top)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,6 @@ struct SearchView: View {
|
|||
@State private var saveDebounceTimer: Timer?
|
||||
@State private var searchDebounceTimer: Timer?
|
||||
|
||||
private var columns: [GridItem] {
|
||||
Array(repeating: GridItem(.flexible(), spacing: 16), count: columnsCount)
|
||||
}
|
||||
|
||||
init(searchQuery: Binding<String>) {
|
||||
self._searchQuery = searchQuery
|
||||
}
|
||||
|
|
@ -52,6 +48,10 @@ struct SearchView: View {
|
|||
return moduleManager.modules.first { $0.id.uuidString == id }
|
||||
}
|
||||
|
||||
private let columns = [
|
||||
GridItem(.adaptive(minimum: 150), spacing: 12)
|
||||
]
|
||||
|
||||
private var columnsCount: Int {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
let isLandscape = UIScreen.main.bounds.width > UIScreen.main.bounds.height
|
||||
|
|
|
|||
|
|
@ -174,7 +174,8 @@ struct SearchContent: View {
|
|||
SearchResultsGrid(
|
||||
items: searchItems,
|
||||
columns: columns,
|
||||
selectedModule: module
|
||||
selectedModule: module,
|
||||
cellWidth: cellWidth
|
||||
)
|
||||
} else {
|
||||
SearchStateView(
|
||||
|
|
|
|||
|
|
@ -203,11 +203,6 @@ struct SettingsViewData: View {
|
|||
}
|
||||
|
||||
VStack {
|
||||
Spacer()
|
||||
Spacer()
|
||||
Text("Current Metadata Cache Size")
|
||||
Spacer()
|
||||
|
||||
if isCalculatingSize {
|
||||
ProgressView()
|
||||
.scaleEffect(0.7)
|
||||
|
|
|
|||
Loading…
Reference in a new issue