change logic displayng modal

pull/16/head
Lucas DELANIER 1 year ago
parent 57786190c8
commit a940c747d7

@ -8,7 +8,9 @@
import SwiftUI import SwiftUI
struct BetCard: View { struct BetCard: View {
@State var showDetails: Bool = false
var body: some View { var body: some View {
ZStack{
VStack(spacing: 0){ VStack(spacing: 0){
VStack(alignment: .leading,spacing: 2){ VStack(alignment: .leading,spacing: 2){
HStack{ HStack{
@ -39,29 +41,7 @@ struct BetCard: View {
Spacer() Spacer()
}.padding(0) }.padding(0)
Button { ParticipateButton().padding(.top, 5)
} 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)
).padding([.top],5)
} }
.frame(width: .infinity) .frame(width: .infinity)
@ -70,6 +50,12 @@ struct BetCard: View {
.cornerRadius(20, corners: [.bottomLeft,.bottomRight]) .cornerRadius(20, corners: [.bottomLeft,.bottomRight])
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
} }
}.onTapGesture {
showDetails.toggle()
}.fullScreenCover(isPresented: $showDetails) {
DetailsView(isModalPresented: $showDetails)
}
} }
} }

@ -9,7 +9,30 @@ import SwiftUI
struct ParticipateButton: View { struct ParticipateButton: View {
var body: some 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)
)
} }
} }

@ -11,6 +11,7 @@ struct RecapBetCard: View {
@GestureState private var longPressTap = false @GestureState private var longPressTap = false
@State private var isPressed = false @State private var isPressed = false
@State var showDetails: Bool = false
var body: some View { var body: some View {
VStack(spacing: 0){ VStack(spacing: 0){
VStack(alignment: .leading,spacing: 2){ VStack(alignment: .leading,spacing: 2){
@ -104,6 +105,11 @@ struct RecapBetCard: View {
.padding(.bottom,0).border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) .padding(.bottom,0).border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
}.scaleEffect(longPressTap ? 0.97 : 1.0) }.scaleEffect(longPressTap ? 0.97 : 1.0)
.animation(.easeInOut, value: longPressTap) .animation(.easeInOut, value: longPressTap)
.onTapGesture {
showDetails.toggle()
}.fullScreenCover(isPresented: $showDetails) {
DetailsView(isModalPresented: $showDetails)
}
.gesture( .gesture(
LongPressGesture(minimumDuration: 0.5) LongPressGesture(minimumDuration: 0.5)
.updating($longPressTap) { value, state, _ in .updating($longPressTap) { value, state, _ in

@ -9,7 +9,29 @@ import SwiftUI
struct ResultBanner: View { struct ResultBanner: View {
var body: some 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))
} }
} }

@ -8,6 +8,7 @@
import SwiftUI import SwiftUI
struct ReviewCard: View { struct ReviewCard: View {
@State var showDetails: Bool = false
var amountBetted: Int var amountBetted: Int
var isAWin: Bool var isAWin: Bool
@ -67,5 +68,10 @@ struct ReviewCard: View {
) .cornerRadius(20, corners: [.bottomLeft,.bottomRight]) ) .cornerRadius(20, corners: [.bottomLeft,.bottomRight])
.border(width: 1, edges: [.top], color: AllInColors.delimiterGrey) .border(width: 1, edges: [.top], color: AllInColors.delimiterGrey)
} }
.onTapGesture {
showDetails.toggle()
}.fullScreenCover(isPresented: $showDetails) {
DetailsView(isModalPresented: $showDetails)
}
} }
} }

@ -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)
)
}
}

@ -47,6 +47,7 @@ struct AllInColors {
static let lightGrey300Color = Color("LightGrey300Color") static let lightGrey300Color = Color("LightGrey300Color")
static let componentBackgroundColor = Color("ComponentBackgroundColor") static let componentBackgroundColor = Color("ComponentBackgroundColor")
static let underComponentBackgroundColor = Color("UnderComponentBackgroundColor") static let underComponentBackgroundColor = Color("UnderComponentBackgroundColor")
static let winBannerBackground = Color("WinBannerBackground")
// Gradients // Gradients
static let primaryGradient = LinearGradient( static let primaryGradient = LinearGradient(

@ -23,6 +23,10 @@ class LoginViewModel: ObservableObject {
func login() { func login() {
#if DEBUG
self.onLoginSuccess()
#endif
guard checkAndSetError(forLogin: true, forPassword: true) else { guard checkAndSetError(forLogin: true, forPassword: true) else {
return return
} }

@ -11,12 +11,14 @@ struct BetView: View {
@StateObject private var viewModel = BetViewModel() @StateObject private var viewModel = BetViewModel()
@Binding var showMenu: Bool @Binding var showMenu: Bool
@State private var showingSheet = false @State var showingSheet: Bool = false
var body: some View { var body: some View {
ZStack(){
VStack(alignment: .center, spacing: 0) { VStack(alignment: .center, spacing: 0) {
TopBar(showMenu: self.$showMenu) TopBar(showMenu: self.$showMenu)
ScrollView(showsIndicators: false) { ScrollView(showsIndicators: false) {
LazyVStack(alignment: .leading, spacing: 0, pinnedViews: [.sectionHeaders]) { LazyVStack(alignment: .leading, spacing: 0, pinnedViews: [.sectionHeaders]) {
@ -25,14 +27,11 @@ struct BetView: View {
Section { Section {
VStack(spacing: 20){ VStack(spacing: 20){
BetCard()
BetCard() BetCard()
Button("Show Sheet") { Button("Show Sheet") {
showingSheet.toggle() showingSheet.toggle()
} }
.sheet(isPresented: $showingSheet) {
WinModal()
}
} }
.padding([.leading,.trailing],25) .padding([.leading,.trailing],25)
@ -56,16 +55,21 @@ struct BetView: View {
} }
} }
} }
.sheet(isPresented: $showingSheet) {
WinModal()
}
Spacer() Spacer()
} }
.edgesIgnoringSafeArea(.bottom) .edgesIgnoringSafeArea(.bottom)
.background(AllInColors.backgroundColor) .background(AllInColors.backgroundColor)
}
} }
} }
struct BetView_Previews: PreviewProvider { struct BetView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
BetView(showMenu: .constant(false)) BetView(showMenu: .constant(false))
.preferredColorScheme(.dark) .preferredColorScheme(.light)
} }
} }

@ -1,18 +1,80 @@
//
// DetailsView.swift
// AllIn
//
// Created by Lucas Delanier on 12/01/2024.
//
import SwiftUI import SwiftUI
struct DetailsView: View { struct DetailsView: View {
@Binding var isModalPresented: Bool
var body: some View { 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()
TextCapsule()
Spacer()
}.padding(.bottom, 10)
HStack{
Text("Fini le").frame(maxWidth: 100).font(.system(size: 15)).foregroundColor(AllInColors.grey800Color)
TextCapsule()
TextCapsule()
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 { struct DetailsView_Previews: PreviewProvider {
DetailsView() static var previews: some View {
ContentView()
}
} }

@ -10,6 +10,7 @@ import SwiftUI
struct MainView: View { struct MainView: View {
@State var showMenu = false @State var showMenu = false
var page: String var page: String
var body: some View { var body: some View {
@ -58,6 +59,7 @@ struct MainView: View {
.frame(width: geometry.size.width*0.83) .frame(width: geometry.size.width*0.83)
.transition(.move(edge: .leading)) .transition(.move(edge: .leading))
} }
} }
.gesture(closeDrag) .gesture(closeDrag)
} }

@ -7,6 +7,9 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */; }; 1244EF602B4EC31E00374ABF /* HistoricBetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */; };
1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; }; 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1244EF612B4EC67000374ABF /* ReviewCard.swift */; };
EC0193782B25BF16005D81E6 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC0193772B25BF16005D81E6 /* AllcoinsCapsule.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; }; 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 = "<group>"; }; 122278B92B4BDE9500E632AA /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Model/Package.swift; sourceTree = "<group>"; };
122278BB2B4BDEC300E632AA /* Sources */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Sources; path = ../StubLib/Sources; sourceTree = "<group>"; }; 122278BB2B4BDEC300E632AA /* Sources */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Sources; path = ../StubLib/Sources; sourceTree = "<group>"; };
123590B32B51792000F7AEBD /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; };
123590B52B5537E200F7AEBD /* ResultBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultBanner.swift; sourceTree = "<group>"; };
123590B72B5541BA00F7AEBD /* ParticipateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticipateButton.swift; sourceTree = "<group>"; };
1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricBetView.swift; sourceTree = "<group>"; }; 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricBetView.swift; sourceTree = "<group>"; };
1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = "<group>"; }; 1244EF612B4EC67000374ABF /* ReviewCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewCard.swift; sourceTree = "<group>"; };
EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = "<group>"; }; EC0193772B25BF16005D81E6 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllcoinsCapsule.swift; sourceTree = "<group>"; };
@ -290,6 +296,7 @@
EC650A512B2794DD003AFCAD /* BetView.swift */, EC650A512B2794DD003AFCAD /* BetView.swift */,
EC7A882C2B28D8A1004F226A /* CreationBetView.swift */, EC7A882C2B28D8A1004F226A /* CreationBetView.swift */,
1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */, 1244EF5F2B4EC31E00374ABF /* HistoricBetView.swift */,
123590B32B51792000F7AEBD /* DetailsView.swift */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@ -316,6 +323,8 @@
ECA9D1C82B2D9ADA0076E0EC /* UserInfo.swift */, ECA9D1C82B2D9ADA0076E0EC /* UserInfo.swift */,
ECA9D1CA2B2DA2320076E0EC /* DropDownFriends.swift */, ECA9D1CA2B2DA2320076E0EC /* DropDownFriends.swift */,
1244EF612B4EC67000374ABF /* ReviewCard.swift */, 1244EF612B4EC67000374ABF /* ReviewCard.swift */,
123590B52B5537E200F7AEBD /* ResultBanner.swift */,
123590B72B5541BA00F7AEBD /* ParticipateButton.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@ -496,6 +505,7 @@
EC30770F2B24FCB00060E34D /* RegisterView.swift in Sources */, EC30770F2B24FCB00060E34D /* RegisterView.swift in Sources */,
EC650A522B2794DD003AFCAD /* BetView.swift in Sources */, EC650A522B2794DD003AFCAD /* BetView.swift in Sources */,
EC6B969C2B24B4CC00FC1C58 /* AllInApp.swift in Sources */, EC6B969C2B24B4CC00FC1C58 /* AllInApp.swift in Sources */,
123590B42B51792000F7AEBD /* DetailsView.swift in Sources */,
ECB26A192B40744F00FE06B3 /* RankingViewModel.swift in Sources */, ECB26A192B40744F00FE06B3 /* RankingViewModel.swift in Sources */,
EC650A502B2793D5003AFCAD /* TextCapsule.swift in Sources */, EC650A502B2793D5003AFCAD /* TextCapsule.swift in Sources */,
EC650A482B25DCFF003AFCAD /* UsersPreview.swift in Sources */, EC650A482B25DCFF003AFCAD /* UsersPreview.swift in Sources */,
@ -518,12 +528,14 @@
EC3077072B24CB840060E34D /* SplashView.swift in Sources */, EC3077072B24CB840060E34D /* SplashView.swift in Sources */,
EC01937E2B25C52E005D81E6 /* TopBar.swift in Sources */, EC01937E2B25C52E005D81E6 /* TopBar.swift in Sources */,
ECA9D1CB2B2DA2320076E0EC /* DropDownFriends.swift in Sources */, ECA9D1CB2B2DA2320076E0EC /* DropDownFriends.swift in Sources */,
123590B82B5541BA00F7AEBD /* ParticipateButton.swift in Sources */,
ECB26A1B2B40746C00FE06B3 /* FriendsViewModel.swift in Sources */, ECB26A1B2B40746C00FE06B3 /* FriendsViewModel.swift in Sources */,
ECB7BC682B2F1ADF002A6654 /* LoginViewModel.swift in Sources */, ECB7BC682B2F1ADF002A6654 /* LoginViewModel.swift in Sources */,
1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */, 1244EF622B4EC67000374ABF /* ReviewCard.swift in Sources */,
EC6B96D52B24BE0E00FC1C58 /* MainView.swift in Sources */, EC6B96D52B24BE0E00FC1C58 /* MainView.swift in Sources */,
EC650A562B279D68003AFCAD /* WinModal.swift in Sources */, EC650A562B279D68003AFCAD /* WinModal.swift in Sources */,
EC6B96D12B24BAE800FC1C58 /* AuthService.swift in Sources */, EC6B96D12B24BAE800FC1C58 /* AuthService.swift in Sources */,
123590B62B5537E200F7AEBD /* ResultBanner.swift in Sources */,
EC01937C2B25C2A8005D81E6 /* AllcoinsCounter.swift in Sources */, EC01937C2B25C2A8005D81E6 /* AllcoinsCounter.swift in Sources */,
EC650A542B279545003AFCAD /* ChoiceCapsule.swift in Sources */, EC650A542B279545003AFCAD /* ChoiceCapsule.swift in Sources */,
ECB7BC6C2B2F43EE002A6654 /* AppState.swift in Sources */, ECB7BC6C2B2F43EE002A6654 /* AppState.swift in Sources */,

Loading…
Cancel
Save