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

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

@ -32,6 +32,9 @@ struct NavButton<D1:View>: View {
} }
} }
#Preview { struct NavButton_Previews: PreviewProvider {
static var previews: some View {
NavButton("Menu princ", destinationView: {MainMenuView()}) 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,6 +13,8 @@ struct MainMenuView: View {
var body: some View { var body: some View {
NavigationStack { NavigationStack {
ZStack {
Rectangle().fill(Color.bgColor).ignoresSafeArea()
VStack { VStack {
Image("DouShouQi") Image("DouShouQi")
.resizable() .resizable()
@ -42,16 +44,17 @@ struct MainMenuView: View {
Text("Quitter") Text("Quitter")
.font(.title2) .font(.title2)
.padding() .padding()
.foregroundColor(.yellow) .foregroundColor(.fontColor)
}.overlay( }.overlay(
RoundedRectangle(cornerRadius: 10) RoundedRectangle(cornerRadius: 10)
.stroke(.yellow, lineWidth: 3) .stroke(Color.primaryColor, lineWidth: 3)
) )
.padding(.top, 20) .padding(.top, 20)
}.navigationBarBackButtonHidden(true) }.navigationBarBackButtonHidden(true)
} }
} }
}
} }
struct MainMenuView_Previews: PreviewProvider { struct MainMenuView_Previews: PreviewProvider {

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

@ -6,6 +6,8 @@
// //
import SwiftUI import SwiftUI
import DouShouQiModel
struct PlayerView: View { struct PlayerView: View {
//var Player : Player; //var Player : Player;
@ -17,10 +19,13 @@ struct PlayerView: View {
var losses: Int var losses: Int
var histoMatches : [ Match ] var histoMatches : [ Match ]
@State var isEdited : Bool = false
//@ObservedObject var player : PlayerVM //TODO
var body: some View { var body: some View {
ZStack{ //ZStack{
/*Rectangle().fill(Color.orange.opacity(0.1))*/ //Rectangle().fill(Color.bgColor).ignoresSafeArea()
NavigationStack{ VStack{
VStack{ VStack{
Image("Blob") Image("Blob")
.resizable() .resizable()
@ -54,7 +59,7 @@ struct PlayerView: View {
}.frame(maxWidth: .infinity) }.frame(maxWidth: .infinity)
.padding(20) .padding(20)
.background(Color.yellow) .background(Color.primaryColor)
.cornerRadius(50) .cornerRadius(50)
.shadow(color: .gray, radius: 3, x: 2, y: 2) .shadow(color: .gray, radius: 3, x: 2, y: 2)
.padding(20) .padding(20)
@ -66,43 +71,23 @@ struct PlayerView: View {
Text("Statistiques") Text("Statistiques")
.fontWeight(.heavy) .fontWeight(.heavy)
.font(.largeTitle) .font(.largeTitle)
.foregroundColor(Color.yellow) .foregroundColor(Color.primaryColor)
Spacer()
Grid{
GridRow{
DoubleTextDisplay(textL: "Nombre de victoires", textR: "9") DoubleTextDisplay(textL: "Nombre de victoires", textR: "9")
}
DoubleTextDisplay(textL: "Nombre de défaites", textR: "5")
DoubleTextDisplay(textL: "Nombre de parties jouées", textR: "14")
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() Spacer()
} }
.foregroundStyle(.white) .foregroundStyle(.white)
.overlay( .overlay(
RoundedRectangle(cornerRadius: 16) RoundedRectangle(cornerRadius: 16)
.stroke(.yellow, lineWidth: 5) .stroke(Color.primaryColor, lineWidth: 5)
) )
.padding(20) .padding(20)
@ -111,8 +96,15 @@ struct PlayerView: View {
NavButton("Historique", destinationView: {HistoryView(playerName: name, matches: histoMatches)}) NavButton("Historique", destinationView: {HistoryView(playerName: name, matches: histoMatches)})
.padding(.top, 20) .padding(.top, 20)
} }
.toolbar {
//ToolbarItemGroup(placement: .bottomBar) {
Button(action: {isEdited.toggle()}, label: {Text("Edit")})
//}
} }
.sheet(isPresented: $isEdited, content: {
Text("CouCou")
})
//}//Zstack
} }
} }

Loading…
Cancel
Save