Add DropDownMenuView

pull/7/head
Emre KARTAL 2 years ago
parent a9d586ac82
commit ca1f4a9814

@ -25,6 +25,7 @@
EC3737E62AC41DB000E6BDB5 /* WinModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E52AC41DB000E6BDB5 /* WinModal.swift */; }; EC3737E62AC41DB000E6BDB5 /* WinModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E52AC41DB000E6BDB5 /* WinModal.swift */; };
EC3737E82AC5A53B00E6BDB5 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E72AC5A53B00E6BDB5 /* AllcoinsCapsule.swift */; }; EC3737E82AC5A53B00E6BDB5 /* AllcoinsCapsule.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E72AC5A53B00E6BDB5 /* AllcoinsCapsule.swift */; };
EC3737EA2AC5A58B00E6BDB5 /* RecapBetCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC3737E92AC5A58B00E6BDB5 /* RecapBetCard.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 */; }; EC46D7DD2ABCCC270030AC04 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC46D7DC2ABCCC270030AC04 /* MenuView.swift */; };
EC46D7DF2ABCE0A20030AC04 /* ParameterMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC46D7DE2ABCE0A20030AC04 /* ParameterMenuView.swift */; }; EC46D7DF2ABCE0A20030AC04 /* ParameterMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC46D7DE2ABCE0A20030AC04 /* ParameterMenuView.swift */; };
EC50BF962ABF4D3300197685 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC50BF952ABF4D3300197685 /* SplashScreen.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; }; 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; }; 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; }; 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; }; 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; }; 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; }; 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 */, EC3737E72AC5A53B00E6BDB5 /* AllcoinsCapsule.swift */,
EC3737E92AC5A58B00E6BDB5 /* RecapBetCard.swift */, EC3737E92AC5A58B00E6BDB5 /* RecapBetCard.swift */,
EC31955D2ACD3B8E00D0A4DC /* ConfidentialityView.swift */, EC31955D2ACD3B8E00D0A4DC /* ConfidentialityView.swift */,
EC4163502AE126B3001E620D /* DropDownMenuView.swift */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@ -416,6 +419,7 @@
EC3737EA2AC5A58B00E6BDB5 /* RecapBetCard.swift in Sources */, EC3737EA2AC5A58B00E6BDB5 /* RecapBetCard.swift in Sources */,
EC55565D2AD6E5B900E5CA3F /* AuthService.swift in Sources */, EC55565D2AD6E5B900E5CA3F /* AuthService.swift in Sources */,
D98C4D662AB9D017007A6B4D /* ContentView.swift in Sources */, D98C4D662AB9D017007A6B4D /* ContentView.swift in Sources */,
EC4163512AE126B3001E620D /* DropDownMenuView.swift in Sources */,
ECCD6DD92AD7228B00F947C4 /* Singleton.swift in Sources */, ECCD6DD92AD7228B00F947C4 /* Singleton.swift in Sources */,
D92EC57C2ABADA2800CCD30E /* CoinCounterView.swift in Sources */, D92EC57C2ABADA2800CCD30E /* CoinCounterView.swift in Sources */,
EC3737E42AC2F5FB00E6BDB5 /* ChoiceCapsule.swift in Sources */, EC3737E42AC2F5FB00E6BDB5 /* ChoiceCapsule.swift in Sources */,

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@ -11,7 +11,7 @@ struct ContentView: View {
var body: some View { var body: some View {
NavigationView { NavigationView {
Welcome() Home(page: "CreationBet")
} }
} }
} }

@ -19,6 +19,7 @@ struct AllinColor {
static let StartBackground = Color("StartBackground") static let StartBackground = Color("StartBackground")
static let blueAccent = Color("BlueAccent") static let blueAccent = Color("BlueAccent")
static let TopBarColorPink = Color("TopBarColorPink") static let TopBarColorPink = Color("TopBarColorPink")
static let GrayTextColor = Color("GrayTextColor")
static let VeryLightGray = Color("VeryLightGray") static let VeryLightGray = Color("VeryLightGray")
static let StartTextColor = Color("StartTextColor") static let StartTextColor = Color("StartTextColor")
static let LightPurple = Color("LightPurple") static let LightPurple = Color("LightPurple")

@ -27,10 +27,10 @@ struct CreationBet: View {
@State private var values: [String] = [] @State private var values: [String] = []
@State private var selectedOption = 0 @State private var selectedOption = 0
let options: [(String, String)] = [ let options: [(Int, String, String)] = [
("globe", "image1"), (0, "globe", "Oui / Non"),
("futbol", "image2"), (1, "futbol", "Pari sportif"),
("paintbrush", "image3") (2, "paintbrush", "Réponses personnalisées")
] ]
var body: some View { var body: some View {
@ -55,7 +55,7 @@ struct CreationBet: View {
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 9) RoundedRectangle(cornerRadius: 9)
.fill(Color.white) .fill(.white)
.frame(height: 40) .frame(height: 40)
) )
.frame(width: 350, height: 40) .frame(width: 350, height: 40)
@ -215,35 +215,39 @@ struct CreationBet: View {
.tag(0) .tag(0)
VStack(alignment: .leading, spacing: 5) { VStack(alignment: .leading, spacing: 5) {
Picker("Sélectionnez une option", selection: $selectedOption) {
ForEach(0..<options.count, id: \.self) { index in
let (imageName, text) = options[index]
HStack {
Image(imageName)
.resizable()
.scaledToFit()
.frame(width: 30, height: 30)
Text(text)
VStack() {
DropDownMenuView(selectedOption: $selectedOption, options: options)
} }
.background(Color.white) .padding([.bottom], 15)
}
}
.pickerStyle(MenuPickerStyle())
Group {
switch selectedOption {
case 0:
Text("Les utilisateurs devront répondre au pari avec OUI ou NON.") Text("Les utilisateurs devront répondre au pari avec OUI ou NON.")
.font(.system(size: 13)) .font(.system(size: 13))
.fontWeight(.bold) .fontWeight(.bold)
.padding(.leading, 35) .padding(.leading, 40)
.foregroundColor(AllinColor.PurpleLight) .foregroundColor(AllinColor.PurpleLight)
Text("Aucune autre réponse ne sera acceptée.") Text("Aucune autre réponse ne sera acceptée.")
.font(.system(size: 13)) .font(.system(size: 13))
.fontWeight(.bold) .fontWeight(.bold)
.padding(.leading, 35) .padding(.leading, 40)
.foregroundColor(AllinColor.PurpleLight) .foregroundColor(AllinColor.PurpleLight)
case 2:
VStack { Text("Vous allez renseigner les différentes réponses disponibles dans ce pari.")
.font(.system(size: 13))
.fontWeight(.bold)
.padding(.leading, 40)
.foregroundColor(AllinColor.PurpleLight)
Text("Faites attention a etre claire et éviter toutes incertitudes")
.font(.system(size: 13))
.fontWeight(.bold)
.padding(.leading, 40)
.padding(.bottom, 15)
.foregroundColor(AllinColor.PurpleLight)
VStack(spacing: 5) {
HStack(spacing: 0) { HStack(spacing: 0) {
TextField("", text: $response, prompt: Text("Intitulé de réponse").foregroundColor(AllinColor.PlaceholderLightGrayColor).font(.system(size: 16)).fontWeight(.medium)) TextField("", text: $response, prompt: Text("Intitulé de réponse").foregroundColor(AllinColor.PlaceholderLightGrayColor).font(.system(size: 16)).fontWeight(.medium))
.padding() .padding()
@ -263,7 +267,7 @@ struct CreationBet: View {
Button(action: { Button(action: {
if !response.isEmpty { if !response.isEmpty && values.count < 5 {
values.append(response) values.append(response)
response = "" response = ""
} }
@ -276,11 +280,19 @@ struct CreationBet: View {
.cornerRadius(10, corners: [.bottomRight, .topRight]) .cornerRadius(10, corners: [.bottomRight, .topRight])
.cornerRadius(2, corners: [.bottomLeft, .topLeft]) .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) { HStack(spacing: 10) {
ForEach(values, id: \.self) { text in ForEach(values, id: \.self) { text in
HStack { HStack {
Text(text) Text(text)
.foregroundColor(.white) .foregroundColor(.white)
.lineLimit(1)
Button(action: { Button(action: {
if let index = values.firstIndex(of: text) { if let index = values.firstIndex(of: text) {
values.remove(at: index) values.remove(at: index)
@ -299,7 +311,10 @@ struct CreationBet: View {
} }
} }
} }
.padding() default:
Text("En attente")
}
}
Spacer() Spacer()
} }
.padding([.leading, .trailing, .bottom], 30) .padding([.leading, .trailing, .bottom], 30)
@ -335,5 +350,4 @@ struct CreationBet: View {
} }
.edgesIgnoringSafeArea(.bottom).background(AllinColor.backgroundWhite) .edgesIgnoringSafeArea(.bottom).background(AllinColor.backgroundWhite)
} }
} }

@ -254,11 +254,7 @@ struct Register: View {
func isValidEmail(email: String) -> Bool func isValidEmail(email: String) -> Bool
{ {
if(email.range(of:"^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", options: .regularExpression) != nil) { return email.range(of:"^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", options: .regularExpression) == nil
return false
} else {
return true
}
} }
func cleanError() { func cleanError() {
@ -266,5 +262,4 @@ struct Register: View {
errorMail = false errorMail = false
errorUsername = false errorUsername = false
} }
} }

@ -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..<options.count, id: \.self) { index in
if options[index].0 != selectedOption {
Button(action: {self.selectedOption = options[index].0
self.expand.toggle()}) {
HStack{
Image(options[index].1)
.resizable()
.scaledToFit()
.frame(width: 15, height: 15)
Text(options[index].2).fontWeight(.bold).foregroundColor(AllinColor.PrimaryTextColor).font(.system(size: 15))
Spacer()
}
}
.padding(.bottom, 15)
}
}
}
.padding([.leading, .trailing], 15)
}
})
.frame(width: 345)
.background(.white)
.cornerRadius(10)
}
}

@ -9,11 +9,9 @@ import SwiftUI
@main @main
struct AllInApp: App { struct AllInApp: App {
//@StateObject var auth = AuthService()
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView() ContentView()
// .environmentObject(auth)
} }
} }
} }

Loading…
Cancel
Save