diff --git a/Sources/SwiftMvvm/SwiftMvvm.xcodeproj/project.pbxproj b/Sources/SwiftMvvm/SwiftMvvm.xcodeproj/project.pbxproj index 68ec149..34a4737 100644 --- a/Sources/SwiftMvvm/SwiftMvvm.xcodeproj/project.pbxproj +++ b/Sources/SwiftMvvm/SwiftMvvm.xcodeproj/project.pbxproj @@ -14,23 +14,30 @@ EC1A52732A1CE12A00F8CC93 /* SwiftMvvmTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1A52722A1CE12A00F8CC93 /* SwiftMvvmTests.swift */; }; EC1A527D2A1CE12A00F8CC93 /* SwiftMvvmUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1A527C2A1CE12A00F8CC93 /* SwiftMvvmUITests.swift */; }; EC1A527F2A1CE12A00F8CC93 /* SwiftMvvmUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1A527E2A1CE12A00F8CC93 /* SwiftMvvmUITestsLaunchTests.swift */; }; - EC1A528C2A1CE77F00F8CC93 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC1A528B2A1CE77F00F8CC93 /* HomeView.swift */; }; - EC2E21F42A25E9FA00DED570 /* MatiereUniq.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2E21F32A25E9FA00DED570 /* MatiereUniq.swift */; }; - EC2E21F82A25FCAA00DED570 /* stbmat.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2E21F72A25FCAA00DED570 /* stbmat.swift */; }; - EC369C212A325FB5005EE7C8 /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC369C202A325FB5005EE7C8 /* Note.swift */; }; EC47F9D62A34C50C00CA3A3F /* DataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9D52A34C50C00CA3A3F /* DataManager.swift */; }; - EC47F9D82A34C62000CA3A3F /* Manager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9D72A34C62000CA3A3F /* Manager.swift */; }; EC47F9DA2A34C73B00CA3A3F /* Stub.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9D92A34C73B00CA3A3F /* Stub.swift */; }; - EC47F9DC2A34D36200CA3A3F /* EditableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9DB2A34D36200CA3A3F /* EditableView.swift */; }; - EC47F9E02A34F00C00CA3A3F /* MatiereEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9DF2A34F00C00CA3A3F /* MatiereEditView.swift */; }; EC47F9E22A35E89400CA3A3F /* UeeVm.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9E12A35E89400CA3A3F /* UeeVm.swift */; }; EC47F9E42A35EF1800CA3A3F /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9E32A35EF1800CA3A3F /* ArrayExtension.swift */; }; - EC47F9E62A3633DA00CA3A3F /* ManagerVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9E52A3633DA00CA3A3F /* ManagerVM.swift */; }; - EC7725432A1F80980075CBBF /* BlocView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7725422A1F80980075CBBF /* BlocView.swift */; }; + EC47F9E62A3633DA00CA3A3F /* DataManagerVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC47F9E52A3633DA00CA3A3F /* DataManagerVM.swift */; }; + EC7692E82A4565ED00F9F644 /* UeCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692E72A4565ED00F9F644 /* UeCollection.swift */; }; + EC7692EA2A45660500F9F644 /* MatiereCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692E92A45660500F9F644 /* MatiereCollection.swift */; }; + EC7692EC2A45661C00F9F644 /* BlocCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692EB2A45661C00F9F644 /* BlocCollection.swift */; }; + EC7692EE2A45667700F9F644 /* CollectionVMUe.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692ED2A45667700F9F644 /* CollectionVMUe.swift */; }; + EC7692F02A45669000F9F644 /* MatiereCollectionVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692EF2A45669000F9F644 /* MatiereCollectionVM.swift */; }; + EC7692F22A4566CF00F9F644 /* BlocCollectionVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692F12A4566CF00F9F644 /* BlocCollectionVM.swift */; }; + EC7692F42A45680700F9F644 /* Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692F32A45680700F9F644 /* Home.swift */; }; + EC7692F62A45683100F9F644 /* Uee.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692F52A45683100F9F644 /* Uee.swift */; }; + EC7692F82A45685200F9F644 /* MatiereUnq.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692F72A45685200F9F644 /* MatiereUnq.swift */; }; + EC7692FA2A45687000F9F644 /* edit.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692F92A45687000F9F644 /* edit.swift */; }; + EC7692FC2A45689000F9F644 /* UeCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692FB2A45689000F9F644 /* UeCapsule.swift */; }; + EC7692FE2A4568A900F9F644 /* MatiereCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692FD2A4568A900F9F644 /* MatiereCapsule.swift */; }; + EC7693002A4568BD00F9F644 /* EditSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7692FF2A4568BD00F9F644 /* EditSheet.swift */; }; + EC7693022A4568D700F9F644 /* MatiereEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7693012A4568D700F9F644 /* MatiereEditView.swift */; }; + EC7693042A4568F300F9F644 /* BlockItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7693032A4568F300F9F644 /* BlockItem.swift */; }; + EC7693062A45691900F9F644 /* AddSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7693052A45691900F9F644 /* AddSheet.swift */; }; + EC7693082A456A2400F9F644 /* NoteColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7693072A456A2400F9F644 /* NoteColor.swift */; }; + EC76930A2A456B6B00F9F644 /* Block.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7693092A456B6B00F9F644 /* Block.swift */; }; EC7725452A1F814A0075CBBF /* UeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7725442A1F814A0075CBBF /* UeView.swift */; }; - EC7725492A1F8DFE0075CBBF /* MatiereView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7725482A1F8DFE0075CBBF /* MatiereView.swift */; }; - EC77254B2A1F8E770075CBBF /* VuePrincipale.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC77254A2A1F8E770075CBBF /* VuePrincipale.swift */; }; - EC77254D2A1F8EE90075CBBF /* ListUe.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC77254C2A1F8EE90075CBBF /* ListUe.swift */; }; EC7725542A1F90CF0075CBBF /* BlocModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7725532A1F90CF0075CBBF /* BlocModel.swift */; }; EC7725562A1F90FD0075CBBF /* UE.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7725552A1F90FD0075CBBF /* UE.swift */; }; EC7725582A1F91300075CBBF /* Matiere.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7725572A1F91300075CBBF /* Matiere.swift */; }; @@ -71,23 +78,30 @@ EC1A52782A1CE12A00F8CC93 /* SwiftMvvmUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftMvvmUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; EC1A527C2A1CE12A00F8CC93 /* SwiftMvvmUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMvvmUITests.swift; sourceTree = ""; }; EC1A527E2A1CE12A00F8CC93 /* SwiftMvvmUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMvvmUITestsLaunchTests.swift; sourceTree = ""; }; - EC1A528B2A1CE77F00F8CC93 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; - EC2E21F32A25E9FA00DED570 /* MatiereUniq.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereUniq.swift; sourceTree = ""; }; - EC2E21F72A25FCAA00DED570 /* stbmat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = stbmat.swift; sourceTree = ""; }; - EC369C202A325FB5005EE7C8 /* Note.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Note.swift; sourceTree = ""; }; EC47F9D52A34C50C00CA3A3F /* DataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataManager.swift; sourceTree = ""; }; - EC47F9D72A34C62000CA3A3F /* Manager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Manager.swift; sourceTree = ""; }; EC47F9D92A34C73B00CA3A3F /* Stub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stub.swift; sourceTree = ""; }; - EC47F9DB2A34D36200CA3A3F /* EditableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditableView.swift; sourceTree = ""; }; - EC47F9DF2A34F00C00CA3A3F /* MatiereEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereEditView.swift; sourceTree = ""; }; EC47F9E12A35E89400CA3A3F /* UeeVm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UeeVm.swift; sourceTree = ""; }; EC47F9E32A35EF1800CA3A3F /* ArrayExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayExtension.swift; sourceTree = ""; }; - EC47F9E52A3633DA00CA3A3F /* ManagerVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagerVM.swift; sourceTree = ""; }; - EC7725422A1F80980075CBBF /* BlocView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocView.swift; sourceTree = ""; }; + EC47F9E52A3633DA00CA3A3F /* DataManagerVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataManagerVM.swift; sourceTree = ""; }; + EC7692E72A4565ED00F9F644 /* UeCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UeCollection.swift; sourceTree = ""; }; + EC7692E92A45660500F9F644 /* MatiereCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereCollection.swift; sourceTree = ""; }; + EC7692EB2A45661C00F9F644 /* BlocCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocCollection.swift; sourceTree = ""; }; + EC7692ED2A45667700F9F644 /* CollectionVMUe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionVMUe.swift; sourceTree = ""; }; + EC7692EF2A45669000F9F644 /* MatiereCollectionVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereCollectionVM.swift; sourceTree = ""; }; + EC7692F12A4566CF00F9F644 /* BlocCollectionVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocCollectionVM.swift; sourceTree = ""; }; + EC7692F32A45680700F9F644 /* Home.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Home.swift; sourceTree = ""; }; + EC7692F52A45683100F9F644 /* Uee.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Uee.swift; sourceTree = ""; }; + EC7692F72A45685200F9F644 /* MatiereUnq.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereUnq.swift; sourceTree = ""; }; + EC7692F92A45687000F9F644 /* edit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = edit.swift; sourceTree = ""; }; + EC7692FB2A45689000F9F644 /* UeCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UeCapsule.swift; sourceTree = ""; }; + EC7692FD2A4568A900F9F644 /* MatiereCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereCapsule.swift; sourceTree = ""; }; + EC7692FF2A4568BD00F9F644 /* EditSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditSheet.swift; sourceTree = ""; }; + EC7693012A4568D700F9F644 /* MatiereEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereEditView.swift; sourceTree = ""; }; + EC7693032A4568F300F9F644 /* BlockItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockItem.swift; sourceTree = ""; }; + EC7693052A45691900F9F644 /* AddSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSheet.swift; sourceTree = ""; }; + EC7693072A456A2400F9F644 /* NoteColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteColor.swift; sourceTree = ""; }; + EC7693092A456B6B00F9F644 /* Block.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Block.swift; sourceTree = ""; }; EC7725442A1F814A0075CBBF /* UeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UeView.swift; sourceTree = ""; }; - EC7725482A1F8DFE0075CBBF /* MatiereView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereView.swift; sourceTree = ""; }; - EC77254A2A1F8E770075CBBF /* VuePrincipale.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VuePrincipale.swift; sourceTree = ""; }; - EC77254C2A1F8EE90075CBBF /* ListUe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListUe.swift; sourceTree = ""; }; EC7725532A1F90CF0075CBBF /* BlocModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocModel.swift; sourceTree = ""; }; EC7725552A1F90FD0075CBBF /* UE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UE.swift; sourceTree = ""; }; EC7725572A1F91300075CBBF /* Matiere.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Matiere.swift; sourceTree = ""; }; @@ -157,6 +171,7 @@ EC1A52612A1CE12900F8CC93 /* SwiftMvvmApp.swift */, EC1A52632A1CE12900F8CC93 /* ContentView.swift */, EC1A52652A1CE12A00F8CC93 /* Assets.xcassets */, + EC7693072A456A2400F9F644 /* NoteColor.swift */, EC1A52672A1CE12A00F8CC93 /* Preview Content */, ); path = SwiftMvvm; @@ -191,7 +206,6 @@ isa = PBXGroup; children = ( EC47F9D52A34C50C00CA3A3F /* DataManager.swift */, - EC47F9D72A34C62000CA3A3F /* Manager.swift */, EC47F9D92A34C73B00CA3A3F /* Stub.swift */, ); path = Manager; @@ -204,6 +218,9 @@ EC7725552A1F90FD0075CBBF /* UE.swift */, EC7725572A1F91300075CBBF /* Matiere.swift */, EC77255A2A1F92EC0075CBBF /* Maquette.swift */, + EC7692E72A4565ED00F9F644 /* UeCollection.swift */, + EC7692E92A45660500F9F644 /* MatiereCollection.swift */, + EC7692EB2A45661C00F9F644 /* BlocCollection.swift */, ); path = Model; sourceTree = ""; @@ -211,17 +228,18 @@ EC7725592A1F91530075CBBF /* Vue */ = { isa = PBXGroup; children = ( - EC77254A2A1F8E770075CBBF /* VuePrincipale.swift */, - EC77254C2A1F8EE90075CBBF /* ListUe.swift */, - EC7725482A1F8DFE0075CBBF /* MatiereView.swift */, - EC1A528B2A1CE77F00F8CC93 /* HomeView.swift */, EC7725442A1F814A0075CBBF /* UeView.swift */, - EC7725422A1F80980075CBBF /* BlocView.swift */, - EC2E21F32A25E9FA00DED570 /* MatiereUniq.swift */, - EC2E21F72A25FCAA00DED570 /* stbmat.swift */, - EC369C202A325FB5005EE7C8 /* Note.swift */, - EC47F9DB2A34D36200CA3A3F /* EditableView.swift */, - EC47F9DF2A34F00C00CA3A3F /* MatiereEditView.swift */, + EC7692F32A45680700F9F644 /* Home.swift */, + EC7692F52A45683100F9F644 /* Uee.swift */, + EC7692F72A45685200F9F644 /* MatiereUnq.swift */, + EC7692F92A45687000F9F644 /* edit.swift */, + EC7692FB2A45689000F9F644 /* UeCapsule.swift */, + EC7692FD2A4568A900F9F644 /* MatiereCapsule.swift */, + EC7692FF2A4568BD00F9F644 /* EditSheet.swift */, + EC7693012A4568D700F9F644 /* MatiereEditView.swift */, + EC7693032A4568F300F9F644 /* BlockItem.swift */, + EC7693052A45691900F9F644 /* AddSheet.swift */, + EC7693092A456B6B00F9F644 /* Block.swift */, ); path = Vue; sourceTree = ""; @@ -233,7 +251,10 @@ ECF5E2752A23104800A2E9CA /* MatiereVm.swift */, EC47F9E12A35E89400CA3A3F /* UeeVm.swift */, EC47F9E32A35EF1800CA3A3F /* ArrayExtension.swift */, - EC47F9E52A3633DA00CA3A3F /* ManagerVM.swift */, + EC47F9E52A3633DA00CA3A3F /* DataManagerVM.swift */, + EC7692ED2A45667700F9F644 /* CollectionVMUe.swift */, + EC7692EF2A45669000F9F644 /* MatiereCollectionVM.swift */, + EC7692F12A4566CF00F9F644 /* BlocCollectionVM.swift */, ); path = ViewModel; sourceTree = ""; @@ -386,35 +407,42 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - EC7725432A1F80980075CBBF /* BlocView.swift in Sources */, - EC77254D2A1F8EE90075CBBF /* ListUe.swift in Sources */, EC47F9E22A35E89400CA3A3F /* UeeVm.swift in Sources */, - EC369C212A325FB5005EE7C8 /* Note.swift in Sources */, + EC7693042A4568F300F9F644 /* BlockItem.swift in Sources */, + EC7693022A4568D700F9F644 /* MatiereEditView.swift in Sources */, ECF5E2722A23102800A2E9CA /* BlocVm.swift in Sources */, + EC7692E82A4565ED00F9F644 /* UeCollection.swift in Sources */, + EC7693002A4568BD00F9F644 /* EditSheet.swift in Sources */, + EC7693082A456A2400F9F644 /* NoteColor.swift in Sources */, + EC7692F82A45685200F9F644 /* MatiereUnq.swift in Sources */, + EC7692EA2A45660500F9F644 /* MatiereCollection.swift in Sources */, EC47F9D62A34C50C00CA3A3F /* DataManager.swift in Sources */, - EC47F9DC2A34D36200CA3A3F /* EditableView.swift in Sources */, - EC1A528C2A1CE77F00F8CC93 /* HomeView.swift in Sources */, + EC76930A2A456B6B00F9F644 /* Block.swift in Sources */, EC1A52642A1CE12900F8CC93 /* ContentView.swift in Sources */, EC7725562A1F90FD0075CBBF /* UE.swift in Sources */, - EC2E21F82A25FCAA00DED570 /* stbmat.swift in Sources */, EC7725542A1F90CF0075CBBF /* BlocModel.swift in Sources */, EC7725452A1F814A0075CBBF /* UeView.swift in Sources */, EC9D96642A33519800513D62 /* StubMat.swift in Sources */, EC77255B2A1F92EC0075CBBF /* Maquette.swift in Sources */, - EC47F9D82A34C62000CA3A3F /* Manager.swift in Sources */, - EC2E21F42A25E9FA00DED570 /* MatiereUniq.swift in Sources */, - EC77254B2A1F8E770075CBBF /* VuePrincipale.swift in Sources */, + EC7692FC2A45689000F9F644 /* UeCapsule.swift in Sources */, + EC7692FE2A4568A900F9F644 /* MatiereCapsule.swift in Sources */, ECF5E27A2A23177500A2E9CA /* UeStruct.swift in Sources */, + EC7692FA2A45687000F9F644 /* edit.swift in Sources */, EC7725652A2095620075CBBF /* StructBlocs.swift in Sources */, EC1A52622A1CE12900F8CC93 /* SwiftMvvmApp.swift in Sources */, - EC47F9E62A3633DA00CA3A3F /* ManagerVM.swift in Sources */, - EC7725492A1F8DFE0075CBBF /* MatiereView.swift in Sources */, + EC47F9E62A3633DA00CA3A3F /* DataManagerVM.swift in Sources */, + EC7693062A45691900F9F644 /* AddSheet.swift in Sources */, EC7725582A1F91300075CBBF /* Matiere.swift in Sources */, - EC47F9E02A34F00C00CA3A3F /* MatiereEditView.swift in Sources */, + EC7692EC2A45661C00F9F644 /* BlocCollection.swift in Sources */, + EC7692F42A45680700F9F644 /* Home.swift in Sources */, + EC7692EE2A45667700F9F644 /* CollectionVMUe.swift in Sources */, EC47F9E42A35EF1800CA3A3F /* ArrayExtension.swift in Sources */, + EC7692F62A45683100F9F644 /* Uee.swift in Sources */, + EC7692F02A45669000F9F644 /* MatiereCollectionVM.swift in Sources */, ECF5E2762A23104800A2E9CA /* MatiereVm.swift in Sources */, EC9D96622A334F9A00513D62 /* StubData.swift in Sources */, EC47F9DA2A34C73B00CA3A3F /* Stub.swift in Sources */, + EC7692F22A4566CF00F9F644 /* BlocCollectionVM.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Sources/SwiftMvvm/SwiftMvvm/ContentView.swift b/Sources/SwiftMvvm/SwiftMvvm/ContentView.swift index 4a8d751..dfffe1b 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/ContentView.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/ContentView.swift @@ -5,7 +5,7 @@ // Created by etudiant on 23/05/2023. // -import SwiftUI +/*import SwiftUI struct ContentView: View { var body: some View { @@ -23,4 +23,4 @@ struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } -} +}*/ diff --git a/Sources/SwiftMvvm/SwiftMvvm/Manager/DataManager.swift b/Sources/SwiftMvvm/SwiftMvvm/Manager/DataManager.swift index f7e048b..c31fec0 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Manager/DataManager.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Manager/DataManager.swift @@ -9,6 +9,7 @@ import Foundation public protocol DataManager { - func loadUes() -> [UE] - func save(ues: [UE]) + func load() -> [Ue] + func loadUeStage_Proj() -> [Ue] + func save(ues: [Ue]) } diff --git a/Sources/SwiftMvvm/SwiftMvvm/Manager/Manager.swift b/Sources/SwiftMvvm/SwiftMvvm/Manager/Manager.swift deleted file mode 100644 index 703f831..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Manager/Manager.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// Manager.swift -// SwiftMvvm -// -// Created by etudiant on 10/06/2023. -// - -import Foundation - - -public struct Manager { - let dataManager: DataManager - public var ues: [UE] = [] - - public init(withDataManager dataManager: DataManager){ - self.dataManager = dataManager - } - - public mutating func loadUes() { - self.ues.removeAll() - for ue in self.dataManager.loadUes() { - self.ues.append(ue) - } - } - - public func saveUes() { - self.dataManager.save(ues:self.ues) - } -} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Manager/Stub.swift b/Sources/SwiftMvvm/SwiftMvvm/Manager/Stub.swift index 30c49dc..4cb7fb7 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Manager/Stub.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Manager/Stub.swift @@ -6,72 +6,103 @@ // import Foundation - -public struct Stub : DataManager { - +public struct DataStub : DataManager{ + public func load() -> [Ue] { + return [ + Ue( nom: "Génie Logiciel", matieres: loadMartiereUE1(),coef: 6), + Ue( nom: "Systèmes et réseaux", matieres: loadMartiereUE2(), coef: 6), + Ue( nom: "Insertion Professionnelle", matieres: loadMartiereUE3(),coef: 6), + Ue( nom: "Technologies Mobiles 1", matieres: loadMartiereUE4(),coef:9), + Ue( nom: "Technologies Mobiles 2", matieres: loadMartiereUE5(),coef:9), + + ] + } + + public func save(ues: [Ue]) { + + } + + var ue_proj : Ue { + return Ue( nom: "Projet", matieres: loadMartiereUE6(),coef: 9)} + var ue_stage : Ue { + return Ue( nom: "Stage", matieres: loadMartiereUE7(),coef: 15) + } + + + var ue_projvm : UeVM { + return UeVM(withUe: ue_proj)} + var ue_stagevm : UeVM { + return UeVM(withUe: ue_stage) + } + public init(){} - public func loadUes() -> [UE] { - - var ues: [UE] = [] - - - /* UE 1 : Génie Logiciel (coeff. 6) */ - ues.append(UE(id: UUID(), coefficient: 6, moyenne: 0.0, nom: "Systèmes et réseaux ", - listeMatiere: [ - Matiere(id: UUID(), nom: "Internet des Objets", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Réseaux", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Services Mobiles", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Système ", coefficient: 5, note: 0.0), - ])) - ues.append(UE(id: UUID(), coefficient: 6, moyenne: 0.0, nom: "Génie Logiciel", - listeMatiere: [ - Matiere(id: UUID(), nom: "Processus de développement", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Programmation Objets", coefficient: 9, note: 0.0), - Matiere(id: UUID(), nom: "Qualité de développpement", coefficient: 5, note: 0.0), - Matiere(id: UUID(), nom: "Remise à niveau objets", coefficient: 4, note: 0.0), - ])) - ues.append(UE(id: UUID(), coefficient: 6, moyenne: 0.0, nom: "Insertion Professionnelle ", - listeMatiere: [ - Matiere(id: UUID(), nom: "Anglais", coefficient: 5, note: 0.0), - Matiere(id: UUID(), nom: "Economie", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Gestion", coefficient: 3, note: 0.0), - Matiere(id: UUID(), nom: "Communication", coefficient: 4, note: 0.0), - ])) - ues.append(UE(id: UUID(), coefficient: 9, moyenne: 0.0, nom: "Technologies Mobiles 1 ", - listeMatiere: [ - Matiere(id: UUID(), nom: "Android ", coefficient: 6, note: 0.0), - Matiere(id: UUID(), nom: "Architecture de projets C# .NET", coefficient: 5, note: 0.0), - Matiere(id: UUID(), nom: "C++", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Swift", coefficient: 5, note: 0.0), - ])) - ues.append(UE(id: UUID(), coefficient: 9, moyenne: 0.0, nom: "Technologies Mobiles 2 ", - listeMatiere: [ - Matiere(id: UUID(), nom: "Architecture de projets C# .NET ", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "Client/Serveur", coefficient: 4, note: 0.0), - Matiere(id: UUID(), nom: "iOS ", coefficient: 5, note: 0.0), - Matiere(id: UUID(), nom: "Multiplateformes ", coefficient: 3, note: 0.0), - Matiere(id: UUID(), nom: "QT Quick ", coefficient: 5, note: 0.0), - Matiere(id: UUID(), nom: "Xamarin ", coefficient: 5, note: 0.0), - ])) - ues.append(UE(id: UUID(), coefficient: 9, moyenne: 0.0, nom: "Projet ", - listeMatiere: [ - Matiere(id: UUID(), nom: "Projet ", coefficient: 1, note: 0.0), - - ])) - ues.append(UE(id: UUID(), coefficient: 15, moyenne: 0.0, nom: "Stage ", - listeMatiere: [ - Matiere(id: UUID(), nom: "Stage ", coefficient: 1, note: 0.0), - - ])) - - - - - - return ues + + + public func loadUeStage_Proj()->[Ue]{ + return [ + ue_proj, + ue_stage + + ] + } + + func loadMartiereUE1()->[Matiere]{ + return [ + Matiere( name: "Processus de développement", moy: 12, coef: 4), + Matiere( name: "Programmation Objets", moy: 12, coef: 9), + Matiere( name: "Qualité de développpement", moy: 12, coef: 5), + Matiere( name: "Remise à niveau objets", moy: 12, coef: 4) + ] + } + + func loadMartiereUE2()->[Matiere]{ + return [ + Matiere( name: "Internet des Objets", moy: 8, coef: 4), + Matiere( name: "Réseaux", moy: 7, coef: 4), + Matiere( name: "Services Mobiles", moy: 7, coef: 4), + Matiere( name: "Système", moy: 7, coef: 4), + ] + } + + func loadMartiereUE3()->[Matiere]{ + return [ + Matiere( name: "Anglais", moy: 12, coef: 5), + Matiere( name: "Economie", moy: 12, coef: 4), + Matiere( name: "Gestion", moy: 12, coef: 3), + Matiere( name: "Communication", moy: 12, coef: 4), + ] + } + + func loadMartiereUE4()->[Matiere]{ + return [ + Matiere( name: "Android", moy: 12, coef: 6), + Matiere( name: "Architecture de projets C# .NET (1)", moy: 12, coef: 5), + Matiere( name: "C++", moy: 12, coef: 4), + Matiere( name: "Swift", moy: 12, coef: 5), + ] + } + + func loadMartiereUE5()->[Matiere]{ + return [ + Matiere( name: "Architecture de projets C# .NET (2)", moy: 12, coef: 4), + Matiere( name: "Client/Serveur", moy: 12, coef: 4), + Matiere( name: "iOS", moy: 12, coef: 5), + Matiere( name: "Multiplateformes", moy: 12, coef: 3), + Matiere( name: "QT Quick", moy: 12, coef: 5), + Matiere( name: "Xamarin", moy: 12, coef: 5), + ] + } + + func loadMartiereUE6()->[Matiere]{ + return [ + Matiere( name: "Projet", moy: 12, coef: 9) + ] } - public func save(ues: [UE]) { + func loadMartiereUE7()->[Matiere]{ + return [ + Matiere( name: "Stage", moy: 12, coef: 15) + ] } } diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/BlocCollection.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/BlocCollection.swift new file mode 100644 index 0000000..6ee69ae --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/BlocCollection.swift @@ -0,0 +1,21 @@ +// +// BlocCollection.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +struct BlocCollection : Identifiable, Equatable { + + + var id : UUID + + + var blocs: [Bloc] + + init(blocs: [Bloc]) { + self.id = UUID() + self.blocs = blocs + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/BlocModel.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/BlocModel.swift index 35e2a19..2663633 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Model/BlocModel.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/BlocModel.swift @@ -5,26 +5,25 @@ // Created by etudiant on 25/05/2023. // + + import Foundation -struct BlocModel: Identifiable ,Equatable { - static func == (lhs: BlocModel, rhs: BlocModel) -> Bool { +public class Bloc : Identifiable, Equatable{ + public static func == (lhs: Bloc, rhs: Bloc) -> Bool { lhs.id == rhs.id } - let id = UUID() - var Nombloc: String - var Moyenneg: Double - var listeUE: [UE] - public init(Nombloc: String, Moyenneg: Double, listeUE: [UE]) { - self.Nombloc = Nombloc - self.Moyenneg = Moyenneg - self.listeUE = listeUE - } - //a modifier l calcul de la moyenne - // func MoyenneBloc(bloc: BlocModel) -> Double { - // let sumOfMoyennes = bloc.listeUE.reduce(into: 0.0) { $0 + $1.MoyenneUE } - // let numberOfUEs = Double(bloc.listeUE.count) - // return sumOfMoyennes / numberOfUEs - // } - + var nom : String + var isUnique : Bool + public var id : UUID + var ues : [Ue] + var total : Double { + return Double(ues.reduce(0) { $0 + $1.totalMoyenne }) / Double(ues.count) + } + init(nom: String, ues: [Ue], isUq : Bool) { + self.id = UUID() + self.nom = nom + self.ues = ues + self.isUnique = isUq + } } diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/Maquette.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/Maquette.swift index 698dcdf..7d7fce4 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Model/Maquette.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/Maquette.swift @@ -5,7 +5,7 @@ // Created by etudiant on 25/05/2023. // -import Foundation +/*import Foundation struct Maquette { var listeBloc: [BlocModel] var listeUE: [UE] @@ -14,3 +14,4 @@ struct Maquette { self.listeUE = listeUE } } +*/ diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/Matiere.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/Matiere.swift index f7fa9df..75927ba 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Model/Matiere.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/Matiere.swift @@ -6,19 +6,21 @@ // import Foundation -public struct Matiere: Identifiable, Equatable { - - public let id: UUID - public var nom: String - public var coefficient: Double - public var note:Double - - - public init(id: UUID, nom: String, coefficient: Double,note :Double ) { - self.id = id - self.nom = nom - self.coefficient = coefficient - self.note=note + +struct Matiere : Identifiable, Equatable{ + static func == (lhs: Matiere, rhs: Matiere) -> Bool { + lhs.id == rhs.id + } + let id: UUID + var name: String + var moyenne: Float + var coef : Int + + init( name: String, moy: Float, coef : Int) { + self.id = UUID() + self.name = name + self.moyenne = moy + self.coef = coef } } diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/MatiereCollection.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/MatiereCollection.swift new file mode 100644 index 0000000..557ab68 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/MatiereCollection.swift @@ -0,0 +1,24 @@ +// +// MatiereCollection.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +struct MatiereCollection : Identifiable, Equatable{ + static func == (lhs: MatiereCollection, rhs: MatiereCollection) -> Bool { + lhs.id == rhs.id + } + + var id : UUID + + var nom: String + var matieres: [Matiere] + + init(nom: String, matieres: [Matiere]) { + self.id = UUID() + self.nom = nom + self.matieres = matieres + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/UE.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/UE.swift index 2c9b7cd..9918448 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Model/UE.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/UE.swift @@ -6,26 +6,24 @@ // import Foundation -public struct UE: Identifiable,Equatable { - public static func == (lhs: UE, rhs: UE) -> Bool { +public struct Ue : Identifiable, Equatable { + public static func == (lhs: Ue, rhs: Ue) -> Bool { lhs.id == rhs.id } - public let id: UUID - var coefficient: Double - var moyenne: Double - var nom: String - var listeMatiere: [Matiere] - public init(id: UUID, coefficient: Double, moyenne: Double, nom: String, listeMatiere: [Matiere]) { - self.id = id - self.coefficient = coefficient - self.moyenne = moyenne - self.nom = nom - self.listeMatiere = listeMatiere - } - func calculerMoyenneUE() -> Double { - let sommeDesNotes = listeMatiere.reduce(into: 0) { $0 + $1.note } - let nombreDeMatieres = Double(listeMatiere.count) - return sommeDesNotes / nombreDeMatieres + public let id : UUID + var nom: String + var coef : Int + var matieres: [Matiere] + + var totalMoyenne: Double { + return Double(matieres.reduce(0) { $0 + $1.moyenne }) / Double(matieres.count) } + + init( nom: String, matieres: [Matiere], coef : Int) { + self.id = UUID() + self.nom = nom + self.matieres = matieres + self.coef = coef + } } diff --git a/Sources/SwiftMvvm/SwiftMvvm/Model/UeCollection.swift b/Sources/SwiftMvvm/SwiftMvvm/Model/UeCollection.swift new file mode 100644 index 0000000..045fa27 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Model/UeCollection.swift @@ -0,0 +1,25 @@ +// +// UeCollection.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +struct UeCollection : Identifiable, Equatable { + + public static func == (lhs: UeCollection, rhs: UeCollection) -> Bool { + lhs.id == rhs.id + } + + var id : UUID + + var nom: String + var ues: [Ue] + + init(nom: String, ues: [Ue]) { + self.id = UUID() + self.nom = nom + self.ues = ues + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/NoteColor.swift b/Sources/SwiftMvvm/SwiftMvvm/NoteColor.swift new file mode 100644 index 0000000..e5fb714 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/NoteColor.swift @@ -0,0 +1,13 @@ +// +// NoteColor.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import Foundation +import SwiftUI +public struct NoteColor{ + public let ue_back = Color("background_UE") +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Structs/StructBlocs.swift b/Sources/SwiftMvvm/SwiftMvvm/Structs/StructBlocs.swift index 8013d82..69f8a64 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Structs/StructBlocs.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Structs/StructBlocs.swift @@ -5,7 +5,7 @@ // Created by etudiant on 26/05/2023. // -import Foundation +/*import Foundation extension BlocModel { struct Data: Identifiable { let id = UUID() @@ -22,5 +22,5 @@ extension BlocModel { } } - + */ diff --git a/Sources/SwiftMvvm/SwiftMvvm/Structs/UeStruct.swift b/Sources/SwiftMvvm/SwiftMvvm/Structs/UeStruct.swift index 83f88e7..47dce64 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Structs/UeStruct.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Structs/UeStruct.swift @@ -7,7 +7,7 @@ import Foundation -extension UE { +extension UeView { struct Data: Identifiable { let id = UUID() var coefficient: Double diff --git a/Sources/SwiftMvvm/SwiftMvvm/Stub/StubData.swift b/Sources/SwiftMvvm/SwiftMvvm/Stub/StubData.swift index 30745f8..8626866 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Stub/StubData.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Stub/StubData.swift @@ -5,7 +5,7 @@ // Created by etudiant on 09/06/2023. // -import Foundation +/*import Foundation import SwiftUI let stubUES: [UE] = [ @@ -16,5 +16,5 @@ let stubUES: [UE] = [ UE(id: UUID(), coefficient: 9, moyenne: 13.5, nom: "UE5 : Technologies Mobiles 2", listeMatiere: []), UE(id: UUID(), coefficient: 9, moyenne: 11.0, nom: "UE6 : Projet", listeMatiere: []), UE(id: UUID(), coefficient: 9, moyenne: 15.0, nom: "UE7 : ÉconoStagemie", listeMatiere: []) -] +]*/ diff --git a/Sources/SwiftMvvm/SwiftMvvm/Stub/StubMat.swift b/Sources/SwiftMvvm/SwiftMvvm/Stub/StubMat.swift index 69f7d9f..81b5126 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Stub/StubMat.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Stub/StubMat.swift @@ -5,10 +5,11 @@ // Created by etudiant on 09/06/2023. // -import Foundation +/*import Foundation import SwiftUI let stubMatieres: [Matiere] = [ Matiere(id: UUID(), nom: "Mathématiques", coefficient: 2.0, note: 15.0), Matiere(id: UUID(), nom: "Physique", coefficient: 1.5, note: 12.0), Matiere(id: UUID(), nom: "Chimie", coefficient: 1.0, note: 10.5) ] +*/ diff --git a/Sources/SwiftMvvm/SwiftMvvm/SwiftMvvmApp.swift b/Sources/SwiftMvvm/SwiftMvvm/SwiftMvvmApp.swift index 77f1cae..2228f65 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/SwiftMvvmApp.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/SwiftMvvmApp.swift @@ -5,13 +5,27 @@ // Created by etudiant on 23/05/2023. // + + +/*struct SwiftMvvmApp: App { + var body: some Scene { + WindowGroup { + VuePrincipale() + } + } +}*/ import SwiftUI @main -struct SwiftMvvmApp: App { +struct NoteApp: App { + var blocs = [ + BlocVM(withBloc: Bloc(nom: "Total", ues: DataStub().load(),isUq: false)), + BlocVM(withBloc: Bloc(nom: "Projet/Stage", ues: DataStub().loadUeStage_Proj(), isUq: true)) + ] var body: some Scene { WindowGroup { - VuePrincipale() + Home(manager: ManagerVM( withBlocs: blocs + )) } } } diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocCollectionVM.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocCollectionVM.swift new file mode 100644 index 0000000..e023002 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocCollectionVM.swift @@ -0,0 +1,47 @@ +// +// BlocCollectionVM.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +class BlocCollectionVM : ObservableObject,Identifiable,Equatable { + static func == (lhs: BlocCollectionVM, rhs: BlocCollectionVM) -> Bool { + lhs.id == rhs.id + } + + + + public var id: UUID { model.id } + + + + @Published var model : BlocCollection = BlocCollection( blocs: []){ + didSet{ + + if !self.model.blocs.compare(to: self.someBlocVM.map({$0.model})){ + + self.someBlocVM = self.model.blocs.map({BlocVM(withBloc: $0)}) + } + } + } + + + + @Published var someBlocVM: [BlocVM] = [] { + didSet { + let someModelBlocs = self.someBlocVM.map({$0.model}) + if !self.model.blocs.compare(to: someModelBlocs) { + self.model.blocs = someBlocVM.map({$0.model}) + } + } + } + + + init(withbloc blocs : BlocCollection) { + self.model = blocs + } + + +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocVm.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocVm.swift index 590fb7e..3147996 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocVm.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/BlocVm.swift @@ -8,69 +8,119 @@ // BlocVM.swift import Foundation +class BlocVM : ObservableObject, Identifiable, Equatable, Hashable { + static func == (lhs: BlocVM, rhs: BlocVM) -> Bool { + lhs.id == rhs.id + } + func hash(into hasher: inout Hasher) { + hasher.combine(self.nom) + hasher.combine(self.totalMoyenne) + } + func onNotifyChanged(source:UeVM){ + if let index = self.model.ues.firstIndex(where: {$0 == source.model}) { + self.model.ues[index] = source.model + } + self.objectWillChange.send() + } + private var notificationFuncs: [AnyHashable:(BlocVM) -> ()] = [:] + + public func subscribe(with subscriber: AnyHashable, andWithFunction function:@escaping (BlocVM) -> ()) { + notificationFuncs[subscriber] = function + } + + public func unsubscribe(with subscriber: AnyHashable) { + notificationFuncs.removeValue(forKey: subscriber) + } + private func onNotifyChanged(){ + for f in notificationFuncs.values { + print("moi") + f(self) + } + } + @Published var totalMoyenne: Double = 0.0 { + didSet{ + let moy = updateTotalMoyenne() + print("Moy =\(moy)") + if moy != self.totalMoyenne { + self.totalMoyenne = moy + } + self.onNotifyChanged() + } + } + @Published var isUnique : Bool = false { + didSet{ + if self.isUnique != self.model.isUnique { + self.model.isUnique = self.isUnique + } + } + } + public func updateTotalMoyenne()->Double { -/* let id = UUID() - var Nombloc: String - var Moyenneg: Double - var listeUE: [UE]*/ + let totalMoyenn = self.someUesVM.reduce(0.0) { $0 + Double($1.totalMoyenne) * Double($1.coef) } + let totalCoef = self.someUesVM.reduce(0.0) { $0 + Double($1.coef) } + + print("bloc") + print( totalMoyenn / totalCoef) + return totalMoyenn / totalCoef -class BlocVm : ObservableObject ,Equatable{ - static func == (lhs: BlocVm, rhs: BlocVm) -> Bool { - lhs.id == rhs.id } - // dans le model on met à jour les donnes du vue model les proprietes à présenter à la vue - @Published var model: BlocModel = BlocModel(Nombloc: "", Moyenneg: 17, listeUE: []) - { + @Published var model : Bloc = Bloc(nom: "Total", ues: DataStub().load(), isUq: false) { + + willSet(newValue) { + if !self.someUesVM.map({$0.model}).compare(to: newValue.ues){ + self.someUesVM.forEach { uevm in + uevm.unsubscribe(with: self) + } + } + } didSet{ + if self.model.nom != self.nom { + self.nom = self.model.nom + } - if self.model.Nombloc != self.Nombloc { - self.Nombloc = self.model.Nombloc + if !self.model.ues.compare(to: self.someUesVM.map({$0.model})){ + self.someUesVM = self.model.ues.map({UeVM(withUe: $0)}) + self.someUesVM.forEach { uevm in + uevm.subscribe(with: self, andWithFunction: onNotifyChanged(source:)) + } } - if self.model.Moyenneg != self.Moyenneg { - self.Moyenneg = self.model.Moyenneg + if self.model.isUnique != self.isUnique { + self.isUnique = self.model.isUnique } - if !self.model.listeUE.compare(to: self.someUeVM.map({$0.model})){ - self.someUeVM = self.model.listeUE.map({UeVm(withModel: $0)}) - } - + + let moy = updateTotalMoyenne() + if moy != self.totalMoyenne { + self.totalMoyenne = moy + } + + self.onNotifyChanged() } } + init(withBloc blc : Bloc) { + self.model = blc + + } public var id: UUID { model.id } - - @Published - var Nombloc: String = "" { - didSet { - if self.model.Nombloc != self.Nombloc { - self.model.Nombloc = self.Nombloc - } - } - } + @Published - var Moyenneg : Double = 0 { + var nom: String = "" { didSet { - if self.model.Moyenneg != self.Moyenneg { - self.model.Moyenneg = self.Moyenneg + if self.model.nom != self.nom { + self.model.nom = self.nom } } } - //collection on met a jour le Ue avec l dernier - @Published var someUeVM: [UeVm] = [] { - didSet { - let someModelUe = self.someUeVM.map({$0.model}) - if !self.model.listeUE.compare(to: someModelUe){ - self.model.listeUE = someUeVM.map({$0.model}) - } + @Published var someUesVM: [UeVM] = [] { + didSet { + let someModelue = self.someUesVM.map({$0.model}) + if !self.model.ues.compare(to: someModelue){ + self.model.ues = someModelue.map({$0}) + } - } - - init(withModel BlocModel: BlocModel) { - model = BlocModel + } } - - - } diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/CollectionVMUe.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/CollectionVMUe.swift new file mode 100644 index 0000000..3f11ead --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/CollectionVMUe.swift @@ -0,0 +1,59 @@ +// +// CollectionVMUe.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation + +class CollectionVMUe : ObservableObject,Identifiable,Equatable { + static func == (lhs: CollectionVMUe, rhs: CollectionVMUe) -> Bool { + lhs.id == rhs.id + } + + public var id: UUID { model.id } + + + + @Published var model : UeCollection = UeCollection(nom: "", ues: []){ + didSet{ + if self.model.nom != self.nom { + self.nom = self.model.nom + } + if !self.model.ues.compare(to: self.someUesVM.map({$0.model})){ + self.someUesVM = self.model.ues.map({UeVM(withUe: $0)}) + } + } + } + + @Published var nom: String = "" { + didSet { + if self.model.nom != self.nom { + self.model.nom = self.nom + } + } + } + + @Published var someUesVM: [UeVM] = [] { + didSet { + let someModelUe = self.someUesVM.map({$0.model}) + if !self.model.ues.compare(to: someModelUe) { + self.model.ues = someUesVM.map({$0.model}) + } + } + } + + + init(withUe ues : UeCollection) { + self.model = ues + } + + + + +} + + + + diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/DataManagerVM.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/DataManagerVM.swift new file mode 100644 index 0000000..10e7f92 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/DataManagerVM.swift @@ -0,0 +1,44 @@ +// +// ManagerVM.swift +// SwiftMvvm +// +// Created by etudiant on 11/06/2023. +// + +import Foundation + +class ManagerVM: ObservableObject, Hashable { + + static func == (lhs: ManagerVM, rhs: ManagerVM) -> Bool { + lhs.blocs.compare(to: rhs.blocs) + } + + @Published var blocs: [BlocVM] + + // abonnée + func hash(into hasher: inout Hasher) { + hasher.combine("manager") + } + + func onNotifyChanged(source:BlocVM){ + self.objectWillChange.send() + } + + public init(withBloc blocs: [Bloc]){ + self.blocs = blocs.map({BlocVM(withBloc: $0)}) + self.blocs.forEach { blocvm in + blocvm.subscribe(with: self, andWithFunction: onNotifyChanged(source:)) + } + } + + var total : Double { + return Double(blocs.reduce(0) { $0 + $1.totalMoyenne }) / Double(blocs.count) + } + + public init(withBlocs blocs: [BlocVM]){ + self.blocs = blocs + self.blocs.forEach { blocvm in + blocvm.subscribe(with: self, andWithFunction: onNotifyChanged(source:)) + } + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/ManagerVM.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/ManagerVM.swift deleted file mode 100644 index f6277c4..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/ManagerVM.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// ManagerVM.swift -// SwiftMvvm -// -// Created by etudiant on 11/06/2023. -// - -import Foundation - -//pouvoir les utiliser dans la vue -class ManagerVM: ObservableObject { - @Published var blocs: [BlocVm] = [] - - public init(withBeds blocs: [BlocModel]){ - self.blocs = blocs.map({BlocVm(withModel: $0)}) - } - - public init(withBeds blocs: [BlocVm]){ - self.blocs = blocs - } -} diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereCollectionVM.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereCollectionVM.swift new file mode 100644 index 0000000..198b5d3 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereCollectionVM.swift @@ -0,0 +1,66 @@ +// +// MatiereCollectionVM.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation + +class MatiereCollectionVM : ObservableObject,Identifiable,Equatable { + static func == (lhs: MatiereCollectionVM, rhs: MatiereCollectionVM) -> Bool { + lhs.id == rhs.id + } + + public var id: UUID { model.id } + + /* + var id : UUID + + var nom: String + var matieres: [Matiere] + */ + + @Published var model : MatiereCollection = MatiereCollection(nom: "", matieres: []){ + didSet{ + if self.model.nom != self.nom { + self.nom = self.model.nom + } + if !self.model.matieres.compare(to: self.someMatieresVM.map({$0.model})){ + self.someMatieresVM = self.model.matieres.map({MatiereVM(withMat: $0)}) + } + } + } + + @Published var nom: String = "" { + didSet { + if self.model.nom != self.nom { + self.model.nom = self.nom + } + } + } + + @Published var someMatieresVM: [MatiereVM] = [] { + didSet { + let someModelMatiere = self.someMatieresVM.map({$0.model}) + if !self.model.matieres.compare(to: someModelMatiere){ + self.model.matieres = someMatieresVM.map({$0.model}) + } + print("vjgjjh") + } + } + + + init(withMat matieres : MatiereCollection) { + self.model = matieres + } + + + + + + +} + + + diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereVm.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereVm.swift index d3937ed..2efdb8e 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereVm.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/MatiereVm.swift @@ -7,64 +7,99 @@ import Foundation -class MatiereVm : ObservableObject ,Identifiable { - // dans le model on met à kjour les donnes du vue model les proprietes à présenter à la vue - //on vérifie que someNounourscollection de Nounoursdu modèle est différent du someNounoursVMcollection de NounoursVM - @Published var model: Matiere = Matiere(id: UUID(), nom: "Ma mat", coefficient: 2, note: 12) { - didSet{ - - if self.model.nom != self.nom { - self.nom = self.model.nom - } - - if self.model.coefficient != self.coefficient { - self.coefficient = self.model.coefficient - } - if self.model.note != self.note - { - self.note = self.model.note + +class MatiereVM : ObservableObject, Identifiable, Equatable { + private var notificationFuncs: [AnyHashable:(MatiereVM) -> ()] = [:] + public func subscribe(with subscriber: AnyHashable, andWithFunction function:@escaping (MatiereVM) -> ()) { + notificationFuncs[subscriber] = function + } + + public func unsubscribe(with subscriber: AnyHashable) { + notificationFuncs.removeValue(forKey: subscriber) + } + func notifyChanged(){ + for f in notificationFuncs.values { + f(self) } } + + static func == (lhs: MatiereVM, rhs: MatiereVM) -> Bool { + lhs.id == rhs.id } - /* - public let id: UUID - public var nom: String - public var coefficient: Double - public var note:Double - */ - public var id: UUID { model.id } - @Published - var nom: String = "" { - didSet { - if self.model.nom != self.nom { - self.model.nom = self.nom + public var id: UUID { model.id } + @Published var model : Matiere = Matiere(name: "", moy: 0, coef: 0) + { + + didSet { + if self.name != self.model.name { + self.name = self.model.name + }; + if self.moyenne != self.model.moyenne { + self.moyenne = self.model.moyenne + }; + if self.coef != self.model.coef { + self.coef = self.model.coef + } + self.notifyChanged() } } - } - - @Published - var coefficient : Double = 0 { + var name: String = "" { didSet { - if self.model.coefficient != self.coefficient { - self.model.coefficient = self.coefficient + if self.model.name != self.name { + self.model.name = self.name } - } + } } + @Published - var note : Double = 0 { + var moyenne: Float=0 { didSet { - if self.model.note != self.note { - self.model.note = self.note + if self.model.moyenne != self.moyenne { + self.model.moyenne = self.moyenne + } - } - } + } + } - init(withModel Matiere: Matiere) { - model = Matiere + @Published + var coef: Int = 0 { + didSet { + if self.model.coef != self.coef { + self.model.coef = self.coef + } + } } - + public init(){} + + init(withMat mat : Matiere) { + + self.model = mat + } + @Published + var isEditing: Bool = false + + private var copy: MatiereVM { MatiereVM(withMat: self.model) } + + var editedCopy: MatiereVM? + + func onEditing(){ + editedCopy = self.copy + isEditing = true + } + + func onEdited(isCancelled cancel: Bool = false) { + if !cancel { + if let editedCopy = editedCopy { + self.model = editedCopy.model + } + } + editedCopy = nil + isEditing = false + } } + + diff --git a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/UeeVm.swift b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/UeeVm.swift index 8f1e23e..7ae753b 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/ViewModel/UeeVm.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/ViewModel/UeeVm.swift @@ -12,72 +12,160 @@ import Foundation var nom: String var listeMatiere: [Matiere] */ -class UeVm : ObservableObject,Equatable , Identifiable { - static func == (lhs: UeVm, rhs: UeVm) -> Bool { + + +class UeVM : ObservableObject, Identifiable, Equatable,Hashable { + static func == (lhs: UeVM, rhs: UeVM) -> Bool { lhs.id == rhs.id } - - // dans le model on met à jour les donnes du vue model les proprietes à présenter à la vue - @Published var model: UE = UE(id: UUID(), coefficient: 2,moyenne: 10,nom: "", listeMatiere: [] ) { + private var notificationFuncs: [AnyHashable:(UeVM) -> ()] = [:] + func onNotifyChanged(source:MatiereVM){ + if let index = self.model.matieres.firstIndex(where: {$0 == source.model}) { + self.model.matieres[index] = source.model + } + self.objectWillChange.send() + } + func hash(into hasher: inout Hasher) { + hasher.combine(self.nom) + hasher.combine(self.totalMoyenne) + } + public func subscribe(with subscriber: AnyHashable, andWithFunction function:@escaping (UeVM) -> ()) { + notificationFuncs[subscriber] = function + } + public func unsubscribe(with subscriber: AnyHashable) { + notificationFuncs.removeValue(forKey: subscriber) + } + func onNotifyChanged(){ + for f in notificationFuncs.values { + f(self) + } + } + @Published var totalMoyenne: Double = 0.0 { + didSet{ + let moy = updateTotalMoyenne() + if moy != self.totalMoyenne { + self.totalMoyenne = moy + } + } + } + public func updateTotalMoyenne()->Double { + let totalMoyenne = someMatieresVM.reduce(0.0) { $0 + Double($1.moyenne) * Double($1.coef) } + let totalCoef = someMatieresVM.reduce(0.0) { $0 + Double($1.coef) } + print("ue") + print(self.someMatieresVM.count) + return totalMoyenne / totalCoef + + } + init(withUe ue : Ue) { + self.model = ue + + } + @Published var model : Ue = DataStub().load()[0]{ + willSet(newValue) { + if !self.someMatieresVM.map({$0.model}).compare(to: newValue.matieres){ + self.someMatieresVM.forEach { $0.unsubscribe(with: self) } + } + } didSet{ - if self.model.nom != self.nom { self.nom = self.model.nom } - - if self.model.coefficient != self.coefficient { - self.coefficient = self.model.coefficient + if self.model.coef != self.coef { + self.coef = self.model.coef } - if self.model.moyenne != self.moyenne - { - self.moyenne = self.model.moyenne + if !self.model.matieres.compare(to: self.someMatieresVM.map({$0.model})){ + self.someMatieresVM = self.model.matieres.map({MatiereVM(withMat: $0)}) + self.someMatieresVM.forEach { mvm in + mvm.subscribe(with: self, andWithFunction: onNotifyChanged(source:)) + } + } - if !self.model.listeMatiere.compare(to: self.someMatVM.map({$0.model})){ - self.someMatVM = self.model.listeMatiere.map({MatiereVm(withModel: $0)}) - } + let moyen = updateTotalMoyenne() + if moyen != self.totalMoyenne { + self.totalMoyenne = moyen + } + self.onNotifyChanged() } - } + } public var id: UUID { model.id } - + @Published - var nom: String = "" { - didSet { - if self.model.nom != self.nom { - self.model.nom = self.nom - } + var nom: String = "" { + didSet { + if self.model.nom != self.nom { + self.model.nom = self.nom } } + } + @Published - var coefficient : Double = 0 { + var coef: Int = 0 { didSet { - if self.model.coefficient != self.coefficient { - self.model.coefficient = self.coefficient - } + if self.model.coef != self.coef { + self.model.coef = self.coef + } } } - @Published - var moyenne : Double = 0 { + @Published var someMatieresVM: [MatiereVM] = [] { didSet { - if self.model.moyenne != self.moyenne { - self.model.moyenne = self.moyenne + let someModelMatiere = self.someMatieresVM.map({$0.model}) + if !self.model.matieres.compare(to: someModelMatiere){ + self.model.matieres = someModelMatiere.map({$0}) + + } } } + public init (){} + @Published + var isEditing: Bool = false + + private var copy: UeVM { UeVM(withUe: self.model) } + + var editedCopy: UeVM? + + func onEditing(){ + editedCopy = self.copy + isEditing = true } -/* chaque fois que someNounoursVM est modifié, le bloc didSet vérifie si les modèles qu'il contient sont différents de ceux déjà présents dans self.model.someNounours. Si tel est le cas, il met à jour self.model.someNounours avec les nouveaux modèles.*/ - @Published var someMatVM: [MatiereVm] = [] { - didSet { - let someModelMatier = self.someMatVM.map({$0.model}) - if !self.model.listeMatiere.compare(to: someModelMatier){ - self.model.listeMatiere = someMatVM.map({$0.model}) - } + func onEdited(isCancelled cancel: Bool = false) { + if !cancel { + if let editedCopy = editedCopy { + self.model = editedCopy.model } } - init(withModel UE: UE) { - model = UE + isEditing = false } - + var addedItem: MatiereVM? = MatiereVM(withMat: Matiere(name: "", moy: 0.0, coef: 1)) + @Published + var isAdding: Bool = false + + func onAdding() { + addedItem = MatiereVM() + isAdding = true + } + func onAdded(isCancelled cancel:Bool = false) { + if !cancel { + if let addedItem = addedItem { + self.someMatieresVM.append(addedItem) + addedItem.subscribe(with: self, andWithFunction: onNotifyChanged(source:)) + } + } + addedItem = nil + isAdding = false + } + func onDeleted(_ matiere:MatiereVM, isCancelled cancel: Bool = false) { + if !cancel { + if self.someMatieresVM.contains(matiere) { + self.someMatieresVM.filter { $0 == matiere } + .forEach { $0.unsubscribe(with: self) } + self.someMatieresVM.removeAll(where: {$0 == matiere}) + } + } + } + } + diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/AddSheet.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/AddSheet.swift new file mode 100644 index 0000000..2dc0fe0 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/AddSheet.swift @@ -0,0 +1,33 @@ +// +// AddSheet.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import SwiftUI + +struct AddSheet: View { + @ObservedObject var mat : MatiereVM + var body: some View { + VStack{ + HStack{ + Text("Nom : ") + TextField("Description", text: $mat.name) + } + HStack{ + Text("Coef : ") + TextField("Coefficient", value: $mat.coef, format: .number) + + } + } + + } +} + +struct AddSheet_Previews: PreviewProvider { + static var previews: some View { + AddSheet(mat: MatiereVM()) + } +} + diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/BlocView.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/BlocView.swift deleted file mode 100644 index ad31e89..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/BlocView.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// BlocView.swift -// SwiftMvvm -// -// Created by etudiant on 25/05/2023. -// - -import SwiftUI - -struct BlocView: View { - - var body: some View { - VStack(alignment: .leading) { - Label("Blocs", systemImage: "doc.on.doc.fill") - .font(.title) - Text("Vous devez avoir la moyenne à chacun de ces blocs pour avoir votre diplôme.") - HStack { - Label("Total", systemImage: "doc.on.doc.fill") - Spacer() - Label("11.67", systemImage: "graduationcap.circle.fill") - } - HStack { - Label("Total", systemImage: "doc.on.doc.fill") - Spacer() - Label("11.67", systemImage: "graduationcap.circle.fill") - } - } - .padding() - .background(Color("ListItemBackgroundColor")) - .cornerRadius(12) - } - - } - - -struct BlocView_Previews: PreviewProvider { - static var previews: some View { - BlocView() - } -} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/Block.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/Block.swift new file mode 100644 index 0000000..39c1792 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/Block.swift @@ -0,0 +1,46 @@ +// +// Block.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + + +import SwiftUI + +import SwiftUI + +struct Block: View { + + @ObservedObject var manager : ManagerVM + + var body: some View { + VStack(alignment: .leading) { + + HStack { + Image(systemName: "menucard.fill") + Text("Blocs").bold().font(.title) + } + + Text("Vous devez avoir la moyenne à chacun de ces blocs pour avoir votre diplôme.").padding(.bottom) + BlockItem(total: .constant( manager.total), name: .constant("Total")) + + ForEach(manager.blocs) { item in + if item.isUnique { + BlockItem(total: .constant(item.totalMoyenne), name: .constant(item.nom)) + Divider() + } + + } + }.padding().background(NoteColor().ue_back).cornerRadius(10) + } +} +struct Block_Previews: PreviewProvider { + static var previews: some View { + let blocs = [ + BlocVM(withBloc: Bloc(nom: "Total", ues:DataStub().load(),isUq: false)), +BlocVM(withBloc: Bloc(nom: "Projet", ues: DataStub().loadUeStage_Proj(), isUq: true))] + Block(manager: ManagerVM(withBlocs: blocs) ) + + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/BlockItem.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/BlockItem.swift new file mode 100644 index 0000000..14e9910 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/BlockItem.swift @@ -0,0 +1,36 @@ +// +// BlockItem.swift +// SwiftMvvm +// +// Created by etudiant on 20/06/2023. +// +import SwiftUI + +struct BlockItem: View { + @Binding var total : Double + @Binding var name : String + + var body: some View { + HStack(spacing: 15) { + Grid{ + GridRow { + Image(systemName: "rectangle.on.rectangle") + Text(self.name).font(.title3) + Text( self.total,format: .number) + + Image(systemName: "graduationcap.circle.fill") + + } + } + + + } + } +} + +struct BlockItem_Previews: PreviewProvider { + static var previews: some View { + BlockItem(total: .constant( 12.9), name: .constant( "Total")) + } +} + diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/EditSheet.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/EditSheet.swift new file mode 100644 index 0000000..9fd94af --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/EditSheet.swift @@ -0,0 +1,93 @@ +// +// EditSheet.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import SwiftUI + +struct EditSheet : View{ + @ObservedObject var ue: UeVM + @Binding var isEditMode: Bool + var body: some View { + + NavigationView { + + VStack{ + Section(header: Text("UE Info").font(.title)) + { + VStack{ + TextField("Description", text: $ue.nom) + TextField("Coefficient", value: $ue.coef, format: .number) + } + + + + } + Divider() + Section(header: Text("Matieres").font(.title)) { + ForEach(ue.someMatieresVM) { matiere in + HStack{ + MatiereEditView(matiere: matiere) + Button(action: { + self.ue.onDeleted(matiere) + }){ + Text("Supprimer") + } + } + + } + Spacer() + Button(action: { + self.ue.onAdding() + }) { + Text("Ajouter une matiere") + } + } + }.padding().background(NoteColor().ue_back) + + } + .navigationBarItems(trailing: + Button(action: { + self.ue.onEdited() + }) { + Text( self.ue.isEditing ? "Done" : "Modifier") + }) + + // Feuille d'ajout + .sheet(isPresented: $ue.isAdding){ + NavigationStack{ + + AddSheet(mat: self.ue.addedItem ?? MatiereVM()) + + .toolbar{ + ToolbarItem(id: "Ajouter", placement: .confirmationAction){ + Button(action: { + self.ue.onAdded() + }){ + Text("Add") + } + } + ToolbarItem(id: "cancel", placement: .cancellationAction){ + Button(action: { + self.ue.onAdded(isCancelled: true) + }){ + Text("Cancel") + } + } + } + .navigationBarTitle("Ajout d'une nouvelle matière") + } + } + + }} + + +struct EditSheet_Previews: PreviewProvider { + static var previews: some View { + let uevm : UeVM = UeVM(withUe: DataStub().ue_proj) + EditSheet(ue: uevm, isEditMode: .constant(true)) + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/EditableView.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/EditableView.swift deleted file mode 100644 index 1cf159b..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/EditableView.swift +++ /dev/null @@ -1,79 +0,0 @@ -// -// EditableView.swift -// SwiftMvvm -// -// Created by etudiant on 10/06/2023. -// - -import SwiftUI - - -struct EditableView: View { - @ObservedObject var editableUe:UeVm - @State var isEditing: Bool = false - var body: some View { - NavigationStack{ - Form{ - NavigationLink{ - Form{ - TextField("", text: $editableUe.nom, prompt: Text("enter the name")) - } - .navigationBarTitleDisplayMode(.inline) - .navigationTitle("Name") - } - label: { - HStack{ - Text("Name") - Spacer() - Text(editableUe.nom) - .foregroundColor(.gray) - } - } - NavigationLink{ - Form{ - TextField("", value: $editableUe.coefficient, format: .number, prompt: Text("enter the COEF")) - } - .navigationBarTitleDisplayMode(.inline) - .navigationTitle("enter the COEFt") - } - label: { - HStack{ - Text("enter the COEFt") - Spacer() - Text(String(editableUe.coefficient)) - .foregroundColor(.gray) - } - } - NavigationLink{ - Form{ - TextField("", value: $editableUe.moyenne, format: .number, prompt: Text("enter the NOTE")) - } - .navigationBarTitleDisplayMode(.inline) - .navigationTitle("enter the NOTE") - } - label: { - HStack{ - Text("enter the NOTE") - Spacer() - Text(String(editableUe.moyenne)) - .foregroundColor(.gray) - } - } - // - } - } - } -} - - struct EditableView_Previews: PreviewProvider { - static var previews: some View { - let ueee = Stub().loadUes()[0] - EditableView(editableUe:UeVm(withModel:ueee)) - } - } - - - - - - diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/Home.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/Home.swift new file mode 100644 index 0000000..21a7fd1 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/Home.swift @@ -0,0 +1,59 @@ +// +// Home.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import SwiftUI + +struct Home: View { + // @State public var ues = DataStub().load() + @StateObject var manager: ManagerVM + var body: some View { + NavigationView{ + + VStack(alignment : .leading){ + + HStack { + + Text("Calculette").bold().font(.title) + } + Block(manager: manager ) + VStack(alignment : .leading){ + HStack(alignment:.bottom){ + Image(systemName: "menucard.fill") + Text("UEs").bold().font(.title) + }.padding() + + ScrollView{ + ForEach(manager.blocs) { item in + ForEach(item.someUesVM) { + ue in + + UeView(bloc: item, ue: ue) + } + + + + } + + } + }.padding().background(NoteColor().ue_back).cornerRadius(10) + + + }.padding() + + + } + + } +} + +struct Home_Previews: PreviewProvider { + static var previews: some View { + let managerVM = ManagerVM(withBlocs: [BlocVM(withBloc: Bloc(nom: "Total", ues: DataStub().load(), isUq: false)),BlocVM(withBloc: Bloc(nom: "Projet", ues: DataStub().loadUeStage_Proj(),isUq: true))]) + Home(manager: managerVM ) + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/HomeView.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/HomeView.swift deleted file mode 100644 index 0668567..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/HomeView.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// HomeView.swift -// SwiftMvvm -// -// Created by etudiant on 23/05/2023. -// - -import SwiftUI - -struct HomeView: View{ - - var body: some View { - Text("Calculatrice ") - .font(.headline) - .padding(.trailing, 20) - .font(.headline) - .foregroundColor(.blue) - } -} - -struct HomeView_Previews: PreviewProvider { - static var previews: some View { - HomeView() - } -} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/ListUe.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/ListUe.swift deleted file mode 100644 index 068ad0e..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/ListUe.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// ListUe.swift -// SwiftMvvm -// -// Created by etudiant on 25/05/2023. -// - -import SwiftUI - -struct ListUe: View { - var body: some View { - NavigationStack { - VStack(alignment: .leading) { - Label("UEs", systemImage: "doc.fill") - .font(.title) - Text("Détails des UEs") - LazyVStack { - HStack { - UeView(blocs: BlocVm(withModel: BlocModel(Nombloc: "HST", Moyenneg: 14, listeUE: []))) - Divider() - } - .padding() - } - .padding() - .background(Color("ListItemBackgroundColor")) - .cornerRadius(12) - } - } - - } - - struct ListUe_Previews: PreviewProvider { - static var previews: some View { - ListUe() - } - }} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereCapsule.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereCapsule.swift new file mode 100644 index 0000000..434ed24 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereCapsule.swift @@ -0,0 +1,98 @@ +// +// CapsuleMatiere.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import SwiftUI +import UIKit + + + + struct ExpandingCapsuleViewMatiere : View{ + @ObservedObject var matiere : MatiereVM + @ObservedObject var ue : UeVM + @ObservedObject var bloc : BlocVM + var islock : Bool = true + @GestureState private var dragState = DragState.inactive + @State private var capsuleWidth: CGFloat = 25.0 + var widthMax = 100.0 + var widthMin = 5.0 + enum DragState { + case inactive + case dragging(translation: CGSize) + + var translation: CGSize { + switch self { + case .inactive: + return .zero + case .dragging(let translation): + return translation + } + } + } + + + + + public var body: some View { + let dragGesture = DragGesture() + + .onEnded { value in + let dragThreshold: CGFloat = 0.02 + let dragTranslation = value.translation.width + + if CGFloat(matiere.moyenne)*5 <= 100 { + if dragTranslation > dragThreshold { + capsuleWidth += (dragTranslation - dragThreshold) + updateMoy() + // print(capsuleWidth/5) + } else if dragTranslation < -dragThreshold { + + capsuleWidth = dragTranslation/5 - dragThreshold + updateMoy() + } + } + + } + + return GeometryReader { geometry in + Capsule() + .frame(width: Double(matiere.moyenne * 5) >= widthMax ? 100.0 : CGFloat(matiere.moyenne) * 5 + 2 , height: 22) + .foregroundColor(CGFloat(matiere.moyenne) * 5 < 50 ? .red : .green) + .gesture( islock ? DragGesture().onEnded({_ in }) : dragGesture) + .animation(.spring()) + .offset(x: dragState.translation.width, y: 0) + .onAppear { + // Set initial capsule width + capsuleWidth = min(geometry.size.width, geometry.size.height) + } + } + } + + + private func updateMoy(){ + self.matiere.moyenne += Float(capsuleWidth) / 5 + if matiere.moyenne > 20 { matiere.moyenne = 20 } + if matiere.moyenne < 0 { matiere.moyenne = 0 } + ue.totalMoyenne = ue.updateTotalMoyenne() + bloc.totalMoyenne = bloc.updateTotalMoyenne() + + + + print(bloc.nom) + } +} + + + + +struct CapsuleMatiere_Previews: PreviewProvider { + static var previews: some View { + + ExpandingCapsuleViewMatiere(matiere: MatiereVM(withMat: Matiere(name: "Projet", moy: 12, coef: 9)),ue: UeVM(withUe: DataStub().loadUeStage_Proj()[0]), + bloc: BlocVM(withBloc: Bloc(nom: "", ues: DataStub().loadUeStage_Proj(), isUq: true)) ) + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereEditView.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereEditView.swift index 79305f3..86549a4 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereEditView.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereEditView.swift @@ -2,53 +2,55 @@ // MatiereEditView.swift // SwiftMvvm // -// Created by etudiant on 10/06/2023. +// Created by etudiant on 23/06/2023. // +import Foundation import SwiftUI -struct MatiereEditView: View { - @Binding var matiere : Matiere + +struct MatiereEditView : View{ + @ObservedObject var matiere: MatiereVM + var body: some View { - VStack { - NavigationLink(destination: TextField("", text: $matiere.nom, prompt: Text("enter the name")) - .navigationBarTitleDisplayMode(.inline) - .navigationTitle("Name")) { - HStack { - Text("Nom") - Spacer() - Text(matiere.nom) - .foregroundColor(.gray) - } + HStack{ + if self.matiere.isEditing { + VStack { + TextField("Nom", text: $matiere.name) + TextField("Coefficient", value: $matiere.coef, format: .number) + Divider() } - - NavigationLink(destination: TextField("", value: $matiere.coefficient, format: .number, prompt: Text("enter the count")) - .navigationBarTitleDisplayMode(.inline) - .navigationTitle("Hair count")) { - HStack { - Text("coef") - Spacer() - Text(String(matiere.coefficient)) - .foregroundColor(.gray) - } + } else { + VStack { + Text(matiere.name) + Text(matiere.coef, format: .number) + Divider() } - - NavigationLink(destination: TextField("", value: $matiere.note, format: .number, prompt: Text("enter the note")) - .navigationBarTitleDisplayMode(.inline) - .navigationTitle("note")) { - HStack { - Text("Note") - Spacer() - Text(String(matiere.note)) - .foregroundColor(.gray) - } + } + Button(action: { + if self.matiere.isEditing { + print(self.matiere.coef) + + self.matiere.onEdited(isCancelled: true) + } else { + self.matiere.onEditing() + } + + }) { + Text( self.matiere.isEditing ? "Done" : "Modifier") + } + + + } + } } struct MatiereEditView_Previews: PreviewProvider { static var previews: some View { - MatiereEditView(matiere: .constant(Stub().loadUes()[0].listeMatiere[0])) + let matiere = MatiereVM(withMat: DataStub().loadMartiereUE1()[0]) + MatiereEditView(matiere: matiere) } } diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereUniq.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereUniq.swift deleted file mode 100644 index 1de3c46..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereUniq.swift +++ /dev/null @@ -1,73 +0,0 @@ -// MatiereUniq.swift -// SwiftMvvm -// -// Created by etudiant on 30/05/2023. -// - -import SwiftUI - -struct MatiereUniq: View { - //1 changement avec Vm - @ObservedObject var mat: MatiereVm - @State private var islocked = true - - var body: some View { - VStack(alignment: .leading) { - HStack { - Text(mat.nom) - .font(.title2) - - Spacer() - - Text("\(mat.coefficient)") - .font(.title2) - .padding(.horizontal, 30.0) - } - .padding(.horizontal, 11.0) - - HStack { - Button(action: { - islocked.toggle() - }) { - Image(systemName: islocked ? "lock" : "lock.open") - .resizable() - .frame(width: 20, height: 20) - } - - GeometryReader { geometry in - HStack { - Capsule() - .fill(mat.note < 10 ? .red : .blue) - .frame(height: 20) - .frame(width: CGFloat(mat.note) / 30 * geometry.size.width) - .gesture( - islocked ? DragGesture(minimumDistance: 0).onChanged({_ in }) - : DragGesture(minimumDistance: 23) - .onChanged({ value in - let newNote = value.location.x / geometry.size.width * 20 - mat.note = min(max(newNote, 0), 20) - }) - ) - - Text("\(Double(mat.note))") - - if !islocked { - Image("gouffle") - .resizable() - .frame(width: 20, height: 20) - } - } - } - - Divider() - } - } - } -} - -struct MatiereUniq_Previews: PreviewProvider { - static var previews: some View { - MatiereUniq(mat: MatiereVm(withModel: Matiere(id: UUID(), nom: "JAVA", coefficient: 6, note: 19))) - } -} - diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereUnq.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereUnq.swift new file mode 100644 index 0000000..ec2bea6 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereUnq.swift @@ -0,0 +1,59 @@ +// +// MatiereUi.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import SwiftUI + +struct MatiereUnq: View{ + @ObservedObject var matiere : MatiereVM + @ObservedObject var ue : UeVM + @ObservedObject var bloc : BlocVM + @State var islocked : Bool = true + var body: some View { + VStack(alignment:.leading){ + Divider() + HStack(spacing: 20){ + Text(matiere.name ).bold().font(.caption).padding() + } + + + HStack(spacing: 15){ + Button(action: { + if self.matiere.isEditing { + + self.matiere.onEdited(isCancelled: true) + print(self.matiere.moyenne) + + } else { + self.matiere.onEditing() + + } + }) { + + Image(systemName: !matiere.isEditing ? "lock.fill" : "lock.open.fill") + } + ExpandingCapsuleViewMatiere(matiere: matiere, ue : ue, bloc : bloc ,islock: !matiere.isEditing).frame(width:50,height: 20) + + Spacer() + Text(matiere.moyenne.description) + + Spacer() + Text(matiere.coef.description) + + } + + }.padding() + } +} + +struct MatiereUnq_Previews: PreviewProvider { + static var previews: some View { + MatiereUnq(matiere: MatiereVM(withMat: Matiere(name : "Projet",moy: 12, coef: 9)), ue: UeVM(withUe: DataStub().loadUeStage_Proj()[0]), + bloc: BlocVM(withBloc: Bloc(nom: "", ues: DataStub().loadUeStage_Proj(), isUq: true)), + islocked: true) + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereView.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereView.swift deleted file mode 100644 index 574f7ac..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/MatiereView.swift +++ /dev/null @@ -1,60 +0,0 @@ -import SwiftUI - - -struct MatiereView: View { - @ObservedObject var ue : UeVm - @State var isEditing: Bool = false - var body: some View { - NavigationStack { - ScrollView { - VStack(alignment: .leading) { - - Label("Coefficient :\(ue.coefficient)", systemImage: "xmark.circle.fill") - Label("Détails des notes: ", systemImage: "note.text") - } - VStack { - ForEach(ue.someMatVM) { matiere in - MatiereUniq(mat: matiere) - } - } - .toolbar{ - Button(action: { - self.isEditing.toggle() - }){ - Text("Edit") - } - } - - .sheet(isPresented: $isEditing){ - NavigationStack{ - EditableView(editableUe: ue) - .toolbar{ - ToolbarItem(id: "done", placement: .confirmationAction){ - Button(action: { - self.isEditing.toggle() - }){ - Text("Done") - } - } - ToolbarItem(id: "cancel", placement: .cancellationAction){ - Button(action: { - self.isEditing.toggle() - }){ - Text("Cancel") - } - } - } - .navigationTitle("Edit: \(ue.nom)") - } - } - } - } - } -} - -struct MatiereView_Previews: PreviewProvider { - static var previews: some View { - MatiereView(ue: UeVm(withModel: UE(id: UUID(), coefficient: 2, moyenne: 16, nom: "MAT", listeMatiere: []))) - } -} - diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/Note.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/Note.swift deleted file mode 100644 index a838463..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/Note.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// Note.swift -// SwiftMvvm -// -// Created by etudiant on 08/06/2023. -// - -// -// NoteInfo.swift -// App -// -// Created by BREUIL Yohann on 26/05/2023. -// - -/*import SwiftUI - -struct NoteInfo: View { - var body: some View { - VStack { - - MatiereView(ue: <#UeVm#> ) - Divider() - } - } -} - -struct NoteInfo_Previews: PreviewProvider { - static var previews: some View { - NoteInfo() - } -}*/ diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/UeCapsule.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/UeCapsule.swift new file mode 100644 index 0000000..5f19e3c --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/UeCapsule.swift @@ -0,0 +1,91 @@ +// +// CapsuleUe.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation + + +import SwiftUI +import UIKit + + struct ExpandingCapsuleView : View{ + @ObservedObject var ue : UeVM + @GestureState private var dragState = DragState.inactive + @State private var capsuleWidth: CGFloat = 5.0 + private var widthMax = 100.0 + private var widthMin = 5.0 + private enum DragState { + case inactive + case dragging(translation: CGSize) + + var translation: CGSize { + switch self { + case .inactive: + return .zero + case .dragging(let translation): + return translation + } + } + } + + + init(ue: UeVM) { + self.ue = ue + + } + + var body: some View { + let dragGesture = DragGesture() + + .onEnded { value in + let dragThreshold: CGFloat = 1.005 + let dragTranslation = value.translation.width + + if dragTranslation > dragThreshold { + + + capsuleWidth += dragTranslation - dragThreshold + updateMoy() + + } else if dragTranslation < -dragThreshold { + + capsuleWidth -= abs(dragTranslation) - dragThreshold + updateMoy() + } + } + + return GeometryReader { geometry in + Capsule() + .frame(width: capsuleWidth >= widthMax ? 100.0 : capsuleWidth , height: 30) + .foregroundColor(.blue) + .gesture(dragGesture) + .animation(.spring()) + .offset(x: dragState.translation.width, y: 0) + .onAppear { + // Set initial capsule width + capsuleWidth = min(geometry.size.width, geometry.size.height) + } + } + } + + + private func updateMoy(){ + var da = ue.model.totalMoyenne * capsuleWidth / 100 + ue.model.coef = ue.model.coef + 1 + print(da) + } +} + + + + +struct CapsuleV_Previews: PreviewProvider { + static var previews: some View { + + + ExpandingCapsuleView(ue : UeVM(withUe: Ue( nom: "UE 2", matieres: DataStub().loadMartiereUE2(),coef: 9))) + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/UeView.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/UeView.swift index 42788c4..d48a7e7 100644 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/UeView.swift +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/UeView.swift @@ -1,45 +1,45 @@ import SwiftUI -struct UeView: View { - - @ObservedObject var blocs : BlocVm - - var body: some View { - VStack { - ForEach(blocs.someUeVM) { ue in - HStack { - Text(ue.nom) - .font(.subheadline) - .foregroundColor(.primary) - Spacer() - Text("\(ue.coefficient)") - NavigationLink(destination: MatiereView(ue: UeVm(withModel: UE(id: UUID(), coefficient: 4, moyenne: 3, nom: "HST", listeMatiere: [])) )) { - Image(systemName: "square.and.pencil") - } - .foregroundColor(.blue) - } - .padding(.bottom, 10) - HStack { - Capsule() - .fill(ue.moyenne < 10 ? .red : .blue) - .frame(height: 20) - .frame(width: CGFloat(ue.moyenne) * 10) - .background(Color.clear) - Text("\(ue.moyenne)") + +public struct UeView : View{ + @ObservedObject var bloc : BlocVM + @ObservedObject var ue : UeVM + public var body: some View { + + VStack(alignment:.leading){ + + Divider() + HStack(spacing: 20){ + Text(ue.nom ).bold().font(.caption).padding() + Spacer() + Text(ue.coef.description) + } + + + HStack(){ + Capsule().foregroundColor( ue.totalMoyenne * 5 < 50 ? .red : .green).frame(width: ue.totalMoyenne * 5 ,height: 22) + Spacer() + Text(ue.totalMoyenne.description) + Spacer() + NavigationLink(destination: Uee(ue: ue, bloc: bloc)) { + Image(systemName: "square.and.pencil") } - .padding() - - Divider() } - } - .padding() + Divider() + + + }.padding() } } struct UeView_Previews: PreviewProvider { static var previews: some View { - UeView(blocs: BlocVm(withModel: BlocModel(Nombloc: "ANG", Moyenneg: 12, listeUE: []))) - } + + let ue = DataStub().load()[0] + let ueVM = UeVM(withUe: ue) + + UeView(bloc: BlocVM(withBloc: Bloc(nom: "Projet/Stage", ues: DataStub().loadUeStage_Proj(),isUq: true)), ue: ueVM) + } + } - diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/Uee.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/Uee.swift new file mode 100644 index 0000000..41d1b86 --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/Uee.swift @@ -0,0 +1,50 @@ +// +// UePage.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import SwiftUI +struct Uee: View { + @ObservedObject var ue: UeVM + @ObservedObject var bloc: BlocVM + + + var body: some View { + NavigationView { + VStack { + HStack(spacing: 20) { + Text(ue.nom) + .bold() + .font(.title) + } + Divider() + HStack(spacing: 15) { + Capsule() + .foregroundColor(ue.totalMoyenne * 5 < 50 ? .red : .green) + .frame(width: ue.totalMoyenne * 5, height: 22) + Text(ue.coef.description) + Text(ue.totalMoyenne.description) + } + + ScrollView { + ForEach(ue.someMatieresVM) { mat in + MatiereUnq(matiere: mat, ue : ue, bloc : bloc, islocked: true) + } + } + } + + } + .navigationBarItems(trailing: Button(action: { + + self.ue.onEditing() + }) { + Text( self.ue.isEditing ? "Done" : "Modifier") + }) + .sheet(isPresented: $ue.isEditing) { + EditSheet(ue: ue, isEditMode: $ue.isAdding) + } + } +} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/VuePrincipale.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/VuePrincipale.swift deleted file mode 100644 index e4bd529..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/VuePrincipale.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// VuePrincipale.swift -// SwiftMvvm -// -// Created by etudiant on 25/05/2023. -// - -import SwiftUI - -struct VuePrincipale: View { - var body: some View { - NavigationStack { - ScrollView { - BlocView() - Divider() - ListUe() - } - .navigationTitle("Calculette") - } - } -} - -struct VuePrincipale_Previews: PreviewProvider { - static var previews: some View { - VuePrincipale() - } -} diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/edit.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/edit.swift new file mode 100644 index 0000000..eb0aedf --- /dev/null +++ b/Sources/SwiftMvvm/SwiftMvvm/Vue/edit.swift @@ -0,0 +1,31 @@ +// +// edit.swift +// SwiftMvvm +// +// Created by etudiant on 23/06/2023. +// + +import Foundation +import SwiftUI + +struct edit: View { + @Binding public var ue : Ue + + var body: some View { + NavigationView{ + VStack{ + Text(ue.nom) + TextField("name", text:$ue.nom ) + } + }.toolbar{ + Button(action: { + + }) { + + Image(systemName: "square.and.pencil") + } + } + } +} + + diff --git a/Sources/SwiftMvvm/SwiftMvvm/Vue/stbmat.swift b/Sources/SwiftMvvm/SwiftMvvm/Vue/stbmat.swift deleted file mode 100644 index ce69614..0000000 --- a/Sources/SwiftMvvm/SwiftMvvm/Vue/stbmat.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// stbmat.swift -// SwiftMvvm -// -// Created by etudiant on 30/05/2023. -// - -/*import SwiftUI - -/*struct stbmat: View { - let matieres: [Matiere] = [ - Matiere(id: UUID(), nom: "Mathématiques", coefficient: 2.0, note: 15.0), - Matiere(id: UUID(), nom: "Physique", coefficient: 1.5, note: 12.0), - Matiere(id: UUID(), nom: "Chimie", coefficient: 1.0, note: 10.5) - ] - - var body: some View { - VStack { - ForEach(matieres) { matiere in - MatiereUniq(mat: matiere) - } - } - } - }*/*/