🚧 Update: ButtonView

dev_views_SelectPlayer
Nathan VERDIER 11 months ago
parent e799c19d45
commit 6bfe8980f5

@ -16,6 +16,8 @@
645834792BF5F92600E18321 /* DouShouQi_AppUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 645834782BF5F92600E18321 /* DouShouQi_AppUITestsLaunchTests.swift */; };
645834882BF5FEA000E18321 /* DSQ.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 645834872BF5FEA000E18321 /* DSQ.xcframework */; };
645834892BF5FEA000E18321 /* DSQ.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 645834872BF5FEA000E18321 /* DSQ.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
ECDA24872BFFE73E00AFC2AB /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECDA24862BFFE73E00AFC2AB /* ButtonView.swift */; };
ECDA24892BFFE98200AFC2AB /* SelectPlayerButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECDA24882BFFE98200AFC2AB /* SelectPlayerButtonView.swift */; };
ECDE63532BFFD5C900753917 /* SelectPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECDE63522BFFD5C900753917 /* SelectPlayerView.swift */; };
/* End PBXBuildFile section */
@ -63,6 +65,8 @@
645834782BF5F92600E18321 /* DouShouQi_AppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DouShouQi_AppUITestsLaunchTests.swift; sourceTree = "<group>"; };
645834852BF5FE1400E18321 /* DouShouQi-App-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "DouShouQi-App-Info.plist"; sourceTree = SOURCE_ROOT; };
645834872BF5FEA000E18321 /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = DSQ.xcframework; sourceTree = "<group>"; };
ECDA24862BFFE73E00AFC2AB /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = "<group>"; };
ECDA24882BFFE98200AFC2AB /* SelectPlayerButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectPlayerButtonView.swift; sourceTree = "<group>"; };
ECDE63522BFFD5C900753917 /* SelectPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectPlayerView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -171,6 +175,8 @@
649ABF5E2BF60ED5002E8894 /* Components */ = {
isa = PBXGroup;
children = (
ECDA24862BFFE73E00AFC2AB /* ButtonView.swift */,
ECDA24882BFFE98200AFC2AB /* SelectPlayerButtonView.swift */,
);
path = Components;
sourceTree = "<group>";
@ -306,8 +312,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ECDA24892BFFE98200AFC2AB /* SelectPlayerButtonView.swift in Sources */,
6458345E2BF5F92300E18321 /* ContentView.swift in Sources */,
ECDE63532BFFD5C900753917 /* SelectPlayerView.swift in Sources */,
ECDA24872BFFE73E00AFC2AB /* ButtonView.swift in Sources */,
6458345C2BF5F92300E18321 /* DouShouQi_AppApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

@ -1,18 +1,26 @@
//
// ButtonView.swift
// DouShouQi_App
//
// Created by etudiant on 23/05/2024.
//
import SwiftUI
struct ButtonView: View {
var button1Title: String
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
VStack {
Button(action: {
print("\(button1Title) pressé!")
}) {
Text(button1Title)
.frame(width: 200)
.padding()
.background(Color.red)
.foregroundColor(.white)
.cornerRadius(10)
}
}
}
}
#Preview {
ButtonView()
struct ButtonsViewPreviews: PreviewProvider {
static var previews: some View {
ButtonView(button1Title: "Button")
}
}

@ -7,9 +7,95 @@
import SwiftUI
struct CustomShapeLeftButton: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: rect.minX, y: rect.minY)) // coin supérieur gauche
path.addLine(to: CGPoint(x: rect.maxX - 60, y: rect.minY)) // un peu avant le coin supérieur droit
path.addLine(to: CGPoint(x: rect.maxX, y: rect.minY + 60)) // un peu en dessous du coin supérieur droit
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY)) // coin inférieur droit
path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY)) // coin inférieur gauche
path.closeSubpath()
return path
}
}
struct CustomShapeRightButton: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: rect.minX + 60, y: rect.minY)) // un peu à droite du coin supérieur gauche
path.addLine(to: CGPoint(x: rect.maxX, y: rect.minY)) // coin supérieur droit
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY)) // coin inférieur droit
path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY)) // coin inférieur gauche
path.addLine(to: CGPoint(x: rect.minX, y: rect.minY + 60)) // un peu en dessous du coin supérieur gauche
path.closeSubpath()
return path
}
}
struct SelectPlayerButtonView: View {
var player1:String = "IA"
var player2:String = "IA"
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
ZStack{
Image("vs-custom")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 100, height: 100)
.offset(y: -60)
HStack{
VStack (alignment: .leading) {
Text(player1)
.font(.title)
.padding(3)
Button(action: {
print("Button j1 pressé!")
//player1 = "Player1"
}) {
VStack {
Text("+")
.font(.largeTitle)
.bold()
Text("Add a player")
.font(.body)
.bold()
}
.frame(width: 150, height: 150)
.padding()
.border(/*@START_MENU_TOKEN@*/Color.black/*@END_MENU_TOKEN@*/, width: 4)
.foregroundColor(.black)
.foregroundColor(.white)
.cornerRadius(10)
.clipShape(CustomShapeLeftButton())
}
}
VStack (alignment: .trailing) {
Text(player2)
.font(.title)
.padding(3)
Button(action: {
print(" pressé!")
}) {
VStack {
Text("+")
.font(.largeTitle)
.bold()
Text("Add a player")
.font(.body)
.bold()
} .frame(width: 150, height: 150)
.padding()
.foregroundColor(.black)
.border(/*@START_MENU_TOKEN@*/Color.black/*@END_MENU_TOKEN@*/, width: 4)
.foregroundColor(.white)
.cornerRadius(10)
.clipShape(CustomShapeRightButton())
}
}
}
}
}
}

@ -2,7 +2,7 @@
// SelectPlayerView.swift
// DouShouQi_App
//
// Created by etudiant on 23/05/2024.
// Created by nathan on 23/05/2024.
//
import SwiftUI
@ -10,19 +10,32 @@ import SwiftUI
struct SelectPlayerView: View {
var body: some View {
VStack {
Text("Coucou!")
Button(action: {
// Ajoutez ici l'action à effectuer lorsque le bouton est pressé
print("Bouton pressé!")
}) {
Text("Mon Bouton")
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
ZStack {
Image("title-background")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 250, height: 250)
Text("Select Your Player")
.font(.largeTitle)
.foregroundColor(.black)
.bold()
}
SelectPlayerButtonView()
Spacer()
HStack {
Spacer()
VStack(alignment: .trailing)
{
ButtonView(button1Title: "Start")
ButtonView(button1Title: "Setting")
}
}
Spacer()
}
}
}
struct SelectPlayerViewPreviews: PreviewProvider {

Loading…
Cancel
Save