This commit is contained in:
2024-01-24 18:02:39 +08:00
parent e681d68c65
commit 2d7d3dc836
7 changed files with 161 additions and 50 deletions

View File

@@ -35,6 +35,9 @@
968A6FAE2B5FA329008609EE /* CamelPrice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FAD2B5FA329008609EE /* CamelPrice.swift */; }; 968A6FAE2B5FA329008609EE /* CamelPrice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FAD2B5FA329008609EE /* CamelPrice.swift */; };
968A6FB02B5FBB86008609EE /* GoodsCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FAF2B5FBB86008609EE /* GoodsCard.swift */; }; 968A6FB02B5FBB86008609EE /* GoodsCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FAF2B5FBB86008609EE /* GoodsCard.swift */; };
968A6FB22B5FC3A2008609EE /* ShowMore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FB12B5FC3A2008609EE /* ShowMore.swift */; }; 968A6FB22B5FC3A2008609EE /* ShowMore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FB12B5FC3A2008609EE /* ShowMore.swift */; };
968A6FB42B610C67008609EE /* KillCountDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FB32B610C67008609EE /* KillCountDown.swift */; };
968A6FB62B6113BE008609EE /* UserAccountCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FB52B6113BE008609EE /* UserAccountCard.swift */; };
968A6FB82B6113FF008609EE /* UserAccountCardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968A6FB72B6113FF008609EE /* UserAccountCardModel.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@@ -67,6 +70,9 @@
968A6FAD2B5FA329008609EE /* CamelPrice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CamelPrice.swift; sourceTree = "<group>"; }; 968A6FAD2B5FA329008609EE /* CamelPrice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CamelPrice.swift; sourceTree = "<group>"; };
968A6FAF2B5FBB86008609EE /* GoodsCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoodsCard.swift; sourceTree = "<group>"; }; 968A6FAF2B5FBB86008609EE /* GoodsCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoodsCard.swift; sourceTree = "<group>"; };
968A6FB12B5FC3A2008609EE /* ShowMore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowMore.swift; sourceTree = "<group>"; }; 968A6FB12B5FC3A2008609EE /* ShowMore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowMore.swift; sourceTree = "<group>"; };
968A6FB32B610C67008609EE /* KillCountDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KillCountDown.swift; sourceTree = "<group>"; };
968A6FB52B6113BE008609EE /* UserAccountCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAccountCard.swift; sourceTree = "<group>"; };
968A6FB72B6113FF008609EE /* UserAccountCardModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAccountCardModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -129,6 +135,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
968A6F7B2B5F4E63008609EE /* TabBar.swift */, 968A6F7B2B5F4E63008609EE /* TabBar.swift */,
968A6FB72B6113FF008609EE /* UserAccountCardModel.swift */,
); );
path = Models; path = Models;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -152,6 +159,8 @@
968A6FAD2B5FA329008609EE /* CamelPrice.swift */, 968A6FAD2B5FA329008609EE /* CamelPrice.swift */,
968A6FAF2B5FBB86008609EE /* GoodsCard.swift */, 968A6FAF2B5FBB86008609EE /* GoodsCard.swift */,
968A6FB12B5FC3A2008609EE /* ShowMore.swift */, 968A6FB12B5FC3A2008609EE /* ShowMore.swift */,
968A6FB32B610C67008609EE /* KillCountDown.swift */,
968A6FB52B6113BE008609EE /* UserAccountCard.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -326,8 +335,11 @@
968A6F792B5F4E28008609EE /* TabBarView.swift in Sources */, 968A6F792B5F4E28008609EE /* TabBarView.swift in Sources */,
968A6FA82B5F6AF3008609EE /* CartView.swift in Sources */, 968A6FA82B5F6AF3008609EE /* CartView.swift in Sources */,
968A6FAA2B5F6B07008609EE /* CategoryView.swift in Sources */, 968A6FAA2B5F6B07008609EE /* CategoryView.swift in Sources */,
968A6FB82B6113FF008609EE /* UserAccountCardModel.swift in Sources */,
968A6F642B5F4C99008609EE /* demoApp.swift in Sources */, 968A6F642B5F4C99008609EE /* demoApp.swift in Sources */,
968A6FB62B6113BE008609EE /* UserAccountCard.swift in Sources */,
968A6F952B5F6836008609EE /* BalanceView.swift in Sources */, 968A6F952B5F6836008609EE /* BalanceView.swift in Sources */,
968A6FB42B610C67008609EE /* KillCountDown.swift in Sources */,
968A6F882B5F4EC4008609EE /* UserView.swift in Sources */, 968A6F882B5F4EC4008609EE /* UserView.swift in Sources */,
968A6F9E2B5F688A008609EE /* LoginView.swift in Sources */, 968A6F9E2B5F688A008609EE /* LoginView.swift in Sources */,
968A6F8C2B5F67ED008609EE /* OrdersView.swift in Sources */, 968A6F8C2B5F67ED008609EE /* OrdersView.swift in Sources */,

View File

@@ -0,0 +1,38 @@
//
// KillCountDown.swift
// demo
//
// Created by Jason on 2024/1/24.
//
import SwiftUI
struct KillCountDown: View {
var body: some View {
HStack(spacing: 6) {
number(num: 23)
spector
number(num: 19)
spector
number(num: 9)
}
}
func number(num: Int) -> some View {
var s = String(num)
if num < 10 {
s = "0".appending(s)
}
return Text(s)
.padding(4)
.foregroundColor(Color.red)
.background(Color.white)
.font(.system(size: 14))
.cornerRadius(4)
}
var spector: some View {
Text(":")
.foregroundColor(Color.white)
}
}

View File

@@ -0,0 +1,25 @@
//
// UserAccountCard.swift
// demo
//
// Created by Jason on 2024/1/24.
//
import SwiftUI
struct UserAccountCard: View {
var model: UserAccountCardModel
var body: some View {
VStack {
HStack {
Image(systemName: model.icon)
Text(model.title)
}
Text(model.info)
.font(.caption)
}
.padding(12)
.background(Color.white)
.cornerRadius(8)
}
}

View File

@@ -0,0 +1,15 @@
//
// UserAccountCardModel.swift
// demo
//
// Created by Jason on 2024/1/24.
//
import Foundation
struct UserAccountCardModel: Identifiable {
var id = UUID()
var title: String
var icon: String
var info: String
}

View File

@@ -13,10 +13,10 @@ struct HomeView: View {
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack(spacing: 12) { VStack(spacing: 12) {
Search // Search
// Banner // Banner
// Navigation // Navigation
// TodayKill TodayKill
// Living // Living
// Bestselling // Bestselling
// PartyReading // PartyReading
@@ -173,18 +173,31 @@ struct HomeView: View {
} }
var TodayKill: some View { var TodayKill: some View {
VStack(alignment: .leading) {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack { HStack {
Text("今日秒杀") Text("今日秒杀")
Text("00:00:00") .foregroundColor(Color.white)
KillCountDown()
} }
HStack { .padding(8)
.background(LinearGradient(colors: [Color.yellow.opacity(0.3), Color.white.opacity(0.3)], startPoint: .leading, endPoint: .bottom))
HStack(spacing: 12) {
Image("Images/LaunchScreen") Image("Images/LaunchScreen")
.resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/) .resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/)
.aspectRatio(contentMode: .fit) .frame(maxWidth: 120, maxHeight: 150)
.frame(maxWidth: 120) .overlay(alignment: .bottom) {
Text("剩余100")
.font(.system(size: 14))
.foregroundColor(Color.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 4)
.background(Color.red.opacity(0.5))
}
.cornerRadius(8)
VStack { VStack {
Text("石床垫:阿特伍德黑暗就故事(有的人说啥就是啥呢有的人说啥就是啥呢有的人说啥就是啥呢)") Text("石床垫:阿特伍德黑暗就故事(有的人说啥就是啥呢有的人说啥就是啥呢有的人说啥就是啥呢)")
.font(.title2)
.multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/) .multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/)
.lineLimit(/*@START_MENU_TOKEN@*/2/*@END_MENU_TOKEN@*/) .lineLimit(/*@START_MENU_TOKEN@*/2/*@END_MENU_TOKEN@*/)
.foregroundColor(Color.white) .foregroundColor(Color.white)
@@ -199,21 +212,30 @@ struct HomeView: View {
} }
.foregroundColor(Color.white) .foregroundColor(Color.white)
} }
.frame(height: 150)
} }
}
.padding(12)
VStack {
ScrollView(.horizontal) {
HStack { HStack {
ForEach(0 ..< 5) { _ in ForEach(0 ..< 8) { _ in
VStack { VStack {
Image("Images/LaunchScreen") Image("Images/LaunchScreen")
.resizable(resizingMode: /*@START_MENU_TOKEN@*/ .stretch/*@END_MENU_TOKEN@*/) .antialiased(true)
.aspectRatio(contentMode: .fit) .resizable(resizingMode: .stretch)
.frame(maxWidth: 120) .frame(maxWidth: 100, maxHeight: 130)
Text("是石床垫:阿特伍德黑暗就故事") Text("是石床垫:阿特伍德黑暗就故事")
.font(.system(size: 14))
.lineLimit(1) .lineLimit(1)
Text("¥19.99") CamelPrice(amount: 19.99, size: 12)
.foregroundColor(Color.red)
} }
.padding(4)
.frame(maxWidth: 110) .frame(maxWidth: 110)
.background(Color.white) .background(Color.white)
.cornerRadius(4)
}
}
} }
} }
.padding(12) .padding(12)

View File

@@ -8,6 +8,8 @@
import SwiftUI import SwiftUI
struct UserView: View { struct UserView: View {
@State private var showDetail = false
var body: some View { var body: some View {
ScrollView { ScrollView {
Header Header
@@ -21,9 +23,8 @@ struct UserView: View {
tj tj
} }
.padding(16) .padding(16)
.background(LinearGradient(colors: [Color.orange, Color.gray], startPoint: .top, endPoint: UnitPoint(x: 0, y: 0.5))) .background(Color.gray.opacity(0.2))
.cornerRadius(12) .cornerRadius(12)
.offset(y: -76)
} }
} }
@@ -51,11 +52,17 @@ struct UserView: View {
Image(systemName: "gearshape") Image(systemName: "gearshape")
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
} }
.padding(.horizontal, 16) .padding(.horizontal, 24)
} }
var ToVip: some View { var ToVip: some View {
HStack(spacing: /*@START_MENU_TOKEN@*/nil/*@END_MENU_TOKEN@*/, content: { HStack(spacing: /*@START_MENU_TOKEN@*/nil/*@END_MENU_TOKEN@*/, content: {
Text("VIP de yixie 简介部分")
Button(action: {
self.showDetail.toggle()
}, label: {
Text("详情")
})
Spacer() Spacer()
Button("立即开通") {} Button("立即开通") {}
.foregroundColor(Color.red) .foregroundColor(Color.red)
@@ -68,6 +75,8 @@ struct UserView: View {
.padding(16) .padding(16)
.padding(.bottom, 64) .padding(.bottom, 64)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.frame(height: showDetail ? 100 : 200)
.animation(.default, value: showDetail)
.background( .background(
Image("Images/banner3").resizable(resizingMode: .tile) Image("Images/banner3").resizable(resizingMode: .tile)
// .overlay( // .overlay(
@@ -82,17 +91,7 @@ struct UserView: View {
ScrollView(.horizontal) { ScrollView(.horizontal) {
HStack(spacing: 16) { HStack(spacing: 16) {
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in
VStack { UserAccountCard(model: UserAccountCardModel(title: "我的积分", icon: "star", info: "共30001分"))
HStack {
Image(systemName: "star")
Text("我的积分")
}
Text("共8888分")
.font(.caption)
}
.padding(12)
.background(Color.white)
.cornerRadius(8)
} }
} }
} }