init
This commit is contained in:
72
jason/Views/Auth/LoginView.swift
Normal file
72
jason/Views/Auth/LoginView.swift
Normal 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()
|
||||
}
|
||||
70
jason/Views/Auth/RegisterView.swift
Normal file
70
jason/Views/Auth/RegisterView.swift
Normal 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()
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
49
jason/Views/LaunchScreen.storyboard
Normal file
49
jason/Views/LaunchScreen.storyboard
Normal 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>
|
||||
30
jason/Views/Layouts/LaunchScreen.swift
Normal file
30
jason/Views/Layouts/LaunchScreen.swift
Normal 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()
|
||||
}
|
||||
65
jason/Views/Layouts/TabbarView.swift
Normal file
65
jason/Views/Layouts/TabbarView.swift
Normal 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()
|
||||
}
|
||||
|
||||
20
jason/Views/Mall/MallView.swift
Normal file
20
jason/Views/Mall/MallView.swift
Normal 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()
|
||||
}
|
||||
25
jason/Views/Message/MessageView.swift
Normal file
25
jason/Views/Message/MessageView.swift
Normal 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()
|
||||
}
|
||||
18
jason/Views/Search/SearchView.swift
Normal file
18
jason/Views/Search/SearchView.swift
Normal 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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user