// // CartView.swift // demo // // Created by Jason on 2024/1/23. // import SwiftUI struct CartView: View { @State private var isCheckAll = false @State private var canSettle: Bool = false var body: some View { VStack(spacing: 0) { HStack(spacing: 2) { Text("购物车") .font(.system(size: 18)) Text("(12)") .font(.system(size: 12)) .foregroundColor(Color.gray) Spacer() Text("管理") .font(.system(size: 16)) .foregroundColor(Color.black) .onTapGesture { canSettle.toggle() } } .padding(.horizontal, 16) .padding(.bottom, 12) ScrollView(.vertical, showsIndicators: false) { VStack(spacing: 12) { ForEach(0 ..< 22) { _ in Rectangle() .fill(Color.white) .frame(maxWidth: .infinity) .frame(height: 100) } } .padding(.bottom, 12) } .frame(maxWidth: .infinity) .padding(.horizontal, 12) HStack(alignment: .center, spacing: 4) { RadioButton(checked: $isCheckAll, label: "全选") Spacer() Text("合计") .font(.system(size: 14)) CamelPrice(amount: 0) Text("结 算") .font(.system(size: 14)) .padding(.horizontal, 24) .padding(.vertical, 12) .foregroundColor(Color.white) .background( LinearGradient(colors: [ canSettle ? Color.orange : Color.gray.opacity(0.5), canSettle ? Color.red : Color.gray, ], startPoint: .leading, endPoint: .trailing) ) .cornerRadius(32) .onTapGesture {} } .padding(12) .background(Color.white) } .animation(.linear(duration: 10), value: isCheckAll) .padding(.bottom, 62) } } #Preview { CartView() }