feat: 主页样式

This commit is contained in:
jinyaqiu 2025-08-26 16:04:53 +08:00
parent f232c70ef1
commit f96ce2a93c
5 changed files with 131 additions and 121 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.5 MiB

5
wake/Assets/Svg/User.svg Normal file
View File

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.97485 5.97461H19.9748" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3.97485 11.9746H19.9748" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3.97485 17.9746H19.9748" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 451 B

View File

@ -30,150 +30,104 @@ struct ContentView: View {
var body: some View {
NavigationView {
ZStack {
//
Color.themeTextWhiteSecondary.ignoresSafeArea()
//
VStack {
VStack(spacing: 20) {
//
Spacer().frame(height: UIApplication.shared.windows.first?.safeAreaInsets.top ?? 0)
//
HStack {
//
Button(action: showUserProfile) {
Image(systemName: "gearshape")
.font(.title2)
.padding()
SVGImage(svgName: "User")
.frame(width: 24, height: 24)
}
Spacer()
// //
// NavigationLink(destination: TestView()) {
// Text("TestView")
// .font(.subheadline)
// .padding(.horizontal, 12)
// .padding(.vertical, 6)
// .background(Color.brown)
// .foregroundColor(.white)
// .cornerRadius(8)
// }
Text("Wake")
.font(.largeTitle)
.fontWeight(.bold)
.onTapGesture {
if login.isEmpty {
print("⚠️ 没有登录记录,正在创建新记录...")
let newLogin = Login(
email: "jyq@example.com",
name: "New User"
)
modelContext.insert(newLogin)
try? modelContext.save()
print("✅ 已创建新登录记录")
} else if let firstLogin = login.first {
// 2.
print("🔍 找到现有记录,正在更新...")
firstLogin.email = "updated@example.com"
firstLogin.name = "Updated Name"
try? modelContext.save()
print("✅ 记录已更新")
}
}
//
Button(action: {
showLogin = true
}) {
Text("登录")
.font(.headline)
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
//
NavigationLink(destination: TestView()) {
Text("TestView")
.font(.subheadline)
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(Color.brown)
.foregroundColor(.white)
.cornerRadius(8)
}
//
// //
// NavigationLink(destination: SubscribeView()) {
// Text("Subscribe")
// .font(.subheadline)
// .padding(.horizontal, 12)
// .padding(.vertical, 6)
// .background(Color.orange)
// .foregroundColor(.white)
// .cornerRadius(8)
// }
// .padding(.trailing)
// .fullScreenCover(isPresented: $showLogin) {
// LoginView()
// }
NavigationLink(destination: SubscribeView()) {
Text("Subscribe")
.font(.subheadline)
Text("3290")
.font(Typography.font(for: .subtitle))
.fontWeight(.bold)
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(Color.orange)
.background(Color.black)
.foregroundColor(.white)
.cornerRadius(8)
.cornerRadius(16)
}
.padding(.trailing)
.fullScreenCover(isPresented: $showLogin) {
LoginView()
}
}
Spacer()
//
List {
Section(header: Text("我的收藏")) {
ForEach(1...5, id: \.self) { item in
HStack {
Image(systemName: "photo")
.foregroundColor(.blue)
.frame(width: 40, height: 40)
.background(Color.blue.opacity(0.1))
.cornerRadius(8)
VStack(alignment: .leading, spacing: 4) {
Text("项目 \(item)")
.font(.headline)
Text("这是第\(item)个项目的描述")
.font(.subheadline)
.foregroundColor(.secondary)
}
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.gray)
}
.padding(.vertical, 4)
}
}
Section(header: Text("最近活动")) {
ForEach(6...10, id: \.self) { item in
HStack {
Image(systemName: "clock")
.foregroundColor(.orange)
.frame(width: 40, height: 40)
.background(Color.orange.opacity(0.1))
.cornerRadius(8)
VStack(alignment: .leading, spacing: 4) {
Text("活动 \(item)")
.font(.headline)
Text("\(item)分钟前更新")
.font(.subheadline)
.foregroundColor(.secondary)
}
Spacer()
Text("查看")
.font(.caption)
.padding(6)
.background(Color.blue.opacity(0.1))
.foregroundColor(.blue)
.cornerRadius(4)
}
.padding(.vertical, 4)
}
}
.padding(.horizontal)
//
VStack(alignment: .leading, spacing: 4) {
Text("Hi! Click And")
Text("Open Your Box~")
}
.listStyle(GroupedListStyle())
.padding(.top, 0)
.font(Typography.font(for: .smallLargeTitle))
.fontWeight(.bold)
.foregroundColor(Color.themeTextMessageMain)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal)
//
// SVG
GeometryReader { geometry in
Color.clear.overlay(
SVGImage(svgName: "BlindBg")
.frame(
width: UIScreen.main.bounds.width * 1.8,
height: geometry.size.height
)
.position(x: geometry.size.width / 2, y: geometry.size.height / 2),
alignment: .center
)
}
.frame(
maxWidth: .infinity,
maxHeight: UIScreen.main.bounds.height * 0.65
)
//
Button(action: showUserProfile) {
Text("Go to Buy")
.font(Typography.font(for: .body))
.fontWeight(.bold)
.frame(maxWidth: .infinity)
.padding()
.background(Color.themePrimary)
.foregroundColor(Color.themeTextMessageMain)
.cornerRadius(32)
}
.padding(.horizontal)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(.systemBackground))
.background(Color.themeTextWhiteSecondary)
.offset(x: showModal ? UIScreen.main.bounds.width * 0.8 : 0)
.animation(.spring(response: 0.6, dampingFraction: 0.8), value: showModal)
.edgesIgnoringSafeArea(.all)
@ -209,6 +163,7 @@ struct ContentView: View {
}
.animation(.spring(response: 0.6, dampingFraction: 0.8), value: showSettings)
}
.background(Color.themeTextWhiteSecondary)
.navigationBarHidden(true)
}
}

View File

@ -24,6 +24,7 @@ extension FontFamily {
/// 使
enum TypographyStyle {
case largeTitle //
case smallLargeTitle //
case headline //
case title //
case title2 //
@ -51,6 +52,7 @@ struct Typography {
///
private static let styleConfig: [TypographyStyle: TypographyConfig] = [
.largeTitle: TypographyConfig(size: 32, weight: .heavy, textStyle: .largeTitle),
.smallLargeTitle: TypographyConfig(size: 30, weight: .heavy, textStyle: .largeTitle),
.headline: TypographyConfig(size: 24, weight: .bold, textStyle: .headline),
.title: TypographyConfig(size: 20, weight: .semibold, textStyle: .title2),
.title2: TypographyConfig(size: 18, weight: .bold, textStyle: .title2),

View File

@ -46,7 +46,7 @@ struct WakeApp: App {
//
if authState.isAuthenticated {
// userInfo
UserInfo()
ContentView()
.environmentObject(authState)
} else {
//