This commit is contained in:
2024-01-23 18:00:59 +08:00
commit c10f0dd29d
55 changed files with 1906 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
//
// CamelPrice.swift
//
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct CamelPrice: View {
@State public var amount: Double
@State public var size = 16.0
@State public var color = Color.red
func getInt(amount: Double) -> String {
return String(Int(amount.rounded(.down)))
}
func getDecimal(amount: Double) -> String {
var decimal = String(amount.truncatingRemainder(dividingBy: 1))
let range = decimal.range(of: "0.")!
decimal.replaceSubrange(range, with: ".")
if decimal.count < 3 {
decimal.append("0")
} else {
decimal = String(decimal[..<decimal.index(decimal.startIndex, offsetBy: 3)])
}
return decimal
}
var body: some View {
HStack(alignment: .bottom, spacing: 0) {
Group {
Text("")
.font(.system(size: size))
.baselineOffset(size / 10)
.offset(x: 2)
Text(getInt(amount: amount))
.font(.system(size: size * 1.4))
Text(getDecimal(amount: amount))
.font(.system(size: size))
.baselineOffset(size / 12)
}
.foregroundColor(color)
}
}
}

View File

@@ -0,0 +1,39 @@
//
// GoodsCard.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct GoodsCard: View {
func getHeight() -> CGFloat {
(UIScreen.main.bounds.width - 24 - 12) / 2 * 1.2
}
var body: some View {
VStack {
Image("Images/LaunchScreen")
.resizable()
.frame(maxWidth: .infinity)
.frame(maxHeight: getHeight())
VStack(spacing: 4) {
Text("苏东坡专辑,谁谁会注解的内容哦")
.font(.subheadline)
.lineLimit(1)
HStack(alignment: .bottom) {
CamelPrice(amount: 125.9229, size: 16)
Spacer()
Text("100+付款")
.foregroundColor(Color.gray)
.font(.caption)
.baselineOffset(2)
}
}
.padding(4)
}
.background(Color.white)
.cornerRadius(8)
}
}

View File

@@ -0,0 +1,23 @@
//
// ShowMore.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct ShowMore: View {
var title = "查看全部"
var body: some View {
HStack(spacing: 4) {
Text(title)
.font(.system(size: 14))
.foregroundColor(Color.gray)
Image(systemName: "chevron.forward")
.resizable()
.frame(width: 6, height: 10)
.foregroundColor(Color.gray)
}
}
}