🔀 Merging branch to add MainMenuButton parameters

pull/8/head
Rémi REGNAULT 11 months ago
commit aa2fc70d96

@ -30,6 +30,12 @@
649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B12BF65392002BAE38 /* TextStyles.swift */; }; 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B12BF65392002BAE38 /* TextStyles.swift */; };
649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */; }; 649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */; };
EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */; }; EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */; };
EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4F82C0371660048CD0B /* MusicPlayer.swift */; };
EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FA2C038BD20048CD0B /* PlayersView.swift */; };
EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */; };
EC62C4FF2C0457AD0048CD0B /* TitleScreenMusic.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */; };
EC62C5012C045B590048CD0B /* SoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C5002C045B590048CD0B /* SoundPlayer.swift */; };
EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -90,6 +96,12 @@
649B59B12BF65392002BAE38 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = "<group>"; }; 649B59B12BF65392002BAE38 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = "<group>"; };
649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTitleTextStyle.swift; sourceTree = "<group>"; }; 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTitleTextStyle.swift; sourceTree = "<group>"; };
EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; }; EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
EC62C4F82C0371660048CD0B /* MusicPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicPlayer.swift; sourceTree = "<group>"; };
EC62C4FA2C038BD20048CD0B /* PlayersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersView.swift; sourceTree = "<group>"; };
EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRow.swift; sourceTree = "<group>"; };
EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = TitleScreenMusic.mp3; sourceTree = "<group>"; };
EC62C5002C045B590048CD0B /* SoundPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundPlayer.swift; sourceTree = "<group>"; };
EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = TitleScreenButtonSound.mp3; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -159,6 +171,7 @@
6458345A2BF5F92300E18321 /* DouShouQi_App */ = { 6458345A2BF5F92300E18321 /* DouShouQi_App */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EC62C5022C045BB90048CD0B /* SoundPlayerClass */,
649B59A52BF64B1B002BAE38 /* Assets */, 649B59A52BF64B1B002BAE38 /* Assets */,
649ABF5E2BF60ED5002E8894 /* Components */, 649ABF5E2BF60ED5002E8894 /* Components */,
649ABF592BF60D13002E8894 /* Views */, 649ABF592BF60D13002E8894 /* Views */,
@ -208,6 +221,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
645B4C1F2BFCCA0500FD658A /* PlayerResumeFrame.swift */, 645B4C1F2BFCCA0500FD658A /* PlayerResumeFrame.swift */,
EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */,
); );
path = Player; path = Player;
sourceTree = "<group>"; sourceTree = "<group>";
@ -216,16 +230,25 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
645B4C242BFCD3C600FD658A /* ScoreBoardView.swift */, 645B4C242BFCD3C600FD658A /* ScoreBoardView.swift */,
EC62C4FA2C038BD20048CD0B /* PlayersView.swift */,
); );
path = Player; path = Player;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
6493C1BE2C04650200B5121D /* Menu */ = {
isa = PBXGroup;
children = (
649ABF5A2BF60D78002E8894 /* MainMenuView.swift */,
);
path = Menu;
sourceTree = "<group>";
};
649ABF592BF60D13002E8894 /* Views */ = { 649ABF592BF60D13002E8894 /* Views */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
643AB6992BFCFB480018DA73 /* Game */, 643AB6992BFCFB480018DA73 /* Game */,
645B4C232BFCD39A00FD658A /* Player */, 645B4C232BFCD39A00FD658A /* Player */,
649ABF5A2BF60D78002E8894 /* MainMenuView.swift */, 6493C1BE2C04650200B5121D /* Menu */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@ -244,6 +267,8 @@
649B59A52BF64B1B002BAE38 /* Assets */ = { 649B59A52BF64B1B002BAE38 /* Assets */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EC62C5042C045BE00048CD0B /* Musics */,
EC62C5032C045BD30048CD0B /* Sounds */,
649B59B02BF65360002BAE38 /* TextStyles */, 649B59B02BF65360002BAE38 /* TextStyles */,
649B59AF2BF64F0A002BAE38 /* Colors */, 649B59AF2BF64F0A002BAE38 /* Colors */,
649B59AA2BF64DF1002BAE38 /* Images */, 649B59AA2BF64DF1002BAE38 /* Images */,
@ -278,6 +303,31 @@
path = TextStyles; path = TextStyles;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
EC62C5022C045BB90048CD0B /* SoundPlayerClass */ = {
isa = PBXGroup;
children = (
EC62C5002C045B590048CD0B /* SoundPlayer.swift */,
EC62C4F82C0371660048CD0B /* MusicPlayer.swift */,
);
path = SoundPlayerClass;
sourceTree = "<group>";
};
EC62C5032C045BD30048CD0B /* Sounds */ = {
isa = PBXGroup;
children = (
EC62C5052C045C1A0048CD0B /* TitleScreenButtonSound.mp3 */,
);
path = Sounds;
sourceTree = "<group>";
};
EC62C5042C045BE00048CD0B /* Musics */ = {
isa = PBXGroup;
children = (
EC62C4FE2C0457AD0048CD0B /* TitleScreenMusic.mp3 */,
);
path = Musics;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -384,9 +434,11 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
649B59A72BF64BA9002BAE38 /* Colors.xcassets in Resources */, 649B59A72BF64BA9002BAE38 /* Colors.xcassets in Resources */,
EC62C5062C045C1A0048CD0B /* TitleScreenButtonSound.mp3 in Resources */,
649B59AC2BF64E12002BAE38 /* Images.xcassets in Resources */, 649B59AC2BF64E12002BAE38 /* Images.xcassets in Resources */,
645834632BF5F92500E18321 /* Preview Assets.xcassets in Resources */, 645834632BF5F92500E18321 /* Preview Assets.xcassets in Resources */,
645834602BF5F92500E18321 /* Assets.xcassets in Resources */, 645834602BF5F92500E18321 /* Assets.xcassets in Resources */,
EC62C4FF2C0457AD0048CD0B /* TitleScreenMusic.mp3 in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -415,12 +467,16 @@
6458345E2BF5F92300E18321 /* ContentView.swift in Sources */, 6458345E2BF5F92300E18321 /* ContentView.swift in Sources */,
649B59A92BF64C6A002BAE38 /* Colors.swift in Sources */, 649B59A92BF64C6A002BAE38 /* Colors.swift in Sources */,
649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */, 649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */,
EC62C5012C045B590048CD0B /* SoundPlayer.swift in Sources */,
645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */, 645B4C252BFCD3C600FD658A /* ScoreBoardView.swift in Sources */,
649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */, 649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */,
649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */, 649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */,
643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */, 643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */,
EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */, EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */,
649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */, 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */,
EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */,
EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */,
EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */,
6458345C2BF5F92300E18321 /* DouShouQi_AppApp.swift in Sources */, 6458345C2BF5F92300E18321 /* DouShouQi_AppApp.swift in Sources */,
645B4C202BFCCA0500FD658A /* PlayerResumeFrame.swift in Sources */, 645B4C202BFCCA0500FD658A /* PlayerResumeFrame.swift in Sources */,
649ABF5B2BF60D78002E8894 /* MainMenuView.swift in Sources */, 649ABF5B2BF60D78002E8894 /* MainMenuView.swift in Sources */,

@ -11,4 +11,5 @@ import SwiftUI
public struct Colors { public struct Colors {
static let TitleText = Color("TitleTextColor") static let TitleText = Color("TitleTextColor")
static let Button = Color("ButtonColor") static let Button = Color("ButtonColor")
static let TextButton = Color("ButtonTextColor")
} }

@ -6,3 +6,9 @@
// //
import Foundation import Foundation
import SwiftUI
public struct AppMusic {
static let ScreenTitleMusic = "ScreenTitleMusique"
}

@ -7,11 +7,13 @@
import SwiftUI import SwiftUI
struct MainMenuButton: View { struct MainMenuButton<Destination: View>: View {
// Text Params // Text Params
var text: String var text: String
@State private var isHovered: Bool = false var destination: Destination
var sound: String
// Button Alignment // Button Alignment
var horizontalAlignment: Alignment = .center var horizontalAlignment: Alignment = .center
@ -23,9 +25,7 @@ struct MainMenuButton: View {
var bottomRightCorner: CGFloat = 0 var bottomRightCorner: CGFloat = 0
var body: some View { var body: some View {
Button(action: { NavigationLink(destination: destination) {
// Action du bouton
}, label: {
Text(text.uppercased()) Text(text.uppercased())
.font(.headline) .font(.headline)
.fontWeight(.semibold) .fontWeight(.semibold)
@ -33,18 +33,16 @@ struct MainMenuButton: View {
.padding() .padding()
.frame(maxWidth: .infinity, maxHeight: 40) .frame(maxWidth: .infinity, maxHeight: 40)
.background( .background(
Colors.Button Color.red
.clipShape(RoundedRectangle(cornerSize: CGSize(width: 0, height: 0))) .clipShape(RoundedRectangle(cornerSize: CGSize(width: 0, height: 0)))
.mask(RoundedCornersShape(cornerRadii: (topLeft: topLeftCorner, topRight: topRightCorner, bottomLeft: bottomLeftCorner, bottomRight: bottomRightCorner))) .mask(RoundedCornersShape(cornerRadii: (topLeft: topLeftCorner, topRight: topRightCorner, bottomLeft: bottomLeftCorner, bottomRight: bottomRightCorner)))
) )
}
.simultaneousGesture(TapGesture().onEnded {
playSound(named: sound)
}) })
.frame(width: UIScreen.main.bounds.width / 1.7) .frame(width: UIScreen.main.bounds.width / 1.7)
.frame(maxWidth: .infinity, alignment: horizontalAlignment) .frame(maxWidth: .infinity, alignment: horizontalAlignment)
.scaleEffect(isHovered ? 1.1 : 1.0)
.animation(.easeInOut(duration: 0.2), value: isHovered)
.onHover { hovering in
self.isHovered = hovering
}
} }
} }
@ -94,6 +92,6 @@ struct RoundedCornersShape: Shape {
struct MainMenuButton_Previews: PreviewProvider { struct MainMenuButton_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
MainMenuButton(text: "test", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10) MainMenuButton(text: "test", destination: HistoricView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
} }
} }

@ -0,0 +1,43 @@
//
// PlayerRow.swift
// DouShouQi_App
//
// Created by étudiant on 26/05/2024.
//
import Foundation
import SwiftUI
struct PlayerRow: View {
var player: Player
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(player.name)
.font(.headline)
Text("Victoires : \(player.wins) Défaites : \(player.losses)")
.font(.subheadline)
}
Spacer()
Button(action: {
// Action pour éditer le joueur
}) {
Image(systemName: "pencil")
.foregroundColor(.red)
}
Button(action: {
// Action pour supprimer le joueur
}) {
Image(systemName: "trash")
.foregroundColor(.red)
}
}
.padding()
.background(Color.white)
.cornerRadius(10)
.shadow(radius: 1)
}
}

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

@ -1,8 +0,0 @@
//
// MusicPlayer.swift
// DouShouQi_App
//
// Created by étudiant on 26/05/2024.
//
import Foundation

@ -0,0 +1,34 @@
//
// MusicPlayer.swift
// DouShouQi_App
//
// Created by étudiant on 26/05/2024.
//
import Foundation
import AVFoundation
class MusicPlayer {
static let shared = MusicPlayer()
var audioPlayer: AVAudioPlayer?
func playBackgroundMusic(music: String) {
if let bundle = Bundle.main.path(forResource: music, ofType: "mp3") {
let backgroundMusic = NSURL(fileURLWithPath: bundle)
do {
audioPlayer = try AVAudioPlayer(contentsOf: backgroundMusic as URL)
guard let audioPlayer = audioPlayer else { return }
audioPlayer.numberOfLoops = -1 // Loop indefinitely
audioPlayer.prepareToPlay()
audioPlayer.play()
} catch {
print(error)
}
}
}
func stopBackgroundMusic() {
audioPlayer?.stop()
}
}

@ -0,0 +1,22 @@
//
// SoundPlayer.swift
// DouShouQi_App
//
// Created by étudiant on 27/05/2024.
//
import Foundation
import AVFoundation
var audioPlayer: AVAudioPlayer?
func playSound(named soundName: String) {
guard let url = Bundle.main.url(forResource: soundName, withExtension: "mp3") else { return }
do {
audioPlayer = try AVAudioPlayer(contentsOf: url)
audioPlayer?.play()
} catch let error {
print("Error playing sound. \(error.localizedDescription)")
}
}

@ -1,60 +0,0 @@
//
// MainMenuView.swift
// DouShouQi_App
//
// Created by Rémi REGNAULT on 16/05/2024.
//
import SwiftUI
struct MainMenuView: View {
var body: some View {
VStack {
TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200)
Spacer()
VStack {
HStack{
VStack(spacing: 25) {
MainMenuButton(text: "Play", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Historique", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Best Scores", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Players", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
}
Image(AppImages.SemiLion)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 500)
}
}
Spacer()
HStack {
Text("Copyright @")
.font(.headline)
.frame(alignment: .trailing)
Text("Dou Shou Qi Team")
Spacer()
Text("2024")
.frame(alignment: .trailing)
}
.padding() // Ajout de padding pour éviter que le contenu ne touche la bordure
.background(Color.white) // Couleur de fond pour le HStack
.overlay(
Rectangle()
.stroke(Color.black, lineWidth: 1) // Couleur et épaisseur de la bordure
)
Spacer()
}
}
}
struct MainMenuView_Previews: PreviewProvider {
static var previews: some View {
MainMenuView()
}
}

@ -0,0 +1,71 @@
//
// MainMenuView.swift
// DouShouQi_App
//
// Created by Rémi REGNAULT on 16/05/2024.
//
import SwiftUI
struct MainMenuView: View {
var body: some View {
NavigationView {
VStack {
TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200)
Spacer()
VStack {
HStack{
VStack(spacing: 25) {
MainMenuButton(text: "Play", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Historique", destination: HistoricView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10)
}
Image(AppImages.SemiLion)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 200, height: 500)
}
}
Spacer()
HStack {
Text("Copyright @")
.font(.headline)
.frame(alignment: .trailing)
Text("Dou Shou Qi Team")
Spacer()
Text("2024")
.frame(alignment: .trailing)
}
.padding() // Ajout de padding pour éviter que le contenu ne touche la bordure
.background(Color.white) // Couleur de fond pour le HStack
.overlay(
Rectangle()
.stroke(Color.black, lineWidth: 1) // Couleur et épaisseur de la bordure
)
Spacer()
.onAppear {
MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic")
}
.onDisappear {
MusicPlayer.shared.stopBackgroundMusic()
}
}
}
}
}
struct MainMenuView_Previews: PreviewProvider {
static var previews: some View {
MainMenuView()
}
}

@ -0,0 +1,119 @@
//
// PlayersView.swift
// DouShouQi_App
//
// Created by étudiant on 26/05/2024.
//
import Foundation
import SwiftUI
// Modèle de données pour un joueur
struct Player: Identifiable {
var id = UUID()
var name: String
var wins: Int
var losses: Int
}
// Exemple de vue pour l'interface utilisateur des joueurs
struct PlayersView: View {
// Liste de joueurs pour l'exemple
@State private var players = [
Player(name: "Rayhan", wins: 7, losses: 6),
Player(name: "Remi", wins: 7, losses: 2),
Player(name: "Nathan", wins: 14, losses: 5)
]
@State private var searchText = ""
var filteredPlayers: [Player] {
if searchText.isEmpty {
return players
} else {
return players.filter { $0.name.lowercased().contains(searchText.lowercased()) }
}
}
var body: some View {
NavigationView {
VStack {
// Image en haut
TitlePageFrame(Text: "PLAYERS", ImageWidth: 200, ImageHeight: 200)
// Barre de recherche
SearchBar(text: $searchText)
.padding(.horizontal)
// Liste de joueurs
List {
ForEach(groupedPlayers.keys.sorted(), id: \.self) { key in
Section(header: Text(key)) {
ForEach(groupedPlayers[key]!) { player in
PlayerRow(player: player)
}
}
}
}
Button(action: {
}) {
Text("Add a player")
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(maxWidth: .infinity)
.background(Color.red)
.cornerRadius(10)
.padding(.horizontal)
}
.padding(.bottom)
}
}
}
var groupedPlayers: [String: [Player]] {
Dictionary(grouping: filteredPlayers) { player in
String(player.name.prefix(1)).uppercased()
}
}
}
// Vue pour la barre de recherche
struct SearchBar: UIViewRepresentable {
@Binding var text: String
class Coordinator: NSObject, UISearchBarDelegate {
@Binding var text: String
init(text: Binding<String>) {
_text = text
}
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
text = searchText
}
}
func makeCoordinator() -> Coordinator {
return Coordinator(text: $text)
}
func makeUIView(context: Context) -> UISearchBar {
let searchBar = UISearchBar(frame: .zero)
searchBar.delegate = context.coordinator
return searchBar
}
func updateUIView(_ uiView: UISearchBar, context: Context) {
uiView.text = text
}
}
struct PlayersPageView_Previews: PreviewProvider {
static var previews: some View {
PlayersView()
}
}
Loading…
Cancel
Save