Compare commits

...

9 Commits

Author SHA1 Message Date
Lucas DELANIER a0a1b4b30f Merge branch 'master'
11 months ago
Lucas DELANIER ce4e858cc1 review cards
11 months ago
Lucas DELANIER 209205c1bd Merge branch 'fix/change-page-order'
11 months ago
Lucas DELANIER b32a4efe51 fix review card
11 months ago
Lucas DELANIER ee7ed587b0 Merge branch 'fix/final-view-detail'
11 months ago
Lucas DELANIER ba09fafef5 background color
11 months ago
Lucas DELANIER c3f4ac0a68 fix mistake ispublic
11 months ago
Lucas DELANIER c4263d3ad1 Fix menu order to be sync with android client
11 months ago
Lucas DELANIER 7a41d5379f final banner now working and bind with the wonparticipation on the betdetail
11 months ago

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "globe.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

@ -15,20 +15,19 @@ struct Menu: View {
let parameters: [(String, String, String, String)] = [ let parameters: [(String, String, String, String)] = [
("videoGameImage", String(localized: "drawer_create_a_bet"), String(localized: "drawer_create_a_bet_subtitle"), "CreationBet"), ("videoGameImage", String(localized: "drawer_create_a_bet"), String(localized: "drawer_create_a_bet_subtitle"), "CreationBet"),
("globeImage", String(localized: "drawer_public_bets"), String(localized: "drawer_public_bets_subtitle"), "Bet"),
("moneyImage", String(localized: "drawer_current_bets"), String(localized: "drawer_current_bets_subtitle"), "Current"),
("eyesImage", String(localized: "drawer_bet_history"), String(localized: "drawer_bet_history_subtitle"),"Historic"), ("eyesImage", String(localized: "drawer_bet_history"), String(localized: "drawer_bet_history_subtitle"),"Historic"),
("friendsImage", String(localized: "drawer_friends"), String(localized: "drawer_friends_subtitle"), "Friends"), ("friendsImage", String(localized: "drawer_friends"), String(localized: "drawer_friends_subtitle"), "Friends"),
("moneyImage", String(localized: "drawer_public_bets"), String(localized: "drawer_public_bets_subtitle"), "Bet"),
("rankingImage", String(localized: "drawer_ranking"), String(localized: "drawer_ranking_subtitle"), "Ranking"), ("rankingImage", String(localized: "drawer_ranking"), String(localized: "drawer_ranking_subtitle"), "Ranking"),
("eyesImage", String(localized: "drawer_current_bets"), String(localized: "drawer_current_bets_subtitle"), "Current")
] ]
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 10) { VStack(alignment: .leading, spacing: 10) {
HStack() { HStack() {
Spacer() Spacer()
VStack(){ VStack(){
UserPicture(username: (AppStateContainer.shared.user?.username)!, size: 100) UserPicture(picture: AppStateContainer.shared.user?.image, username: (AppStateContainer.shared.user?.username)!,size: 100)
Text(AppStateContainer.shared.user?.username.capitalized ?? "") Text(AppStateContainer.shared.user?.username.capitalized ?? "")
.fontWeight(.medium) .fontWeight(.medium)
.font(.system(size: 17)) .font(.system(size: 17))

@ -6,26 +6,29 @@
// //
import SwiftUI import SwiftUI
import Model
struct ResultBanner: View { struct ResultBanner: View {
var finalAnswer: Participation
var odds: Float
var body: some View { var body: some View {
VStack{ VStack{
HStack{ HStack{
Image("BleueTrophyIcon").resizable().frame(maxWidth: 70, maxHeight: 60) Image(systemName: "trophy.fill").resizable().frame(maxWidth: 70, maxHeight: 60).foregroundColor(AllInColors.blueGrey800Color)
Text("OUI").font(.system(size: 70)).fontWeight(.bold).foregroundStyle(AllInColors.blueGrey800Color) Text(finalAnswer.answer).font(.system(size: 70)).fontWeight(.bold).foregroundStyle(AllInColors.blueGrey800Color)
}.frame(height: 80) }.frame(height: 80)
HStack(spacing: 20){ HStack(spacing: 20){
HStack{ HStack{
Image("BlueAllCoinIcon").resizable().frame(maxWidth: 12, maxHeight: 12) Image("BlueAllCoinIcon").resizable().frame(maxWidth: 12, maxHeight: 12)
Text("460").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) Text(finalAnswer.stake.description).font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color)
} }
HStack{ HStack{
Image("BleuePersonIcon").resizable().frame(maxWidth: 15, maxHeight: 12) Image("BleuePersonIcon").resizable().frame(maxWidth: 15, maxHeight: 12)
Text("ImriDu43").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) Text(finalAnswer.username).font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color)
} }
HStack{ HStack{
Image("BleueTrophyIcon").resizable().frame(maxWidth: 15, maxHeight: 12) Image("BleueTrophyIcon").resizable().frame(maxWidth: 15, maxHeight: 12)
Text("x1.2").font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color) Text(odds.description).font(.system(size: 16)).fontWeight(.semibold).foregroundStyle(AllInColors.blueGrey800Color)
} }
} }
} }

@ -44,13 +44,27 @@ struct ReviewCard: View {
VStack(alignment: .center,spacing:0){ VStack(alignment: .center,spacing:0){
HStack(){ HStack(){
Spacer() Spacer()
if(betDetail.bet.endBetDate < Date()){ if(betDetail.userParticipation != nil){
Text("bet_finished") Text((betDetail.userParticipation?.stake.description ?? ""))
.foregroundColor(.white) .foregroundColor(.white)
.font(.system(size: 25)) .font(.system(size: 25))
.fontWeight(.bold) .fontWeight(.bold)
Image("allcoinWhiteIcon")
.resizable()
.frame(width: 18, height: 20)
} }
else{ switch betDetail.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(amountBetted.description) Text(amountBetted.description)
.foregroundColor(.white) .foregroundColor(.white)
.font(.system(size: 25)) .font(.system(size: 25))
@ -62,6 +76,11 @@ struct ReviewCard: View {
.foregroundColor(.white) .foregroundColor(.white)
.font(.system(size: 25)) .font(.system(size: 25))
.fontWeight(.bold) .fontWeight(.bold)
case .cancelled:
Text("cancelled")
.foregroundColor(.white)
.font(.system(size: 25))
.fontWeight(.bold)
} }
Spacer() Spacer()
@ -72,11 +91,18 @@ struct ReviewCard: View {
} }
.frame(width: .infinity) .frame(width: .infinity)
.padding(.all,2) .padding(.all,2)
.background( .background({
isAWin || betDetail.bet.endBetDate < Date() ? switch betDetail.bet.status {
AnyView(AllInColors.primaryGradient) : case .inProgress, .waiting, .closing:
AnyView(Color.black) return AllInColors.grey50Color
) .cornerRadius(20, corners: [.bottomLeft,.bottomRight]) case .finished:
return Color.black
case .cancelled:
return Color.red
}
}())
.cornerRadius(20, corners: [.bottomLeft,.bottomRight])
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
} }
.onTapGesture { .onTapGesture {

@ -8,14 +8,14 @@
import SwiftUI import SwiftUI
struct UserPicture: View { struct UserPicture: View {
var picture: URL? var picture: String?
var username: String var username: String
var size: CGFloat var size: CGFloat
var body: some View { var body: some View {
ZStack { ZStack {
if picture != nil { if picture != nil {
AsyncImage( AsyncImage(
url: picture, url: URL(string:picture!),
content: { image in content: { image in
image image
.resizable() .resizable()

@ -46,15 +46,13 @@
"drawer_nb_friends" = "Friends"; "drawer_nb_friends" = "Friends";
"drawer_friends" = "FRIENDS"; "drawer_friends" = "FRIENDS";
"drawer_friends_subtitle" = "Challenge your folks by adding them as friends."; "drawer_friends_subtitle" = "Challenge your folks by adding them as friends.";
"drawer_public_bets" = "PUBLIC BETS"; "drawer_public_bets" = "PARTICIPATE";
"drawer_public_bets_subtitle" = "Browse the most popular bets of the moment."; "drawer_public_bets_subtitle" = "Browse the most popular bets of the moment.";
"drawer_current_bets" = "CURRENT BETS"; "drawer_create_a_bet" = "NEW BET";
"drawer_current_bets_subtitle" = "View your current bets.";
"drawer_create_a_bet" = "CREATE A BET";
"drawer_create_a_bet_subtitle" = "Create a net bet and get your friends participating."; "drawer_create_a_bet_subtitle" = "Create a net bet and get your friends participating.";
"drawer_bet_history" = "BET HISTORY"; "drawer_bet_history" = "HISTORY";
"drawer_bet_history_subtitle" = "View your current and finished bets."; "drawer_bet_history_subtitle" = "View your current and finished bets.";
"drawer_current_bets" = "CURRENT BETS"; "drawer_current_bets" = "MY PARTICIPATIONS";
"drawer_current_bets_subtitle" = "Manage your bets and reward the winners."; "drawer_current_bets_subtitle" = "Manage your bets and reward the winners.";
"drawer_ranking" = "RANKING"; "drawer_ranking" = "RANKING";
"drawer_ranking_subtitle" = "Check your ranking among your friends."; "drawer_ranking_subtitle" = "Check your ranking among your friends.";
@ -150,6 +148,7 @@
"bet_status_participants_list" = "Participants"; "bet_status_participants_list" = "Participants";
"bet_status_details_drawer" = "Details"; "bet_status_details_drawer" = "Details";
"participation_possible_winnings" = "Possible winnings"; "participation_possible_winnings" = "Possible winnings";
"bet_status_stake" = "Gambled";
/// Bet history /// Bet history

@ -28,7 +28,6 @@
"network_error_text" = "Assurez-vous d\'être bien connecté au réseau puis réessayez."; "network_error_text" = "Assurez-vous d\'être bien connecté au réseau puis réessayez.";
/// Bet type /// Bet type
"bet_type_binary" = "Oui / Non"; "bet_type_binary" = "Oui / Non";
"bet_type_match" = "Match sportif"; "bet_type_match" = "Match sportif";
"bet_type_custom" = "Réponses personnalisées"; "bet_type_custom" = "Réponses personnalisées";
@ -46,15 +45,13 @@
"drawer_nb_friends" = "Amis"; "drawer_nb_friends" = "Amis";
"drawer_friends" = "AMIS"; "drawer_friends" = "AMIS";
"drawer_friends_subtitle" = "Défiez vos proches en les ajoutant en amis."; "drawer_friends_subtitle" = "Défiez vos proches en les ajoutant en amis.";
"drawer_public_bets" = "BETS PUBLIQUES"; "drawer_public_bets" = "PARTICIPER";
"drawer_public_bets_subtitle" = "Parcourez les bets les plus populaires du moment."; "drawer_public_bets_subtitle" = "Parcourez les bets les plus populaires du moment.";
"drawer_current_bets" = "BETS EN COURS"; "drawer_create_a_bet" = "NOUVEAU BET";
"drawer_current_bets_subtitle" = "Consultez vos paris en cours.";
"drawer_create_a_bet" = "CREER UN BET";
"drawer_create_a_bet_subtitle" = "Créez un nouveau bet et faites participer vos amis."; "drawer_create_a_bet_subtitle" = "Créez un nouveau bet et faites participer vos amis.";
"drawer_bet_history" = "HISTORIQUE DES BETS"; "drawer_bet_history" = "HISTORIQUE";
"drawer_bet_history_subtitle" = "Consultez vos paris en cours et terminés."; "drawer_bet_history_subtitle" = "Consultez vos paris en cours et terminés.";
"drawer_current_bets" = "BETS EN COURS"; "drawer_current_bets" = "MES PARTICIPATIONS";
"drawer_current_bets_subtitle" = "Gérez vos bets et récompensez les gagnants."; "drawer_current_bets_subtitle" = "Gérez vos bets et récompensez les gagnants.";
"drawer_ranking" = "CLASSEMENT"; "drawer_ranking" = "CLASSEMENT";
"drawer_ranking_subtitle" = "Consultez votre classement parmis vos amis."; "drawer_ranking_subtitle" = "Consultez votre classement parmis vos amis.";
@ -150,6 +147,7 @@
"bet_status_participants_list" = "Liste des participants"; "bet_status_participants_list" = "Liste des participants";
"bet_status_details_drawer" = "Détails"; "bet_status_details_drawer" = "Détails";
"participation_possible_winnings" = "Gains possibles"; "participation_possible_winnings" = "Gains possibles";
"bet_status_stake" = "Pariés";
/// Bet history /// Bet history

@ -8,7 +8,7 @@ struct DetailsView: View {
@StateObject private var viewModel: DetailsViewModel @StateObject private var viewModel: DetailsViewModel
var isFinished: Bool { var isFinished: Bool {
viewModel.betDetail?.finalAnswer == nil ? false : true viewModel.betDetail?.wonParticipation == nil ? false : true
} }
var StatusValues: (String, Color) { var StatusValues: (String, Color) {
@ -110,7 +110,7 @@ struct DetailsView: View {
.cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0) .cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0)
if isFinished { if isFinished {
ResultBanner() ResultBanner(finalAnswer: (viewModel.betDetail?.wonParticipation)!, odds: (viewModel.betDetail?.odds)!)
} }
VStack(alignment: .leading, spacing: 5) { VStack(alignment: .leading, spacing: 5) {
BetLineLoading(participations: viewModel.betDetail?.participations ?? []) BetLineLoading(participations: viewModel.betDetail?.participations ?? [])

@ -7,5 +7,21 @@
<key>NSExtensionPointIdentifier</key> <key>NSExtensionPointIdentifier</key>
<string>com.apple.widgetkit-extension</string> <string>com.apple.widgetkit-extension</string>
</dict> </dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>codefirst.iut.uca.fr</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict> </dict>
</plist> </plist>

@ -63,6 +63,8 @@ public class FactoryApiBet: FactoryBet {
} }
var participations: [Participation] = [] var participations: [Participation] = []
var wonParticipation: Participation?
var userParticipation: Participation?
if let participationsJson = json["participations"] as? [[String: Any]] { if let participationsJson = json["participations"] as? [[String: Any]] {
do { do {
@ -82,7 +84,22 @@ public class FactoryApiBet: FactoryBet {
} }
} }
return BetDetail(bet: bet, answers: answers, participations: participations) if let participationJson = json["wonParticipation"] as? [String: Any] {
do {
wonParticipation = try JSONDecoder().decode(Participation.self, from: JSONSerialization.data(withJSONObject: participationJson))
} catch {
print("Error decoding participations: \(error)")
}
}
if let participationUserJson = json["userParticipation"] as? [String: Any] {
do {
userParticipation = try JSONDecoder().decode(Participation.self, from: JSONSerialization.data(withJSONObject: participationUserJson))
} catch {
print("Error decoding participations: \(error)")
}
}
return BetDetail(bet: bet, answers: answers, participations: participations, wonParticipation: wonParticipation, userParticipation: userParticipation)
} }
public func betTypeString(fromType type: String) -> String { public func betTypeString(fromType type: String) -> String {

@ -20,7 +20,19 @@ public class BetDetail: ObservableObject {
public private(set) var participations: [Participation] public private(set) var participations: [Participation]
/// The final answer selected for the bet, if available. /// The final answer selected for the bet, if available.
public private(set) var finalAnswer: String? public private(set) var wonParticipation: Participation?
public private(set) var userParticipation: Participation?
public var odds: Float? {
guard let wonParticipation = self.wonParticipation else {
return nil
}
if let matchingAnswer = self.answers.first(where: { $0.response == wonParticipation.answer }) {
return matchingAnswer.odds
} else {
return nil
}
}
/// Custom Constructor /// Custom Constructor
/// ///
@ -29,18 +41,19 @@ public class BetDetail: ObservableObject {
/// - answers: Details about the answers available for the bet. /// - answers: Details about the answers available for the bet.
/// - participations: List of user participations in the bet. /// - participations: List of user participations in the bet.
/// - finalAnswer: The final answer selected for the bet, if available. /// - finalAnswer: The final answer selected for the bet, if available.
public init(bet: Bet, answers: [AnswerDetail], participations: [Participation], finalAnswer: String? = nil) { public init(bet: Bet, answers: [AnswerDetail], participations: [Participation], wonParticipation: Participation? = nil, userParticipation: Participation? = nil) {
self.bet = bet self.bet = bet
self.answers = answers self.answers = answers
self.participations = participations self.participations = participations
self.finalAnswer = finalAnswer self.wonParticipation = wonParticipation
self.userParticipation = userParticipation
} }
/// Updates the final answer selected for the bet. /// Updates the final answer selected for the bet.
/// ///
/// - Parameter newFinalAnswer: The new final answer for the bet. /// - Parameter newFinalAnswer: The new final answer for the bet.
public func updateFinalAnswer(newFinalAnswer: String) { public func updateFinalAnswer(wonParticipation: Participation) {
self.finalAnswer = newFinalAnswer self.wonParticipation = wonParticipation
} }
/// Adds a new user participation to the list of participations for the bet. /// Adds a new user participation to the list of participations for the bet.

@ -91,7 +91,7 @@ struct Stub {
} }
public mutating func add(bet: Bet) { public mutating func add(bet: Bet) {
let newBetDetail = BetDetail(bet: bet, answers: [], participations: [], finalAnswer: "test") let newBetDetail = BetDetail(bet: bet, answers: [], participations: [])
self.betsDetail.append(newBetDetail) self.betsDetail.append(newBetDetail)
} }
} }

Loading…
Cancel
Save