Ajout de l'historique, du menu principale et de style un peu partout 💥

gameBranch^2
Pierre FERREIRA 11 months ago
parent ade74defe5
commit 95efe097dd

@ -18,6 +18,8 @@
7B4508EA2BF206B10027E1EF /* DouShouQiIOSUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4508E92BF206B10027E1EF /* DouShouQiIOSUITestsLaunchTests.swift */; };
7B4508F72BF2084B0027E1EF /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4508F62BF2084B0027E1EF /* PlayerView.swift */; };
7B4508FA2BF214F50027E1EF /* PlayerListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4508F92BF214F50027E1EF /* PlayerListView.swift */; };
7BDD43C72BFCC927003984FB /* MainMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDD43C62BFCC927003984FB /* MainMenuView.swift */; };
7BDD43C92BFCD2C4003984FB /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDD43C82BFCD2C4003984FB /* HistoryView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -52,6 +54,8 @@
7B4508E92BF206B10027E1EF /* DouShouQiIOSUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DouShouQiIOSUITestsLaunchTests.swift; sourceTree = "<group>"; };
7B4508F62BF2084B0027E1EF /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = "<group>"; };
7B4508F92BF214F50027E1EF /* PlayerListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerListView.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>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -160,6 +164,8 @@
children = (
7B4508F62BF2084B0027E1EF /* PlayerView.swift */,
7B4508F92BF214F50027E1EF /* PlayerListView.swift */,
7BDD43C62BFCC927003984FB /* MainMenuView.swift */,
7BDD43C82BFCD2C4003984FB /* HistoryView.swift */,
);
path = View;
sourceTree = "<group>";
@ -302,8 +308,10 @@
buildActionMask = 2147483647;
files = (
7B4508F72BF2084B0027E1EF /* PlayerView.swift in Sources */,
7BDD43C72BFCC927003984FB /* MainMenuView.swift in Sources */,
7B4508CF2BF206AF0027E1EF /* ContentView.swift in Sources */,
7B4508CD2BF206AF0027E1EF /* DouShouQiIOSApp.swift in Sources */,
7BDD43C92BFCD2C4003984FB /* HistoryView.swift in Sources */,
7B3B17642BF24B32002BC817 /* Player.swift in Sources */,
7B3B17672BF24ED6002BC817 /* FullButtonStyle.swift in Sources */,
7B4508FA2BF214F50027E1EF /* PlayerListView.swift in Sources */,

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Doushouqi_Logo.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: 81 KiB

@ -11,7 +11,9 @@ import SwiftUI
struct DouShouQiIOSApp: App {
var body: some Scene {
WindowGroup {
ContentView()
NavigationStack {
MainMenuView()
}
}
}
}

@ -0,0 +1,109 @@
//
// HistoryView.swift
// DouShouQiIOS
//
// Created by Pierre FERREIRA on 21/05/2024.
//
import SwiftUI
struct HistoryView: View {
var playerName: String
var matches: [Match] // Modèle des parties du joueur
var body: some View {
VStack{
Text("Historique du joueur").font(.largeTitle)
HStack{
Spacer()
HStack{
Text("Ratio")
.frame(height: 50, alignment: .center)
.padding([.leading, .trailing], 20)
.background(Color.yellow)
.foregroundColor(Color.white)
.bold()
.cornerRadius(15)
Text("0,3")
.foregroundColor(.yellow)
.padding([.leading], 10)
.padding([.trailing], 20)
}.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.yellow, lineWidth: 3)
)
Spacer()
HStack{
Text("Total")
.frame(height: 50, alignment: .center)
.padding([.leading, .trailing], 20)
.background(Color.yellow)
.foregroundColor(Color.white)
.bold()
.cornerRadius(15)
Text("\(matches.count)")
.foregroundColor(.yellow)
.padding([.leading], 10)
.padding([.trailing], 20)
}.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.yellow, lineWidth: 3)
)
Spacer()
}
List(matches) { match in
HStack {
Image(match.gameEndScreen)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 50, height: 50)
.cornerRadius(8)
VStack(alignment: .leading) {
Text(match.opponent)
.font(.headline)
Text("Score: \(match.score)")
.font(.subheadline)
}
.padding(.leading, 10)
Spacer()
Text(match.result)
.foregroundColor(match.result == "Victoire" ? .green : .red)
.padding(.trailing, 10)
}
.padding()
.background(match.result == "Victoire" ? Color.green.opacity(0.3) : Color.red.opacity(0.3))
.cornerRadius(10)
}
.navigationTitle("\(playerName)'s Historique")
}
}
}
struct Match: Identifiable {
var id = UUID()
var gameEndScreen: String
var opponent: String
var score: String
var result: String
}
struct HistoryView_Previews: PreviewProvider {
static var previews: some View {
let sampleMatches = [
Match(gameEndScreen: "DouShouQi", opponent: "Opponent 1", score: "3-0", result: "Victoire"),
Match(gameEndScreen: "DouShouQi", opponent: "Opponent 2", score: "0-3", result: "Défaite"),
Match(gameEndScreen: "DouShouQi", opponent: "Opponent 3", score: "2-2", result: "Nul")
]
HistoryView(playerName: "bro", matches: sampleMatches)
}
}

@ -0,0 +1,82 @@
//
// MainMenuView.swift
// DouShouQiIOS
//
// Created by Pierre FERREIRA on 21/05/2024.
//
import SwiftUI
struct MainMenuView: View {
var body: some View {
VStack {
Image("DouShouQi")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 200)
Text("DouShouQi")
.font(.largeTitle)
.bold()
.padding()
Button(action: {
// Action pour Jouer Seul
print("Jouer Seul tapped!")
}) {
Text("Jouer Seul")
.font(.title2)
.padding()
.background(Color.yellow)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding(.top, 10)
Button(action: {
// Action pour Jouer en Multi
print("Jouer en Multi tapped!")
}) {
Text("Jouer en Multi")
.font(.title2)
.padding()
.background(Color.yellow)
.foregroundColor(.white)
.cornerRadius(8)
}
NavigationLink(destination: PlayerListView()) {
Text("Leaderboard")
.font(.title2)
.padding()
.background(Color.yellow)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding(.top, 20)
Button(action: {
// Quitter
print("Quitter tapped!")
}
) {
Text("Quitter")
.font(.title2)
.padding()
.foregroundColor(.yellow)
}.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(.yellow, lineWidth: 3)
)
.padding(.top, 20)
}.navigationBarBackButtonHidden(true)
}
}
struct MainMenuView_Previews: PreviewProvider {
static var previews: some View {
MainMenuView()
}
}

@ -9,12 +9,13 @@ import SwiftUI
struct PlayerListView: View {
var body: some View {
ZStack{
//Rectangle().fill(Color.yellow)
VStack{
Text("Classement des joueurs")
.scaleEffect(1.75)
NavigationStack {
NavigationStack {
ZStack {
//Rectangle().fill(Color.yellow)
VStack {
/*Text("Classement des joueurs")
.scaleEffect(1.75)*/
List {
NavigationLink("Billy", value: "Billy")
NavigationLink("Bob", value: "Bob")
@ -22,17 +23,29 @@ struct PlayerListView: View {
}
.background(Color.yellow)
.navigationDestination(for: String.self) { name in
PlayerView(name: name)
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: "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
}
.navigationTitle("Leaderboard")
}
}.background(Color.yellow)
Button("Menu") {
print("About tapped!")
}.buttonStyle(FullButtonStyle())
.background(Color.yellow)
VStack {
Spacer()
NavigationLink(destination: MainMenuView().navigationBarBackButtonHidden(true)) {
Text("Menu")
.font(.title2)
.padding()
.background(Color.yellow)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding(.bottom, 20)
}
}
}
}
}

@ -8,18 +8,23 @@
import SwiftUI
struct PlayerView: View {
var Player : Player;
var name : String;
//var Player : Player;
var name : String
var age: Int
var winLossRatio: Double
var gamesPlayed: Int
var wins: Int
var losses: Int
var histoMatches : [ Match ]
var body: some View {
ZStack{
Rectangle().fill(Color.orange.opacity(0.1))
/*Rectangle().fill(Color.orange.opacity(0.1))*/
VStack{
Text("Détail du joueur").font(.title)
HStack{
VStack{
Image("Blob")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 100, height: 100)
.clipShape(Circle())
.overlay(Circle().strokeBorder(Color.orange, lineWidth: 2))
.scaleEffect(1)
@ -27,18 +32,32 @@ struct PlayerView: View {
Spacer()
VStack(alignment: .leading){
Text("\(name)").font(.largeTitle)
Text("Sname :").font(.title2)
Text("Age :")
Text("Classement :")
} .frame(width: 200, height: 150)
.background(Color.orange.opacity(0.3))
.cornerRadius(15)
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))
)
}.frame(width: 200, height: 150)
}.padding(20)
}.frame(maxWidth: .infinity)
.padding(20)
.background(Color.yellow)
.cornerRadius(15)
.cornerRadius(50)
.shadow(color: .gray, radius: 3, x: 2, y: 2)
.padding(20)
Spacer()
@ -47,16 +66,27 @@ struct PlayerView: View {
Text("Statistiques")
.fontWeight(.heavy)
.font(.largeTitle)
.foregroundColor(Color.yellow)
Grid{
GridRow{
HStack{
Text("Nombre de victoires").frame(width: 100, height: 50, alignment: .center)
Text("Nombre de victoires")
.frame(height: 50, alignment: .center)
.padding([.leading, .trailing], 20)
.background(Color.yellow)
.cornerRadius(15)
Text("9")
.foregroundColor(.yellow)
.padding([.leading, .trailing], 10)
}
} .frame(width: 150)
.background(Color.orange.opacity(0.3))
.cornerRadius(15)
}
.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.yellow, lineWidth: 5)
)
GridRow{
HStack{
@ -84,21 +114,40 @@ struct PlayerView: View {
}
.foregroundStyle(.white)
.background(Color.yellow)
.cornerRadius(15)
.padding(20)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(.yellow, lineWidth: 5)
)
.padding(20)
Spacer()
}.padding(20)
NavigationLink(destination: HistoryView(playerName: name, matches: histoMatches)) {
Text("Historique")
.font(.title2)
.padding()
.background(Color.yellow)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding(.top, 20)
}
}
}
}
struct PlayerView_Previews: PreviewProvider {
static var previews: some View {
var player1 = new Player(Player(withName: "Meruemu", andSName: "Roi", andId: 2, andAge: 1)
PlayerView(name: "bro", player1)
/*var player1 = new Player(Player(withName: "Meruemu", andSName: "Roi", andId: 2, andAge: 1)*/
let stubedMatches = [
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")
]
PlayerView(name: "bro", age: 18, winLossRatio: 1.0, gamesPlayed: 10, wins: 5, losses: 5, histoMatches : stubedMatches)
}
}

Loading…
Cancel
Save