I have ImageSettingView which Im using multiple places. When I used this view at multiple place in my project it takes static name all time in the navigationBarItem i.e Text("Image Collab View"). I want to give dynamic name change based on where parent view it comes from.
ImageColorView -> ImageSettingView (Back NavButon text - ImageColor ) ProfilePictureView -> ImageSettingView (Back NavButon text - ProfilePictureView )
Sample code of ImageSettingView :-
struct ImageSettingView : View {
var body: some View {
GeometryReader { geometry in
VStack {
Form {
Text("Image View")
}
.navigationBarBackButtonHidden(true)
.navigationBarItems(
leading:
Button(action: {
onUserImage()
}) {
HStack {
Image(systemName: "backward")
Text("Image")
// I want to use change above text based on what name of the parent view was
}
},
trailing:
Button(action: {
onDelete()
}) {
HStack {
Text("Delete")
}
}
)
}
}
}