You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SwiftUiTp/DouShouQiIOS/DouShouQiIOS/View/PlayerSelect.swift

96 lines
3.5 KiB

//
// PlayerSelect.swift
// DouShouQiIOS
//
// Created by Pierre FERREIRA on 17/06/2024.
//
import SwiftUI
/// PlayerSelect
/// Cette vue est utilisée pour sélectionner un joueur
struct PlayerSelect: View {
@State private var image = UIImage()
@State private var showSheet = false
var versus : Bool
var body: some View {
ZStack {
Rectangle().fill(Color.bgColor).ignoresSafeArea()
VStack {
VStack{
Text("Joueur 1")
HStack {
Image(uiImage: self.image)
.resizable()
.cornerRadius(50)
.frame(width: 100, height: 100)
.background(Color.black.opacity(0.2))
.aspectRatio(contentMode: .fill)
.clipShape(Circle())
ClassicTextDisplay(text: "Change photo")
.onTapGesture {
showSheet = true
}
}
.padding(.horizontal, 20)
.sheet(isPresented: $showSheet) {
ImagePicker(sourceType: .photoLibrary, selectedImage: self.$image)
}
TextField("Entrez un nom ici",text: .constant(""))
}.foregroundStyle(.primary)
.padding(20)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(Color.player1, lineWidth: 5)
)
.padding(40)
if (versus){
VStack{
Text("Joueur 1")
HStack {
Image(uiImage: self.image)
.resizable()
.cornerRadius(50)
.frame(width: 100, height: 100)
.background(Color.black.opacity(0.2))
.aspectRatio(contentMode: .fill)
.clipShape(Circle())
ClassicTextDisplay(text: "Change photo")
.onTapGesture {
showSheet = true
}
}
.padding(.horizontal, 20)
.sheet(isPresented: $showSheet) {
ImagePicker(sourceType: .photoLibrary, selectedImage: self.$image)
}
TextField("Entrez un nom ici",text: .constant(""))
}.foregroundStyle(.primary)
.padding(20)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(Color.player2, lineWidth: 5)
)
.padding(40)
}
}
}
}
}
struct PlayerSelect_Previews: PreviewProvider {
static var previews: some View {
PlayerSelect(versus: true)
}
}