diff --git a/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift b/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift index e8609f2..9393578 100644 --- a/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift +++ b/DouShouQi_App/DouShouQi_App/Components/MainMenuButton.swift @@ -13,6 +13,15 @@ struct MainMenuButton: View { var text: String @State private var isHovered: Bool = false + // Button Alignment + var horizontalAlignment: Alignment = .center + + // Button corner radius + var topLeftCorner: CGFloat = 0 + var topRightCorner: CGFloat = 0 + var bottomLeftCorner: CGFloat = 0 + var bottomRightCorner: CGFloat = 0 + var body: some View { Button(action: { // Action du bouton @@ -26,11 +35,11 @@ struct MainMenuButton: View { .background( Colors.Button .clipShape(RoundedRectangle(cornerSize: CGSize(width: 0, height: 0))) - .mask(RoundedCornersShape(cornerRadii: (topLeft: 0, topRight: 10, bottomLeft: 0, bottomRight: 10))) + .mask(RoundedCornersShape(cornerRadii: (topLeft: topLeftCorner, topRight: topRightCorner, bottomLeft: bottomLeftCorner, bottomRight: bottomRightCorner))) ) }) .frame(width: UIScreen.main.bounds.width / 1.7) - .frame(maxWidth: .infinity, alignment: .leading) + .frame(maxWidth: .infinity, alignment: horizontalAlignment) .scaleEffect(isHovered ? 1.1 : 1.0) .animation(.easeInOut(duration: 0.2), value: isHovered) .onHover { hovering in @@ -85,6 +94,6 @@ struct RoundedCornersShape: Shape { struct MainMenuButton_Previews: PreviewProvider { static var previews: some View { - MainMenuButton(text: "test") + MainMenuButton(text: "test", horizontalAlignment: .leading, topRightCorner: 10, bottomRightCorner: 10) } } diff --git a/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift b/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift index 408d411..6b44b3f 100644 --- a/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift +++ b/DouShouQi_App/DouShouQi_App/Views/MainMenuView.swift @@ -16,10 +16,10 @@ struct MainMenuView: View { VStack { HStack{ VStack(spacing: 25) { - MainMenuButton(text: "Play") - MainMenuButton(text: "Historique") - MainMenuButton(text: "Best Scores") - MainMenuButton(text: "Players") + 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()