update
This commit is contained in:
@@ -11,29 +11,66 @@ struct HomeView: View {
|
||||
@State private var selectedTab = 0
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack(spacing: 12) {
|
||||
// Search
|
||||
// Banner
|
||||
// Navigation
|
||||
Search
|
||||
Banner
|
||||
Navigation
|
||||
TodayKill
|
||||
// Living
|
||||
// Bestselling
|
||||
// PartyReading
|
||||
// NewBooks
|
||||
// Categories
|
||||
Living
|
||||
Bestselling
|
||||
PartyReading
|
||||
NewBooks
|
||||
Categories
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.bottom, 48)
|
||||
.background(Color.gray.opacity(0.2))
|
||||
}
|
||||
|
||||
var Search: some View {
|
||||
HStack(alignment: .center, spacing: 16) {
|
||||
HStack {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
.foregroundColor(Color.gray)
|
||||
Text("搜索书籍")
|
||||
.foregroundColor(Color.gray)
|
||||
.font(.system(size: 16))
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: /*@START_MENU_TOKEN@*/ .infinity/*@END_MENU_TOKEN@*/)
|
||||
.padding(12)
|
||||
.background(Color.white)
|
||||
.cornerRadius(32)
|
||||
Image(systemName: "bell")
|
||||
.resizable()
|
||||
.frame(width: 24, height: 24)
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Circle()
|
||||
.fill(Color.red.opacity(0.8))
|
||||
.frame(width: 20, height: 20)
|
||||
.overlay {
|
||||
Text("20")
|
||||
.foregroundColor(Color.white)
|
||||
.font(.system(size: 12))
|
||||
}
|
||||
.offset(x: 8, y: -10)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
let columns = [GridItem(.flexible()), GridItem(.flexible())]
|
||||
|
||||
var Categories: some View {
|
||||
VStack {
|
||||
ScrollView(.horizontal) {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack {
|
||||
Text("推荐")
|
||||
Text("竞品书单")
|
||||
@@ -55,6 +92,27 @@ struct HomeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var Banner: some View {
|
||||
TabView {
|
||||
ForEach(1 ..< 4) { index in
|
||||
GeometryReader { proxy in
|
||||
let minX = proxy.frame(in: .global).minX
|
||||
Image("Images/banner" + String(index))
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.cornerRadius(12)
|
||||
.rotation3DEffect(
|
||||
.degrees(minX / -10),
|
||||
axis: (x: 0.0, y: 1, z: 0.0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.page(indexDisplayMode: .always))
|
||||
.frame(height: 220)
|
||||
.cornerRadius(12)
|
||||
}
|
||||
|
||||
var NewBooks: some View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
@@ -178,6 +236,7 @@ struct HomeView: View {
|
||||
HStack {
|
||||
Text("今日秒杀")
|
||||
.foregroundColor(Color.white)
|
||||
.font(.system(size: 16))
|
||||
KillCountDown()
|
||||
}
|
||||
.padding(8)
|
||||
@@ -197,7 +256,7 @@ struct HomeView: View {
|
||||
.cornerRadius(8)
|
||||
VStack {
|
||||
Text("石床垫:阿特伍德黑暗就故事(有的人说啥就是啥呢有的人说啥就是啥呢有的人说啥就是啥呢)")
|
||||
.font(.title2)
|
||||
.font(.system(size: 20))
|
||||
.multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/)
|
||||
.lineLimit(/*@START_MENU_TOKEN@*/2/*@END_MENU_TOKEN@*/)
|
||||
.foregroundColor(Color.white)
|
||||
@@ -208,6 +267,7 @@ struct HomeView: View {
|
||||
.background(Color.white)
|
||||
HStack {
|
||||
Text("抢购")
|
||||
.font(.system(size: 14))
|
||||
Image(systemName: "chevron.forward")
|
||||
}
|
||||
.foregroundColor(Color.white)
|
||||
@@ -257,63 +317,13 @@ struct HomeView: View {
|
||||
.cornerRadius(64)
|
||||
|
||||
Text("图书")
|
||||
.font(.system(size: 14))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var Banner: some View {
|
||||
HStack {
|
||||
Image("Images/banner1")
|
||||
.resizable(resizingMode: .stretch)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
Image("Images/banner2")
|
||||
.resizable(resizingMode: .stretch)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
Image("Images/banner3")
|
||||
.resizable(resizingMode: .stretch)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
}
|
||||
|
||||
.frame(maxWidth: /*@START_MENU_TOKEN@*/ .infinity/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
|
||||
var Search: some View {
|
||||
HStack(alignment: .center, spacing: 16) {
|
||||
HStack {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.resizable()
|
||||
.frame(width: 18, height: 18)
|
||||
.foregroundColor(Color.gray)
|
||||
Text("搜索书籍")
|
||||
.foregroundColor(Color.gray)
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: /*@START_MENU_TOKEN@*/ .infinity/*@END_MENU_TOKEN@*/)
|
||||
.padding(12)
|
||||
.background(Color.white)
|
||||
.cornerRadius(32)
|
||||
Image(systemName: "bell")
|
||||
.resizable()
|
||||
.frame(width: 24, height: 24)
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Circle()
|
||||
.fill(Color.red)
|
||||
.frame(width: 20, height: 20)
|
||||
.offset(x: 4, y: -8)
|
||||
}
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Text("20")
|
||||
.foregroundColor(Color.white)
|
||||
.font(.system(size: 12))
|
||||
.offset(x: 2, y: -5)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// #Preview {
|
||||
// HomeView()
|
||||
// }
|
||||
#Preview {
|
||||
HomeView()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user