diff --git a/Sources/AllInApp/AllIn/Components/BetCard.swift b/Sources/AllInApp/AllIn/Components/BetCard.swift index 9a37c5f..c75b2b7 100644 --- a/Sources/AllInApp/AllIn/Components/BetCard.swift +++ b/Sources/AllInApp/AllIn/Components/BetCard.swift @@ -11,7 +11,8 @@ import Model struct BetCard: View { var bet: Bet - + @State var showDetails: Bool = false + var body: some View { VStack(spacing: 0){ VStack(alignment: .leading,spacing: 2){ @@ -66,13 +67,30 @@ struct BetCard: View { RoundedRectangle(cornerRadius: 12).stroke(AllInColors.delimiterGrey, lineWidth: 1) ).padding([.top],5) + VStack(alignment: .leading,spacing: 2){ + HStack{ + Spacer() + UsersPreview() + Text(" 4 joueurs en attente").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color).fontWeight(.medium) + + Spacer() + + }.padding(0) + ParticipateButton().padding(.top, 5) + + } + .frame(width: .infinity) + .padding(.all,8) + .background(AllInColors.underComponentBackgroundColor) + .cornerRadius(20, corners: [.bottomLeft,.bottomRight]) + .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) } - .frame(width: .infinity) - .padding(.all,8) - .background(AllInColors.underComponentBackgroundColor) - .cornerRadius(20, corners: [.bottomLeft,.bottomRight]) - .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) + }.onTapGesture { + showDetails.toggle() + }.fullScreenCover(isPresented: $showDetails) { + DetailsView(isModalPresented: $showDetails) } + } } diff --git a/Sources/AllInApp/AllIn/Components/ParticipateButton.swift b/Sources/AllInApp/AllIn/Components/ParticipateButton.swift index 5cb234e..16611e5 100644 --- a/Sources/AllInApp/AllIn/Components/ParticipateButton.swift +++ b/Sources/AllInApp/AllIn/Components/ParticipateButton.swift @@ -9,10 +9,29 @@ import SwiftUI struct ParticipateButton: View { var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + Button { + + } label: { + Text("Participer") + .font(.system(size: 30)) + .fontWeight(.bold) + .frame(maxWidth: .infinity).padding(10) + .multilineTextAlignment(.center) + .overlay { + AllInColors.primaryGradient.frame(width: 170) + .mask( + Text("Participer") + .font(.system(size: 30)) + .fontWeight(.bold) + .frame(maxWidth: .infinity).padding(10) + ) + } + } + .accentColor(AllInColors.componentBackgroundColor) + .buttonStyle(.borderedProminent).cornerRadius(4.0) + .overlay( + RoundedRectangle(cornerRadius: 12).stroke(AllInColors.delimiterGrey, lineWidth: 1) + ) + } } - -#Preview { - ParticipateButton() -} diff --git a/Sources/AllInApp/AllIn/Components/RecapBetCard.swift b/Sources/AllInApp/AllIn/Components/RecapBetCard.swift index df1957e..1a47b77 100644 --- a/Sources/AllInApp/AllIn/Components/RecapBetCard.swift +++ b/Sources/AllInApp/AllIn/Components/RecapBetCard.swift @@ -11,6 +11,7 @@ struct RecapBetCard: View { @GestureState private var longPressTap = false @State private var isPressed = false + @State var showDetails: Bool = false var body: some View { VStack(spacing: 0){ VStack(alignment: .leading,spacing: 2){ @@ -103,6 +104,11 @@ struct RecapBetCard: View { .padding(.bottom,0).border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) }.scaleEffect(longPressTap ? 0.97 : 1.0) .animation(.easeInOut, value: longPressTap) + .onTapGesture { + showDetails.toggle() + }.fullScreenCover(isPresented: $showDetails) { + DetailsView(isModalPresented: $showDetails) + } .gesture( LongPressGesture(minimumDuration: 0.5) .updating($longPressTap) { value, state, _ in diff --git a/Sources/AllInApp/AllIn/Components/ResultBanner.swift b/Sources/AllInApp/AllIn/Components/ResultBanner.swift index 2b9b09c..441542f 100644 --- a/Sources/AllInApp/AllIn/Components/ResultBanner.swift +++ b/Sources/AllInApp/AllIn/Components/ResultBanner.swift @@ -9,10 +9,28 @@ import SwiftUI struct ResultBanner: View { var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + 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)) } } - -#Preview { - ResultBanner() -} diff --git a/Sources/AllInApp/AllIn/Components/ReviewCard.swift b/Sources/AllInApp/AllIn/Components/ReviewCard.swift index 7b4754b..001ef16 100644 --- a/Sources/AllInApp/AllIn/Components/ReviewCard.swift +++ b/Sources/AllInApp/AllIn/Components/ReviewCard.swift @@ -8,6 +8,7 @@ import SwiftUI struct ReviewCard: View { + @State var showDetails: Bool = false var amountBetted: Int var isAWin: Bool @@ -66,5 +67,10 @@ struct ReviewCard: View { ) .cornerRadius(20, corners: [.bottomLeft,.bottomRight]) .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) } + .onTapGesture { + showDetails.toggle() + }.fullScreenCover(isPresented: $showDetails) { + DetailsView(isModalPresented: $showDetails) + } } } diff --git a/Sources/AllInApp/AllIn/Extensions/Extensions.swift b/Sources/AllInApp/AllIn/Extensions/Extensions.swift index 74732e0..a79953c 100644 --- a/Sources/AllInApp/AllIn/Extensions/Extensions.swift +++ b/Sources/AllInApp/AllIn/Extensions/Extensions.swift @@ -83,3 +83,42 @@ extension View { } } } + +struct SlideInFromBottomTransition: ViewModifier { + var yOffset: CGFloat + + func body(content: Content) -> some View { + content + .offset(y: yOffset) + .animation(.easeInOut(duration: 0.3)) + } +} + +extension AnyTransition { + static func slideInFromBottom(yOffset: CGFloat) -> AnyTransition { + AnyTransition.modifier( + active: SlideInFromBottomTransition(yOffset: yOffset), + identity: SlideInFromBottomTransition(yOffset: 0) + ) + } +} + +struct SlideOutToBottomTransition: ViewModifier { + var yOffset: CGFloat + + func body(content: Content) -> some View { + content + .offset(y: yOffset) + .opacity(yOffset == 0 ? 1 : 0) + .animation(.easeInOut(duration: 0.3)) + } +} + +extension AnyTransition { + static func slideOutToBottom(yOffset: CGFloat) -> AnyTransition { + AnyTransition.modifier( + active: SlideOutToBottomTransition(yOffset: yOffset), + identity: SlideOutToBottomTransition(yOffset: 0) + ) + } +} diff --git a/Sources/AllInApp/AllIn/Ressources/Colors.swift b/Sources/AllInApp/AllIn/Ressources/Colors.swift index 2f53a3e..a8eba0a 100644 --- a/Sources/AllInApp/AllIn/Ressources/Colors.swift +++ b/Sources/AllInApp/AllIn/Ressources/Colors.swift @@ -47,6 +47,7 @@ struct AllInColors { static let lightGrey300Color = Color("LightGrey300Color") static let componentBackgroundColor = Color("ComponentBackgroundColor") static let underComponentBackgroundColor = Color("UnderComponentBackgroundColor") + static let winBannerBackground = Color("WinBannerBackground") // Gradients static let primaryGradient = LinearGradient( diff --git a/Sources/AllInApp/AllIn/Services/AuthService.swift b/Sources/AllInApp/AllIn/Services/AuthService.swift index 62a99ec..5c75fe3 100644 --- a/Sources/AllInApp/AllIn/Services/AuthService.swift +++ b/Sources/AllInApp/AllIn/Services/AuthService.swift @@ -60,8 +60,7 @@ class AuthService: IAuthService { let json = [ "email": email.lowercased(), "username": username.lowercased(), - "password": password, - "nbCoins": "0" + "password": password ] if let jsonData = try? JSONSerialization.data(withJSONObject: json, options: []){ diff --git a/Sources/AllInApp/AllIn/Views/BetView.swift b/Sources/AllInApp/AllIn/Views/BetView.swift index bc21e48..7a6ef13 100644 --- a/Sources/AllInApp/AllIn/Views/BetView.swift +++ b/Sources/AllInApp/AllIn/Views/BetView.swift @@ -12,7 +12,7 @@ struct BetView: View { @StateObject private var viewModel = BetViewModel() @Binding var showMenu: Bool - @State private var showingSheet = false + @State var showingSheet: Bool = false var body: some View { @@ -31,9 +31,6 @@ struct BetView: View { Button("Show Sheet") { showingSheet.toggle() } - .sheet(isPresented: $showingSheet) { - WinModal() - } } .padding([.leading,.trailing],25) @@ -57,16 +54,21 @@ struct BetView: View { } } } + .sheet(isPresented: $showingSheet) { + WinModal() + } Spacer() } .edgesIgnoringSafeArea(.bottom) .background(AllInColors.backgroundColor) + } } + struct BetView_Previews: PreviewProvider { static var previews: some View { BetView(showMenu: .constant(false)) - .preferredColorScheme(.dark) + .preferredColorScheme(.light) } } diff --git a/Sources/AllInApp/AllIn/Views/DetailsView.swift b/Sources/AllInApp/AllIn/Views/DetailsView.swift index 599844c..6bf0660 100644 --- a/Sources/AllInApp/AllIn/Views/DetailsView.swift +++ b/Sources/AllInApp/AllIn/Views/DetailsView.swift @@ -1,18 +1,80 @@ -// -// DetailsView.swift -// AllIn -// -// Created by Lucas Delanier on 12/01/2024. -// - import SwiftUI struct DetailsView: View { + @Binding var isModalPresented: Bool var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + GeometryReader { geometry in + ZStack(alignment: .bottom) { + VStack(alignment: .trailing) { + HStack{ + Spacer() + Image("CloseiconRounded") + .resizable() + .padding(8) + .frame(maxWidth: 40, maxHeight: 40) + .onTapGesture { + isModalPresented = false + } + } + Spacer() + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(Color.green) + .transition(.slideInFromBottom(yOffset:0)) + VStack(spacing: 0) { + VStack(alignment: .leading,spacing: 5){ + HStack{ + Spacer() + Text("proposé par Lucas").font(.system(size: 10)).foregroundColor(AllInColors.grey800Color) + + } + Text("Etudes").font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) + Text("Emre va réussir son TP de CI/CD mercredi?").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: Date()) + TextCapsule(date: Date()) + Spacer() + + }.padding(.bottom, 10) + HStack{ + Text("Fini le").frame(maxWidth: 100).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color) + TextCapsule(date: Date()) + TextCapsule(date: Date()) + Spacer() + + } + } + .frame(width: .infinity) + .padding(.all,15).padding(.vertical, 10) + .background(AllInColors.componentBackgroundColor).cornerRadius(20, corners: [.topLeft,.topRight]).padding(.bottom,0) + ResultBanner() + VStack(alignment: .leading,spacing: 2){ + + + + } + .frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/, maxHeight : .infinity) + .padding([.bottom,.trailing,.leading],8) + .background(AllInColors.underComponentBackgroundColor) + .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) + Spacer() + + + } + .frame(maxWidth: .infinity, maxHeight: geometry.size.height*0.98) + .background(Color.white) + .cornerRadius(15) + ParticipateButton().padding(10) + } + .transition(.slideInFromBottom(yOffset: 800)) + .edgesIgnoringSafeArea(.bottom) + } } } -#Preview { - DetailsView() +struct DetailsView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } } diff --git a/Sources/AllInApp/AllIn/Views/MainView.swift b/Sources/AllInApp/AllIn/Views/MainView.swift index 790873f..9b7900a 100644 --- a/Sources/AllInApp/AllIn/Views/MainView.swift +++ b/Sources/AllInApp/AllIn/Views/MainView.swift @@ -10,6 +10,7 @@ import SwiftUI struct MainView: View { @State var showMenu = false + var page: String var body: some View { @@ -58,6 +59,7 @@ struct MainView: View { .frame(width: geometry.size.width*0.83) .transition(.move(edge: .leading)) } + } .gesture(closeDrag) } diff --git a/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj b/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj index bde5765..a86ec07 100644 --- a/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj +++ b/Sources/AllInApp/AllInApp.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 123590B42B51792000F7AEBD /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B32B51792000F7AEBD /* DetailsView.swift */; }; + 123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B52B5537E200F7AEBD /* ResultBanner.swift */; }; + 123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */; }; 1244EF602B4EC31E00374ABF /* HistoricBetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */; }; 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; }; EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */; }; @@ -99,6 +102,9 @@ 122278B72B4BDE1100E632AA /* DependencyInjection.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DependencyInjection.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 122278B92B4BDE9500E632AA /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Model/Package.swift; sourceTree = ""; }; 122278BB2B4BDEC300E632AA /* Sources */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Sources; path = ../StubLib/Sources; sourceTree = ""; }; + 123590B32B51792000F7AEBD /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = ""; }; + 123590B52B5537E200F7AEBD /* ResultBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultBanner.swift; sourceTree = ""; }; + 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipateButton.swift; sourceTree = ""; }; 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricBetView.swift; sourceTree = ""; }; 1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = ""; }; EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = ""; }; @@ -290,6 +296,7 @@ EC650A512B2794DD003AFCAD /* BetView.swift */, EC7A882C2B28D8A1004F226A /* CreationBetView.swift */, 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */, + 123590B32B51792000F7AEBD /* DetailsView.swift */, ); path = Views; sourceTree = ""; @@ -316,6 +323,8 @@ ECA9D1C82B2D9ADA0076E0EC /* UserInfo.swift */, ECA9D1CA2B2DA2320076E0EC /* DropDownFriends.swift */, 1244EF612B4EC67000374ABF /* ReviewCard.swift */, + 123590B52B5537E200F7AEBD /* ResultBanner.swift */, + 123590B72B5541BA00F7AEBD /* ParticipateButton.swift */, ); path = Components; sourceTree = ""; @@ -496,6 +505,7 @@ EC30770F2B24FCB00060E34D /* RegisterView.swift in Sources */, EC650A522B2794DD003AFCAD /* BetView.swift in Sources */, EC6B969C2B24B4CC00FC1C58 /* AllInApp.swift in Sources */, + 123590B42B51792000F7AEBD /* DetailsView.swift in Sources */, ECB26A192B40744F00FE06B3 /* RankingViewModel.swift in Sources */, EC650A502B2793D5003AFCAD /* TextCapsule.swift in Sources */, EC650A482B25DCFF003AFCAD /* UsersPreview.swift in Sources */, @@ -518,12 +528,14 @@ EC3077072B24CB840060E34D /* SplashView.swift in Sources */, EC01937E2B25C52E005D81E6 /* TopBar.swift in Sources */, ECA9D1CB2B2DA2320076E0EC /* DropDownFriends.swift in Sources */, + 123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */, ECB26A1B2B40746C00FE06B3 /* FriendsViewModel.swift in Sources */, ECB7BC682B2F1ADF002A6654 /* LoginViewModel.swift in Sources */, 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */, EC6B96D52B24BE0E00FC1C58 /* MainView.swift in Sources */, EC650A562B279D68003AFCAD /* WinModal.swift in Sources */, EC6B96D12B24BAE800FC1C58 /* AuthService.swift in Sources */, + 123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */, EC01937C2B25C2A8005D81E6 /* AllcoinsCounter.swift in Sources */, EC650A542B279545003AFCAD /* ChoiceCapsule.swift in Sources */, ECB7BC6C2B2F43EE002A6654 /* AppState.swift in Sources */,