You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.7 KiB
107 lines
3.7 KiB
//
|
|
// BetCard.swift
|
|
// AllIn
|
|
//
|
|
// Created by Lucas on 24/09/2023.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Model
|
|
|
|
struct ReviewCard: View {
|
|
|
|
@State var showDetails: Bool = false
|
|
@State var showPartipated: Bool = false
|
|
var bet: Bet
|
|
var amount: Int
|
|
var isWin: Bool
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0){
|
|
VStack(alignment: .leading,spacing: 2){
|
|
HStack{
|
|
Spacer()
|
|
Text("bet_proposed_by_format \(bet.author)")
|
|
.font(.system(size: 10))
|
|
.foregroundColor(AllInColors.grey800Color)
|
|
|
|
}
|
|
Text(bet.theme).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color)
|
|
Text(bet.phrase).font(.system(size: 20)).fontWeight(.bold)
|
|
HStack{
|
|
Text("bet_ends").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color)
|
|
TextCapsule(date: bet.endBetDate)
|
|
Spacer()
|
|
|
|
}
|
|
}
|
|
.frame(width: .infinity)
|
|
.padding(.all,15)
|
|
.background(AllInColors.componentBackgroundColor)
|
|
.cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0)
|
|
VStack(alignment: .center,spacing:0){
|
|
HStack(){
|
|
Spacer()
|
|
Text(amount.description)
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 25))
|
|
.fontWeight(.bold)
|
|
Image("allcoinWhiteIcon")
|
|
.resizable()
|
|
.frame(width: 18, height: 20)
|
|
|
|
switch bet.status {
|
|
case .waiting, .inProgress:
|
|
Text("bet_status_stake")
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 25))
|
|
.fontWeight(.bold)
|
|
case .closing:
|
|
Text("bet_status_finished")
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 25))
|
|
.fontWeight(.bold)
|
|
case .finished:
|
|
Text(isWin ? "Gagnés!" : "Perdus!")
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 25))
|
|
.fontWeight(.bold)
|
|
case .cancelled:
|
|
Text("cancelled")
|
|
.foregroundColor(.white)
|
|
.font(.system(size: 25))
|
|
.fontWeight(.bold)
|
|
}
|
|
Spacer()
|
|
|
|
}
|
|
.frame(width: .infinity)
|
|
.padding(.all,10)
|
|
|
|
}
|
|
.frame(width: .infinity)
|
|
.padding(.all,2)
|
|
.background(backgroundColor())
|
|
|
|
.cornerRadius(20, corners: [.bottomLeft,.bottomRight])
|
|
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
|
|
}
|
|
.onTapGesture {
|
|
showDetails.toggle()
|
|
}.fullScreenCover(isPresented: $showDetails) {
|
|
DetailsView(isModalPresented: $showDetails, isModalParticipated: $showPartipated, id: bet.id)
|
|
}
|
|
}
|
|
|
|
private func backgroundColor() -> Color {
|
|
switch bet.status {
|
|
case .inProgress, .waiting, .closing:
|
|
return AllInColors.grey50Color
|
|
case .finished:
|
|
return Color.black
|
|
case .cancelled:
|
|
return Color.red
|
|
}
|
|
}
|
|
}
|