
- 在FeedView中添加加号按钮,允许用户进行操作。 - 更新HomeView以支持全屏显示和更好的布局。 - 在MeView中优化用户信息展示,增加用户ID显示。 - 调整底部导航栏样式,提升视觉效果和用户体验。 - 确保视图在安全区域内适配,增强整体布局的适应性。
147 lines
5.3 KiB
Swift
147 lines
5.3 KiB
Swift
import SwiftUI
|
|
|
|
struct FeedView: View {
|
|
var body: some View {
|
|
GeometryReader { geometry in
|
|
ScrollView {
|
|
VStack(spacing: 20) {
|
|
// 顶部区域 - 标题和加号按钮
|
|
HStack {
|
|
Spacer()
|
|
|
|
// 标题
|
|
Text("Enjoy your Life Time")
|
|
.font(.system(size: 22, weight: .semibold))
|
|
.foregroundColor(.white)
|
|
|
|
Spacer()
|
|
|
|
// 右侧加号按钮
|
|
Button(action: {
|
|
// 加号按钮操作
|
|
}) {
|
|
Image("add icon")
|
|
.frame(width: 36, height: 36)
|
|
}
|
|
}
|
|
.padding(.horizontal, 20)
|
|
// .padding(.top, geometry.safeAreaInsets.top + 20)
|
|
|
|
// 心脏图标
|
|
Image(systemName: "heart.fill")
|
|
.font(.system(size: 60))
|
|
.foregroundColor(.red)
|
|
.padding(.top, 40)
|
|
|
|
// 励志文字
|
|
Text("The disease is like a cruel ruler,\nand time is our most precious treasure.\nEvery moment we live is a victory\nagainst the inevitable.")
|
|
.font(.system(size: 16))
|
|
.multilineTextAlignment(.center)
|
|
.foregroundColor(.white.opacity(0.9))
|
|
.padding(.horizontal, 30)
|
|
.padding(.top, 20)
|
|
|
|
// 模拟动态卡片
|
|
LazyVStack(spacing: 16) {
|
|
ForEach(0..<3) { index in
|
|
DynamicCardView(index: index)
|
|
}
|
|
}
|
|
.padding(.horizontal, 16)
|
|
.padding(.top, 30)
|
|
|
|
// 底部安全区域 - 为底部导航栏和安全区域留出空间
|
|
Color.clear.frame(height: geometry.safeAreaInsets.bottom + 100)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - 动态卡片组件
|
|
struct DynamicCardView: View {
|
|
let index: Int
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
// 用户信息
|
|
HStack {
|
|
Circle()
|
|
.fill(Color.gray.opacity(0.3))
|
|
.frame(width: 40, height: 40)
|
|
.overlay(
|
|
Text("U\(index + 1)")
|
|
.font(.system(size: 16, weight: .medium))
|
|
.foregroundColor(.white)
|
|
)
|
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
Text("用户\(index + 1)")
|
|
.font(.system(size: 16, weight: .medium))
|
|
.foregroundColor(.white)
|
|
|
|
Text("2小时前")
|
|
.font(.system(size: 12))
|
|
.foregroundColor(.white.opacity(0.6))
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
|
|
// 动态内容
|
|
Text("今天是美好的一天,分享一些生活中的小确幸。希望大家都能珍惜每一个当下的时刻。")
|
|
.font(.system(size: 14))
|
|
.foregroundColor(.white.opacity(0.9))
|
|
.multilineTextAlignment(.leading)
|
|
|
|
// 图片网格
|
|
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 8), count: 3), spacing: 8) {
|
|
ForEach(0..<3) { imageIndex in
|
|
Rectangle()
|
|
.fill(Color.gray.opacity(0.3))
|
|
.aspectRatio(1, contentMode: .fit)
|
|
.overlay(
|
|
Image(systemName: "photo")
|
|
.foregroundColor(.white.opacity(0.6))
|
|
)
|
|
}
|
|
}
|
|
|
|
// 互动按钮
|
|
HStack(spacing: 20) {
|
|
Button(action: {}) {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: "message")
|
|
.font(.system(size: 16))
|
|
Text("354")
|
|
.font(.system(size: 14))
|
|
}
|
|
.foregroundColor(.white.opacity(0.8))
|
|
}
|
|
|
|
Button(action: {}) {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: "heart")
|
|
.font(.system(size: 16))
|
|
Text("354")
|
|
.font(.system(size: 14))
|
|
}
|
|
.foregroundColor(.white.opacity(0.8))
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(.top, 8)
|
|
}
|
|
.padding(16)
|
|
.background(
|
|
Color.white.opacity(0.1)
|
|
.cornerRadius(12)
|
|
)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
FeedView()
|
|
}
|