diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/App/App.xcodeproj/project.pbxproj b/src/App/App.xcodeproj/project.pbxproj index dc9f86f..ba62493 100644 --- a/src/App/App.xcodeproj/project.pbxproj +++ b/src/App/App.xcodeproj/project.pbxproj @@ -18,9 +18,9 @@ 1E0D89132A1E7C4500786FE3 /* CalculatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0D89122A1E7C4500786FE3 /* CalculatorView.swift */; }; 1E0D89152A1E7F5800786FE3 /* BlocListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0D89142A1E7F5800786FE3 /* BlocListItem.swift */; }; 1E0D89172A1E838700786FE3 /* UEListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0D89162A1E838700786FE3 /* UEListItem.swift */; }; - 1E0D89192A1E84AE00786FE3 /* UEItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0D89182A1E84AE00786FE3 /* UEItem.swift */; }; 1E0D891B2A1E9BEF00786FE3 /* UEView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0D891A2A1E9BEF00786FE3 /* UEView.swift */; }; - 1E0D891D2A1EBBBF00786FE3 /* MatiereItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0D891C2A1EBBBF00786FE3 /* MatiereItem.swift */; }; + 1E160AB22A1FA51600ECDB3F /* NoteSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E160AB12A1FA51600ECDB3F /* NoteSlider.swift */; }; + 1EDC99232A20DDAB00C3561D /* NoteInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDC99222A20DDAB00C3561D /* NoteInfo.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -54,9 +54,9 @@ 1E0D89122A1E7C4500786FE3 /* CalculatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalculatorView.swift; sourceTree = ""; }; 1E0D89142A1E7F5800786FE3 /* BlocListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocListItem.swift; sourceTree = ""; }; 1E0D89162A1E838700786FE3 /* UEListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UEListItem.swift; sourceTree = ""; }; - 1E0D89182A1E84AE00786FE3 /* UEItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UEItem.swift; sourceTree = ""; }; 1E0D891A2A1E9BEF00786FE3 /* UEView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UEView.swift; sourceTree = ""; }; - 1E0D891C2A1EBBBF00786FE3 /* MatiereItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatiereItem.swift; sourceTree = ""; }; + 1E160AB12A1FA51600ECDB3F /* NoteSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteSlider.swift; sourceTree = ""; }; + 1EDC99222A20DDAB00C3561D /* NoteInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteInfo.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -156,9 +156,9 @@ 1E0D89122A1E7C4500786FE3 /* CalculatorView.swift */, 1E0D89142A1E7F5800786FE3 /* BlocListItem.swift */, 1E0D89162A1E838700786FE3 /* UEListItem.swift */, - 1E0D89182A1E84AE00786FE3 /* UEItem.swift */, 1E0D891A2A1E9BEF00786FE3 /* UEView.swift */, - 1E0D891C2A1EBBBF00786FE3 /* MatiereItem.swift */, + 1E160AB12A1FA51600ECDB3F /* NoteSlider.swift */, + 1EDC99222A20DDAB00C3561D /* NoteInfo.swift */, ); path = Views; sourceTree = ""; @@ -296,12 +296,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 1E160AB22A1FA51600ECDB3F /* NoteSlider.swift in Sources */, 1E0D89152A1E7F5800786FE3 /* BlocListItem.swift in Sources */, 1E0D88E52A1E759A00786FE3 /* ContentView.swift in Sources */, - 1E0D891D2A1EBBBF00786FE3 /* MatiereItem.swift in Sources */, 1E0D89132A1E7C4500786FE3 /* CalculatorView.swift in Sources */, 1E0D88E32A1E759A00786FE3 /* AppApp.swift in Sources */, - 1E0D89192A1E84AE00786FE3 /* UEItem.swift in Sources */, + 1EDC99232A20DDAB00C3561D /* NoteInfo.swift in Sources */, 1E0D891B2A1E9BEF00786FE3 /* UEView.swift in Sources */, 1E0D89172A1E838700786FE3 /* UEListItem.swift in Sources */, ); diff --git a/src/App/App/Assets.xcassets/BadColor.colorset/Contents.json b/src/App/App/Assets.xcassets/BadColor.colorset/Contents.json new file mode 100644 index 0000000..b389538 --- /dev/null +++ b/src/App/App/Assets.xcassets/BadColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x30", + "green" : "0x3B", + "red" : "0xFF" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/src/App/App/Assets.xcassets/GoodColor.colorset/Contents.json b/src/App/App/Assets.xcassets/GoodColor.colorset/Contents.json new file mode 100644 index 0000000..4395dbb --- /dev/null +++ b/src/App/App/Assets.xcassets/GoodColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x59", + "green" : "0xC7", + "red" : "0x34" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/src/App/Views/BlocListItem.swift b/src/App/Views/BlocListItem.swift index 4e3c559..c57f9f5 100644 --- a/src/App/Views/BlocListItem.swift +++ b/src/App/Views/BlocListItem.swift @@ -1,10 +1,3 @@ -// -// BlocListItem.swift -// App -// -// Created by BREUIL Yohann on 24/05/2023. -// - import SwiftUI struct BlocListItem: View { @@ -16,12 +9,14 @@ struct BlocListItem: View { HStack { Label("Total", systemImage: "doc.on.doc.fill") Spacer() - Label("11.67", systemImage: "graduationcap.circle.fill") + Text("11.67") + Image(systemName: "graduationcap.circle.fill") } HStack { Label("Total", systemImage: "doc.on.doc.fill") Spacer() - Label("11.67", systemImage: "graduationcap.circle.fill") + Text("11.67") + Image(systemName: "graduationcap.circle.fill") } } .padding() diff --git a/src/App/Views/CalculatorView.swift b/src/App/Views/CalculatorView.swift index a2b4f02..39c9efb 100644 --- a/src/App/Views/CalculatorView.swift +++ b/src/App/Views/CalculatorView.swift @@ -1,12 +1,4 @@ -// -// CalculatorView.swift -// App -// -// Created by BREUIL Yohann on 24/05/2023. -// - import SwiftUI -import Model struct CalculatorView: View { var body: some View { diff --git a/src/App/Views/MatiereItem.swift b/src/App/Views/MatiereItem.swift deleted file mode 100644 index be8aac1..0000000 --- a/src/App/Views/MatiereItem.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// MatiereItem.swift -// App -// -// Created by BREUIL Yohann on 24/05/2023. -// - -import SwiftUI - -struct MatiereItem: View { - @State private var note = 12.5 - - var body: some View { - VStack { - HStack() { - Text("Qualité de Développement") - Spacer() - Text("6") - } - HStack { - Slider( - value: $note, - in: 0...20, - step: 0.1 - ) - Text("\(note)") - } - Divider() - } - } -} - -struct MatiereItem_Previews: PreviewProvider { - static var previews: some View { - MatiereItem() - } -} diff --git a/src/App/Views/NoteInfo.swift b/src/App/Views/NoteInfo.swift new file mode 100644 index 0000000..a7acdf4 --- /dev/null +++ b/src/App/Views/NoteInfo.swift @@ -0,0 +1,28 @@ +// +// NoteInfo.swift +// App +// +// Created by BREUIL Yohann on 26/05/2023. +// + +import SwiftUI + +struct NoteInfo: View { + var body: some View { + VStack { + HStack() { + Text("Qualité de Développement") + Spacer() + Text("6") + } + NoteSlider() + Divider() + } + } +} + +struct NoteInfo_Previews: PreviewProvider { + static var previews: some View { + NoteInfo() + } +} diff --git a/src/App/Views/NoteSlider.swift b/src/App/Views/NoteSlider.swift new file mode 100644 index 0000000..e6399d8 --- /dev/null +++ b/src/App/Views/NoteSlider.swift @@ -0,0 +1,54 @@ +// +// NoteSliderComponent.swift +// App +// +// Created by BREUIL Yohann on 25/05/2023. +// + +import SwiftUI + +struct NoteSlider: View { + @State private var sliderProgress: CGFloat = 0 + @State private var sliderWidth: CGFloat = 20 + @State private var sliderMaxWidth: CGFloat = 200 + @State private var sliderCurrentWidth: CGFloat = 0 + + var drag: some Gesture { + DragGesture() + .onChanged { value in + let translation = value.translation.width + sliderWidth = translation + sliderCurrentWidth + + sliderWidth = sliderWidth > sliderMaxWidth ? sliderMaxWidth : sliderWidth + sliderWidth = sliderWidth >= 0 ? sliderWidth : 20 + + let progress = sliderWidth / sliderMaxWidth + sliderProgress = progress <= 1.0 ? progress : 1 + } + .onEnded { value in + sliderWidth = sliderWidth > sliderMaxWidth ? sliderMaxWidth : sliderWidth + sliderWidth = sliderWidth >= 0 ? sliderWidth : 20 + + sliderCurrentWidth = sliderWidth + } + } + + var body: some View { + HStack { + Rectangle() + .fill(sliderProgress < 0.5 ? Color("BadColor") : Color("GoodColor")) + .frame(width: sliderWidth, height: 25) + .clipShape(Capsule()) + .gesture(drag) + Spacer() + Text("\(sliderProgress)") + } + .padding() + } +} + +struct NoteSliderComponent_Previews: PreviewProvider { + static var previews: some View { + NoteSlider() + } +} diff --git a/src/App/Views/UEItem.swift b/src/App/Views/UEItem.swift deleted file mode 100644 index 4db5f0e..0000000 --- a/src/App/Views/UEItem.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// UEItem.swift -// App -// -// Created by BREUIL Yohann on 24/05/2023. -// - -import SwiftUI - -struct UEItem: View { - @State private var note = 12.5 - - var body: some View { - VStack { - HStack() { - Text("UE1 Génie Logiciel") - Spacer() - Text("6") - } - HStack { - Slider( - value: $note, - in: 0...20, - step: 0.1 - ) - Text("\(note)") - } - Divider() - } - } -} - -struct UEItem_Previews: PreviewProvider { - static var previews: some View { - UEItem() - } -} diff --git a/src/App/Views/UEListItem.swift b/src/App/Views/UEListItem.swift index ccbd87d..684574e 100644 --- a/src/App/Views/UEListItem.swift +++ b/src/App/Views/UEListItem.swift @@ -16,7 +16,7 @@ struct UEListItem: View { Text("Détails des UEs") LazyVStack { HStack { - UEItem() + NoteInfo() NavigationLink(destination: UEView()) { Image(systemName: "square.and.pencil") } @@ -24,7 +24,7 @@ struct UEListItem: View { } .padding() HStack { - UEItem() + NoteInfo() NavigationLink(destination: UEView()) { Image(systemName: "square.and.pencil") } @@ -32,7 +32,7 @@ struct UEListItem: View { } .padding() HStack { - UEItem() + NoteInfo() NavigationLink(destination: UEView()) { Image(systemName: "square.and.pencil") } @@ -40,7 +40,7 @@ struct UEListItem: View { } .padding() HStack { - UEItem() + NoteInfo() NavigationLink(destination: UEView()) { Image(systemName: "square.and.pencil") } @@ -48,7 +48,7 @@ struct UEListItem: View { } .padding() HStack { - UEItem() + NoteInfo() NavigationLink(destination: UEView()) { Image(systemName: "square.and.pencil") } diff --git a/src/App/Views/UEView.swift b/src/App/Views/UEView.swift index 8ae4b7f..231cc7d 100644 --- a/src/App/Views/UEView.swift +++ b/src/App/Views/UEView.swift @@ -11,7 +11,7 @@ struct UEView: View { var body: some View { NavigationStack { ScrollView { - UEItem() + NoteInfo() VStack(alignment: .leading) { Label("Coefficcient : 6", systemImage: "xmark.circle.fill") Label("Détails des notes ", systemImage: "note.text") @@ -21,29 +21,30 @@ struct UEView: View { Button(action: {}) { Image(systemName: "lock") } - MatiereItem() + NoteInfo() } HStack { Button(action: {}) { Image(systemName: "lock") } - MatiereItem() + NoteInfo() } HStack { Button(action: {}) { Image(systemName: "lock") } - MatiereItem() + NoteInfo() } HStack { Button(action: {}) { Image(systemName: "lock") } - MatiereItem() + NoteInfo() } } } + .padding() .navigationTitle("UE1 Génie logiciel") .toolbar { Button(action: {}) { @@ -51,7 +52,6 @@ struct UEView: View { } } } - } } diff --git a/src/AverageCalculator.xcworkspace/xcuserdata/djyohann.xcuserdatad/UserInterfaceState.xcuserstate b/src/AverageCalculator.xcworkspace/xcuserdata/djyohann.xcuserdatad/UserInterfaceState.xcuserstate index e4a45d8..d274cf7 100644 Binary files a/src/AverageCalculator.xcworkspace/xcuserdata/djyohann.xcuserdatad/UserInterfaceState.xcuserstate and b/src/AverageCalculator.xcworkspace/xcuserdata/djyohann.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/src/Model/Sources/Model/Bloc.swift b/src/Model/Sources/Model/Bloc.swift new file mode 100644 index 0000000..7899e39 --- /dev/null +++ b/src/Model/Sources/Model/Bloc.swift @@ -0,0 +1,18 @@ +import Foundation + +public struct Bloc: Identifiable { + public let id: UUID + + public var name: String + public var ues: [UE] + + init(id: UUID, name: String, ues: [UE]) { + self.id = id + self.name = name + self.ues = ues + } + + init(name: String, ues: [UE]) { + self.init(id: UUID(), name: name, ues: ues) + } +} diff --git a/src/Model/Sources/Model/Matiere.swift b/src/Model/Sources/Model/Matiere.swift new file mode 100644 index 0000000..95d7a30 --- /dev/null +++ b/src/Model/Sources/Model/Matiere.swift @@ -0,0 +1,20 @@ +import Foundation + +public struct Matiere : Identifiable { + public let id: UUID + + public var name: String + public var factor: Int + public var note: Float + + init(id: UUID, name: String, factor: Int, note: Float) { + self.id = id + self.name = name + self.factor = factor + self.note = note + } + + init(name: String, factor: Int, note: Float) { + self.init(id: UUID(), name: name, factor: factor, note: note) + } +} diff --git a/src/Model/Sources/Model/Model.swift b/src/Model/Sources/Model/Model.swift deleted file mode 100644 index c88e2a8..0000000 --- a/src/Model/Sources/Model/Model.swift +++ /dev/null @@ -1,6 +0,0 @@ -public struct Model { - public private(set) var text = "Hello, World!" - - public init() { - } -} diff --git a/src/Model/Sources/Model/Stub.swift b/src/Model/Sources/Model/Stub.swift new file mode 100644 index 0000000..72db421 --- /dev/null +++ b/src/Model/Sources/Model/Stub.swift @@ -0,0 +1,48 @@ +import Foundation + +public struct Stub { + func loadBlocs() -> [Bloc] {[ + Bloc(name: "Total", ues: [ + UE(number: 1, name: "Génie logiciel", factor: 6, matieres: [ + Matiere(name: "Processus de développement", factor: 4, note: 19.04), + Matiere(name: "Programmation objets", factor: 9, note: 9.08), + Matiere(name: "Qualité de développement", factor: 5, note: 13), + Matiere(name: "Remise à niveau Objets", factor: 4, note: 12), + ]), + UE(number: 2, name: "Systèmes et réseaux", factor: 6, matieres: [ + Matiere(name: "Internet des Objets", factor: 4, note: 10), + Matiere(name: "Réseaux", factor: 4, note: 10), + Matiere(name: "Services Mobiles", factor: 4, note: 10), + Matiere(name: "Système", factor: 5, note: 10) + ]), + UE(number: 3, name: "Insertion Professionnellle", factor: 6, matieres: [ + Matiere(name: "Anglais", factor: 5, note: 10), + Matiere(name: "Économie", factor: 4, note: 10), + Matiere(name: "Gestion", factor: 3, note: 10), + Matiere(name: "Communication", factor: 4, note: 10) + ]), + UE(number: 4, name: "Technologies Mobiles 1", factor: 9, matieres: [ + Matiere(name: "Android", factor: 6, note: 10), + Matiere(name: "Architecture de projets .NET (1)", factor: 5, note: 10), + Matiere(name: "C++", factor: 4, note: 10), + Matiere(name: "Swift", factor: 5, note: 10) + ]), + UE(number: 5, name: "Technologies Mobiles 2", factor: 9, matieres: [ + Matiere(name: "Architecture de projets .NET (2)", factor: 4, note: 10), + Matiere(name: "Client / Serveur", factor: 4, note: 10), + Matiere(name: "iOS", factor: 5, note: 10), + Matiere(name: "Multiplateformes", factor: 3, note: 10), + Matiere(name: "QT Quick", factor: 5, note: 10), + Matiere(name: "Xamarin", factor: 5, note: 10) + ]), + ]), + Bloc(name: "Projet / Stage", ues: [ + UE(number: 6, name: "Projet", factor: 9, matieres: [ + Matiere(name: "Projet", factor: 1, note: 10) + ]), + UE(number: 7, name: "Stage", factor: 15, matieres: [ + Matiere(name: "Stage", factor: 1, note: 10) + ]) + ]) + ]} +} diff --git a/src/Model/Sources/Model/UE.swift b/src/Model/Sources/Model/UE.swift new file mode 100644 index 0000000..550627f --- /dev/null +++ b/src/Model/Sources/Model/UE.swift @@ -0,0 +1,22 @@ +import Foundation + +public struct UE: Identifiable { + public let id: UUID + + public var number: Int + public var name: String + public var factor: Int + public var matieres: [Matiere] + + init(id: UUID, number: Int, name: String, factor: Int, matieres: [Matiere]) { + self.id = id + self.number = number + self.name = name + self.factor = factor + self.matieres = matieres + } + + init(number: Int, name: String, factor: Int, matieres: [Matiere]) { + self.init(id: UUID(), number: number, name: name, factor: factor, matieres: matieres) + } +}