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

BIN
demo/.DS_Store vendored Normal file

Binary file not shown.

BIN
demo/Assets.xcassets/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "logo.jpg",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View File

@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x23",
"green" : "0x23",
"red" : "0x23"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xEF",
"green" : "0xEF",
"red" : "0xEF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0x00",
"red" : "0x00"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0x00",
"red" : "0x00"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,9 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"provides-namespace" : true
}
}

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sunset-675847_1920.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "413.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "420.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "476.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "3 1.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "3ac79f3df8dcd10010dddf20758b4710b9122f69.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

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)
}
}
}

29
demo/Models/TabBar.swift Normal file
View File

@@ -0,0 +1,29 @@
//
// TabBar.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct TabItem: Identifiable {
var id = UUID()
var icon: String
var text: String
var tab: Tab
}
var tabItems = [
TabItem(icon: "book", text: "图书馆", tab: .home),
TabItem(icon: "bag", text: "生活馆", tab: .explore),
TabItem(icon: "cart", text: "购物车", tab: .message),
TabItem(icon: "person", text: "个人中心", tab: .account)
]
enum Tab: String {
case home
case explore
case message
case account
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,18 @@
//
// ForgotView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct ForgotView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
ForgotView()
}

View File

@@ -0,0 +1,18 @@
//
// Licence.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct LicenceView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
LicenceView()
}

View File

@@ -0,0 +1,18 @@
//
// LoginView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct LoginView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
LoginView()
}

View File

@@ -0,0 +1,18 @@
//
// Register.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct RegisterView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
RegisterView()
}

View File

@@ -0,0 +1,293 @@
//
// HomeView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct HomeView: View {
@State private var selectedTab = 0
var body: some View {
ScrollView {
VStack(spacing: 12) {
// Search
// Banner
// Navigation
// TodayKill
// Living
// Bestselling
PartyReading
// NewBooks
// Categories
}
}
.frame(maxWidth: .infinity)
.padding(.horizontal, 12)
.background(Color.gray.opacity(0.2))
}
let columns = [GridItem(.flexible()), GridItem(.flexible())]
var Categories: some View {
VStack {
ScrollView(.horizontal) {
HStack {
Text("推荐")
Text("竞品书单")
Text("少儿")
Text("武侠")
Text("文创")
Text("历史")
Text("专辑")
Text("世纪难题")
Text("个性推荐")
}
}
LazyVGrid(columns: columns, alignment: .center) {
ForEach(0 ..< 20, id: \.self) { _ in
GoodsCard()
}
}
}
}
var NewBooks: some View {
VStack(alignment: .leading) {
HStack {
Text("新书上架")
Spacer()
Image(systemName: "chevron.forward")
}
HStack(alignment: .top) {
ForEach(0 ..< 4) { _ in
VStack {
Image("Images/LaunchScreen")
.resizable()
.frame(maxHeight: 120)
.cornerRadius(4)
Text("唐伯虎的故事,成就的是谁")
.lineLimit(1)
}
.frame(maxWidth: 100)
}
}
}
.padding(12)
.background(Color.white)
.cornerRadius(12)
}
var PartyReading: some View {
VStack(alignment: .leading) {
HStack {
Text("党政读物预订专区")
.font(.title3)
.foregroundColor(Color.white)
Spacer()
ShowMore(title: "全部")
}
Text("阅读这10本书让你深度学习党政相关知识思想提升")
.foregroundColor(Color.red)
Text("治国必先治党,治党才能国强,进入新时代,以习近平通知为核心的党中央以前所未有的勇气和定理推进全面从严治党,")
.font(.caption)
.foregroundColor(Color.gray)
.lineLimit(2)
ScrollView(.horizontal) {
HStack(alignment: .top) {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack {
Image("Images/LaunchScreen")
.resizable()
.frame(maxWidth: 120, maxHeight: 150)
.cornerRadius(4)
Text("唐伯虎的故事,成就的是谁")
.lineLimit(1)
}
.frame(maxWidth: 100)
}
}
}
}
.padding(12)
.background(LinearGradient(colors: [Color.red, Color.white], startPoint: UnitPoint.top, endPoint: UnitPoint.bottom))
.cornerRadius(12)
}
var Bestselling: some View {
VStack(alignment: .leading) {
HStack {
Text("畅销图书")
Spacer()
Text("全部")
Image(systemName: "chevron.forward")
}
ScrollView(.horizontal) {
HStack(alignment: .top) {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack {
Image("Images/LaunchScreen")
.resizable()
.frame(maxWidth: 120, maxHeight: 150)
.cornerRadius(4)
Text("唐伯虎的故事,成就的是谁")
.lineLimit(1)
HStack {
Image(systemName: "eye")
Text("299万")
}
}
.frame(maxWidth: 100)
}
}
}
}
.padding(12)
.background(Color.white)
.cornerRadius(12)
}
var Living: some View {
HStack {
ForEach(0 ..< 3) { _ in
VStack {
HStack {
Text("正在直播")
Image(systemName: "livephoto")
}
Image("Images/LaunchScreen")
.resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/)
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 120)
.cornerRadius(12)
}
.background(Color.pink.opacity(0.5))
.cornerRadius(12)
}
}
}
var TodayKill: some View {
VStack(alignment: .leading) {
HStack {
Text("今日秒杀")
Text("00:00:00")
}
HStack {
Image("Images/LaunchScreen")
.resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/)
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 120)
VStack {
Text("石床垫:阿特伍德黑暗就故事(有的人说啥就是啥呢有的人说啥就是啥呢有的人说啥就是啥呢)")
.multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/)
.lineLimit(/*@START_MENU_TOKEN@*/2/*@END_MENU_TOKEN@*/)
.foregroundColor(Color.white)
Text("¥19.99")
.foregroundColor(Color.red)
.padding(12)
.cornerRadius(12)
.background(Color.white)
HStack {
Text("抢购")
Image(systemName: "chevron.forward")
}
.foregroundColor(Color.white)
}
}
HStack {
ForEach(0 ..< 5) { _ in
VStack {
Image("Images/LaunchScreen")
.resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/)
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 120)
Text("是石床垫:阿特伍德黑暗就故事")
.lineLimit(1)
Text("¥19.99")
.foregroundColor(Color.red)
}
.frame(maxWidth: 110)
.background(Color.white)
}
}
.padding(12)
.background(Color.white.opacity(0.3))
}
.frame(maxWidth: /*@START_MENU_TOKEN@*/ .infinity/*@END_MENU_TOKEN@*/)
.background(Color.pink)
.cornerRadius(12)
}
var Navigation: some View {
HStack(spacing: 32) {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack {
Image("Images/logo")
.resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/)
.aspectRatio(contentMode: .fit)
.background(Color.white)
.cornerRadius(64)
Text("图书")
}
}
}
}
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)
ZStack {
Image(systemName: "bell").resizable().frame(width: 24, height: 24)
Text("9")
.font(.system(size: 12))
.padding(4)
.frame(minWidth: 24)
.background(Color.red)
.foregroundColor(Color.white)
.cornerRadius(99)
.offset(x: 10, y: -10)
}
.padding(.trailing, 12)
}
}
}
//
// #Preview {
// HomeView()
// }

View File

@@ -0,0 +1,18 @@
//
// NoticeListView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct NoticeListView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
NoticeListView()
}

View File

@@ -0,0 +1,18 @@
//
// NoticeView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct NoticeView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
NoticeView()
}

View File

@@ -0,0 +1,18 @@
//
// SearchView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct SearchView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
SearchView()
}

View File

@@ -0,0 +1,64 @@
//
// TabBarView.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct TabBarView: View {
@AppStorage("selectedTab") var selectedTab: Tab = .home
var body: some View {
ZStack(alignment: .leading) {
Group {
switch selectedTab {
case .home:
HomeView()
case .explore:
MallView()
case .message:
MessageView()
case .account:
UserView()
}
}
// .offset(y: -64)
// .safeAreaInset(edge: .top) {
// Color.clear.frame(height: 32)
// }
HStack {
ForEach(tabItems) { item in
Button(action: {
selectedTab = item.tab
}, label: {
VStack(spacing: 6) {
Image(systemName: item.icon).resizable().frame(width: 18, height: 18)
Text(item.text)
.font(.caption)
.fontWeight(.regular)
.multilineTextAlignment(.center)
.lineLimit(1)
}
.frame(maxWidth: .infinity)
})
.foregroundColor(selectedTab == item.tab ? Color("MainText") : Color.secondary)
.shadow(color: selectedTab == item.tab ? Color.orange : Color.blue, radius: 15)
}
}
.padding(.top, 12.0)
.padding(.bottom, 32)
.background(Color("TabBarColor"))
.frame(maxHeight: .infinity, alignment: .bottom)
.shadow(color: Color.gray.opacity(0.5), radius: 6, x: 0, y: 6)
.ignoresSafeArea()
}
.statusBarHidden(false)
}
}
#Preview {
TabBarView()
}

View File

@@ -0,0 +1,18 @@
//
// CartView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct CartView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
CartView()
}

View File

@@ -0,0 +1,18 @@
//
// CategoryView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct CategoryView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
CategoryView()
}

View File

@@ -0,0 +1,18 @@
//
// GoodsCommentsView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct GoodsCommentsView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
GoodsCommentsView()
}

View File

@@ -0,0 +1,18 @@
//
// GoodsDetail.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct GoodsDetailView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
GoodsDetailView()
}

View File

@@ -0,0 +1,18 @@
//
// MallView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct MallView: View {
var body: some View {
Text("Mall Page")
}
}
#Preview {
MallView()
}

View File

@@ -0,0 +1,18 @@
//
// MessageView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct MessageView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
MessageView()
}

View File

@@ -0,0 +1,18 @@
//
// AccountView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct AccountView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
AccountView()
}

View File

@@ -0,0 +1,18 @@
//
// BalanceView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct BalanceView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
BalanceView()
}

View File

@@ -0,0 +1,18 @@
//
// CouponView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct CouponView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
CouponView()
}

View File

@@ -0,0 +1,18 @@
//
// OrderDetailView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct OrderDetailView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
OrderDetailView()
}

View File

@@ -0,0 +1,18 @@
//
// OrdersView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct OrdersView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
OrdersView()
}

View File

@@ -0,0 +1,183 @@
//
// UserView.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
struct UserView: View {
var body: some View {
ScrollView {
Header
ToVip
VStack(spacing: 16) {
InfoList
Notice
OrderShow
Coupons
tj
}
.padding(16)
.background(LinearGradient(colors: [Color.orange, Color.gray], startPoint: .top, endPoint: UnitPoint(x: 0, y: 0.5)))
.cornerRadius(12)
.offset(y: -76)
}
}
var Header: some View {
HStack {
Image("Images/logo")
.resizable()
.frame(width: 64, height: 64)
.cornerRadius(32)
.overlay(
RoundedRectangle(cornerRadius: 32, style: .continuous)
.stroke(Color.red, lineWidth: 2)
)
VStack(alignment: .leading, spacing: 12, content: {
Text("用户名称")
.font(.title2)
.fontWeight(.regular)
Text("我的用户简介,超出部分需要隐藏,隐藏需要自动设置,这个文字长度也要有约束")
.font(.caption)
.foregroundColor(Color.gray)
.lineLimit(1)
})
Image(systemName: "gearshape")
.foregroundColor(Color.gray)
}
.padding(.horizontal, 16)
}
var ToVip: some View {
HStack(spacing: /*@START_MENU_TOKEN@*/nil/*@END_MENU_TOKEN@*/, content: {
Spacer()
Button("立即开通") {}
.foregroundColor(Color.red)
.font(.subheadline)
.padding(.vertical, 8)
.padding(.horizontal, 16)
.background(Color.gray)
.cornerRadius(32)
})
.padding(16)
.padding(.bottom, 64)
.frame(maxWidth: .infinity)
.background(
Image("Images/banner3").resizable(resizingMode: .tile)
// .overlay(
// UnevenRoundedRectangle(cornerRadii: RectangleCornerRadii(topLeading: 12, topTrailing: 12))
// )
)
.cornerRadius(12)
.padding(.horizontal, 16)
}
var InfoList: some View {
ScrollView(.horizontal) {
HStack(spacing: 16) {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack {
HStack {
Image(systemName: "star")
Text("我的积分")
}
Text("共8888分")
.font(.caption)
}
.padding(12)
.background(Color.white)
.cornerRadius(8)
}
}
}
}
var Notice: some View {
HStack {
Text("资讯")
.padding(4)
.background(Color.red)
.foregroundColor(Color.white)
Text("平台与2024年1余额开始更新敬请期待@@@")
.foregroundColor(Color.gray)
.frame(maxWidth: .infinity)
.multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/)
.lineLimit(1)
Text("更多")
.foregroundColor(Color.secondary)
}
.frame(maxWidth: .infinity)
.padding(8)
.background(Color.white)
.cornerRadius(8)
}
var OrderShow: some View {
VStack(spacing: 16) {
HStack {
Text("订单中心")
Spacer()
ShowMore()
}
.padding(8)
HStack {
Spacer()
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack {
Image(systemName: "wallet.pass")
Text("待付款")
.font(.system(size: 12))
}
Spacer()
}
}
}
.background(Color.white)
.cornerRadius(6)
}
var Coupons: some View {
VStack(spacing: 16) {
HStack {
Spacer()
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack {
Image(systemName: "wallet.pass")
Text("优惠券")
.font(.system(size: 12))
}
Spacer()
}
}
}
.padding(12)
.background(Color.white)
.cornerRadius(6)
}
let columns = [GridItem(.flexible()), GridItem(.flexible())]
var tj: some View {
LazyVGrid(columns: columns, alignment: .center) {
Section {
ForEach(0 ..< 20, id: \.self) { _ in
GoodsCard()
}
}
header: {
Text("推荐广场")
}
}
}
}
//
// #Preview {
// UserView()
// }

18
demo/demoApp.swift Normal file
View File

@@ -0,0 +1,18 @@
//
// demoApp.swift
// demo
//
// Created by Jason on 2024/1/23.
//
import SwiftUI
import SwiftData
@main
struct demoApp: App {
var body: some Scene {
WindowGroup {
TabBarView()
}
}
}