diff --git a/Sources/allin/allin.xcodeproj/project.pbxproj b/Sources/allin/allin.xcodeproj/project.pbxproj index 30fc174..b8c045a 100644 --- a/Sources/allin/allin.xcodeproj/project.pbxproj +++ b/Sources/allin/allin.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ EC3737E62AC41DB000E6BDB5 /* WinModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E52AC41DB000E6BDB5 /* WinModal.swift */; }; EC3737E82AC5A53B00E6BDB5 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E72AC5A53B00E6BDB5 /* AllcoinsCapsule.swift */; }; EC3737EA2AC5A58B00E6BDB5 /* RecapBetCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E92AC5A58B00E6BDB5 /* RecapBetCard.swift */; }; + EC4163512AE126B3001E620D /* DropDownMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC4163502AE126B3001E620D /* DropDownMenuView.swift */; }; EC46D7DD2ABCCC270030AC04 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC46D7DC2ABCCC270030AC04 /* MenuView.swift */; }; EC46D7DF2ABCE0A20030AC04 /* ParameterMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC46D7DE2ABCE0A20030AC04 /* ParameterMenuView.swift */; }; EC50BF962ABF4D3300197685 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC50BF952ABF4D3300197685 /* SplashScreen.swift */; }; @@ -85,6 +86,7 @@ EC3737E52AC41DB000E6BDB5 /* WinModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WinModal.swift; path = allin/Screens/WinModal.swift; sourceTree = SOURCE_ROOT; }; EC3737E72AC5A53B00E6BDB5 /* AllcoinsCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AllcoinsCapsule.swift; path = allin/Views/AllcoinsCapsule.swift; sourceTree = SOURCE_ROOT; }; EC3737E92AC5A58B00E6BDB5 /* RecapBetCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RecapBetCard.swift; path = allin/Views/RecapBetCard.swift; sourceTree = SOURCE_ROOT; }; + EC4163502AE126B3001E620D /* DropDownMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DropDownMenuView.swift; path = allin/Views/DropDownMenuView.swift; sourceTree = SOURCE_ROOT; }; EC46D7DC2ABCCC270030AC04 /* MenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuView.swift; path = allin/Views/MenuView.swift; sourceTree = SOURCE_ROOT; }; EC46D7DE2ABCE0A20030AC04 /* ParameterMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ParameterMenuView.swift; path = allin/Views/ParameterMenuView.swift; sourceTree = SOURCE_ROOT; }; EC50BF952ABF4D3300197685 /* SplashScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SplashScreen.swift; path = allin/Screens/SplashScreen.swift; sourceTree = SOURCE_ROOT; }; @@ -147,6 +149,7 @@ EC3737E72AC5A53B00E6BDB5 /* AllcoinsCapsule.swift */, EC3737E92AC5A58B00E6BDB5 /* RecapBetCard.swift */, EC31955D2ACD3B8E00D0A4DC /* ConfidentialityView.swift */, + EC4163502AE126B3001E620D /* DropDownMenuView.swift */, ); path = Views; sourceTree = ""; @@ -416,6 +419,7 @@ EC3737EA2AC5A58B00E6BDB5 /* RecapBetCard.swift in Sources */, EC55565D2AD6E5B900E5CA3F /* AuthService.swift in Sources */, D98C4D662AB9D017007A6B4D /* ContentView.swift in Sources */, + EC4163512AE126B3001E620D /* DropDownMenuView.swift in Sources */, ECCD6DD92AD7228B00F947C4 /* Singleton.swift in Sources */, D92EC57C2ABADA2800CCD30E /* CoinCounterView.swift in Sources */, EC3737E42AC2F5FB00E6BDB5 /* ChoiceCapsule.swift in Sources */, diff --git a/Sources/allin/allin/Assets.xcassets/GrayTextColor.colorset/Contents.json b/Sources/allin/allin/Assets.xcassets/GrayTextColor.colorset/Contents.json new file mode 100644 index 0000000..0e54db2 --- /dev/null +++ b/Sources/allin/allin/Assets.xcassets/GrayTextColor.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x49", + "green" : "0x49", + "red" : "0x49" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x49", + "green" : "0x49", + "red" : "0x49" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/allin/allin/Assets.xcassets/chevron_down.imageset/Contents.json b/Sources/allin/allin/Assets.xcassets/chevron_down.imageset/Contents.json new file mode 100644 index 0000000..2691877 --- /dev/null +++ b/Sources/allin/allin/Assets.xcassets/chevron_down.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "chevron_down.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/allin/allin/Assets.xcassets/chevron_down.imageset/chevron_down.png b/Sources/allin/allin/Assets.xcassets/chevron_down.imageset/chevron_down.png new file mode 100644 index 0000000..86d3dd4 Binary files /dev/null and b/Sources/allin/allin/Assets.xcassets/chevron_down.imageset/chevron_down.png differ diff --git a/Sources/allin/allin/Assets.xcassets/chevron_up.imageset/Contents.json b/Sources/allin/allin/Assets.xcassets/chevron_up.imageset/Contents.json new file mode 100644 index 0000000..17ddf4a --- /dev/null +++ b/Sources/allin/allin/Assets.xcassets/chevron_up.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "chevron_up.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/allin/allin/Assets.xcassets/chevron_up.imageset/chevron_up.png b/Sources/allin/allin/Assets.xcassets/chevron_up.imageset/chevron_up.png new file mode 100644 index 0000000..5920d34 Binary files /dev/null and b/Sources/allin/allin/Assets.xcassets/chevron_up.imageset/chevron_up.png differ diff --git a/Sources/allin/allin/ContentView.swift b/Sources/allin/allin/ContentView.swift index f5b2673..30cfc89 100644 --- a/Sources/allin/allin/ContentView.swift +++ b/Sources/allin/allin/ContentView.swift @@ -11,7 +11,7 @@ struct ContentView: View { var body: some View { NavigationView { - Welcome() + Home(page: "CreationBet") } } } diff --git a/Sources/allin/allin/Ressources/Colors.swift b/Sources/allin/allin/Ressources/Colors.swift index 11690c9..9befaa0 100644 --- a/Sources/allin/allin/Ressources/Colors.swift +++ b/Sources/allin/allin/Ressources/Colors.swift @@ -19,6 +19,7 @@ struct AllinColor { static let StartBackground = Color("StartBackground") static let blueAccent = Color("BlueAccent") static let TopBarColorPink = Color("TopBarColorPink") + static let GrayTextColor = Color("GrayTextColor") static let VeryLightGray = Color("VeryLightGray") static let StartTextColor = Color("StartTextColor") static let LightPurple = Color("LightPurple") diff --git a/Sources/allin/allin/Screens/CreationBetScreen.swift b/Sources/allin/allin/Screens/CreationBetScreen.swift index b7b85df..ff481d5 100644 --- a/Sources/allin/allin/Screens/CreationBetScreen.swift +++ b/Sources/allin/allin/Screens/CreationBetScreen.swift @@ -27,10 +27,10 @@ struct CreationBet: View { @State private var values: [String] = [] @State private var selectedOption = 0 - let options: [(String, String)] = [ - ("globe", "image1"), - ("futbol", "image2"), - ("paintbrush", "image3") + let options: [(Int, String, String)] = [ + (0, "globe", "Oui / Non"), + (1, "futbol", "Pari sportif"), + (2, "paintbrush", "Réponses personnalisées") ] var body: some View { @@ -55,7 +55,7 @@ struct CreationBet: View { .padding() .background( RoundedRectangle(cornerRadius: 9) - .fill(Color.white) + .fill(.white) .frame(height: 40) ) .frame(width: 350, height: 40) @@ -215,91 +215,106 @@ struct CreationBet: View { .tag(0) VStack(alignment: .leading, spacing: 5) { - Picker("Sélectionnez une option", selection: $selectedOption) { - ForEach(0.. 20 { response = String(newValue.prefix(20)) } } - - - Button(action: { - if !response.isEmpty { - values.append(response) - response = "" - } - }) { - Text("Ajouter") - .foregroundColor(.white) - } - .frame(width: 95, height: 40) - .background(AllinColor.PrimaryTextColor) - .cornerRadius(10, corners: [.bottomRight, .topRight]) - .cornerRadius(2, corners: [.bottomLeft, .topLeft]) - } - HStack(spacing: 10) { - ForEach(values, id: \.self) { text in - HStack { - Text(text) - .foregroundColor(.white) + + Button(action: { - if let index = values.firstIndex(of: text) { - values.remove(at: index) + if !response.isEmpty && values.count < 5 { + values.append(response) + response = "" } }) { - Image("cross") - .resizable() - .frame(width: 10, height: 10) + Text("Ajouter") .foregroundColor(.white) } + .frame(width: 95, height: 40) + .background(AllinColor.PrimaryTextColor) + .cornerRadius(10, corners: [.bottomRight, .topRight]) + .cornerRadius(2, corners: [.bottomLeft, .topLeft]) + } + HStack { + Spacer() + Text("encore \(5 - values.count) max.") + .font(.system(size: 12)) + .fontWeight(.regular) + .foregroundColor(AllinColor.GrayTextColor) + } + HStack(spacing: 10) { + ForEach(values, id: \.self) { text in + HStack { + Text(text) + .foregroundColor(.white) + .lineLimit(1) + Button(action: { + if let index = values.firstIndex(of: text) { + values.remove(at: index) + } + }) { + Image("cross") + .resizable() + .frame(width: 10, height: 10) + .foregroundColor(.white) + } + } + .padding(5) + .padding([.leading, .trailing], 8) + .background(AllinColor.PrimaryTextColor) + .cornerRadius(16) + } } - .padding(5) - .padding([.leading, .trailing], 8) - .background(AllinColor.PrimaryTextColor) - .cornerRadius(16) } + default: + Text("En attente") } } - .padding() Spacer() } .padding([.leading, .trailing, .bottom], 30) @@ -335,5 +350,4 @@ struct CreationBet: View { } .edgesIgnoringSafeArea(.bottom).background(AllinColor.backgroundWhite) } - } diff --git a/Sources/allin/allin/Screens/RegisterScreen.swift b/Sources/allin/allin/Screens/RegisterScreen.swift index 5628870..af6e149 100644 --- a/Sources/allin/allin/Screens/RegisterScreen.swift +++ b/Sources/allin/allin/Screens/RegisterScreen.swift @@ -254,11 +254,7 @@ struct Register: View { func isValidEmail(email: String) -> Bool { - if(email.range(of:"^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", options: .regularExpression) != nil) { - return false - } else { - return true - } + return email.range(of:"^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", options: .regularExpression) == nil } func cleanError() { @@ -266,5 +262,4 @@ struct Register: View { errorMail = false errorUsername = false } - } diff --git a/Sources/allin/allin/Views/DropDownMenuView.swift b/Sources/allin/allin/Views/DropDownMenuView.swift new file mode 100644 index 0000000..b5627ee --- /dev/null +++ b/Sources/allin/allin/Views/DropDownMenuView.swift @@ -0,0 +1,61 @@ +// +// DropDownMenuView.swift +// AllIn +// +// Created by étudiant on 19/10/2023. +// + +import SwiftUI + +struct DropDownMenuView: View { + + @State var expand = false + @Binding var selectedOption: Int + var options: [(Int, String, String)] + + var body: some View { + VStack(spacing: 0, content: { + Button(action: { self.expand.toggle() }) { + HStack{ + Image(options[selectedOption].1) + .resizable() + .scaledToFit() + .frame(width: 15, height: 15) + Text(options[selectedOption].2).fontWeight(.bold).foregroundColor(AllinColor.PrimaryTextColor).font(.system(size: 15)) + Spacer() + Image(expand ? "chevron_up" : "chevron_down").resizable().frame(width: 15, height: 10).scaledToFill() + } + .padding([.leading, .trailing], 15) + .frame(height: 43) + } + if expand { + Rectangle() + .frame(height: 1) + .foregroundColor(AllinColor.VeryLightGray) + .padding(.bottom, 18) + VStack(spacing: 0) { + ForEach(0..