From e32d032d3ca8d20e074c1884d60d73b90c7ec616 Mon Sep 17 00:00:00 2001 From: Lucas DELANIER Date: Thu, 30 May 2024 10:20:30 +0200 Subject: [PATCH] empty informations (#26) Co-authored-by: ludelanier Reviewed-on: https://codefirst.iut.uca.fr/git/AllDev/Apple/pulls/26 --- .../AllInApp/AllIn/Components/EmptyInfo.swift | 25 +++++++++++++++++++ Sources/AllInApp/AllIn/Views/BetView.swift | 11 +++++--- .../AllInApp/AllIn/Views/FriendsView.swift | 14 +++++++---- .../AllInApp.xcodeproj/project.pbxproj | 4 +++ 4 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 Sources/AllInApp/AllIn/Components/EmptyInfo.swift diff --git a/Sources/AllInApp/AllIn/Components/EmptyInfo.swift b/Sources/AllInApp/AllIn/Components/EmptyInfo.swift new file mode 100644 index 0000000..365b61f --- /dev/null +++ b/Sources/AllInApp/AllIn/Components/EmptyInfo.swift @@ -0,0 +1,25 @@ +// +// EmptyInfo.swift +// AllIn +// +// Created by Lucas Delanier on 29/05/2024. +// + +import SwiftUI + +struct EmptyInfo: View { + let emoji: String + let title: String + let explain: String + var body: some View { + VStack{ + Text(emoji).font(.system(size: 120)) + Text(title).textStyle(weight: .bold, color: .black, size: 15) + explain.isEmpty ? nil : Text(explain).textStyle(weight: .light, color: .gray, size: 12) + }.opacity(0.55).padding(.horizontal, 20).multilineTextAlignment(.center) + } +} + +#Preview { + EmptyInfo(emoji:"👥", title: "Vous n’avez pas encore d’amis", explain: "Ajoutez les depuis cet écran") +} diff --git a/Sources/AllInApp/AllIn/Views/BetView.swift b/Sources/AllInApp/AllIn/Views/BetView.swift index 80e8630..e0f0dc4 100644 --- a/Sources/AllInApp/AllIn/Views/BetView.swift +++ b/Sources/AllInApp/AllIn/Views/BetView.swift @@ -18,14 +18,19 @@ struct BetView: View { VStack(alignment: .center, spacing: 0) { TopBar(showMenu: self.$showMenu) ScrollView(showsIndicators: false) { - LazyVStack(alignment: .leading, spacing: 0, pinnedViews: [.sectionHeaders]) { + LazyVStack(alignment: .center, spacing: 0, pinnedViews: [.sectionHeaders]) { TrendingBetCard().padding(.top,25).padding([.leading,.trailing],25) Section { VStack(spacing: 20){ - ForEach(viewModel.bets, id: \.id) { (bet: Bet) in - BetCard(bet: bet) + if(viewModel.bets.isEmpty){ + EmptyInfo(emoji:"🎮", title: "Aucun Bet ne correspond à votre recherche", explain: "") + } + else{ + ForEach(viewModel.bets, id: \.id) { (bet: Bet) in + BetCard(bet: bet) + } } } .padding([.leading,.trailing],25) diff --git a/Sources/AllInApp/AllIn/Views/FriendsView.swift b/Sources/AllInApp/AllIn/Views/FriendsView.swift index 3166e5f..324ddca 100644 --- a/Sources/AllInApp/AllIn/Views/FriendsView.swift +++ b/Sources/AllInApp/AllIn/Views/FriendsView.swift @@ -45,13 +45,17 @@ struct FriendsView: View { ) .padding(.horizontal, 10) } - - ScrollView(showsIndicators: false){ - ForEach(viewModel.users, id: \.self) { friend in - Friend(user: friend, viewModel: viewModel) + if(viewModel.users.isEmpty){ + EmptyInfo(emoji:"👥", title: "Vous n’avez pas encore d’amis", explain: "Ajoutez les depuis cet écran").padding(.top, 40) + } + else{ + ScrollView(showsIndicators: false){ + ForEach(viewModel.users, id: \.self) { friend in + Friend(user: friend, viewModel: viewModel) + } } + .padding(.top, 25) } - .padding(.top, 25) Spacer() } .edgesIgnoringSafeArea(.bottom) diff --git a/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj b/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj index 089de38..5cc5531 100644 --- a/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj +++ b/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 1244EF602B4EC31E00374ABF /* HistoricBetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */; }; 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; }; 129D051D2B6E7FF0003D3E08 /* OddCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129D051C2B6E7FF0003D3E08 /* OddCapsule.swift */; }; + 12A9E4942C07132600AB8677 /* EmptyInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12A9E4932C07132600AB8677 /* EmptyInfo.swift */; }; 12C370482B5A5EE500CD9F0F /* BetLineLoading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */; }; 12C3704A2B5D5BD000CD9F0F /* ParticipationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C370492B5D5BD000CD9F0F /* ParticipationCell.swift */; }; EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */; }; @@ -155,6 +156,7 @@ 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricBetView.swift; sourceTree = ""; }; 1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = ""; }; 129D051C2B6E7FF0003D3E08 /* OddCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OddCapsule.swift; sourceTree = ""; }; + 12A9E4932C07132600AB8677 /* EmptyInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyInfo.swift; sourceTree = ""; }; 12C370472B5A5EE500CD9F0F /* BetLineLoading.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetLineLoading.swift; sourceTree = ""; }; 12C370492B5D5BD000CD9F0F /* ParticipationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipationCell.swift; sourceTree = ""; }; EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = ""; }; @@ -430,6 +432,7 @@ 12C370492B5D5BD000CD9F0F /* ParticipationCell.swift */, 123225DA2B67E41400D30BB3 /* ChoiceFinalAnswerCell.swift */, 129D051C2B6E7FF0003D3E08 /* OddCapsule.swift */, + 12A9E4932C07132600AB8677 /* EmptyInfo.swift */, ); path = Components; sourceTree = ""; @@ -676,6 +679,7 @@ EC650A482B25DCFF003AFCAD /* UsersPreview.swift in Sources */, EC17A15E2B6A955E008A8679 /* CurrentBetView.swift in Sources */, EC7EF7482B87E3E00022B5D9 /* Delegates.swift in Sources */, + 12A9E4942C07132600AB8677 /* EmptyInfo.swift in Sources */, EC650A462B25D686003AFCAD /* RankingRow.swift in Sources */, EC01937A2B25C12B005D81E6 /* BetCard.swift in Sources */, EC650A422B25C817003AFCAD /* Friend.swift in Sources */,