From ca1f4a9814a878685f565abba169894633544aa1 Mon Sep 17 00:00:00 2001 From: "emre.kartal" Date: Thu, 19 Oct 2023 18:32:51 +0200 Subject: [PATCH] Add DropDownMenuView --- Sources/allin/allin.xcodeproj/project.pbxproj | 4 + .../GrayTextColor.colorset/Contents.json | 38 ++++ .../chevron_down.imageset/Contents.json | 21 +++ .../chevron_down.imageset/chevron_down.png | Bin 0 -> 2229 bytes .../chevron_up.imageset/Contents.json | 21 +++ .../chevron_up.imageset/chevron_up.png | Bin 0 -> 2147 bytes Sources/allin/allin/ContentView.swift | 2 +- Sources/allin/allin/Ressources/Colors.swift | 1 + .../allin/Screens/CreationBetScreen.swift | 166 ++++++++++-------- .../allin/allin/Screens/RegisterScreen.swift | 7 +- .../allin/allin/Views/DropDownMenuView.swift | 61 +++++++ Sources/allin/allin/allinApp.swift | 2 - 12 files changed, 238 insertions(+), 85 deletions(-) create mode 100644 Sources/allin/allin/Assets.xcassets/GrayTextColor.colorset/Contents.json create mode 100644 Sources/allin/allin/Assets.xcassets/chevron_down.imageset/Contents.json create mode 100644 Sources/allin/allin/Assets.xcassets/chevron_down.imageset/chevron_down.png create mode 100644 Sources/allin/allin/Assets.xcassets/chevron_up.imageset/Contents.json create mode 100644 Sources/allin/allin/Assets.xcassets/chevron_up.imageset/chevron_up.png create mode 100644 Sources/allin/allin/Views/DropDownMenuView.swift 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 0000000000000000000000000000000000000000..86d3dd447812723c0e3b39b8935580a45c8f92e5 GIT binary patch literal 2229 zcmWlbdpuO@9>&L*VP=ZfjLX>4SdEp|A?#Ef2isiMT#VZ!Nk}fGHgbtlB2A`kjk0Uh zK@Nr3bTP4|qfLcyq>~+;q*9JcH)R-3bk%v+A8W1mectE!{yy*Jv({3{{Ut^WO9qKV zGV+#Ufh3Y19kh#R2H3lda`tDDv7kjgt+ubC8ZWX)JqMN2uPYftGA#-*~Rzc zlSmCGmwb()l1Ma}H^vV-pf~k=n}3+Zv`x3JTYS(r{lA)WEkhRkUZMV48t&U7f5D9!e`^(E6=pH>uW!X}bKkw&Y3?l6zeisG>h#!uFsPOD z9$)Zus+-0#oiY~>WYnaxN5_w)&TeV;w12U`kHWi{$GvjnUi+r$@Q|F!`1<985$Ug1 zz8*cV>6)uI_qy6*{M>HYU{YL~Tjpr!Y+$QL#AmNRX7V%A$Nm;(C>s4tj@mPUe6r=+W7O(2(3+Vv^jo~Ao`uQo%S((!pv@LUyN%dZP1Erf=OPi2>-ZHPP zJQRBTR;>x9=B(bk<1u zPIiCz&E#g?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3bf`Wl*<}G2#=aFVF4cSO^jtOg z#JlIf1uAeXF<=spV{P`kd+*Mf!mFc=oAg}+(c3zX)?6u}OqVN$Yn~+J1ZKJ1{TLIq zc}!>KyQGFVrR}{^?HXp5rp}+K6r3NwbD~PL_`86ZozcGc7EHc~ejk(CIH^@sbKCmP z&3aSFO>5`Ru5j62diYh!}zHM6}sze$IIC2c9vOg^pk{43-f) G(*Fxn+G`sC literal 0 HcmV?d00001 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..