parent
acbdbdd13c
commit
ff1349aa13
@ -0,0 +1,29 @@
|
||||
import SwiftUI
|
||||
|
||||
struct UEEditSheet: View {
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
VStack {
|
||||
Text("SALUT")
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(action: {}) {
|
||||
Text("Cancel")
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button(action: {}) {
|
||||
Text("Save")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct UEEditSheet_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
UEEditSheet()
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,18 +1,22 @@
|
||||
import Foundation
|
||||
|
||||
public struct Bloc: Identifiable {
|
||||
public struct Bloc: Identifiable, Equatable {
|
||||
public let id: UUID
|
||||
|
||||
public var name: String
|
||||
public var ues: [UE]
|
||||
|
||||
init(id: UUID, name: String, ues: [UE]) {
|
||||
public init(id: UUID, name: String, ues: [UE]) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.ues = ues
|
||||
}
|
||||
|
||||
init(name: String, ues: [UE]) {
|
||||
public init(name: String, ues: [UE]) {
|
||||
self.init(id: UUID(), name: name, ues: ues)
|
||||
}
|
||||
|
||||
public static func == (lhs: Bloc, rhs: Bloc) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
import Foundation
|
||||
|
||||
struct Manager {
|
||||
|
||||
}
|
@ -1,20 +1,30 @@
|
||||
import Foundation
|
||||
|
||||
public struct Matiere : Identifiable {
|
||||
public struct Matiere : Identifiable, Equatable {
|
||||
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) {
|
||||
public var realNote: Float {
|
||||
get {
|
||||
return note * Float(factor)
|
||||
}
|
||||
}
|
||||
|
||||
public 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) {
|
||||
public init(name: String, factor: Int, note: Float) {
|
||||
self.init(id: UUID(), name: name, factor: factor, note: note)
|
||||
}
|
||||
|
||||
public static func == (lhs: Matiere, rhs: Matiere) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
import XCTest
|
||||
@testable import Model
|
||||
|
||||
final class ModelTests: XCTestCase {
|
||||
func testExample() throws {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct
|
||||
// results.
|
||||
XCTAssertEqual(Model().text, "Hello, World!")
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/config/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
@ -0,0 +1,29 @@
|
||||
// swift-tools-version: 5.8
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Stub",
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "Stub",
|
||||
targets: ["Stub"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
.package(name: "Model", path: "../Model")
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "Stub",
|
||||
dependencies: ["Model"]),
|
||||
.testTarget(
|
||||
name: "StubTests",
|
||||
dependencies: ["Stub"]),
|
||||
]
|
||||
)
|
@ -0,0 +1,3 @@
|
||||
# Stub
|
||||
|
||||
A description of this package.
|
@ -0,0 +1,9 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/config/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
@ -0,0 +1,29 @@
|
||||
// swift-tools-version: 5.8
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "ViewModel",
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "ViewModel",
|
||||
targets: ["ViewModel"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
.package(name: "Model", path: "../Model")
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "ViewModel",
|
||||
dependencies: ["Model"]),
|
||||
.testTarget(
|
||||
name: "ViewModelTests",
|
||||
dependencies: ["ViewModel"]),
|
||||
]
|
||||
)
|
@ -0,0 +1,3 @@
|
||||
# ViewModel
|
||||
|
||||
A description of this package.
|
@ -0,0 +1,42 @@
|
||||
import Foundation
|
||||
import Model
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
public class BlocVM : ObservableObject, Identifiable {
|
||||
public init(model: Bloc) {
|
||||
self.model = model
|
||||
}
|
||||
|
||||
public var id: UUID { model.id }
|
||||
|
||||
@Published
|
||||
var model: Bloc = Bloc(id: UUID(), name: "", ues: []) {
|
||||
didSet {
|
||||
if self.name != model.name {
|
||||
self.name = self.model.name
|
||||
}
|
||||
|
||||
if self.ues != model.ues {
|
||||
self.ues = self.model.ues
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var name: String = "" {
|
||||
didSet {
|
||||
if self.name != self.model.name {
|
||||
self.name = self.model.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var ues: [UE] = [] {
|
||||
didSet {
|
||||
if self.ues != self.model.ues {
|
||||
self.ues = self.model.ues
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
import Foundation
|
||||
import Model
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
class MatiereVM : ObservableObject, Identifiable {
|
||||
public init(model: Matiere) {
|
||||
self.model = model
|
||||
}
|
||||
|
||||
public var id: UUID { model.id }
|
||||
|
||||
@Published
|
||||
var model: Matiere = Matiere(id: UUID(), name: "", factor: 0, note: 0) {
|
||||
didSet {
|
||||
if self.name != model.name {
|
||||
self.name = self.model.name
|
||||
}
|
||||
|
||||
if self.factor != model.factor {
|
||||
self.factor = self.model.factor
|
||||
}
|
||||
|
||||
if self.note != model.note {
|
||||
self.note = self.model.note
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var name: String = "" {
|
||||
didSet {
|
||||
if model.name != self.model.name {
|
||||
self.name = self.model.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var factor: Int = 0 {
|
||||
didSet {
|
||||
if model.factor != self.model.factor {
|
||||
self.factor = self.model.factor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var note: Float = 0 {
|
||||
didSet {
|
||||
if model.note != self.model.note {
|
||||
self.note = self.model.note
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
import Foundation
|
||||
import Model
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
public class UEVM : ObservableObject, Identifiable {
|
||||
public init(model: UE) {
|
||||
self.model = model
|
||||
}
|
||||
|
||||
public var id: UUID { model.id }
|
||||
|
||||
@Published
|
||||
var model: UE = UE(id: UUID(), number: 0, name: "", factor: 0, matieres: []) {
|
||||
didSet {
|
||||
if self.number != self.model.number {
|
||||
self.number = self.model.number
|
||||
}
|
||||
|
||||
if self.name != self.model.name {
|
||||
self.name = self.model.name
|
||||
}
|
||||
|
||||
if self.factor != self.model.factor {
|
||||
self.factor = self.model.factor
|
||||
}
|
||||
|
||||
if self.matieres != self.model.matieres {
|
||||
self.matieres = self.model.matieres
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var number: Int32 = 0 {
|
||||
didSet {
|
||||
if model.number != self.model.number {
|
||||
self.number = self.model.number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var name: String = "" {
|
||||
didSet {
|
||||
if model.name != self.model.name {
|
||||
self.name = self.model.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var factor: Int32 = 0 {
|
||||
didSet {
|
||||
if model.factor != self.model.factor {
|
||||
self.factor = self.model.factor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Published
|
||||
var matieres: [Matiere] = [] {
|
||||
didSet {
|
||||
if model.matieres != self.model.matieres {
|
||||
self.matieres = self.model.matieres
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue