feat: mrmory页面布局

This commit is contained in:
jinyaqiu 2025-08-29 20:57:00 +08:00
parent 96e58806d4
commit 0c75e1b446

View File

@ -61,6 +61,7 @@ enum MemoryMediaType: Equatable {
}
struct MemoriesView: View {
@Environment(\.dismiss) private var dismiss
@State private var memories: [MemoryItem] = []
@State private var isLoading = false
@State private var errorMessage: String?
@ -72,41 +73,56 @@ struct MemoriesView: View {
var body: some View {
NavigationView {
ZStack {
Color.themeTextWhiteSecondary.ignoresSafeArea()
VStack(spacing: 0) {
//
HStack {
Button(action: {
//
self.dismiss()
}) {
Image(systemName: "chevron.left")
.foregroundColor(.themeTextMessageMain)
.font(.system(size: 20))
}
Spacer()
Text("My Memories")
.foregroundColor(.themeTextMessageMain)
.font(Typography.font(for: .body, family: .quicksandBold))
Spacer()
}
.padding()
.background(Color.themeTextWhiteSecondary)
Group {
if isLoading {
ProgressView()
.scaleEffect(1.5)
} else if let error = errorMessage {
Text("Error: \(error)")
.foregroundColor(.red)
} else {
ScrollView {
LazyVGrid(columns: columns, spacing: 4) {
ForEach(memories) { memory in
MemoryCard(memory: memory)
.padding(.horizontal, 2)
//
ZStack {
Color.themeTextWhiteSecondary.ignoresSafeArea()
Group {
if isLoading {
ProgressView()
.scaleEffect(1.5)
} else if let error = errorMessage {
Text("Error: \(error)")
.foregroundColor(.red)
} else {
ScrollView {
LazyVGrid(columns: columns, spacing: 4) {
ForEach(memories) { memory in
MemoryCard(memory: memory)
.padding(.horizontal, 2)
}
}
.padding(.top, 4)
.padding(.horizontal, 4)
}
.padding(.top, 4)
.padding(.horizontal, 4)
}
}
}
}
.navigationTitle("My Memories")
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
EmptyView()
}
}
.onAppear {
fetchMemories()
}
}
.navigationBarBackButtonHidden(true)
.onAppear {
fetchMemories()
}
}
@ -140,7 +156,7 @@ struct MemoryCard: View {
let memory: MemoryItem
var body: some View {
VStack(alignment: .leading, spacing: 4) {
VStack(alignment: .leading, spacing: 12) {
ZStack {
// Media content
Group {
@ -194,18 +210,18 @@ struct MemoryCard: View {
}
// Title and Subtitle
VStack(alignment: .leading, spacing: 1) {
VStack(alignment: .leading, spacing: 8) {
Text(memory.title)
.font(.subheadline)
.font(Typography.font(for: .body, family: .quicksandBold))
.foregroundColor(.themeTextMessageMain)
.lineLimit(1)
Text(memory.subtitle)
.font(.caption)
.foregroundColor(.secondary)
.lineLimit(1)
.font(.system(size: 14))
.foregroundColor(.themeTextMessageMain)
}
.padding(.horizontal, 2)
.padding(.bottom, 4)
.padding(.bottom, 8)
}
}
}