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 */; };
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 = "<group>";
@ -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 */,

@ -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 {
NavigationView {
Welcome()
Home(page: "CreationBet")
}
}
}

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

@ -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,35 +215,39 @@ struct CreationBet: View {
.tag(0)
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)
}
}
.pickerStyle(MenuPickerStyle())
.padding([.bottom], 15)
Group {
switch selectedOption {
case 0:
Text("Les utilisateurs devront répondre au pari avec OUI ou NON.")
.font(.system(size: 13))
.fontWeight(.bold)
.padding(.leading, 35)
.padding(.leading, 40)
.foregroundColor(AllinColor.PurpleLight)
Text("Aucune autre réponse ne sera acceptée.")
.font(.system(size: 13))
.fontWeight(.bold)
.padding(.leading, 35)
.padding(.leading, 40)
.foregroundColor(AllinColor.PurpleLight)
VStack {
case 2:
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) {
TextField("", text: $response, prompt: Text("Intitulé de réponse").foregroundColor(AllinColor.PlaceholderLightGrayColor).font(.system(size: 16)).fontWeight(.medium))
.padding()
@ -263,7 +267,7 @@ struct CreationBet: View {
Button(action: {
if !response.isEmpty {
if !response.isEmpty && values.count < 5 {
values.append(response)
response = ""
}
@ -276,11 +280,19 @@ struct CreationBet: View {
.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)
@ -299,7 +311,10 @@ struct CreationBet: View {
}
}
}
.padding()
default:
Text("En attente")
}
}
Spacer()
}
.padding([.leading, .trailing, .bottom], 30)
@ -335,5 +350,4 @@ struct CreationBet: View {
}
.edgesIgnoringSafeArea(.bottom).background(AllinColor.backgroundWhite)
}
}

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

@ -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
struct AllInApp: App {
//@StateObject var auth = AuthService()
var body: some Scene {
WindowGroup {
ContentView()
// .environmentObject(auth)
}
}
}

Loading…
Cancel
Save