fix error when loading

pull/39/head
Lucas DELANIER 10 months ago
parent 77e6790f59
commit f668388088

@ -187,3 +187,8 @@
"empty_bets_title"= "No bet matches your search"; "empty_bets_title"= "No bet matches your search";
"empty_friends_title" = "You don't have any friends yet"; "empty_friends_title" = "You don't have any friends yet";
"empty_friends_explain" = "Add them from this screen"; "empty_friends_explain" = "Add them from this screen";
/// Error Messages
"error_title" = "Error: Failed to Load Content.";
"error_message" = "The content you are trying to load could not be retrieved. Please check your internet connection and try again";

@ -186,3 +186,8 @@
"empty_bets_title"= "Aucun Bet ne correspond à votre recherche"; "empty_bets_title"= "Aucun Bet ne correspond à votre recherche";
"empty_friends_title" = "Vous navez pas encore damis"; "empty_friends_title" = "Vous navez pas encore damis";
"empty_friends_explain" = "Ajoutez les depuis cet écran"; "empty_friends_explain" = "Ajoutez les depuis cet écran";
/// Error Messages
"error_title" = "Erreur : Échec du chargement du contenu.";
"error_message" = "Le contenu que vous essayez de charger n'a pas pu être récupéré. Veuillez vérifier votre connexion internet et réessayer.";

@ -57,89 +57,105 @@ struct DetailsView: View {
} }
.padding(.horizontal, 15) .padding(.horizontal, 15)
.background(StatusValues.1) .background(StatusValues.1)
if viewModel.betDetail != nil{
VStack(spacing: 0) { ScrollView {
VStack(alignment: .leading, spacing: 5) { VStack(alignment: .leading, spacing: 5) {
HStack(spacing: 3) { HStack(spacing: 3) {
Spacer()
Text("bet_proposed_by_format")
.font(.system(size: 10))
.foregroundColor(AllInColors.grey800Color)
Text((viewModel.betDetail?.bet.author ?? "Unknown").capitalized)
.font(.system(size: 10))
.fontWeight(.semibold)
.foregroundColor(AllInColors.primaryTextColor)
}
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 {
HStack {
Spacer() Spacer()
Text("bet_starting") Text("bet_proposed_by_format")
.font(.system(size: 15)) .font(.system(size: 10))
.foregroundColor(AllInColors.grey800Color) .foregroundColor(AllInColors.grey800Color)
Text((viewModel.betDetail?.bet.author ?? "Unknown").capitalized)
.font(.system(size: 10))
.fontWeight(.semibold)
.foregroundColor(AllInColors.primaryTextColor)
} }
.frame(width: 105) Text(viewModel.betDetail?.bet.theme ?? "Not loaded")
.padding(.trailing, 10) .font(.system(size: 15))
TextCapsule(date: viewModel.betDetail?.bet.endRegisterDate ?? Date()) .foregroundColor(AllInColors.grey800Color)
Spacer() Text(viewModel.betDetail?.bet.phrase ?? "Not loaded")
.font(.system(size: 20))
}.padding(.bottom, 10) .fontWeight(.bold)
HStack { .padding(.bottom, 10)
HStack { HStack {
HStack {
Spacer()
Text("bet_starting")
.font(.system(size: 15))
.foregroundColor(AllInColors.grey800Color)
}
.frame(width: 105)
.padding(.trailing, 10)
TextCapsule(date: viewModel.betDetail?.bet.endRegisterDate ?? Date())
Spacer()
}.padding(.bottom, 10)
HStack {
HStack {
Spacer()
Text("bet_ends")
.font(.system(size: 15))
.foregroundColor(AllInColors.grey800Color)
}
.frame(width: 105)
.padding(.trailing, 10)
TextCapsule(date: viewModel.betDetail?.bet.endBetDate ?? Date())
Spacer() Spacer()
Text("bet_ends")
.font(.system(size: 15))
.foregroundColor(AllInColors.grey800Color)
} }
.frame(width: 105)
.padding(.trailing, 10)
TextCapsule(date: viewModel.betDetail?.bet.endBetDate ?? Date())
Spacer()
} }
} .padding(.all, 15)
.padding(.all, 15) .padding(.top, 6)
.padding(.vertical, 10) .border(width: 1, edges: [.bottom], color: AllInColors.delimiterGrey)
.background(AllInColors.componentBackgroundColor) .background(AllInColors.componentBackgroundColor)
.cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0) .cornerRadius(20, corners: [.topLeft,.topRight])
if isFinished { if isFinished {
ResultBanner(finalAnswer: (viewModel.betDetail?.wonParticipation)!, odds: (viewModel.betDetail?.odds)!) ResultBanner(finalAnswer: (viewModel.betDetail?.wonParticipation)!, odds: (viewModel.betDetail?.odds)!)
}
VStack(alignment: .leading, spacing: 5) {
if let bet = viewModel.betDetail{
BetLineLoading(bet: bet).padding(.vertical, 20)
} }
Text("bet_status_participants_list") VStack(alignment: .leading, spacing: 0) {
.font(.system(size: 18)) if let bet = viewModel.betDetail{
.foregroundStyle(AllInColors.grey100Color) BetLineLoading(bet: bet).padding(.vertical, 20)
.fontWeight(.bold)
.padding(.bottom, 10) }
ScrollView(showsIndicators: false) { Text("bet_status_participants_list")
.font(.system(size: 18))
.foregroundStyle(AllInColors.grey100Color)
.fontWeight(.bold)
.padding(.bottom, 10)
ForEach(viewModel.betDetail?.participations ?? []) { participation in ForEach(viewModel.betDetail?.participations ?? []) { participation in
UserInfo(username: participation.username, picture: nil , value: participation.stake).padding(.horizontal, 10) UserInfo(username: participation.username, picture: nil , value: participation.stake).padding(.horizontal, 10)
} }
.padding(.bottom)
Spacer()
} }
.padding(.bottom, geometry.safeAreaInsets.bottom + 28) .padding([.trailing,.leading], 15)
Spacer()
} }
.padding([.bottom,.trailing,.leading], 15) .frame(maxWidth: .infinity, maxHeight: (geometry.size.height + geometry.safeAreaInsets.bottom) - 50)
.background(AllInColors.underComponentBackgroundColor) .background(AllInColors.underComponentBackgroundColor)
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) .cornerRadius(15, corners: [.topLeft, .topRight])
Spacer() }
else{
ScrollView {
HStack(alignment: .center){
Spacer()
Image(systemName: "exclamationmark.triangle.fill").font(.system(size: 45))
VStack(alignment:.leading){
Text("error_title").font(.system(size: 10))
Text("error_message").font(.system(size: 10))
}
Spacer()
}.opacity(0.6)
.padding(.vertical, 20)
}
.frame(maxWidth: .infinity, maxHeight: (geometry.size.height + geometry.safeAreaInsets.bottom) - 50)
.background(AllInColors.underComponentBackgroundColor)
.cornerRadius(15, corners: [.topLeft, .topRight])
} }
.frame(maxWidth: .infinity, maxHeight: (geometry.size.height + geometry.safeAreaInsets.bottom) - 50)
.background(AllInColors.componentBackgroundColor)
.cornerRadius(15, corners: [.topLeft, .topRight])
ParticipateButton(isOpen: $isModalPresented, isParticapatedOpen: $isModalParticipated, bet: viewModel.betDetail?.bet) ParticipateButton(isOpen: $isModalPresented, isParticapatedOpen: $isModalParticipated, bet: viewModel.betDetail?.bet)
.padding(.bottom, geometry.safeAreaInsets.bottom + 5) .padding(.bottom, geometry.safeAreaInsets.bottom + 5)
@ -150,7 +166,7 @@ struct DetailsView: View {
viewModel.addParticipate() viewModel.addParticipate()
isModalParticipated.toggle() isModalParticipated.toggle()
}, },
checkAndSetError: viewModel.checkAndSetError) checkAndSetError: viewModel.checkAndSetError)
.presentationDetents([.fraction(0.55)]) .presentationDetents([.fraction(0.55)])
} }
.edgesIgnoringSafeArea(.bottom) .edgesIgnoringSafeArea(.bottom)

Loading…
Cancel
Save