parent
816d83c4a1
commit
c381fdf0e7
@ -0,0 +1,26 @@
|
||||
//
|
||||
// DetailsViewModel.swift
|
||||
// AllIn
|
||||
//
|
||||
// Created by Emre on 16/01/2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import ViewModel
|
||||
import DependencyInjection
|
||||
|
||||
class DetailsViewModel: ObservableObject {
|
||||
|
||||
@Inject var manager: ManagerVM
|
||||
var id: String
|
||||
|
||||
init(id: String) {
|
||||
self.id = id
|
||||
getItem()
|
||||
}
|
||||
|
||||
func getItem() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
//
|
||||
// HistoricBetViewModel.swift
|
||||
// AllIn
|
||||
//
|
||||
// Created by Emre on 16/01/2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import ViewModel
|
||||
import DependencyInjection
|
||||
|
||||
class HistoricBetViewModel: ObservableObject {
|
||||
|
||||
@Inject var manager: ManagerVM
|
||||
|
||||
init() {
|
||||
getItems()
|
||||
}
|
||||
|
||||
func getItems() {
|
||||
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
// 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: "StubLib",
|
||||
platforms: [
|
||||
.iOS(.v13)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "StubLib",
|
||||
targets: ["StubLib"]),
|
||||
],
|
||||
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: "StubLib",
|
||||
dependencies: ["Model"]),
|
||||
]
|
||||
)
|
@ -1,3 +0,0 @@
|
||||
# StubLib
|
||||
|
||||
A description of this package.
|
@ -1,26 +0,0 @@
|
||||
//
|
||||
// BetStubManager.swift
|
||||
//
|
||||
//
|
||||
// Created by Emre on 31/12/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Model
|
||||
|
||||
public struct BetStubManager: BetDataManager {
|
||||
|
||||
public init() {}
|
||||
|
||||
public func getBets(withIndex index: Int, withCount count: Int, completion: @escaping ([Bet]) -> Void) {
|
||||
completion(Stub.shared.bets)
|
||||
}
|
||||
|
||||
public func getUsers(username: String) -> [User] {
|
||||
return Stub.shared.users
|
||||
.filter { user in
|
||||
user.username.contains(username)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
//
|
||||
// Stub.swift
|
||||
//
|
||||
//
|
||||
// Created by Emre on 01/01/2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Model
|
||||
|
||||
struct Stub {
|
||||
|
||||
static var shared = Stub()
|
||||
public var bets: [Bet] = []
|
||||
public var users: [User] = []
|
||||
|
||||
public init() {
|
||||
loadBets()
|
||||
}
|
||||
|
||||
public mutating func loadBets() {
|
||||
|
||||
var user1 = User(username: "Lucas", email: "lucas.delanier@etu.uca.fr", nbCoins: 100, friends: [])
|
||||
users.append(user1)
|
||||
|
||||
var user2 = User(username: "Imri", email: "emre.kartal@etu.uca.fr", nbCoins: 75, friends: [user1])
|
||||
users.append(user2)
|
||||
user1.addFriend(user: user2)
|
||||
|
||||
let user3 = User(username: "Arthur", email: "arthur.valin@etu.uca.fr", nbCoins: 30, friends: [user2])
|
||||
users.append(user3)
|
||||
user2.addFriend(user: user3)
|
||||
|
||||
let bet1 = BinaryBet(
|
||||
theme: "Football - Finale de la Ligue des Champions",
|
||||
phrase: "Le gagnant de la finale sera l'équipe avec le plus de tirs au but.",
|
||||
endRegisterDate: Date().addingTimeInterval(86400),
|
||||
endBetDate: Date().addingTimeInterval(172800),
|
||||
totalStakes: 100,
|
||||
isPublic: true,
|
||||
invited: [],
|
||||
author: user1,
|
||||
registered: [user2]
|
||||
)
|
||||
self.bets.append(bet1)
|
||||
|
||||
let bet2 = BinaryBet(
|
||||
theme: "Cuisine - Concours de cuisine en direct",
|
||||
phrase: "Le plat préféré du jury sera une recette végétarienne.",
|
||||
endRegisterDate: Date().addingTimeInterval(172800),
|
||||
endBetDate: Date().addingTimeInterval(259200),
|
||||
totalStakes: 150,
|
||||
isPublic: false,
|
||||
invited: [user3],
|
||||
author: user1,
|
||||
registered: [user2]
|
||||
)
|
||||
self.bets.append(bet2)
|
||||
|
||||
let bet3 = BinaryBet(
|
||||
theme: "Technologie - Lancement d'un nouveau smartphone",
|
||||
phrase: "Le nombre total de précommandes dépassera-t-il 1 million dans la première semaine ?",
|
||||
endRegisterDate: Date().addingTimeInterval(259200),
|
||||
endBetDate: Date().addingTimeInterval(345600),
|
||||
totalStakes: 75,
|
||||
isPublic: true,
|
||||
invited: [],
|
||||
author: user1,
|
||||
registered: [user2, user1, user3]
|
||||
)
|
||||
self.bets.append(bet3)
|
||||
|
||||
let bet4 = BinaryBet(
|
||||
theme: "Cinéma - Oscars 2024",
|
||||
phrase: "Le film favori des critiques remportera-t-il le prix du meilleur film ?",
|
||||
endRegisterDate: Date().addingTimeInterval(345600),
|
||||
endBetDate: Date().addingTimeInterval(432000),
|
||||
totalStakes: 120,
|
||||
isPublic: false,
|
||||
invited: [user1],
|
||||
author: user2,
|
||||
registered: [user3]
|
||||
)
|
||||
self.bets.append(bet4)
|
||||
|
||||
}
|
||||
|
||||
public mutating func add(bet: Bet) {
|
||||
self.bets.append(bet)
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
//
|
||||
// UserStubManager.swift
|
||||
//
|
||||
//
|
||||
// Created by Emre on 31/12/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Model
|
||||
|
||||
public struct UserStubManager: UserDataManager {
|
||||
|
||||
private var username: String
|
||||
|
||||
public init(username: String) {
|
||||
self.username = username
|
||||
}
|
||||
|
||||
public func getBets(withIndex index: Int, withCount count: Int) -> [Bet] {
|
||||
return Stub.shared.bets.filter { bet in
|
||||
bet.registered.contains { user in
|
||||
user.username == self.username
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func addBet(bet: Bet) {
|
||||
Stub.shared.add(bet: bet)
|
||||
}
|
||||
|
||||
public func getFriends() -> [User] {
|
||||
return Stub.shared.users.filter { user in
|
||||
user.friends.contains { friend in
|
||||
friend.username == self.username
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue