Skip to content

Commit

Permalink
workaround to refresh tab content
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoEidinger committed Apr 6, 2022
1 parent 35716d5 commit 440fd80
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions DemoApp/DemoApp/Home View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ struct HomeView: View {
ContentView()
.tabItem { Text("Left") }
.tag(1)
SettingsView()
.tabItem { Text("Right") }
.tag(2)
RefreshableContent(when: "\(selection)") {
SettingsView()
}
.tabItem { Text("Right") }
.tag(2)
}
.environmentObject(AppViewModel())
.enableInjection()
Expand All @@ -24,3 +26,16 @@ struct HomeView_Previews: PreviewProvider {
HomeView()
}
}

struct RefreshableContent<Content: View>: View {
var when: String
var content: Content
init(when changed: String, @ViewBuilder content: () -> Content) {
when = changed
self.content = content()
}

var body: some View {
content
}
}

0 comments on commit 440fd80

Please sign in to comment.