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/ContentView/NavButton.swift

38 lines
915 B

//
// NavButton.swift
// DouShouQiIOS
//
// Created by Mathilde Jean on 31/05/2024.
//
import SwiftUI
struct NavButton<D1:View>: View {
let text : String
let destinationView : () -> D1
let hideBackButton : Bool
init(_ text : String, @ViewBuilder destinationView: @escaping () -> D1, hideBackButton : Bool = false) {
self.text = text
self.destinationView = destinationView
self.hideBackButton = hideBackButton
}
var body: some View {
NavigationLink(destination: destinationView().navigationBarBackButtonHidden(hideBackButton))
{
Text("\(text)")
.font(.title2)
.padding()
.background(Color.primaryColor)
.foregroundColor(.white)
.cornerRadius(8)
}
}
}
#Preview {
NavButton("Menu princ", destinationView: {MainMenuView()})
}