Refactor Navigation Toolbar into Separate View

This commit is contained in:
Sebastian Lenzlinger 2023-07-11 18:22:58 +02:00
parent 379d3c8a0e
commit 5e199f41f8
2 changed files with 39 additions and 41 deletions

View File

@ -29,16 +29,12 @@ struct ContentView: View {
FeedListView(feeds: [])
.environmentObject(dataStore)
}
}
.padding()
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
HStack {
Button(action: {
self.currentView = 0
}) {
VStack {
Label("Discovery", systemImage: "dot.radiowaves.left.and.right")
Text("Discovery")
}
}
Spacer()
@ -47,7 +43,6 @@ struct ContentView: View {
}) {
VStack {
Label("Feeds", systemImage: "person.2")
Text("Feeds")
}
}
Spacer()
@ -55,12 +50,14 @@ struct ContentView: View {
self.currentView = 2
}) {
VStack {
Label("Settings", systemImage: "gear")
Text("Settings")
Label("Settings",systemImage: "gear")
}
}
}
.frame(height: UIScreen.main.bounds.height * 0.05)
}
.padding()
}
}

View File

@ -17,40 +17,41 @@ struct SettingsView: View {
var body: some View {
List {
HStack {
Spacer()
Button("Edit") {
isPresentingEditView = true
}
}
Section(header: Text("Personal Feed ID")) {
Label(dataStore.personalID, systemImage: "person.crop.circle")
}
Section(header: Text("Friends")) {
ForEach(dataStore.friends) { friend in
Label(friend, systemImage: "person")
}
List {
Section(header: Text("Personal Feed ID")) {
Label(dataStore.personalID, systemImage: "person.crop.circle")
}
Section(header: Text("Friends")) {
ForEach(dataStore.friends) { friend in
Label(friend, systemImage: "person")
}
}
.navigationTitle("Settings")
.sheet(isPresented: $isPresentingEditView) {
NavigationStack {
SettingsEditView()
.navigationTitle("Settings")
.toolbar {
ToolbarItem(placement: .cancellationAction){
Button("Cancel") {
isPresentingEditView = false
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Done") {
isPresentingEditView = false
}
}
.navigationTitle("Settings")
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Edit") {
isPresentingEditView = true
}
}
}
.sheet(isPresented: $isPresentingEditView) {
NavigationStack {
SettingsEditView()
.navigationTitle("Settings")
.toolbar {
ToolbarItem(placement: .cancellationAction){
Button("Cancel") {
isPresentingEditView = false
}
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Done") {
isPresentingEditView = false
}
}
}
}
}
}