商品详情页
This commit is contained in:
Binary file not shown.
@@ -8,13 +8,14 @@
|
||||
import SwiftUI
|
||||
|
||||
struct GoodsCard: View {
|
||||
var title: String
|
||||
func getHeight() -> CGFloat {
|
||||
(UIScreen.main.bounds.width - 24 - 12) / 2 * 1.2
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationLink {
|
||||
GoodsDetailView()
|
||||
GoodsDetailView(title: title)
|
||||
} label: {
|
||||
VStack {
|
||||
Image("Images/LaunchScreen")
|
||||
|
||||
@@ -84,7 +84,7 @@ struct HomeView: View {
|
||||
|
||||
LazyVGrid(columns: columns, alignment: .center) {
|
||||
ForEach(0 ..< 20, id: \.self) { _ in
|
||||
GoodsCard()
|
||||
GoodsCard(title: "首页进入的商品标题,如果长了,会不会自动隐藏的问题,这里需要测试")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,107 @@
|
||||
import SwiftUI
|
||||
|
||||
struct GoodsDetailView: View {
|
||||
var body: some View {
|
||||
NavigationPageView(title: "商品详情", content: content)
|
||||
}
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
var title: String
|
||||
|
||||
var content: some View {
|
||||
Image("Images/banner1")
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ScrollView {
|
||||
VStack {
|
||||
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
|
||||
Image("Images/banner1")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
}
|
||||
|
||||
HStack {
|
||||
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 {
|
||||
GoodsDetailView()
|
||||
GoodsDetailView(title: "Test")
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ struct UserView: View {
|
||||
LazyVGrid(columns: columns, alignment: .center, spacing: 12, pinnedViews: .sectionHeaders) {
|
||||
Section {
|
||||
ForEach(0 ..< 20, id: \.self) { _ in
|
||||
GoodsCard()
|
||||
GoodsCard(title: "我是商品标题")
|
||||
}
|
||||
}
|
||||
header: {
|
||||
|
||||
Reference in New Issue
Block a user