From 66588ed4642ec2a7d8ae8583fbbed2253f27ef5a Mon Sep 17 00:00:00 2001 From: user Date: Fri, 7 Jul 2023 10:30:04 +0800 Subject: [PATCH] v8.0 --- README.md | 4 ++ WanAndroid_SwiftUI.xcodeproj/project.pbxproj | 4 ++ .../Content/Project/ProjectView.swift | 11 ++-- .../Content/Project/view/ProjectBuilder.swift | 54 +++++++++++++------ .../Content/Project/view/SwiftUIView.swift | 38 +++++++++++++ .../Project/viewmodel/ProjectViewModel.swift | 1 + 6 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 WanAndroid_SwiftUI/Content/Project/view/SwiftUIView.swift diff --git a/README.md b/README.md index 6e5ae01..46200fc 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,10 @@ ViewModel(MVVM设计模式): * 消息 -未读 * 消息item(点击)-详情页 +### v8.0-项目(点击标签切换到对应的视图—修改v5.0bug) + +* 通过onReceive方法,监听标签的切换,显示相应的视图 + ## 四 开发任务 ### 4.1 已完成 diff --git a/WanAndroid_SwiftUI.xcodeproj/project.pbxproj b/WanAndroid_SwiftUI.xcodeproj/project.pbxproj index 52e165c..06e770f 100644 --- a/WanAndroid_SwiftUI.xcodeproj/project.pbxproj +++ b/WanAndroid_SwiftUI.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ F3D5EE152A3C5687000ACDFF /* NavigationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D5EE142A3C5687000ACDFF /* NavigationViewModel.swift */; }; F3D5EE172A3C5748000ACDFF /* TreeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D5EE162A3C5748000ACDFF /* TreeModel.swift */; }; F3D5EE1A2A3C6A64000ACDFF /* NavigationSectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D5EE192A3C6A64000ACDFF /* NavigationSectionBuilder.swift */; }; + F3D6F7F12A57A44100D9801E /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D6F7F02A57A44100D9801E /* SwiftUIView.swift */; }; F3DA08FE2A3FE9E80089A7A6 /* MeBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3DA08FD2A3FE9E80089A7A6 /* MeBuilder.swift */; }; F3DA09032A403FCB0089A7A6 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3DA09022A403FCB0089A7A6 /* LoginView.swift */; }; F3DA09052A40A05A0089A7A6 /* LoginBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3DA09042A40A05A0089A7A6 /* LoginBuilder.swift */; }; @@ -94,6 +95,7 @@ F3D5EE142A3C5687000ACDFF /* NavigationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewModel.swift; sourceTree = ""; }; F3D5EE162A3C5748000ACDFF /* TreeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TreeModel.swift; sourceTree = ""; }; F3D5EE192A3C6A64000ACDFF /* NavigationSectionBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSectionBuilder.swift; sourceTree = ""; }; + F3D6F7F02A57A44100D9801E /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = ""; }; F3DA08FD2A3FE9E80089A7A6 /* MeBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeBuilder.swift; sourceTree = ""; }; F3DA09022A403FCB0089A7A6 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = ""; }; F3DA09042A40A05A0089A7A6 /* LoginBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginBuilder.swift; sourceTree = ""; }; @@ -184,6 +186,7 @@ isa = PBXGroup; children = ( F39290372A3D9C4100DCCFC9 /* ProjectBuilder.swift */, + F3D6F7F02A57A44100D9801E /* SwiftUIView.swift */, ); path = view; sourceTree = ""; @@ -570,6 +573,7 @@ F3D5EE1A2A3C6A64000ACDFF /* NavigationSectionBuilder.swift in Sources */, F3BDCCE62A37092F00FC3CCD /* API.swift in Sources */, F3BDCCE82A37094D00FC3CCD /* Router.swift in Sources */, + F3D6F7F12A57A44100D9801E /* SwiftUIView.swift in Sources */, F3BDCCDB2A37060500FC3CCD /* ModelProtocol.swift in Sources */, F3D56EA42A36CC4D008876F0 /* TabBarView.swift in Sources */, F392903A2A3DF6D200DCCFC9 /* ProjectSonModel.swift in Sources */, diff --git a/WanAndroid_SwiftUI/Content/Project/ProjectView.swift b/WanAndroid_SwiftUI/Content/Project/ProjectView.swift index 0f19abf..d56e92f 100644 --- a/WanAndroid_SwiftUI/Content/Project/ProjectView.swift +++ b/WanAndroid_SwiftUI/Content/Project/ProjectView.swift @@ -10,11 +10,12 @@ import SwiftUI struct ProjectView: View { @StateObject private var vm: ProjectViewModel = ProjectViewModel() var body: some View { - ProjectBuilder(vm: .constant(vm)).pickView - ProjectBuilder(vm: .constant(vm)).articleView -// ProjectBuilder(vm: .constant(vm)).onAppear(){ -// vm.getProjectModel() -// } + //SwiftUIView() + // ProjectBuilder(vm: .constant(vm)).pickView + //ProjectBuilder(vm: .constant(vm)).articleView + ProjectBuilder(vm: .constant(vm)).onAppear(){ + vm.getProjectModel() + } } } diff --git a/WanAndroid_SwiftUI/Content/Project/view/ProjectBuilder.swift b/WanAndroid_SwiftUI/Content/Project/view/ProjectBuilder.swift index 286bd13..7065a2f 100644 --- a/WanAndroid_SwiftUI/Content/Project/view/ProjectBuilder.swift +++ b/WanAndroid_SwiftUI/Content/Project/view/ProjectBuilder.swift @@ -10,17 +10,18 @@ import SwiftUI struct ProjectBuilder: View { @Binding var vm: ProjectViewModel + @State var selectedOptionIndex = 0 + var body: some View { VStack(alignment: .center){ ScrollView{ - //1-导航栏 - //pickView + pickView //文章 - //articleView() + articleView } } @@ -28,37 +29,58 @@ struct ProjectBuilder: View { var pickView: some View{ ScrollView(.horizontal){ - HStack(spacing: 0){ - Picker("Options",selection: $vm.options.first ?? $vm.options_first){ +// if vm.options.isEmpty{ +// Text("Loading") +// }else { + HStack(spacing: 0){ - ForEach(vm.options,id: \.self) { option in - Text(option).onAppear(){ - vm.getProjectTreeArticle(page: 1, cid: vm.optionsDic[option] ?? 0) + Picker("Options",selection: $selectedOptionIndex){ + ForEach(0.. = [:] var options:[String] = [] var options_first: String = "" + var selectedOptionIndex = 0 //用于存储选中的选项索引 init(){