feat: mrmory页面布局
This commit is contained in:
parent
96e58806d4
commit
0c75e1b446
@ -61,6 +61,7 @@ enum MemoryMediaType: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct MemoriesView: View {
|
struct MemoriesView: View {
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
@State private var memories: [MemoryItem] = []
|
@State private var memories: [MemoryItem] = []
|
||||||
@State private var isLoading = false
|
@State private var isLoading = false
|
||||||
@State private var errorMessage: String?
|
@State private var errorMessage: String?
|
||||||
@ -72,41 +73,56 @@ struct MemoriesView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
ZStack {
|
VStack(spacing: 0) {
|
||||||
Color.themeTextWhiteSecondary.ignoresSafeArea()
|
// 顶部导航栏
|
||||||
|
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 {
|
ZStack {
|
||||||
ProgressView()
|
Color.themeTextWhiteSecondary.ignoresSafeArea()
|
||||||
.scaleEffect(1.5)
|
|
||||||
} else if let error = errorMessage {
|
Group {
|
||||||
Text("Error: \(error)")
|
if isLoading {
|
||||||
.foregroundColor(.red)
|
ProgressView()
|
||||||
} else {
|
.scaleEffect(1.5)
|
||||||
ScrollView {
|
} else if let error = errorMessage {
|
||||||
LazyVGrid(columns: columns, spacing: 4) {
|
Text("Error: \(error)")
|
||||||
ForEach(memories) { memory in
|
.foregroundColor(.red)
|
||||||
MemoryCard(memory: memory)
|
} else {
|
||||||
.padding(.horizontal, 2)
|
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)
|
||||||
.navigationBarBackButtonHidden(true)
|
.onAppear {
|
||||||
.toolbar {
|
fetchMemories()
|
||||||
ToolbarItem(placement: .navigationBarLeading) {
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.onAppear {
|
|
||||||
fetchMemories()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +156,7 @@ struct MemoryCard: View {
|
|||||||
let memory: MemoryItem
|
let memory: MemoryItem
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
ZStack {
|
ZStack {
|
||||||
// Media content
|
// Media content
|
||||||
Group {
|
Group {
|
||||||
@ -194,18 +210,18 @@ struct MemoryCard: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Title and Subtitle
|
// Title and Subtitle
|
||||||
VStack(alignment: .leading, spacing: 1) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
Text(memory.title)
|
Text(memory.title)
|
||||||
.font(.subheadline)
|
.font(Typography.font(for: .body, family: .quicksandBold))
|
||||||
|
.foregroundColor(.themeTextMessageMain)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
|
||||||
Text(memory.subtitle)
|
Text(memory.subtitle)
|
||||||
.font(.caption)
|
.font(.system(size: 14))
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.themeTextMessageMain)
|
||||||
.lineLimit(1)
|
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 2)
|
.padding(.horizontal, 2)
|
||||||
.padding(.bottom, 4)
|
.padding(.bottom, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user