112 lines
3.6 KiB
Swift
112 lines
3.6 KiB
Swift
import SwiftUI
|
|
|
|
struct ModalContentView: View {
|
|
let goBack: () -> Void
|
|
@Environment(\.dismiss) private var dismissModal
|
|
|
|
var body: some View {
|
|
VStack(spacing: 20) {
|
|
// 用户信息
|
|
HStack(alignment: .center, spacing: 16) {
|
|
Image(systemName: "person.circle.fill")
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fill)
|
|
.frame(width: 60, height: 60)
|
|
.foregroundColor(.blue)
|
|
.clipShape(Circle())
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text("用户名")
|
|
.font(.headline)
|
|
Text("ID: 12345678")
|
|
.font(.subheadline)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(.horizontal, 16)
|
|
.padding(.top, 16)
|
|
|
|
// 会员区域
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("会员等级").font(.headline)
|
|
Text("会员时间").font(.subheadline).foregroundColor(.secondary)
|
|
Text("会员中心").font(.subheadline).foregroundColor(.secondary)
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(16)
|
|
.background(Color(red: 0.92, green: 0.92, blue: 0.92))
|
|
.cornerRadius(10)
|
|
.padding(.horizontal, 16)
|
|
|
|
// 功能按钮
|
|
VStack(spacing: 12) {
|
|
ModalButton(icon: "crown.fill", color: .orange, text: "My Memories")
|
|
ModalButton(icon: "clock.fill", color: .blue, text: "My Bind Box")
|
|
|
|
// 跳转设置页
|
|
Button(action: {
|
|
goBack()
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
// 模拟从左边滑入的效果
|
|
}
|
|
}) {
|
|
HStack(spacing: 16) {
|
|
Image(systemName: "person.circle.fill")
|
|
.foregroundColor(.purple)
|
|
.frame(width: 24, height: 24)
|
|
Text("Setting")
|
|
.font(.headline)
|
|
.foregroundColor(.primary)
|
|
Spacer()
|
|
Image(systemName: "chevron.right")
|
|
.foregroundColor(.gray)
|
|
}
|
|
.padding()
|
|
.background(Color(.systemBackground))
|
|
.cornerRadius(10)
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
}
|
|
.padding(.horizontal, 16)
|
|
|
|
Spacer()
|
|
}
|
|
.padding(.vertical, 8)
|
|
}
|
|
}
|
|
|
|
// MARK: - 按钮组件
|
|
struct ModalButton: View {
|
|
let icon: String
|
|
let color: Color
|
|
let text: String
|
|
let action: () -> Void
|
|
|
|
init(icon: String, color: Color, text: String, action: @escaping () -> Void = {}) {
|
|
self.icon = icon
|
|
self.color = color
|
|
self.text = text
|
|
self.action = action
|
|
}
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
HStack(spacing: 16) {
|
|
Image(systemName: icon)
|
|
.foregroundColor(color)
|
|
.frame(width: 24, height: 24)
|
|
Text(text)
|
|
.font(.headline)
|
|
.foregroundColor(.primary)
|
|
Spacer()
|
|
}
|
|
.padding()
|
|
.background(Color(.systemBackground))
|
|
.cornerRadius(10)
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
}
|
|
}
|