feature/display_bet_details #16
feature/display_bet_details
into master
1 year ago
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0x49",
|
||||||
|
"green" : "0x49",
|
||||||
|
"red" : "0x49"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0x49",
|
||||||
|
"green" : "0x49",
|
||||||
|
"red" : "0x49"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xF8",
|
||||||
|
"green" : "0x99",
|
||||||
|
"red" : "0x23"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xF8",
|
||||||
|
"green" : "0x99",
|
||||||
|
"red" : "0x23"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Vector.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 986 B |
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Group 107 (1).png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 681 B |
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Group 179.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 832 B |
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Group 210.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Group 107 (1).png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 681 B |
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Group 280.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0x8A",
|
||||||
|
"green" : "0x2B",
|
||||||
|
"red" : "0xFE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0x8A",
|
||||||
|
"green" : "0x2B",
|
||||||
|
"red" : "0xFE"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xA8",
|
||||||
|
"green" : "0x49",
|
||||||
|
"red" : "0xC2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xA8",
|
||||||
|
"green" : "0x49",
|
||||||
|
"red" : "0xC2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Vector (1).png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 1008 B |
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xC5",
|
||||||
|
"green" : "0x66",
|
||||||
|
"red" : "0x8A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xC5",
|
||||||
|
"green" : "0x66",
|
||||||
|
"red" : "0x8A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Vector (3).png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xFF",
|
||||||
|
"green" : "0xE8",
|
||||||
|
"red" : "0xD1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"appearances" : [
|
||||||
|
{
|
||||||
|
"appearance" : "luminosity",
|
||||||
|
"value" : "dark"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"color" : {
|
||||||
|
"color-space" : "srgb",
|
||||||
|
"components" : {
|
||||||
|
"alpha" : "1.000",
|
||||||
|
"blue" : "0xFF",
|
||||||
|
"green" : "0xE8",
|
||||||
|
"red" : "0xD1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "Exclude (1).png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,101 @@
|
|||||||
|
//
|
||||||
|
// BetLineLoading.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Lucas Delanier on 19/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import Model
|
||||||
|
|
||||||
|
struct BetLineLoading: View {
|
||||||
|
|
||||||
|
var participations: [Participation]
|
||||||
|
|
||||||
|
var value: CGFloat {
|
||||||
|
let totalParticipations = participations.count
|
||||||
|
let numberOfYes = participations.filter { $0.response.uppercased() == "YES" }.count
|
||||||
|
let numberOfNo = participations.filter { $0.response.uppercased() == "NO" }.count
|
||||||
|
if(numberOfNo == 0 && numberOfYes == 0){
|
||||||
|
return 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalParticipations > 0 ? CGFloat(numberOfYes) / CGFloat(totalParticipations) : 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var yesParticipations: [Participation] {
|
||||||
|
return participations.filter { $0.response.uppercased() == "YES" }
|
||||||
|
}
|
||||||
|
|
||||||
|
var noParticipations: [Participation] {
|
||||||
|
return participations.filter { $0.response.uppercased() == "NO" }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
GeometryReader { geometry in
|
||||||
|
VStack(alignment: .leading,spacing: 0){
|
||||||
|
HStack(spacing: 5){
|
||||||
|
Text("OUI").font(.system(size: 25)).fontWeight(.bold).foregroundColor(AllInColors.bleue200)
|
||||||
|
Spacer()
|
||||||
|
Text("NON").font(.system(size: 25)).fontWeight(.bold).foregroundColor(AllInColors.pink100)
|
||||||
|
|
||||||
|
}
|
||||||
|
ZStack(alignment: .leading) {
|
||||||
|
HStack{
|
||||||
|
Spacer()
|
||||||
|
Rectangle().frame(width: min(CGFloat(1-self.value)*geometry.size.width, geometry.size.width), height: 17)
|
||||||
|
.foregroundStyle(AllInColors.PinkBetGradiant).cornerRadius(999)
|
||||||
|
}
|
||||||
|
|
||||||
|
HStack(spacing: 0){
|
||||||
|
Rectangle().frame(width: min(CGFloat(self.value)*geometry.size.width, geometry.size.width), height: 17)
|
||||||
|
.foregroundStyle(AllInColors.BlueBetGradiant).cornerRadius(999)
|
||||||
|
.animation(.linear)
|
||||||
|
Image("LoadingHeart").resizable().frame(width: 29, height: 32).padding(.leading, -10)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
VStack(spacing: 1){
|
||||||
|
HStack(spacing: 5){
|
||||||
|
Image("BlueAllCoinIcon").resizable().frame(width:12, height: 12)
|
||||||
|
Text(yesParticipations.reduce(0, {x,y in x + y.stake}).description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200)
|
||||||
|
Spacer()
|
||||||
|
Text(noParticipations.reduce(0, {x,y in x + y.stake}).description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100)
|
||||||
|
Image("PinkBadge").resizable().frame(width:10, height: 14)
|
||||||
|
|
||||||
|
}
|
||||||
|
HStack(spacing: 5){
|
||||||
|
Image("BleuePersonIcon").resizable().frame(width:14, height: 12)
|
||||||
|
Text(yesParticipations.count.description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200)
|
||||||
|
Spacer()
|
||||||
|
Text(noParticipations.count.description).font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100)
|
||||||
|
Image("PinkBadge").resizable().frame(width:10, height: 14)
|
||||||
|
|
||||||
|
}
|
||||||
|
HStack(spacing: 5){
|
||||||
|
Image("BleueBadge").resizable().frame(width:10, height: 14)
|
||||||
|
Text(yesParticipations.max(by: { $0.stake < $1.stake })?.stake.description ?? "0").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200)
|
||||||
|
Spacer()
|
||||||
|
Text(noParticipations.max(by: { $0.stake < $1.stake })?.stake.description ?? "0").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100)
|
||||||
|
Image("PinkBadge").resizable().frame(width:10, height: 14)
|
||||||
|
|
||||||
|
}
|
||||||
|
HStack(spacing: 5){
|
||||||
|
Image("BleueTrophyIcon").resizable().frame(width:14, height: 13)
|
||||||
|
Text("1.2").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.bleue200)
|
||||||
|
Spacer()
|
||||||
|
Text("1.2").font(.system(size: 15)).fontWeight(.bold).foregroundColor(AllInColors.pink100)
|
||||||
|
Image("PinkBadge").resizable().frame(width:10, height: 14)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}.frame(height: 140)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
//
|
||||||
|
// DropDownAnswerMenu.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Lucas Delanier on 16/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
//
|
||||||
|
// DropDownMenu.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Emre on 19/10/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct DropDownAnswerMenu: View {
|
||||||
|
|
||||||
|
@State var expand = false
|
||||||
|
@Binding var selectedOption: Int
|
||||||
|
var options: [(Int, String, Float)]
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack(spacing: 0, content: {
|
||||||
|
Button(action: { self.expand.toggle() }) {
|
||||||
|
HStack{
|
||||||
|
Text(options[selectedOption].1.description)
|
||||||
|
.textStyle(weight: .bold, color: AllInColors.blueAccentColor, size: 20)
|
||||||
|
Text(options[selectedOption].2.description)
|
||||||
|
.textStyle(weight: .bold, color: AllInColors.lightPurpleColor, size: 10)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
Image(expand ? "chevronUpIcon" : "chevronDownIcon").resizable().frame(width: 15, height: 10).scaledToFill()
|
||||||
|
}
|
||||||
|
.padding([.leading, .trailing], 15)
|
||||||
|
.frame(height: 43)
|
||||||
|
}
|
||||||
|
if expand {
|
||||||
|
Rectangle()
|
||||||
|
.frame(height: 1)
|
||||||
|
.foregroundColor(AllInColors.delimiterGrey)
|
||||||
|
.padding(.bottom, 18)
|
||||||
|
VStack(spacing: 0) {
|
||||||
|
ForEach(0..<options.count, id: \.self) { index in
|
||||||
|
if options[index].0 != selectedOption {
|
||||||
|
Button(action: {self.selectedOption = options[index].0
|
||||||
|
self.expand.toggle()}) {
|
||||||
|
HStack{
|
||||||
|
Text(options[index].1.description)
|
||||||
|
.textStyle(weight: .bold, color: AllInColors.blueAccentColor, size: 20)
|
||||||
|
Text(options[index].2.description)
|
||||||
|
.textStyle(weight: .bold, color: AllInColors.lightPurpleColor, size: 10)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.bottom, 15)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding([.leading, .trailing], 15)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.frame(width: .infinity)
|
||||||
|
.background(AllInColors.componentBackgroundColor)
|
||||||
|
.cornerRadius(10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DropDownAnswerMenu_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
DropDownAnswerMenu(selectedOption: .constant(0), options: [
|
||||||
|
(0, "questionMarkIcon", 1.2),
|
||||||
|
(1, "footballIcon", 2.2),
|
||||||
|
(2, "paintbrushIcon", 3.3)
|
||||||
|
])
|
||||||
|
.preferredColorScheme(.dark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// ParticiationCell.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Lucas Delanier on 21/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import Model
|
||||||
|
|
||||||
|
struct ParticiationCell: View {
|
||||||
|
@State var participation: Participation?
|
||||||
|
var body: some View {
|
||||||
|
HStack(alignment: .center, spacing: 0){
|
||||||
|
Circle().frame(width: 30, height: 30).foregroundColor(AllInColors.grey700Color).padding(.trailing, 5)
|
||||||
|
Text(participation?.user.username ?? "Unknown")
|
||||||
|
.font(.system(size: 15))
|
||||||
|
.foregroundStyle(AllInColors.grey100Color)
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
Spacer()
|
||||||
|
Text(participation?.stake.description ?? "NaN")
|
||||||
|
.font(.system(size: 18))
|
||||||
|
.foregroundStyle(AllInColors.lightPurpleColor)
|
||||||
|
.fontWeight(.bold).padding(.trailing, 5)
|
||||||
|
Image("PurpleAllCoin").resizable().frame(width: 11, height: 12)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// ParticipateButton.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Lucas Delanier on 15/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import Model
|
||||||
|
|
||||||
|
struct ParticipateButton: View {
|
||||||
|
|
||||||
|
@Binding var isOpen : Bool
|
||||||
|
@Binding var isParticapatedOpen: Bool
|
||||||
|
var bet: Bet?
|
||||||
|
|
||||||
|
var isDisabled: Bool {
|
||||||
|
guard let endRegisterDate = bet?.endRegisterDate else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentDate = Date()
|
||||||
|
|
||||||
|
switch currentDate.compare(endRegisterDate) {
|
||||||
|
case .orderedAscending:
|
||||||
|
return false
|
||||||
|
case .orderedDescending, .orderedSame:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Button {
|
||||||
|
isOpen = true
|
||||||
|
isParticapatedOpen = true
|
||||||
|
} label: {
|
||||||
|
Text("Participer")
|
||||||
|
.font(.system(size: 27))
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.frame(maxWidth: .infinity).padding(10)
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
.overlay {
|
||||||
|
switch isDisabled {
|
||||||
|
case true:
|
||||||
|
AllInColors.grey700Color.frame(width: 170)
|
||||||
|
.mask(
|
||||||
|
Text("Participer")
|
||||||
|
.font(.system(size: 27))
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.frame(maxWidth: .infinity).padding(10)
|
||||||
|
)
|
||||||
|
case false:
|
||||||
|
AllInColors.primaryGradient.frame(width: 170)
|
||||||
|
.mask(
|
||||||
|
Text("Participer")
|
||||||
|
.font(.system(size: 27))
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
.frame(maxWidth: .infinity).padding(10)
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.accentColor(AllInColors.componentBackgroundColor)
|
||||||
|
.background(isDisabled ? AllInColors.delimiterGrey.opacity(0.5):AllInColors.whiteColor)
|
||||||
|
.buttonStyle(.borderedProminent).cornerRadius(4.0)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: 12).stroke(AllInColors.delimiterGrey, lineWidth: 1)
|
||||||
|
)
|
||||||
|
}.disabled(isDisabled)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,112 @@
|
|||||||
|
//
|
||||||
|
// ParticipationModal.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Lucas Delanier on 16/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct ParticipationModal: View {
|
||||||
|
|
||||||
|
@Binding private var selectedOption: Int
|
||||||
|
@Binding private var mise: String
|
||||||
|
private var description: String
|
||||||
|
var participationAddedCallback: (() -> Void)?
|
||||||
|
|
||||||
|
init(answer: Binding<Int>, mise: Binding<String>, description: String, participationAddedCallback: (() -> Void)? = nil) {
|
||||||
|
self._selectedOption = answer
|
||||||
|
self._mise = mise
|
||||||
|
self.description = description
|
||||||
|
self.participationAddedCallback = participationAddedCallback
|
||||||
|
}
|
||||||
|
|
||||||
|
let options: [(Int, String, Float)] = [
|
||||||
|
(0, "OUI", 1.2),
|
||||||
|
(1, "NON", 3.3),
|
||||||
|
]
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack(alignment: .leading){
|
||||||
|
HStack{
|
||||||
|
Spacer()
|
||||||
|
Rectangle()
|
||||||
|
.foregroundStyle(AllInColors.grey800Color)
|
||||||
|
.frame(maxWidth: 80, maxHeight: 5)
|
||||||
|
.cornerRadius(999)
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
}.padding(10)
|
||||||
|
HStack{
|
||||||
|
Text("Faites vos paris")
|
||||||
|
.font(.system(size: 18))
|
||||||
|
.foregroundColor(AllInColors.blackTitleColor)
|
||||||
|
.fontWeight(.semibold)
|
||||||
|
Spacer()
|
||||||
|
AllcoinsCounter(backgroundColor: AllInColors.purpleAccentColor, foregroundColor: AllInColors.whiteColor)
|
||||||
|
}
|
||||||
|
.padding(.leading, 15)
|
||||||
|
VStack(alignment: .leading){
|
||||||
|
Text(description)
|
||||||
|
.font(.system(size: 13))
|
||||||
|
.foregroundColor(AllInColors.grey100Color)
|
||||||
|
.fontWeight(.light)
|
||||||
|
|
||||||
|
DropDownAnswerMenu(selectedOption: $selectedOption, options: options)
|
||||||
|
|
||||||
|
TextField("",text: $mise, prompt: Text("Mise")
|
||||||
|
.foregroundColor(AllInColors.lightGrey300Color)
|
||||||
|
.font(.system(size: 14))
|
||||||
|
.fontWeight(.bold))
|
||||||
|
.padding()
|
||||||
|
.keyboardType(.numberPad)
|
||||||
|
.background(
|
||||||
|
RoundedRectangle(cornerRadius: 9)
|
||||||
|
.fill(AllInColors.lightGrey200Color)
|
||||||
|
.frame(height: 40)
|
||||||
|
)
|
||||||
|
.frame(width: .infinity, height: 40)
|
||||||
|
.foregroundColor(AllInColors.primaryTextColor)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||||
|
.stroke(AllInColors.delimiterGrey, lineWidth: 1)
|
||||||
|
)
|
||||||
|
.padding(.bottom, 5)
|
||||||
|
|
||||||
|
}
|
||||||
|
.padding(15)
|
||||||
|
Spacer()
|
||||||
|
VStack{
|
||||||
|
HStack{
|
||||||
|
Text("Gains possibles")
|
||||||
|
.font(.system(size: 13))
|
||||||
|
.foregroundColor(AllInColors.blackTitleColor)
|
||||||
|
.fontWeight(.regular)
|
||||||
|
Spacer()
|
||||||
|
Text("231")
|
||||||
|
.font(.system(size: 13))
|
||||||
|
.foregroundColor(AllInColors.blackTitleColor)
|
||||||
|
.fontWeight(.light)
|
||||||
|
}
|
||||||
|
.padding(.top, 10).padding(.bottom, 0)
|
||||||
|
Button {
|
||||||
|
participationAddedCallback?()
|
||||||
|
} label: {
|
||||||
|
Text("Miser")
|
||||||
|
.font(.system(size: 23))
|
||||||
|
.foregroundColor(AllInColors.whiteColor)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.padding(.vertical, 3)
|
||||||
|
}
|
||||||
|
.buttonStyle(.borderedProminent)
|
||||||
|
.tint(AllInColors.purpleAccentColor)
|
||||||
|
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
.background(AllInColors.whiteColor)
|
||||||
|
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
|
||||||
|
}
|
||||||
|
.background(AllInColors.underComponentBackgroundColor)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// ResultBanner.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Lucas Delanier on 15/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct ResultBanner: View {
|
||||||
|
var body: some View {
|
||||||
|
VStack{
|
||||||
|
HStack{
|
||||||
|
Image("BleueTrophyIcon").resizable().frame(maxWidth: 70, maxHeight: 60)
|
||||||
|
Text("OUI").font(.system(size: 70)).fontWeight(.bold).foregroundStyle(AllInColors.blueGrey800Color)
|
||||||
|
}.frame(height: 80)
|
||||||
|
HStack(spacing: 20){
|
||||||
|
HStack{
|
||||||
|
Image("BlueAllCoinIcon").resizable().frame(maxWidth: 12, maxHeight: 12)
|
||||||
|
Text("460").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color)
|
||||||
|
}
|
||||||
|
HStack{
|
||||||
|
Image("BleuePersonIcon").resizable().frame(maxWidth: 15, maxHeight: 12)
|
||||||
|
Text("ImriDu43").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color)
|
||||||
|
}
|
||||||
|
HStack{
|
||||||
|
Image("BleueTrophyIcon").resizable().frame(maxWidth: 15, maxHeight: 12)
|
||||||
|
Text("x1.2").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/)
|
||||||
|
.padding(.vertical, 20).background(AllInColors.winBannerBackground)
|
||||||
|
.border(width: 2, edges: [.top,.bottom], color: AllInColors.blueAccentColor.opacity(0.2))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// DetailsViewModel.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Emre on 16/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
import DependencyInjection
|
||||||
|
import Model
|
||||||
|
|
||||||
|
class DetailsViewModel: ObservableObject {
|
||||||
|
|
||||||
|
@Inject var manager: Manager
|
||||||
|
var id: String
|
||||||
|
@Published var answer = 0
|
||||||
|
@Published var mise: String = ""
|
||||||
|
|
||||||
|
@Published var betDetail: BetDetail?
|
||||||
|
|
||||||
|
init(id: String) {
|
||||||
|
self.id = id
|
||||||
|
getItem(withId: id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getItem(withId id: String) {
|
||||||
|
manager.getBet(withId: id) { bet in
|
||||||
|
self.betDetail = bet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func addParticipate() {
|
||||||
|
if let stake = Int(mise) {
|
||||||
|
var rep: String = ""
|
||||||
|
if answer == 0 {
|
||||||
|
rep = "Yes"
|
||||||
|
} else {
|
||||||
|
rep = "No"
|
||||||
|
}
|
||||||
|
manager.addParticipation(withId: id, withAnswer: rep, andStake: stake)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// HistoricBetViewModel.swift
|
||||||
|
// AllIn
|
||||||
|
//
|
||||||
|
// Created by Emre on 16/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
import DependencyInjection
|
||||||
|
import Model
|
||||||
|
|
||||||
|
class HistoricBetViewModel: ObservableObject {
|
||||||
|
|
||||||
|
@Inject var manager: Manager
|
||||||
|
|
||||||
|
init() {
|
||||||
|
getItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
func getItems() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,166 @@
|
|||||||
|
import SwiftUI
|
||||||
|
import Model
|
||||||
|
|
||||||
|
struct DetailsView: View {
|
||||||
|
|
||||||
|
@Binding var isModalPresented: Bool
|
||||||
|
@Binding var isModalParticipated: Bool
|
||||||
|
@State var progressValue: Float = 0.2
|
||||||
|
var id: String
|
||||||
|
@StateObject private var viewModel: DetailsViewModel
|
||||||
|
|
||||||
|
var isFinished: Bool {
|
||||||
|
viewModel.betDetail?.finalAnswer == nil ? false : true
|
||||||
|
}
|
||||||
|
|
||||||
|
var isDisabled: Bool {
|
||||||
|
if let endRegisterDate = viewModel.betDetail?.bet.endRegisterDate {
|
||||||
|
let currentDate = Date()
|
||||||
|
|
||||||
|
switch currentDate.compare(endRegisterDate) {
|
||||||
|
case .orderedAscending:
|
||||||
|
return false
|
||||||
|
case .orderedDescending:
|
||||||
|
return true
|
||||||
|
case .orderedSame:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var StatusValues: (String, Color) {
|
||||||
|
if let endRegisterDate = viewModel.betDetail?.bet.endRegisterDate {
|
||||||
|
let currentDate = Date()
|
||||||
|
|
||||||
|
switch currentDate.compare(endRegisterDate) {
|
||||||
|
case .orderedAscending:
|
||||||
|
return ("En cours...", AllInColors.purpleAccentColor)
|
||||||
|
case .orderedDescending:
|
||||||
|
return ("En attente...",AllInColors.pink100)
|
||||||
|
case .orderedSame:
|
||||||
|
return ("Fin des inscriptions...",AllInColors.grey50Color)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return ("Statut indisponible", AllInColors.whiteColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init(isModalPresented: Binding<Bool>, isModalParticipated: Binding<Bool>, id: String) {
|
||||||
|
self._isModalPresented = isModalPresented
|
||||||
|
self._isModalParticipated = isModalParticipated
|
||||||
|
self.id = id
|
||||||
|
self._viewModel = StateObject(wrappedValue: DetailsViewModel(id: id))
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
GeometryReader { geometry in
|
||||||
|
ZStack(alignment: .bottom) {
|
||||||
|
VStack(alignment: .center) {
|
||||||
|
HStack{
|
||||||
|
Text(StatusValues.0)
|
||||||
|
.font(.system(size: 25))
|
||||||
|
.fontWeight(.bold).padding(.bottom, 10)
|
||||||
|
.foregroundStyle(Color.black)
|
||||||
|
.opacity(0.4)
|
||||||
|
Spacer()
|
||||||
|
Image("closeIcon")
|
||||||
|
.resizable()
|
||||||
|
.frame(maxWidth: 25, maxHeight: 25)
|
||||||
|
.onTapGesture {
|
||||||
|
isModalPresented = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 15)
|
||||||
|
.background(StatusValues.1)
|
||||||
|
.transition(.slideInFromBottom(yOffset:0))
|
||||||
|
|
||||||
|
VStack(spacing: 0) {
|
||||||
|
VStack(alignment: .leading,spacing: 5){
|
||||||
|
HStack{
|
||||||
|
Spacer()
|
||||||
|
Text("proposé par " + (viewModel.betDetail?.bet.author.username ?? "Unknown").capitalized)
|
||||||
|
.font(.system(size: 10))
|
||||||
|
.foregroundColor(AllInColors.grey800Color)
|
||||||
|
|
||||||
|
}
|
||||||
|
Text(viewModel.betDetail?.bet.theme ?? "Not loaded")
|
||||||
|
.font(.system(size: 15))
|
||||||
|
.foregroundColor(AllInColors.grey800Color)
|
||||||
|
Text(viewModel.betDetail?.bet.phrase ?? "Not loaded")
|
||||||
|
.font(.system(size: 20))
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.padding(.bottom, 10)
|
||||||
|
HStack{
|
||||||
|
Text("Commence le")
|
||||||
|
.frame(maxWidth: 100)
|
||||||
|
.font(.system(size: 15))
|
||||||
|
.foregroundColor(AllInColors.grey800Color)
|
||||||
|
TextCapsule(date: viewModel.betDetail?.bet.endRegisterDate ?? Date())
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
}.padding(.bottom, 10)
|
||||||
|
HStack{
|
||||||
|
Text("Fini le")
|
||||||
|
.frame(maxWidth: 100)
|
||||||
|
.font(.system(size: 15))
|
||||||
|
.foregroundColor(AllInColors.grey800Color)
|
||||||
|
TextCapsule(date: viewModel.betDetail?.bet.endBetDate ?? Date())
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(width: .infinity)
|
||||||
|
.padding(.all,15).padding(.vertical, 10)
|
||||||
|
.background(AllInColors.componentBackgroundColor)
|
||||||
|
.cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0)
|
||||||
|
|
||||||
|
if isFinished {
|
||||||
|
ResultBanner()
|
||||||
|
}
|
||||||
|
VStack(alignment: .leading, spacing: 5) {
|
||||||
|
BetLineLoading(participations: viewModel.betDetail?.participations ?? [])
|
||||||
|
.padding(.vertical,15)
|
||||||
|
Text("Liste des participants")
|
||||||
|
.font(.system(size: 18))
|
||||||
|
.foregroundStyle(AllInColors.grey100Color)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.padding(.bottom, 10)
|
||||||
|
ForEach(viewModel.betDetail?.participations ?? []) { (participation: Participation) in
|
||||||
|
ParticiationCell(participation: participation).padding(.horizontal, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, maxHeight: .infinity)
|
||||||
|
.padding([.bottom,.trailing,.leading], 15)
|
||||||
|
.background(AllInColors.underComponentBackgroundColor)
|
||||||
|
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: geometry.size.height*0.98)
|
||||||
|
.background(AllInColors.componentBackgroundColor)
|
||||||
|
.cornerRadius(15)
|
||||||
|
|
||||||
|
ParticipateButton(isOpen: $isModalPresented, isParticapatedOpen: $isModalParticipated, bet: viewModel.betDetail?.bet)
|
||||||
|
.padding(10)
|
||||||
|
}
|
||||||
|
.sheet(isPresented: $isModalParticipated) {
|
||||||
|
ParticipationModal(answer: $viewModel.answer, mise: $viewModel.mise, description: viewModel.betDetail?.bet.phrase ?? "Not loaded", participationAddedCallback: {
|
||||||
|
viewModel.addParticipate()
|
||||||
|
isModalParticipated.toggle()
|
||||||
|
})
|
||||||
|
.presentationDetents([.fraction(0.55)])
|
||||||
|
}
|
||||||
|
.edgesIgnoringSafeArea(.bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// AnswerDetail.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Emre on 19/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// A class representing detailed information about a specific answer option for a bet.
|
||||||
|
public class AnswerDetail: ObservableObject {
|
||||||
|
|
||||||
|
/// The response or outcome associated with this answer.
|
||||||
|
public private(set) var response: String
|
||||||
|
|
||||||
|
/// The total amount of stakes placed on this answer.
|
||||||
|
public private(set) var totalStakes: Int
|
||||||
|
|
||||||
|
/// The total number of participants who selected this answer.
|
||||||
|
public private(set) var totalParticipants: Int
|
||||||
|
|
||||||
|
/// The highest stake placed on this answer.
|
||||||
|
public private(set) var highestStake: Int
|
||||||
|
|
||||||
|
/// The odds associated with this answer.
|
||||||
|
public private(set) var odds: Float
|
||||||
|
|
||||||
|
/// Custom Constructor
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - response: The response or outcome associated with this answer.
|
||||||
|
/// - totalStakes: The total amount of stakes placed on this answer.
|
||||||
|
/// - totalParticipants: The total number of participants who selected this answer.
|
||||||
|
/// - highestStake: The highest stake placed on this answer.
|
||||||
|
/// - odds: The odds associated with this answer.
|
||||||
|
public init(response: String, totalStakes: Int, totalParticipants: Int, highestStake: Int, odds: Float) {
|
||||||
|
self.response = response
|
||||||
|
self.totalStakes = totalStakes
|
||||||
|
self.totalParticipants = totalParticipants
|
||||||
|
self.highestStake = highestStake
|
||||||
|
self.odds = odds
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// BetDetail.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Emre on 19/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// A class representing detailed information about a specific bet, including answers and user participations.
|
||||||
|
public class BetDetail: ObservableObject {
|
||||||
|
|
||||||
|
/// The main bet information.
|
||||||
|
public private(set) var bet: Bet
|
||||||
|
|
||||||
|
/// Details about the answers available for the bet.
|
||||||
|
public private(set) var answers: [AnswerDetail]
|
||||||
|
|
||||||
|
/// List of user participations in the bet.
|
||||||
|
public private(set) var participations: [Participation]
|
||||||
|
|
||||||
|
public private(set) var finalAnswer: String?
|
||||||
|
|
||||||
|
/// Custom Constructor
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - bet: The main bet information.
|
||||||
|
/// - answers: Details about the answers available for the bet.
|
||||||
|
/// - participations: List of user participations in the bet.
|
||||||
|
/// - userParticipation: The user's own participation in the bet.
|
||||||
|
public init(bet: Bet, answers: [AnswerDetail], participations: [Participation], finalAnswer: String? = nil) {
|
||||||
|
self.bet = bet
|
||||||
|
self.answers = answers
|
||||||
|
self.participations = participations
|
||||||
|
self.finalAnswer = finalAnswer
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateFinalAnswer(newFinalAnswer: String) {
|
||||||
|
self.finalAnswer = newFinalAnswer
|
||||||
|
}
|
||||||
|
|
||||||
|
public func addParticipation(newParticipation: Participation){
|
||||||
|
if !self.bet.registered.contains(where: { existingUser in
|
||||||
|
return existingUser.email == newParticipation.user.email
|
||||||
|
}) {
|
||||||
|
self.bet.addRegistered(newUser: newParticipation.user)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.participations.append(newParticipation)
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +0,0 @@
|
|||||||
//
|
|
||||||
// BinaryParticipation.swift
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Emre on 28/12/2023.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
/// Enum to represent the possible answers for a binary participation.
|
|
||||||
public enum YesNo {
|
|
||||||
case yes
|
|
||||||
case no
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A subclass of Participation that represents a binary participation (yes/no) in a bet.
|
|
||||||
public class BinaryParticipation: Participation {
|
|
||||||
/// The answer for the binary participation (yes or no).
|
|
||||||
public var answer: YesNo
|
|
||||||
|
|
||||||
/// Custom Constructor
|
|
||||||
///
|
|
||||||
/// - Parameters:
|
|
||||||
/// - coinAmount: The amount of coins involved in the binary participation.
|
|
||||||
/// - date: The date and time when the binary participation occurred.
|
|
||||||
/// - user: The user who participated in the binary bet.
|
|
||||||
/// - bet: The binary bet in which the user participated.
|
|
||||||
/// - answer: The answer for the binary participation (yes or no).
|
|
||||||
public init(coinAmount: Int, date: Date, user: User, bet: Bet, answer: YesNo) {
|
|
||||||
self.answer = answer
|
|
||||||
super.init(coinAmount: coinAmount, date: date, user: user, bet: bet)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
//
|
|
||||||
// CustomParticipation.swift
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Emre on 28/12/2023.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
/// A subclass of Participation that represents a custom participation in a bet.
|
|
||||||
public class CustomParticipation: Participation {
|
|
||||||
/// The user's response to the custom bet.
|
|
||||||
public var answer: CustomBetResponse
|
|
||||||
|
|
||||||
/// Custom Constructor
|
|
||||||
///
|
|
||||||
/// - Parameters:
|
|
||||||
/// - coinAmount: The amount of coins involved in the custom participation.
|
|
||||||
/// - date: The date and time when the custom participation occurred.
|
|
||||||
/// - user: The user who participated in the custom bet.
|
|
||||||
/// - bet: The custom bet in which the user participated.
|
|
||||||
/// - answer: The user's response to the custom bet.
|
|
||||||
public init(coinAmount: Int, date: Date, user: User, bet: Bet, answer: CustomBetResponse) {
|
|
||||||
self.answer = answer
|
|
||||||
super.init(coinAmount: coinAmount, date: date, user: user, bet: bet)
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// File.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by étudiant on 23/01/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public enum BetStatus {
|
||||||
|
case WAITING, IN_PROGRESS, FINISHED
|
||||||
|
}
|
@ -1,32 +0,0 @@
|
|||||||
//
|
|
||||||
// MatchParticipation.swift
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Emre on 28/12/2023.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
/// A subclass of Participation that represents a user's participation in a match bet.
|
|
||||||
public class MatchParticipation: Participation {
|
|
||||||
/// The points earned by the user for the first team in the match.
|
|
||||||
public var pointsTeam1: Int
|
|
||||||
|
|
||||||
/// The points earned by the user for the second team in the match.
|
|
||||||
public var pointsTeam2: Int
|
|
||||||
|
|
||||||
/// Custom Constructor
|
|
||||||
///
|
|
||||||
/// - Parameters:
|
|
||||||
/// - coinAmount: The amount of coins involved in the match participation.
|
|
||||||
/// - date: The date and time when the match participation occurred.
|
|
||||||
/// - user: The user who participated in the match bet.
|
|
||||||
/// - bet: The match bet in which the user participated.
|
|
||||||
/// - pointsTeam1: The points earned by the user for the first team in the match.
|
|
||||||
/// - pointsTeam2: The points earned by the user for the second team in the match.
|
|
||||||
public init(coinAmount: Int, date: Date, user: User, bet: Bet, pointsTeam1: Int, pointsTeam2: Int) {
|
|
||||||
self.pointsTeam1 = pointsTeam1
|
|
||||||
self.pointsTeam2 = pointsTeam2
|
|
||||||
super.init(coinAmount: coinAmount, date: date, user: user, bet: 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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: "ViewModel",
|
|
||||||
platforms: [
|
|
||||||
.iOS(.v13)
|
|
||||||
],
|
|
||||||
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"]),
|
|
||||||
]
|
|
||||||
)
|
|
@ -1,3 +0,0 @@
|
|||||||
# ViewModel
|
|
||||||
|
|
||||||
A description of this package.
|
|
@ -1,29 +0,0 @@
|
|||||||
//
|
|
||||||
// ManagerVM.swift
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Emre on 30/12/2023.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import Model
|
|
||||||
|
|
||||||
public class ManagerVM: ObservableObject {
|
|
||||||
@Published var model: Manager
|
|
||||||
|
|
||||||
@Published public var bets: [Bet] = []
|
|
||||||
|
|
||||||
public init(withModel model: Manager) {
|
|
||||||
self.model = model
|
|
||||||
}
|
|
||||||
|
|
||||||
public func getPublicBets() {
|
|
||||||
model.getBets(withIndex: 0, withCount: 20) { bets in
|
|
||||||
self.bets = bets
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func addBet(theme: String, description: String, endRegister: Date, endBet: Date, isPublic: Bool, creator: User) {
|
|
||||||
model.addBet(bet: BinaryBet(theme: theme, phrase: description, endRegisterDate: endRegister, endBetDate: endBet, totalStakes: 0, isPublic: isPublic, invited: [], author: creator, registered: []))
|
|
||||||
}
|
|
||||||
}
|
|