ajout de la navigation avec debut du modal pour le binding

SpriteKit
Pierre FERREIRA 11 months ago
parent 149fe33a0f
commit 19bdf51b2f

@ -25,6 +25,8 @@
7BB279892BFDF79E00491801 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BB279882BFDF79E00491801 /* GameView.swift */; };
7BDD43C72BFCC927003984FB /* MainMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDD43C62BFCC927003984FB /* MainMenuView.swift */; };
7BDD43C92BFCD2C4003984FB /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDD43C82BFCD2C4003984FB /* HistoryView.swift */; };
7BDE976D2C0E13160079F2CD /* EditModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDE976C2C0E13160079F2CD /* EditModalView.swift */; };
7BDE976F2C0E18160079F2CD /* PlayerVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDE976E2C0E18160079F2CD /* PlayerVM.swift */; };
7BE8C5652C09A29A00A6E8C9 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BE8C5642C09A29A00A6E8C9 /* Color.swift */; };
BA5AFD332C09C7470056D332 /* ClassicTextDisplay.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA5AFD322C09C7470056D332 /* ClassicTextDisplay.swift */; };
BA5AFD352C09CAC10056D332 /* NavButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA5AFD342C09CAC10056D332 /* NavButton.swift */; };
@ -71,6 +73,8 @@
7BB279882BFDF79E00491801 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = "<group>"; };
7BDD43C62BFCC927003984FB /* MainMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuView.swift; sourceTree = "<group>"; };
7BDD43C82BFCD2C4003984FB /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = "<group>"; };
7BDE976C2C0E13160079F2CD /* EditModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditModalView.swift; sourceTree = "<group>"; };
7BDE976E2C0E18160079F2CD /* PlayerVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerVM.swift; sourceTree = "<group>"; };
7BE8C5642C09A29A00A6E8C9 /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
BA5AFD322C09C7470056D332 /* ClassicTextDisplay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassicTextDisplay.swift; sourceTree = "<group>"; };
BA5AFD342C09CAC10056D332 /* NavButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavButton.swift; sourceTree = "<group>"; };
@ -109,6 +113,7 @@
7B3B17632BF24B32002BC817 /* Player.swift */,
7B6426F62C00B81400575E16 /* GameScene.swift */,
7B6426FA2C00BFF500575E16 /* SpriteMeeple.swift */,
7BDE976E2C0E18160079F2CD /* PlayerVM.swift */,
);
path = Class;
sourceTree = "<group>";
@ -149,7 +154,6 @@
7BE8C5632C09A27600A6E8C9 /* Extension */,
7B3B17652BF24EB1002BC817 /* Struct */,
7B3B17622BF24B23002BC817 /* Class */,
7BB801372BF2374C00413951 /* Style */,
7B4508CC2BF206AF0027E1EF /* DouShouQiIOSApp.swift */,
7B4508CE2BF206AF0027E1EF /* ContentView.swift */,
7B4508D02BF206B10027E1EF /* Assets.xcassets */,
@ -193,6 +197,7 @@
7BDD43C82BFCD2C4003984FB /* HistoryView.swift */,
7BB279882BFDF79E00491801 /* GameView.swift */,
7B6426F82C00BDEA00575E16 /* SpriteKitView.swift */,
7BDE976C2C0E13160079F2CD /* EditModalView.swift */,
);
path = View;
sourceTree = "<group>";
@ -206,13 +211,6 @@
name = Frameworks;
sourceTree = "<group>";
};
7BB801372BF2374C00413951 /* Style */ = {
isa = PBXGroup;
children = (
);
path = Style;
sourceTree = "<group>";
};
7BE8C5632C09A27600A6E8C9 /* Extension */ = {
isa = PBXGroup;
children = (
@ -369,6 +367,8 @@
7B6426FB2C00BFF500575E16 /* SpriteMeeple.swift in Sources */,
7B4508CD2BF206AF0027E1EF /* DouShouQiIOSApp.swift in Sources */,
7B6426F92C00BDEA00575E16 /* SpriteKitView.swift in Sources */,
7BDE976D2C0E13160079F2CD /* EditModalView.swift in Sources */,
7BDE976F2C0E18160079F2CD /* PlayerVM.swift in Sources */,
BA5AFD392C09D1020056D332 /* DoubleTextDisplay.swift in Sources */,
BA5AFD332C09C7470056D332 /* ClassicTextDisplay.swift in Sources */,
BA5AFD352C09CAC10056D332 /* NavButton.swift in Sources */,

@ -0,0 +1,17 @@
//
// PlayerVM.swift
// DouShouQiIOS
//
// Created by Pierre FERREIRA on 03/06/2024.
//
import Foundation
import DouShouQiModel
class PlayerVM : ObservableObject {
@Published var player : Player
public init(player: Player) {
self.player = player
}
}

@ -28,6 +28,10 @@ struct ClassicTextDisplay: View {
}
}
#Preview {
ClassicTextDisplay(text: "test")
struct ClassicTextDisplay_Previews: PreviewProvider {
static var previews: some View {
ClassicTextDisplay(text: "test")
}
}

@ -21,21 +21,25 @@ struct DoubleTextDisplay: View {
Text(textL)
.frame(height: 50, alignment: .center)
.padding([.leading, .trailing], 20)
.background(Color.yellow)
.background(Color.primaryColor)
.foregroundColor(Color.white)
.bold()
.cornerRadius(15)
Text(textR)
.foregroundColor(.yellow)
.foregroundColor(.primaryColor)
.padding([.leading], 10)
.padding([.trailing], 20)
}.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.yellow, lineWidth: 3)
.stroke(Color.primaryColor, lineWidth: 3)
) }
}
#Preview {
DoubleTextDisplay(textL: "W/L", textR: "2")
struct DoubleTextDisplay_Previews: PreviewProvider {
static var previews: some View {
DoubleTextDisplay(textL: "W/L", textR: "2")
}
}

@ -32,6 +32,9 @@ struct NavButton<D1:View>: View {
}
}
#Preview {
NavButton("Menu princ", destinationView: {MainMenuView()})
struct NavButton_Previews: PreviewProvider {
static var previews: some View {
NavButton("Menu princ", destinationView: {MainMenuView()})
}
}

@ -20,3 +20,4 @@ struct DouShouQiIOSApp: App {
}
}
}

@ -0,0 +1,26 @@
//
// EditModalView.swift
// DouShouQiIOS
//
// Created by Pierre FERREIRA on 03/06/2024.
//
import SwiftUI
struct EditModalView: View {
@Binding var isEdited : Bool
var name : String = ""
var body: some View {
VStack{
Text("Hello, World!")
TextField("Entrez un nom ici",text: .constant(""))
}
}
}
struct EditModalView_Previews: PreviewProvider {
static var previews: some View {
EditModalView(isEdited: .constant(true))
}
}

@ -13,43 +13,46 @@ struct MainMenuView: View {
var body: some View {
NavigationStack {
VStack {
Image("DouShouQi")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 200)
Text("DouShouQi")
.font(.largeTitle)
.bold()
.padding()
NavButton("Jouer Seul", destinationView: {GameView()})
.padding(.top, 10)
NavButton("Jouer en Multi", destinationView: {GameView()})
NavButton("Leaderboard", destinationView: {PlayerListView()})
.padding(.top, 20)
Button(action: {
// Quitter
print("Quitter tapped!")
}
) {
Text("Quitter")
.font(.title2)
ZStack {
Rectangle().fill(Color.bgColor).ignoresSafeArea()
VStack {
Image("DouShouQi")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 200)
Text("DouShouQi")
.font(.largeTitle)
.bold()
.padding()
.foregroundColor(.yellow)
}.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(.yellow, lineWidth: 3)
)
.padding(.top, 20)
}.navigationBarBackButtonHidden(true)
NavButton("Jouer Seul", destinationView: {GameView()})
.padding(.top, 10)
NavButton("Jouer en Multi", destinationView: {GameView()})
NavButton("Leaderboard", destinationView: {PlayerListView()})
.padding(.top, 20)
Button(action: {
// Quitter
print("Quitter tapped!")
}
) {
Text("Quitter")
.font(.title2)
.padding()
.foregroundColor(.fontColor)
}.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.primaryColor, lineWidth: 3)
)
.padding(.top, 20)
}.navigationBarBackButtonHidden(true)
}
}
}
}

@ -9,19 +9,27 @@ import SwiftUI
struct PlayerListView: View {
var body: some View {
NavigationStack {
//NavigationStack {
ZStack {
//Rectangle().fill(Color.yellow)
Rectangle().fill(Color.bgColor).ignoresSafeArea()
VStack {
/*Text("Classement des joueurs")
.scaleEffect(1.75)*/
List {
NavigationLink("Billy", value: "Billy")
NavigationLink{
PlayerView(name: "Billy", age: 18, winLossRatio: 1.0, gamesPlayed: 10, wins: 5, losses: 5, histoMatches: [
Match(gameEndScreen: "opponent1", opponent: "Opponent 1", score: "3-2", result: "Victoire"),
Match(gameEndScreen: "opponent2", opponent: "Opponent 2", score: "1-3", result: "Défaite"),
Match(gameEndScreen: "opponent3", opponent: "Opponent 3", score: "2-2", result: "Nul")
]) //mettre player plus tard
} label:{Text("pif")}
NavigationLink("Billy", value: "Billyname")
NavigationLink("Bob", value: "Bob")
NavigationLink("Bromingo", value: "Bromingo")
}
.background(Color.yellow)
.navigationDestination(for: String.self) { name in
PlayerView(name: name, age: 18, winLossRatio: 1.0, gamesPlayed: 10, wins: 5, losses: 5, histoMatches: [
Match(gameEndScreen: "opponent1", opponent: "Opponent 1", score: "3-2", result: "Victoire"),
@ -31,7 +39,6 @@ struct PlayerListView: View {
}
.navigationTitle("Leaderboard")
}
.background(Color.yellow)
VStack {
Spacer()
@ -39,7 +46,7 @@ struct PlayerListView: View {
.padding(.bottom, 20)
}
}
}
//}
}
}

@ -6,6 +6,8 @@
//
import SwiftUI
import DouShouQiModel
struct PlayerView: View {
//var Player : Player;
@ -17,102 +19,92 @@ struct PlayerView: View {
var losses: Int
var histoMatches : [ Match ]
@State var isEdited : Bool = false
//@ObservedObject var player : PlayerVM //TODO
var body: some View {
ZStack{
/*Rectangle().fill(Color.orange.opacity(0.1))*/
NavigationStack{
VStack{
Image("Blob")
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(Circle())
.overlay(Circle().strokeBorder(Color.orange, lineWidth: 2))
.scaleEffect(1)
.transformEffect(.identity)
Spacer()
//ZStack{
//Rectangle().fill(Color.bgColor).ignoresSafeArea()
VStack{
VStack{
Image("Blob")
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(Circle())
.overlay(Circle().strokeBorder(Color.orange, lineWidth: 2))
.scaleEffect(1)
.transformEffect(.identity)
VStack(alignment: .center){
Text("\(name) Sname")
.font(.largeTitle)
.foregroundColor(Color.white)
Text("1")
.font(.title2)
.foregroundColor(Color.white)
.frame(width: 35, height: 35, alignment: .center)
.padding(5)
.overlay(
Circle()
.fill(Color.orange.opacity(0.3))
)
Spacer()
VStack(alignment: .center){
Text("\(name) Sname")
.font(.largeTitle)
.foregroundColor(Color.white)
}.frame(width: 200, height: 150)
Text("1")
.font(.title2)
.foregroundColor(Color.white)
.frame(width: 35, height: 35, alignment: .center)
.padding(5)
.overlay(
Circle()
.fill(Color.orange.opacity(0.3))
)
}.frame(maxWidth: .infinity)
}.frame(width: 200, height: 150)
}.frame(maxWidth: .infinity)
.padding(20)
.background(Color.yellow)
.background(Color.primaryColor)
.cornerRadius(50)
.shadow(color: .gray, radius: 3, x: 2, y: 2)
.padding(20)
Spacer()
VStack{
Text("Statistiques")
.fontWeight(.heavy)
.font(.largeTitle)
.foregroundColor(Color.primaryColor)
Spacer()
VStack{
Text("Statistiques")
.fontWeight(.heavy)
.font(.largeTitle)
.foregroundColor(Color.yellow)
Grid{
GridRow{
DoubleTextDisplay(textL: "Nombre de victoires", textR: "9")
}
GridRow{
HStack{
Text("Nombre de défaites").frame(width: 100, height: 50, alignment: .center)
Text("5")
}
} .frame(width: 150)
.background(Color.orange.opacity(0.3))
.cornerRadius(15)
GridRow{
HStack{
Text("Nombre de parties jouées").frame(width: 100, height: 50, alignment: .center)
Text("14")
}
} .frame(width: 150)
.background(Color.orange.opacity(0.3))
.cornerRadius(15)
}.frame(
minWidth: 0,
maxWidth: .infinity,
alignment: .center
)
Spacer()
}
.foregroundStyle(.white)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(.yellow, lineWidth: 5)
)
.padding(20)
DoubleTextDisplay(textL: "Nombre de victoires", textR: "9")
DoubleTextDisplay(textL: "Nombre de défaites", textR: "5")
DoubleTextDisplay(textL: "Nombre de parties jouées", textR: "14")
Spacer()
NavButton("Historique", destinationView: {HistoryView(playerName: name, matches: histoMatches)})
.padding(.top, 20)
}
.foregroundStyle(.white)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(Color.primaryColor, lineWidth: 5)
)
.padding(20)
Spacer()
NavButton("Historique", destinationView: {HistoryView(playerName: name, matches: histoMatches)})
.padding(.top, 20)
}
.toolbar {
//ToolbarItemGroup(placement: .bottomBar) {
Button(action: {isEdited.toggle()}, label: {Text("Edit")})
//}
}
.sheet(isPresented: $isEdited, content: {
Text("CouCou")
})
//}//Zstack
}
}

Loading…
Cancel
Save