SwiftUI with custom Tab Bar Item Action

Hello,
Is it possible triggers a function instead a view on the tab item?

This is a standard:
Code Block
TabView {
Text("The First Tab")
.tabItem {
Image(systemName: "1.square.fill")
Text("First")
}
Text("Another Tab")
.tabItem {
Image(systemName: "2.square.fill")
Text("Second")
}
Text("The Last Tab")
.tabItem {
Image(systemName: "3.square.fill")
Text("Third")
}
}
.font(.headline)


Is it possible this? :

Code Block
TabView {
Text("The First Tab")
.tabItem {
Image(systemName: "1.square.fill")
Text("First")
}
Text("Another Tab")
.tabItem {
Image(systemName: "2.square.fill")
Text("Second")
}
someFunction() 👈
.tabItem {
Image(systemName: "3.square.fill")
Text("Third")
}
}
.font(.headline)

Can you help me?
Thanks!
L

Is it possible this?

The code shown would never work as you expect.
Inside the content closure of TabView, you need to write Views which are the contents for the tabItems.
Even if you define your someFunction() to return some View, it is hard to predict when it is invoked.

There may be some better ways that I do not know, but as far as I tried, you need to define your own tabView-like view by yourself.
SwiftUI with custom Tab Bar Item Action
 
 
Q