This commit is contained in:
2024-01-22 18:13:01 +08:00
parent b4f90a9019
commit 8c2daac591
23 changed files with 605 additions and 55 deletions

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,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

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -1,11 +1,12 @@
{
"images" : [
{
"filename" : "3 1.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "3.jpg",
"filename" : "3ac79f3df8dcd10010dddf20758b4710b9122f69.jpg",
"idiom" : "universal",
"scale" : "2x"
},

View File

@@ -8,6 +8,7 @@
import SwiftUI
struct UserCardComponent: View {
var body: some View {
VStack (alignment: .leading, spacing: 8, content: {
Spacer()
@@ -27,7 +28,8 @@ struct UserCardComponent: View {
})
.padding(.all, 20)
.frame(height: 300)
.background(.ultraThinMaterial)
.background(Image("Images/banner2").resizable().aspectRatio(contentMode: .fill))
// .background(.ultraThinMaterial)
.cornerRadius(10)
.shadow(radius: 20)
.padding(.horizontal, 10)

29
jason/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

@@ -6,13 +6,12 @@
//
import SwiftUI
import SwiftData
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
TabbarView()
TabBarView()
}
}
}

View File

@@ -0,0 +1,72 @@
//
// LoginView.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct LoginView: View {
@AppStorage("authUsername") private var username: String = ""
@State private var password: String = ""
@State private var remember: Bool = false
@State private var toRegister: Bool = false
var body: some View {
ScrollView {
NavigationLink(destination: RegisterView(), label: {
Text("去注册")
})
VStack(alignment: .leading ,spacing: 12) {
// Button(action: {
// dismiss()
// }, label: {
// Image(systemName: "chevron.backward")
// Text("")
// })
TextField("请输入用户名",text: $username)
SecureField("请输入密码", text: $password)
Toggle(isOn: $remember) {
Text("记住用户")
}
HStack {
Button("注册") {
toRegister = true
}
.padding(.vertical, 12)
.padding(.horizontal, 32)
.foregroundColor(.white)
.cornerRadius(6)
.fullScreenCover(isPresented: $toRegister, content: {
RegisterView()
})
Spacer()
Button("登录") {
}
.padding(.vertical, 12)
.padding(.horizontal, 32)
.foregroundColor(.white)
.cornerRadius(6)
}
}
.padding(.horizontal, 12)
}
}
}
#Preview {
LoginView()
}

View File

@@ -0,0 +1,70 @@
//
// RegisterView.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct RegisterView: View {
@State private var username: String = ""
@State private var password: String = ""
@State private var showNext: Bool = false
var body: some View {
ScrollView {
VStack (alignment: .leading, spacing: 12) {
// Button(action: {
// dismiss()
// }, label: {
// Image(systemName: "chevron.backward")
// Text("")
// })
//
TextField("请输入用户名",text: $username)
.padding(.all, 12)
.cornerRadius(6)
.border(Color.gray)
SecureField("请输入密码", text: $password)
.padding(.all, 12)
.cornerRadius(6)
.border(Color.gray)
HStack {
Button("注册") {
showNext = true
}
.padding(.vertical, 12)
.padding(.horizontal, 32)
.foregroundColor(.white)
.cornerRadius(6)
.fullScreenCover(isPresented: $showNext, content: {
RegisterView()
})
Spacer()
Button("登录") {
}
.padding(.vertical, 12)
.padding(.horizontal, 32)
.foregroundColor(.white)
.cornerRadius(6)
}
}
.padding(.all, 12)
.navigationTitle("注册")
.navigationBarTitleDisplayMode(.large)
}
}
}
#Preview {
RegisterView()
}

View File

@@ -10,10 +10,10 @@ import SwiftData
struct HomeView: View {
var body: some View {
ScrollView{
VStack(alignment: .leading, content: {
ScrollView {
ZStack(alignment: .leading) {
UserCardComponent()
})
}
}
.background(Color.orange)
}

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="Images/LaunchScreen" translatesAutoresizingMaskIntoConstraints="NO" id="YBo-Ve-E6d">
<rect key="frame" x="-369" y="-10" width="960" height="640"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Jason.Test" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kdI-F4-fGB">
<rect key="frame" x="22" y="648" width="145" height="39"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="32"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Copyright 2023" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FpI-q0-oUO">
<rect key="frame" x="288" y="803" width="89" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="Images/LaunchScreen" width="960" height="639.5"/>
</resources>
</document>

View File

@@ -0,0 +1,30 @@
//
// LaunchScreen.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct LaunchScreen: View {
var body: some View {
Spacer()
Text("Jason.App")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(Color.red)
.multilineTextAlignment(.center)
Spacer()
Text("Copyright By Jason 2023")
.font(.custom("", size: 10))
.foregroundColor(Color.gray)
.multilineTextAlignment(.center)
}
}
#Preview {
LaunchScreen()
}

View File

@@ -0,0 +1,65 @@
//
// 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: -44)
// .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,20 @@
//
// MallView.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct MallView: View {
var body: some View {
ScrollView {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
}
#Preview {
MallView()
}

View File

@@ -0,0 +1,25 @@
//
// MessageView.swift
// jason
//
// Created by Jason on 2024/1/19.
//
import SwiftUI
struct MessageView: View {
var body: some View {
ScrollView {
ForEach (0 ..< 55) { item in
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
}
}
#Preview {
MessageView()
}

View File

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

View File

@@ -1,38 +0,0 @@
//
// TabbarView.swift
// jason
//
// Created by Jason on 2024/1/16.
//
import SwiftUI
struct TabbarView: View {
var body: some View {
TabView() {
HomeView()
.tabItem {
Image(systemName: "house")
Text("Home")
}
.tag(1)
ExploreView()
.tabItem {
Image(systemName: "magnifyingglass")
Text("Explore")
}
.tag(2)
UserView()
.tabItem {
Image(systemName: "person")
Text("User")
}
.tag(3)
}
.background(Color.white)
}
}
#Preview {
TabbarView()
}

View File

@@ -8,17 +8,86 @@
import SwiftUI
struct UserView: View {
@State private var toLogin: Bool = false
var body: some View {
ScrollView {
VStack (alignment: .leading) {
UserCardComponent()
Text("item")
NavigationView {
ScrollView {
VStack (alignment: .leading, spacing: 12) {
Header
ToVip
//
// NavigationLink(destination: LoginView(), label: {
// Text("qu zhuce ")
// })
// Button(""){
// toLogin = true
// }
// .padding(.vertical, 12)
// .padding(.horizontal, 32)
// .foregroundColor(.white)
// .background(Color.blue)
// .cornerRadius(12)
// .fullScreenCover(isPresented: $toLogin, content: {
// LoginView()
// })
}
}
}
.background(Color.red)
}
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)
.frame(maxWidth: .infinity)
.frame( height: 64)
.background(Image("Images/banner3").resizable().cornerRadius(/*@START_MENU_TOKEN@*/12.0/*@END_MENU_TOKEN@*/))
.padding(.horizontal, 16)
}
}
#Preview {
UserView()
}