商品详情页

This commit is contained in:
2024-01-29 17:55:09 +08:00
parent fdc1b1c18f
commit 5109b242a6
6 changed files with 102 additions and 9 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -8,13 +8,14 @@
import SwiftUI import SwiftUI
struct GoodsCard: View { struct GoodsCard: View {
var title: String
func getHeight() -> CGFloat { func getHeight() -> CGFloat {
(UIScreen.main.bounds.width - 24 - 12) / 2 * 1.2 (UIScreen.main.bounds.width - 24 - 12) / 2 * 1.2
} }
var body: some View { var body: some View {
NavigationLink { NavigationLink {
GoodsDetailView() GoodsDetailView(title: title)
} label: { } label: {
VStack { VStack {
Image("Images/LaunchScreen") Image("Images/LaunchScreen")

View File

@@ -84,7 +84,7 @@ struct HomeView: View {
LazyVGrid(columns: columns, alignment: .center) { LazyVGrid(columns: columns, alignment: .center) {
ForEach(0 ..< 20, id: \.self) { _ in ForEach(0 ..< 20, id: \.self) { _ in
GoodsCard() GoodsCard(title: "首页进入的商品标题,如果长了,会不会自动隐藏的问题,这里需要测试")
} }
} }
} }

View File

@@ -8,15 +8,107 @@
import SwiftUI import SwiftUI
struct GoodsDetailView: View { struct GoodsDetailView: View {
@Environment(\.dismiss) private var dismiss
var title: String
var body: some View { var body: some View {
NavigationPageView(title: "商品详情", content: content) ZStack {
ScrollView {
VStack {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
Image("Images/banner1")
.resizable()
.scaledToFit()
} }
var content: some View { HStack {
Image("Images/banner1") Text(title)
CamelPrice(amount: 32.112)
}
VStack {
Text("商品详情部分")
}
}
}
.padding(.bottom, 100)
.ignoresSafeArea(.all)
HStack {
Image(systemName: "chevron.backward")
Spacer()
Image(systemName: "ellipsis")
}
.padding(12.0)
.background(LinearGradient(colors: [Color.white, Color.white.opacity(0)], startPoint: .top, endPoint: .bottom))
.frame(maxHeight: .infinity, alignment: .top)
HStack(spacing: 0) {
HStack(spacing: 8) {
Image(systemName: "house")
.resizable()
.foregroundColor(Color.gray)
.frame(width: 20, height: 18)
Image(systemName: "person.fill.questionmark")
.resizable()
.foregroundColor(Color.gray)
.frame(width: 20, height: 18)
Image(systemName: "star")
.resizable()
.foregroundColor(Color.gray)
.frame(width: 20, height: 18)
Image(systemName: "cart")
.resizable()
.foregroundColor(Color.gray)
.frame(width: 20, height: 18)
}
Spacer()
HStack(spacing: 12) {
Button {} label: {
Text("加入购物车")
.font(.system(size: 15))
.foregroundColor(Color.white)
}
Rectangle()
.fill(Color.white)
.frame(width: 1, height: 14)
Button {} label: {
Text("立即购买")
.font(.system(size: 15))
.foregroundColor(Color.white)
}
}
.padding(.vertical, 12)
.padding(.horizontal, 24)
.background(LinearGradient(colors: [Color.orange, Color.red], startPoint: .leading, endPoint: .trailing))
.clipShape(
RoundedRectangle(cornerRadius: 24)
)
}
.padding(12.0)
.frame(maxWidth: /*@START_MENU_TOKEN@*/ .infinity/*@END_MENU_TOKEN@*/)
.background(Color("TabBarColor"))
.frame(maxHeight: .infinity, alignment: .bottom)
}
.background(Color.gray.opacity(0.2))
// .navigationBarTitleDisplayMode(.inline)
// .navigationTitle(title)
// .navigationBarBackButtonHidden(true)
// .toolbar {
// ToolbarItem(placement: .navigationBarLeading) {
// Button {
// dismiss()
// } label: {
// HStack {
// Image(systemName: "chevron.backward")
// }
// }
// }
// }
} }
} }
#Preview { #Preview {
GoodsDetailView() GoodsDetailView(title: "Test")
} }

View File

@@ -272,7 +272,7 @@ struct UserView: View {
LazyVGrid(columns: columns, alignment: .center, spacing: 12, pinnedViews: .sectionHeaders) { LazyVGrid(columns: columns, alignment: .center, spacing: 12, pinnedViews: .sectionHeaders) {
Section { Section {
ForEach(0 ..< 20, id: \.self) { _ in ForEach(0 ..< 20, id: \.self) { _ in
GoodsCard() GoodsCard(title: "我是商品标题")
} }
} }
header: { header: {