diff --git a/.DS_Store b/.DS_Store index 42f494d..517346e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/demo.xcodeproj/project.pbxproj b/demo.xcodeproj/project.pbxproj index 6d42de8..765919c 100644 --- a/demo.xcodeproj/project.pbxproj +++ b/demo.xcodeproj/project.pbxproj @@ -38,6 +38,11 @@ 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 */; }; + 96E93E972B621CF6004AB649 /* UserInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E93E962B621CF6004AB649 /* UserInfoView.swift */; }; + 96E93E9B2B622931004AB649 /* UserAvatarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E93E9A2B622931004AB649 /* UserAvatarView.swift */; }; + 96E93E9D2B622D00004AB649 /* NavigationPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E93E9C2B622D00004AB649 /* NavigationPageView.swift */; }; + 96E93E9F2B62305F004AB649 /* UserNicknameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E93E9E2B62305F004AB649 /* UserNicknameView.swift */; }; + 96E93EA12B623D4E004AB649 /* MessageDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E93EA02B623D4E004AB649 /* MessageDetailView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -73,6 +78,11 @@ 968A6FB32B610C67008609EE /* KillCountDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KillCountDown.swift; sourceTree = ""; }; 968A6FB52B6113BE008609EE /* UserAccountCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAccountCard.swift; sourceTree = ""; }; 968A6FB72B6113FF008609EE /* UserAccountCardModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAccountCardModel.swift; sourceTree = ""; }; + 96E93E962B621CF6004AB649 /* UserInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserInfoView.swift; sourceTree = ""; }; + 96E93E9A2B622931004AB649 /* UserAvatarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAvatarView.swift; sourceTree = ""; }; + 96E93E9C2B622D00004AB649 /* NavigationPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationPageView.swift; sourceTree = ""; }; + 96E93E9E2B62305F004AB649 /* UserNicknameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNicknameView.swift; sourceTree = ""; }; + 96E93EA02B623D4E004AB649 /* MessageDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageDetailView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -106,9 +116,9 @@ isa = PBXGroup; children = ( 968A6F762B5F4E0D008609EE /* Components */, - 968A6F752B5F4DFD008609EE /* Views */, - 968A6F742B5F4DF9008609EE /* Models */, 968A6F732B5F4DF3008609EE /* Controllers */, + 968A6F742B5F4DF9008609EE /* Models */, + 968A6F752B5F4DFD008609EE /* Views */, 968A6F632B5F4C99008609EE /* demoApp.swift */, 968A6F692B5F4C9B008609EE /* Assets.xcassets */, 968A6F6B2B5F4C9B008609EE /* Preview Content */, @@ -169,6 +179,7 @@ isa = PBXGroup; children = ( 968A6F782B5F4E28008609EE /* TabBarView.swift */, + 96E93E9C2B622D00004AB649 /* NavigationPageView.swift */, ); path = Layouts; sourceTree = ""; @@ -200,6 +211,7 @@ isa = PBXGroup; children = ( 968A6F842B5F4EB2008609EE /* MessageView.swift */, + 96E93EA02B623D4E004AB649 /* MessageDetailView.swift */, ); path = Message; sourceTree = ""; @@ -207,8 +219,9 @@ 968A6F862B5F4EB6008609EE /* User */ = { isa = PBXGroup; children = ( - 968A6F902B5F6810008609EE /* Account */, 968A6F872B5F4EC4008609EE /* UserView.swift */, + 96E93E952B621CD9004AB649 /* Info */, + 968A6F902B5F6810008609EE /* Account */, 968A6F8F2B5F67FE008609EE /* Order */, ); path = User; @@ -244,6 +257,16 @@ path = Auth; sourceTree = ""; }; + 96E93E952B621CD9004AB649 /* Info */ = { + isa = PBXGroup; + children = ( + 96E93E962B621CF6004AB649 /* UserInfoView.swift */, + 96E93E9A2B622931004AB649 /* UserAvatarView.swift */, + 96E93E9E2B62305F004AB649 /* UserNicknameView.swift */, + ); + path = Info; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -320,25 +343,30 @@ 968A6FB22B5FC3A2008609EE /* ShowMore.swift in Sources */, 968A6F822B5F4EA1008609EE /* MallView.swift in Sources */, 968A6F972B5F683E008609EE /* CouponView.swift in Sources */, + 96E93E9B2B622931004AB649 /* UserAvatarView.swift in Sources */, 968A6F7C2B5F4E63008609EE /* TabBar.swift in Sources */, 968A6F8A2B5F6421008609EE /* GoodsDetailView.swift in Sources */, 968A6F922B5F681C008609EE /* AccountView.swift in Sources */, + 96E93E972B621CF6004AB649 /* UserInfoView.swift in Sources */, 968A6FAE2B5FA329008609EE /* CamelPrice.swift in Sources */, 968A6FAC2B5F6B1C008609EE /* GoodsCommentsView.swift in Sources */, 968A6FA42B5F68B8008609EE /* LicenceView.swift in Sources */, 968A6FB02B5FBB86008609EE /* GoodsCard.swift in Sources */, + 96E93EA12B623D4E004AB649 /* MessageDetailView.swift in Sources */, 968A6F9B2B5F686D008609EE /* NoticeListView.swift in Sources */, 968A6F992B5F6860008609EE /* NoticeView.swift in Sources */, 968A6F8E2B5F67F8008609EE /* OrderDetailView.swift in Sources */, 968A6F7F2B5F4E91008609EE /* HomeView.swift in Sources */, 968A6FA22B5F68AA008609EE /* ForgotView.swift in Sources */, 968A6F792B5F4E28008609EE /* TabBarView.swift in Sources */, + 96E93E9F2B62305F004AB649 /* UserNicknameView.swift in Sources */, 968A6FA82B5F6AF3008609EE /* CartView.swift in Sources */, 968A6FAA2B5F6B07008609EE /* CategoryView.swift in Sources */, 968A6FB82B6113FF008609EE /* UserAccountCardModel.swift in Sources */, 968A6F642B5F4C99008609EE /* demoApp.swift in Sources */, 968A6FB62B6113BE008609EE /* UserAccountCard.swift in Sources */, 968A6F952B5F6836008609EE /* BalanceView.swift in Sources */, + 96E93E9D2B622D00004AB649 /* NavigationPageView.swift in Sources */, 968A6FB42B610C67008609EE /* KillCountDown.swift in Sources */, 968A6F882B5F4EC4008609EE /* UserView.swift in Sources */, 968A6F9E2B5F688A008609EE /* LoginView.swift in Sources */, @@ -483,6 +511,8 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard; + INFOPLIST_KEY_UIRequiresFullScreen = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -493,9 +523,13 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = tech.uzchain.demo; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; @@ -514,6 +548,8 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen.storyboard; + INFOPLIST_KEY_UIRequiresFullScreen = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; IPHONEOS_DEPLOYMENT_TARGET = 15.0; @@ -524,9 +560,13 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = tech.uzchain.demo; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; diff --git a/demo.xcodeproj/project.xcworkspace/xcuserdata/jason.xcuserdatad/UserInterfaceState.xcuserstate b/demo.xcodeproj/project.xcworkspace/xcuserdata/jason.xcuserdatad/UserInterfaceState.xcuserstate index 72cb9e1..738442b 100644 Binary files a/demo.xcodeproj/project.xcworkspace/xcuserdata/jason.xcuserdatad/UserInterfaceState.xcuserstate and b/demo.xcodeproj/project.xcworkspace/xcuserdata/jason.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/demo.xcodeproj/xcuserdata/jason.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/demo.xcodeproj/xcuserdata/jason.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..5278322 --- /dev/null +++ b/demo.xcodeproj/xcuserdata/jason.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/demo/Components/GoodsCard.swift b/demo/Components/GoodsCard.swift index be195ba..bf00dea 100644 --- a/demo/Components/GoodsCard.swift +++ b/demo/Components/GoodsCard.swift @@ -13,27 +13,32 @@ struct GoodsCard: View { } 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) + NavigationLink { + GoodsDetailView() + } label: { + VStack { + Image("Images/LaunchScreen") + .resizable() + .frame(maxWidth: .infinity) + .frame(maxHeight: getHeight()) + VStack(spacing: 4) { + Text("苏东坡专辑,谁谁会注解的内容哦") + .font(.subheadline) + .lineLimit(1) + .foregroundColor(Color.black) + HStack(alignment: .bottom) { + CamelPrice(amount: 125.9229, size: 16) + Spacer() + Text("100+付款") + .foregroundColor(Color.gray) + .font(.caption) + .baselineOffset(2) + } } + .padding(4) } - .padding(4) + .background(Color.white) + .cornerRadius(8) } - .background(Color.white) - .cornerRadius(8) } } diff --git a/demo/Components/UserAccountCard.swift b/demo/Components/UserAccountCard.swift index b4f9dd4..c4cfe8d 100644 --- a/demo/Components/UserAccountCard.swift +++ b/demo/Components/UserAccountCard.swift @@ -10,13 +10,19 @@ import SwiftUI struct UserAccountCard: View { var model: UserAccountCardModel var body: some View { - VStack { - HStack { + VStack(alignment: .leading, spacing: 12) { + HStack(spacing: 4) { Image(systemName: model.icon) + .resizable() + .frame(width: 15, height: 15) + .foregroundColor(Color.black) Text(model.title) + .font(.system(size: 16)) + .foregroundColor(Color.black) } Text(model.info) - .font(.caption) + .font(.system(size: 12)) + .foregroundColor(Color.gray) } .padding(12) .background(Color.white) diff --git a/demo/Views/Home/HomeView.swift b/demo/Views/Home/HomeView.swift index 918feac..1d00012 100644 --- a/demo/Views/Home/HomeView.swift +++ b/demo/Views/Home/HomeView.swift @@ -11,29 +11,66 @@ struct HomeView: View { @State private var selectedTab = 0 var body: some View { - ScrollView { + ScrollView(.vertical, showsIndicators: false) { VStack(spacing: 12) { -// Search -// Banner -// Navigation + Search + Banner + Navigation TodayKill -// Living -// Bestselling -// PartyReading -// NewBooks -// Categories + Living + Bestselling + PartyReading + NewBooks + Categories + Spacer() } } .frame(maxWidth: .infinity) .padding(.horizontal, 12) + .padding(.bottom, 48) .background(Color.gray.opacity(0.2)) } + 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) + .font(.system(size: 16)) + Spacer() + } + .frame(maxWidth: /*@START_MENU_TOKEN@*/ .infinity/*@END_MENU_TOKEN@*/) + .padding(12) + .background(Color.white) + .cornerRadius(32) + Image(systemName: "bell") + .resizable() + .frame(width: 24, height: 24) + .overlay(alignment: .topTrailing) { + Circle() + .fill(Color.red.opacity(0.8)) + .frame(width: 20, height: 20) + .overlay { + Text("20") + .foregroundColor(Color.white) + .font(.system(size: 12)) + } + .offset(x: 8, y: -10) + } + + Spacer() + } + } + let columns = [GridItem(.flexible()), GridItem(.flexible())] var Categories: some View { VStack { - ScrollView(.horizontal) { + ScrollView(.horizontal, showsIndicators: false) { HStack { Text("推荐") Text("竞品书单") @@ -55,6 +92,27 @@ struct HomeView: View { } } + var Banner: some View { + TabView { + ForEach(1 ..< 4) { index in + GeometryReader { proxy in + let minX = proxy.frame(in: .global).minX + Image("Images/banner" + String(index)) + .resizable() + .aspectRatio(contentMode: .fill) + .cornerRadius(12) + .rotation3DEffect( + .degrees(minX / -10), + axis: (x: 0.0, y: 1, z: 0.0) + ) + } + } + } + .tabViewStyle(.page(indexDisplayMode: .always)) + .frame(height: 220) + .cornerRadius(12) + } + var NewBooks: some View { VStack(alignment: .leading) { HStack { @@ -178,6 +236,7 @@ struct HomeView: View { HStack { Text("今日秒杀") .foregroundColor(Color.white) + .font(.system(size: 16)) KillCountDown() } .padding(8) @@ -197,7 +256,7 @@ struct HomeView: View { .cornerRadius(8) VStack { Text("石床垫:阿特伍德黑暗就故事(有的人说啥就是啥呢有的人说啥就是啥呢有的人说啥就是啥呢)") - .font(.title2) + .font(.system(size: 20)) .multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/) .lineLimit(/*@START_MENU_TOKEN@*/2/*@END_MENU_TOKEN@*/) .foregroundColor(Color.white) @@ -208,6 +267,7 @@ struct HomeView: View { .background(Color.white) HStack { Text("抢购") + .font(.system(size: 14)) Image(systemName: "chevron.forward") } .foregroundColor(Color.white) @@ -257,63 +317,13 @@ struct HomeView: View { .cornerRadius(64) Text("图书") + .font(.system(size: 14)) } } } } - - 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) - Image(systemName: "bell") - .resizable() - .frame(width: 24, height: 24) - .overlay(alignment: .topTrailing) { - Circle() - .fill(Color.red) - .frame(width: 20, height: 20) - .offset(x: 4, y: -8) - } - .overlay(alignment: .topTrailing) { - Text("20") - .foregroundColor(Color.white) - .font(.system(size: 12)) - .offset(x: 2, y: -5) - } - Spacer() - } - } } -// -// #Preview { -// HomeView() -// } +#Preview { + HomeView() +} diff --git a/demo/Views/Layouts/NavigationPageView.swift b/demo/Views/Layouts/NavigationPageView.swift new file mode 100644 index 0000000..85cbb9a --- /dev/null +++ b/demo/Views/Layouts/NavigationPageView.swift @@ -0,0 +1,34 @@ +// +// NavigationPageView.swift +// demo +// +// Created by Jason on 2024/1/25. +// + +import SwiftUI + +struct NavigationPageView: View { + @Environment(\.dismiss) private var dismiss + var title: String = "" + var content: any View + + var body: some View { + ScrollView { + AnyView(content) + } + .navigationBarTitleDisplayMode(.inline) + .navigationTitle(title) + .navigationBarBackButtonHidden(true) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button { + dismiss() + } label: { + HStack { + Image(systemName: "chevron.backward") + } + } + } + } + } +} diff --git a/demo/Views/Layouts/TabBarView.swift b/demo/Views/Layouts/TabBarView.swift index a2c552a..62739cf 100644 --- a/demo/Views/Layouts/TabBarView.swift +++ b/demo/Views/Layouts/TabBarView.swift @@ -11,51 +11,54 @@ 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() + NavigationView { + 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) -// } + // .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) + 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() } - .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) } - .statusBarHidden(false) + .navigationViewStyle(.columns) } } diff --git a/demo/Views/Mall/GoodsDetailView.swift b/demo/Views/Mall/GoodsDetailView.swift index 0834c6b..13099ab 100644 --- a/demo/Views/Mall/GoodsDetailView.swift +++ b/demo/Views/Mall/GoodsDetailView.swift @@ -9,7 +9,11 @@ import SwiftUI struct GoodsDetailView: View { var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + NavigationPageView(title: "商品详情", content: content) + } + + var content: some View { + Image("Images/banner1") } } diff --git a/demo/Views/Message/MessageDetailView.swift b/demo/Views/Message/MessageDetailView.swift new file mode 100644 index 0000000..c1bd911 --- /dev/null +++ b/demo/Views/Message/MessageDetailView.swift @@ -0,0 +1,22 @@ +// +// MessageDetailView.swift +// demo +// +// Created by Jason on 2024/1/25. +// + +import SwiftUI + +struct MessageDetailView: View { + var body: some View { + NavigationPageView(title: "消息详情", content: content) + } + + var content: some View { + Text("asdf") + } +} + +#Preview { + MessageDetailView() +} diff --git a/demo/Views/Message/MessageView.swift b/demo/Views/Message/MessageView.swift index 3051e4f..5fe1c68 100644 --- a/demo/Views/Message/MessageView.swift +++ b/demo/Views/Message/MessageView.swift @@ -9,7 +9,17 @@ import SwiftUI struct MessageView: View { var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + NavigationPageView(title: "资讯列表", content: content) + } + + var content: some View { + VStack { + NavigationLink { + MessageDetailView() + } label: { + Text("xiaoxo") + } + } } } diff --git a/demo/Views/User/Account/AccountView.swift b/demo/Views/User/Account/AccountView.swift index 9ddc3fa..dd7d13e 100644 --- a/demo/Views/User/Account/AccountView.swift +++ b/demo/Views/User/Account/AccountView.swift @@ -9,7 +9,7 @@ import SwiftUI struct AccountView: View { var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + NavigationPageView(title: "我的积分", content: Text("Account View")) } } diff --git a/demo/Views/User/Info/UserAvatarView.swift b/demo/Views/User/Info/UserAvatarView.swift new file mode 100644 index 0000000..96f3275 --- /dev/null +++ b/demo/Views/User/Info/UserAvatarView.swift @@ -0,0 +1,54 @@ +// +// UserAvatarView.swift +// demo +// +// Created by Jason on 2024/1/25. +// + +import SwiftUI + +struct UserAvatarView: View { + @Environment(\.dismiss) private var dismiss + + @State private var showSheet = false + + var body: some View { + VStack { + Image("Images/banner1") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width) + } + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button { + dismiss() + } label: { + Image(systemName: "chevron.backward") + } + } + + ToolbarItem(placement: .navigationBarTrailing) { + Button { + showSheet = true + } label: { + Image(systemName: "ellipsis") + } + .actionSheet(isPresented: $showSheet, content: { + ActionSheet(title: Text("更换头像"), message: nil, buttons: [ + .default(Text("从相册选择"), action: {}), + .default(Text("拍一张"), action: {}), + .cancel(Text("取消")) + ]) + }) + } + } + .navigationBarBackButtonHidden(true) + .navigationBarTitleDisplayMode(.inline) + .navigationTitle("头像") + } +} + +#Preview { + UserAvatarView() +} diff --git a/demo/Views/User/Info/UserInfoView.swift b/demo/Views/User/Info/UserInfoView.swift new file mode 100644 index 0000000..6c52da3 --- /dev/null +++ b/demo/Views/User/Info/UserInfoView.swift @@ -0,0 +1,24 @@ +// +// UserInfoView.swift +// demo +// +// Created by Jason on 2024/1/25. +// + +import SwiftUI + +struct UserInfoView: View { + var body: some View { + NavigationPageView(title: "用户设置", content: VStack { + NavigationLink { + UserNicknameView() + } label: { + Text("用户昵称") + } + }) + } +} + +#Preview { + UserInfoView() +} diff --git a/demo/Views/User/Info/UserNicknameView.swift b/demo/Views/User/Info/UserNicknameView.swift new file mode 100644 index 0000000..ef05497 --- /dev/null +++ b/demo/Views/User/Info/UserNicknameView.swift @@ -0,0 +1,18 @@ +// +// UserNicknameView.swift +// demo +// +// Created by Jason on 2024/1/25. +// + +import SwiftUI + +struct UserNicknameView: View { + var body: some View { + NavigationPageView(title: "用户昵称", content: Text("nickname")) + } +} + +#Preview { + UserNicknameView() +} diff --git a/demo/Views/User/Order/OrdersView.swift b/demo/Views/User/Order/OrdersView.swift index cbcaf4d..a1912ba 100644 --- a/demo/Views/User/Order/OrdersView.swift +++ b/demo/Views/User/Order/OrdersView.swift @@ -9,7 +9,11 @@ import SwiftUI struct OrdersView: View { var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + NavigationPageView(title: "全部订单", content: content) + } + + var content: some View { + Text("q全部订单, World!") } } diff --git a/demo/Views/User/UserView.swift b/demo/Views/User/UserView.swift index 079dec7..ace3376 100644 --- a/demo/Views/User/UserView.swift +++ b/demo/Views/User/UserView.swift @@ -9,35 +9,38 @@ import SwiftUI struct UserView: View { @State private var showDetail = false + @State private var showUserInfo = false var body: some View { - ScrollView { - Header - ToVip - - VStack(spacing: 16) { + ScrollView(.vertical, showsIndicators: false) { + VStack(spacing: 0) { + Header + ToVip InfoList Notice OrderShow Coupons - tj + Recommend } - .padding(16) - .background(Color.gray.opacity(0.2)) - .cornerRadius(12) } + .padding(.bottom, 48) + .animation(.spring, value: showDetail) } 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) - ) + NavigationLink { + UserAvatarView() + } label: { + 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("用户名称") @@ -48,15 +51,18 @@ struct UserView: View { .foregroundColor(Color.gray) .lineLimit(1) }) - - Image(systemName: "gearshape") - .foregroundColor(Color.gray) + NavigationLink { + UserInfoView() + } label: { + Image(systemName: "gearshape") + .foregroundColor(Color.gray) + } } .padding(.horizontal, 24) } var ToVip: some View { - HStack(spacing: /*@START_MENU_TOKEN@*/nil/*@END_MENU_TOKEN@*/, content: { + HStack(alignment: .top, spacing: /*@START_MENU_TOKEN@*/nil/*@END_MENU_TOKEN@*/, content: { Text("VIP de yixie 简介部分") Button(action: { self.showDetail.toggle() @@ -72,111 +78,194 @@ struct UserView: View { .background(Color.gray) .cornerRadius(32) }) - .padding(16) - .padding(.bottom, 64) - .frame(maxWidth: .infinity) - .frame(height: showDetail ? 100 : 200) - .animation(.default, value: showDetail) - .background( - Image("Images/banner3").resizable(resizingMode: .tile) -// .overlay( -// UnevenRoundedRectangle(cornerRadii: RectangleCornerRadii(topLeading: 12, topTrailing: 12)) -// ) + .padding(12) + .padding(.top, 12) + .frame(height: showDetail ? 64 : 150, alignment: .topLeading) + .background(Color.red.opacity(0.3)) + .clipShape( + RoundedRectangle(cornerRadius: 12) + .offset(y: 12) ) - .cornerRadius(12) - .padding(.horizontal, 16) + + .padding(.horizontal, 12) } var InfoList: some View { - ScrollView(.horizontal) { - HStack(spacing: 16) { - ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in - UserAccountCard(model: UserAccountCardModel(title: "我的积分", icon: "star", info: "共30001分")) + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing: 12) { + ForEach(0 ..< 8) { _ in + NavigationLink { + AccountView() + } label: { + UserAccountCard(model: UserAccountCardModel(title: "我的积分", icon: "star", info: "共30001分")) + } } } } + .padding(12) + .background(Color.gray.opacity(0.2)) } var Notice: some View { - HStack { + HStack(spacing: 4) { 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) + .font(.system(size: 16)) + NavigationLink { + MessageDetailView() + } label: { + Text("平台与2024年1余额开始更新,敬请期待@@@") + .foregroundColor(Color.gray) + .frame(maxWidth: .infinity) + .multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/) + .font(.system(size: 14)) + .lineLimit(1) + } + NavigationLink { + MessageView() + } label: { + HStack(spacing: 2, content: { + Text("更多") + .font(.system(size: 14)) + .foregroundColor(Color.secondary) + Image(systemName: "chevron.forward.2") + .resizable() + .frame(width: 10, height: 10) + .foregroundColor(Color.secondary) + }) + } } .frame(maxWidth: .infinity) .padding(8) .background(Color.white) .cornerRadius(8) + .padding(.horizontal, 12) + .padding(.bottom, 12) + .background(Color.gray.opacity(0.2)) } var OrderShow: some View { - VStack(spacing: 16) { + VStack(spacing: 0) { HStack { Text("订单中心") + .font(.system(size: 16)) Spacer() - ShowMore() + NavigationLink { + OrdersView() + } label: { + ShowMore() + } } - .padding(8) - HStack { + .padding(.horizontal, 12) + Spacer(minLength: 22) + HStack(alignment: .center) { Spacer() ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in - VStack { - Image(systemName: "wallet.pass") - Text("待付款") - .font(.system(size: 12)) + NavigationLink { + OrdersView() + } label: { + VStack { + Image(systemName: "wallet.pass") + .resizable() + .frame(width: 24, height: 24) + .foregroundColor(Color.gray) + .overlay(alignment: .topTrailing) { + Circle() + .fill(Color.red.opacity(0.9)) + .frame(width: 20, height: 20) + .overlay { + Text("5") + .foregroundColor(Color.white) + .font(.system(size: 12)) + } + .offset(x: 12, y: -10) + } + + Text("待付款") + .font(.system(size: 12)) + .foregroundColor(Color.gray) + } } Spacer() } } } + .padding(.vertical, 12) .background(Color.white) .cornerRadius(6) + .padding(.horizontal, 12) + .padding(.bottom, 12) + .background(Color.gray.opacity(0.2)) } var Coupons: some View { - VStack(spacing: 16) { + VStack(spacing: 0) { HStack { Spacer() ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { _ in VStack { Image(systemName: "wallet.pass") - Text("优惠券") + .resizable() + .frame(width: 24, height: 24) + .foregroundColor(Color.gray) + .overlay(alignment: .topTrailing) { + Circle() + .fill(Color.red.opacity(0.9)) + .frame(width: 20, height: 20) + .overlay { + Text("5") + .foregroundColor(Color.white) + .font(.system(size: 12)) + } + .offset(x: 12, y: -10) + } + Text("待付款") .font(.system(size: 12)) + .foregroundColor(Color.gray) } Spacer() } } } - .padding(12) + .padding(.top, 22) + .padding(.bottom, 12) .background(Color.white) .cornerRadius(6) + .padding(.horizontal, 12) + .padding(.bottom, 12) + .background(Color.gray.opacity(0.2)) } - let columns = [GridItem(.flexible()), GridItem(.flexible())] + let columns = [GridItem(.flexible(), spacing: 12), GridItem(.flexible(), spacing: 12)] - var tj: some View { - LazyVGrid(columns: columns, alignment: .center) { + var Recommend: some View { + LazyVGrid(columns: columns, alignment: .center, spacing: 12, pinnedViews: .sectionHeaders) { Section { ForEach(0 ..< 20, id: \.self) { _ in GoodsCard() } } header: { - Text("推荐广场") + HStack { + Rectangle() + .fill(LinearGradient(colors: [Color.gray.opacity(0), Color.gray.opacity(0.8)], startPoint: .leading, endPoint: UnitPoint.trailing)) + .frame(width: 48, height: 4.0) + Text("推荐广场") + .font(.system(size: 16)) + Rectangle() + .fill(LinearGradient(colors: [Color.gray.opacity(0.8), Color.gray.opacity(0)], startPoint: .leading, endPoint: UnitPoint.trailing)) + .frame(width: 48, height: 4.0) + } } } + .padding(.horizontal, 12) + .padding(.bottom, 12) + .background(Color.gray.opacity(0.2)) } } -// -// #Preview { -// UserView() -// } +#Preview { + UserView() +} diff --git a/demo/demoApp.swift b/demo/demoApp.swift index f08e05c..811188b 100644 --- a/demo/demoApp.swift +++ b/demo/demoApp.swift @@ -5,8 +5,8 @@ // Created by Jason on 2024/1/23. // -import SwiftUI import SwiftData +import SwiftUI @main struct demoApp: App {